pub struct GuruFocusConnector { /* private fields */ }
Expand description
Container for connection parameters to gurufocus server.
Implementations§
Source§impl GuruFocusConnector
impl GuruFocusConnector
Sourcepub fn new(token: String) -> GuruFocusConnector
pub fn new(token: String) -> GuruFocusConnector
Constructor for a new instance of GuruFocusConnector. token is the user token you get from gurufocus if you subscribe for a premium or premium plus account.
Examples found in repository?
More examples
- examples/08_insider_trades.rs
- examples/16_analyst_estimate.rs
- examples/02_financials.rs
- examples/07_guru_trades.rs
- examples/15_dividend_history.rs
- examples/06_stock_summary.rs
- examples/04_quotes.rs
- examples/03_keyratios.rs
- examples/19_politicianlist.rs
- examples/13_stocklist.rs
- examples/18_fundamentals_update.rs
- examples/11_guru_portfolios.rs
- examples/20_politician_transactions.rs
- examples/10_guru_picks.rs
Sourcepub async fn get_financials(&self, stock: &str) -> Result<Value, GuruFocusError>
pub async fn get_financials(&self, stock: &str) -> Result<Value, GuruFocusError>
Returns the full history of financial data for stock symbol given as argument
Sourcepub async fn get_key_ratios(&self, stock: &str) -> Result<Value, GuruFocusError>
pub async fn get_key_ratios(&self, stock: &str) -> Result<Value, GuruFocusError>
Returns the current key statistic figures for stock symbol given as argument
Examples found in repository?
5async fn main() {
6 let token = env::var("GURUFOCUS_TOKEN").unwrap();
7 let gf_connect = gfapi::GuruFocusConnector::new(token);
8
9 // Get key ratios of Berkshire Hathaway
10 let stock = "NYSE:BRK.A";
11 let key_ratios = gf_connect.get_key_ratios(stock).await.unwrap();
12
13 let key_ratios: gfapi::KeyRatios = serde_json::from_value(key_ratios).unwrap();
14 println!(
15 "List of key ratios for Berkshire Hathaway\n{:#?}",
16 key_ratios
17 );
18}
Sourcepub async fn get_quotes(&self, stocks: &[&str]) -> Result<Value, GuruFocusError>
pub async fn get_quotes(&self, stocks: &[&str]) -> Result<Value, GuruFocusError>
Returns the current quote data of a comma separated list of symbols given as argument
Sourcepub async fn get_price_hist(&self, stock: &str) -> Result<Value, GuruFocusError>
pub async fn get_price_hist(&self, stock: &str) -> Result<Value, GuruFocusError>
Returns the history of (adjusted) quoted prices for symbol given as argument
Sourcepub async fn get_unadj_price_hist(
&self,
stock: &str,
) -> Result<Value, GuruFocusError>
pub async fn get_unadj_price_hist( &self, stock: &str, ) -> Result<Value, GuruFocusError>
Returns the history of (unadjusted) quoted prices for symbol given as argument
Sourcepub async fn get_stock_summary(
&self,
stock: &str,
) -> Result<Value, GuruFocusError>
pub async fn get_stock_summary( &self, stock: &str, ) -> Result<Value, GuruFocusError>
Returns companies current price, valuation rations and ranks for symbol given as argument
Examples found in repository?
5async fn main() {
6 let token = env::var("GURUFOCUS_TOKEN").unwrap();
7 let gf_connect = gfapi::GuruFocusConnector::new(token);
8
9 let stock = "NYSE:BAC";
10 let stock_summary = gf_connect.get_stock_summary(stock).await.unwrap();
11
12 let stock_summary: gfapi::StockSummary = serde_json::from_value(stock_summary).unwrap();
13 println!(
14 "Stock summary for Bank of America\n{:#?}",
15 stock_summary.summary
16 );
17}
Sourcepub async fn get_guru_trades(
&self,
stock: &str,
) -> Result<Value, GuruFocusError>
pub async fn get_guru_trades( &self, stock: &str, ) -> Result<Value, GuruFocusError>
Returns real-time guru trades and holding data for symbol given as argument
Sourcepub async fn get_insider_trades(
&self,
stock: &str,
) -> Result<Value, GuruFocusError>
pub async fn get_insider_trades( &self, stock: &str, ) -> Result<Value, GuruFocusError>
Returns real-time insider trades for symbol given as argument
Sourcepub async fn get_gurus(&self) -> Result<Value, GuruFocusError>
pub async fn get_gurus(&self) -> Result<Value, GuruFocusError>
Returns lists of all and personalized gurus
Sourcepub async fn get_guru_picks(
&self,
gurus: &[&str],
start_date: Date,
page: i32,
) -> Result<Value, GuruFocusError>
pub async fn get_guru_picks( &self, gurus: &[&str], start_date: Date, page: i32, ) -> Result<Value, GuruFocusError>
Returns list of gurus stock picks using list of guru ids since a given start date.
Examples found in repository?
23async fn main() {
24 let token = env::var("GURUFOCUS_TOKEN").unwrap();
25 let gf_connect = gfapi::GuruFocusConnector::new(token);
26
27 // Buffett, Soros and Klarman
28 let gurus = ["7", "16", "28"];
29 let now = UtcDateTime::now();
30 let three_months_ago = get_months_before(now.date(), 3);
31 let page = 1;
32 let trades = gf_connect
33 .get_guru_picks(&gurus, three_months_ago, page)
34 .await
35 .unwrap();
36
37 println!(
38 "List of trades by a set of gurus (Warren Buffett, George Soros, and Seth Klarman) since {}\n{:#?}", three_months_ago, trades);
39}
Sourcepub async fn get_guru_portfolios(
&self,
gurus: &[&str],
) -> Result<Value, GuruFocusError>
pub async fn get_guru_portfolios( &self, gurus: &[&str], ) -> Result<Value, GuruFocusError>
Returns list of aggregated guru portfolios given a slice of guru ids
Examples found in repository?
6async fn main() {
7 let token = env::var("GURUFOCUS_TOKEN").unwrap();
8 let gf_connect = gfapi::GuruFocusConnector::new(token);
9
10 // Bill Ackman and David Einhorn
11 let gurus = ["47", "39"];
12 let portfolios = gf_connect.get_guru_portfolios(&gurus).await.unwrap();
13
14 let portfolios: HashMap<String, gfapi::gurus::GuruPortfolio> =
15 serde_json::from_value(portfolios).unwrap();
16 println!(
17 "Aggregated Portfolios of Bill Ackman and David Einhorn\n{:#?}",
18 portfolios
19 );
20}
Sourcepub async fn get_exchanges(&self) -> Result<Value, GuruFocusError>
pub async fn get_exchanges(&self) -> Result<Value, GuruFocusError>
Returns list of supported exchanges
Sourcepub async fn get_listed_stocks(
&self,
exchange: &str,
) -> Result<Value, GuruFocusError>
pub async fn get_listed_stocks( &self, exchange: &str, ) -> Result<Value, GuruFocusError>
Returns list of all stocks of a particular exchange
Examples found in repository?
7async fn main() {
8 let token = env::var("GURUFOCUS_TOKEN").unwrap();
9 let gf_connect = gfapi::GuruFocusConnector::new(token);
10 // Get all stocks listed at the Oslo stock exchange (OSL) in Norway
11 let exchange = "OSL";
12 let stocks = gf_connect.get_listed_stocks(exchange).await.unwrap();
13 let stocks: StockList = serde_json::from_value(stocks).unwrap();
14 println!(
15 "List of all stocks listed at the Oslo stock exchange (OSL) in Norway\n{:#?}",
16 stocks
17 );
18}
Sourcepub async fn get_insider_updates(&self) -> Result<Value, GuruFocusError>
pub async fn get_insider_updates(&self) -> Result<Value, GuruFocusError>
Returns list of latest insider trades ordered by insider transctions time
Sourcepub async fn get_dividend_history(
&self,
stock: &str,
) -> Result<Value, GuruFocusError>
pub async fn get_dividend_history( &self, stock: &str, ) -> Result<Value, GuruFocusError>
Returns 30 years dividend history data of a stock
Examples found in repository?
7async fn main() {
8 let token = env::var("GURUFOCUS_TOKEN").unwrap();
9 let gf_connect = gfapi::GuruFocusConnector::new(token);
10
11 let stock = "NAS:MSFT";
12 let dividends = gf_connect.get_dividend_history(stock).await.unwrap();
13
14 let dividends: DividendHistory = serde_json::from_value(dividends).unwrap();
15 println!("Microsoft's dividend history\n");
16 for div in dividends {
17 println!("{:?}", div);
18 }
19}
Sourcepub async fn get_analyst_estimate(
&self,
stock: &str,
) -> Result<Value, GuruFocusError>
pub async fn get_analyst_estimate( &self, stock: &str, ) -> Result<Value, GuruFocusError>
Returns analyst estimate data of a stock
Sourcepub async fn get_personal_portfolio(&self) -> Result<Value, GuruFocusError>
pub async fn get_personal_portfolio(&self) -> Result<Value, GuruFocusError>
Returns list of personal portfolios
Sourcepub async fn get_updated_stocks(
&self,
date: Date,
) -> Result<Value, GuruFocusError>
pub async fn get_updated_stocks( &self, date: Date, ) -> Result<Value, GuruFocusError>
Returns list of all stocks with updated fundamental data within a week of the given date
Examples found in repository?
25async fn main() {
26 let token = env::var("GURUFOCUS_TOKEN").unwrap();
27 let gf_connect = gfapi::GuruFocusConnector::new(token);
28
29 let now = UtcDateTime::now().date();
30 let one_months_ago = get_months_before(now, 6);
31 let stocks = gf_connect.get_updated_stocks(one_months_ago).await.unwrap();
32
33 let stocks: UpdatedStocks = serde_json::from_value(stocks).unwrap();
34 println!(
35 "List of stocks with updated fundamental data since {}\n{:#?}",
36 one_months_ago, stocks
37 );
38}
Sourcepub async fn get_politicians(&self) -> Result<Value, GuruFocusError>
pub async fn get_politicians(&self) -> Result<Value, GuruFocusError>
Returns lists of politicians
Examples found in repository?
5async fn main() {
6 let token = env::var("GURUFOCUS_TOKEN").unwrap();
7 let gf_connect = gfapi::GuruFocusConnector::new(token);
8 let politicians = gf_connect.get_politicians().await.unwrap();
9 let politicians: Vec<gfapi::gurus::Politician> = serde_json::from_value(politicians).unwrap();
10
11 // Print list of politicians
12 println!("List of politicians:");
13 for p in politicians {
14 println!("{}, {}, {}", p.full_name, p.party, p.position);
15 }
16}
Sourcepub async fn get_politician_transactions(
&self,
page: u32,
asset_type: Option<AssetType>,
) -> Result<Value, GuruFocusError>
pub async fn get_politician_transactions( &self, page: u32, asset_type: Option<AssetType>, ) -> Result<Value, GuruFocusError>
Examples found in repository?
5async fn main() {
6 let token = env::var("GURUFOCUS_TOKEN").unwrap();
7 let gf_connect = gfapi::GuruFocusConnector::new(token);
8 let page = 1;
9 let asset_type = None;
10
11 let transactions = gf_connect
12 .get_politician_transactions(page, asset_type)
13 .await
14 .unwrap();
15 let transactions: gfapi::gurus::PoliticianTransactionList =
16 serde_json::from_value(transactions).unwrap();
17
18 println!("List of politician transactions");
19 for t in transactions.data {
20 println!("{t:?}");
21 }
22}