1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
mod api;
mod model;
mod wire;
pub use model::{
InsiderRosterHolder, InsiderTransaction, InstitutionalHolder, MajorHolder,
NetSharePurchaseActivity,
};
use crate::{YfClient, YfError, YfResponse, core::CallOptions};
/// A builder for fetching holder data for a specific symbol.
pub struct HoldersBuilder {
client: YfClient,
symbol: String,
options: CallOptions,
}
impl HoldersBuilder {
/// Creates a new `HoldersBuilder` for a given symbol.
pub fn new(client: &YfClient, symbol: impl Into<String>) -> Self {
Self {
client: client.clone(),
symbol: symbol.into(),
options: CallOptions::default(),
}
}
crate::core::impl_call_option_setters!();
/// Fetches the major holders breakdown (e.g., % insiders, % institutions).
///
/// # Errors
///
/// Returns a `YfError` if the network request fails or the API response cannot be parsed.
pub async fn major_holders(&self) -> Result<Vec<MajorHolder>, YfError> {
Ok(self.major_holders_with_diagnostics().await?.into_data())
}
/// Fetches the major holders breakdown with projection diagnostics.
///
/// # Errors
///
/// Returns a `YfError` if the request fails or strict data-quality mode rejects a projection issue.
pub async fn major_holders_with_diagnostics(
&self,
) -> Result<YfResponse<Vec<MajorHolder>>, YfError> {
api::major_holders(&self.client, &self.symbol, &self.options).await
}
/// Fetches a list of the top institutional holders.
///
/// # Errors
///
/// Returns a `YfError` if the network request fails or the API response cannot be parsed.
pub async fn institutional_holders(&self) -> Result<Vec<InstitutionalHolder>, YfError> {
Ok(self
.institutional_holders_with_diagnostics()
.await?
.into_data())
}
/// Fetches institutional holders with projection diagnostics.
///
/// # Errors
///
/// Returns a `YfError` if the request fails or strict data-quality mode rejects a projection issue.
pub async fn institutional_holders_with_diagnostics(
&self,
) -> Result<YfResponse<Vec<InstitutionalHolder>>, YfError> {
api::institutional_holders(&self.client, &self.symbol, &self.options).await
}
/// Fetches a list of the top mutual fund holders.
///
/// # Errors
///
/// Returns a `YfError` if the network request fails or the API response cannot be parsed.
pub async fn mutual_fund_holders(&self) -> Result<Vec<InstitutionalHolder>, YfError> {
Ok(self
.mutual_fund_holders_with_diagnostics()
.await?
.into_data())
}
/// Fetches mutual fund holders with projection diagnostics.
///
/// # Errors
///
/// Returns a `YfError` if the request fails or strict data-quality mode rejects a projection issue.
pub async fn mutual_fund_holders_with_diagnostics(
&self,
) -> Result<YfResponse<Vec<InstitutionalHolder>>, YfError> {
api::mutual_fund_holders(&self.client, &self.symbol, &self.options).await
}
/// Fetches a list of recent insider transactions.
///
/// # Errors
///
/// Returns a `YfError` if the network request fails or the API response cannot be parsed.
pub async fn insider_transactions(&self) -> Result<Vec<InsiderTransaction>, YfError> {
Ok(self
.insider_transactions_with_diagnostics()
.await?
.into_data())
}
/// Fetches insider transactions with projection diagnostics.
///
/// # Errors
///
/// Returns a `YfError` if the request fails or strict data-quality mode rejects a projection issue.
pub async fn insider_transactions_with_diagnostics(
&self,
) -> Result<YfResponse<Vec<InsiderTransaction>>, YfError> {
api::insider_transactions(&self.client, &self.symbol, &self.options).await
}
/// Fetches a roster of company insiders and their holdings.
///
/// # Errors
///
/// Returns a `YfError` if the network request fails or the API response cannot be parsed.
pub async fn insider_roster_holders(&self) -> Result<Vec<InsiderRosterHolder>, YfError> {
Ok(self
.insider_roster_holders_with_diagnostics()
.await?
.into_data())
}
/// Fetches insider roster holders with projection diagnostics.
///
/// # Errors
///
/// Returns a `YfError` if the request fails or strict data-quality mode rejects a projection issue.
pub async fn insider_roster_holders_with_diagnostics(
&self,
) -> Result<YfResponse<Vec<InsiderRosterHolder>>, YfError> {
api::insider_roster_holders(&self.client, &self.symbol, &self.options).await
}
/// Fetches a summary of net insider purchase and sale activity.
///
/// # Errors
///
/// Returns a `YfError` if the network request fails or the API response cannot be parsed.
pub async fn net_share_purchase_activity(
&self,
) -> Result<Option<NetSharePurchaseActivity>, YfError> {
Ok(self
.net_share_purchase_activity_with_diagnostics()
.await?
.into_data())
}
/// Fetches net insider purchase and sale activity with projection diagnostics.
///
/// # Errors
///
/// Returns a `YfError` if the request fails or strict data-quality mode rejects a projection issue.
pub async fn net_share_purchase_activity_with_diagnostics(
&self,
) -> Result<YfResponse<Option<NetSharePurchaseActivity>>, YfError> {
api::net_share_purchase_activity(&self.client, &self.symbol, &self.options).await
}
}