GuruFocusConnector

Struct GuruFocusConnector 

Source
pub struct GuruFocusConnector { /* private fields */ }
Expand description

Container for connection parameters to gurufocus server.

Implementations§

Source§

impl GuruFocusConnector

Source

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?
examples/09_gurulist.rs (line 7)
5async fn main() {
6    let token = env::var("GURUFOCUS_TOKEN").unwrap();
7    let gf_connect = gfapi::GuruFocusConnector::new(token);
8    let gurus = gf_connect.get_gurus().await.unwrap();
9
10    // Print list of gurus
11    println!("List of all Gurus: {}", gurus);
12}
More examples
Hide additional examples
examples/12_exchanges.rs (line 10)
8async fn main() {
9    let token = env::var("GURUFOCUS_TOKEN").unwrap();
10    let gf_connect = gfapi::GuruFocusConnector::new(token);
11    let exchanges = gf_connect.get_exchanges().await.unwrap();
12    let exchange_map: ExchangeList = serde_json::from_value(exchanges).unwrap();
13    println!("{:#?}", exchange_map);
14}
examples/14_insider_updates.rs (line 9)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10
11    let updates = gf_connect.get_insider_updates().await.unwrap();
12
13    let updates: InsiderUpdaters = serde_json::from_value(updates).unwrap();
14    println!("List of lasted insider updates\n{:#?}", updates);
15}
examples/17_personal_portfolio.rs (line 9)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10    let portfolios = gf_connect.get_personal_portfolio().await.unwrap();
11
12    let portfolios: PersonalPortfolios = serde_json::from_value(portfolios).unwrap();
13    println!("Personal portfolios overview\n{:#?}", portfolios);
14}
examples/05a_price_history.rs (line 9)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10
11    let stock = "NYSE:DIS";
12    let prices = gf_connect.get_price_hist(stock).await.unwrap();
13
14    let prices: PriceHistory = serde_json::from_value(prices).unwrap();
15    println!("Price history for Walt Disney\n{:#?}", prices);
16}
examples/05b_price_history_unadj.rs (line 9)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10
11    let stock = "NYSE:DIS";
12    let prices = gf_connect.get_unadj_price_hist(stock).await.unwrap();
13
14    let prices: PriceHistory = serde_json::from_value(prices).unwrap();
15    println!("Unadjusted Price history for Walt Disney\n{:#?}", prices);
16}
Source

pub async fn get_financials(&self, stock: &str) -> Result<Value, GuruFocusError>

Returns the full history of financial data for stock symbol given as argument

Examples found in repository?
examples/02_financials.rs (line 6)
5async fn show_financials(ticker: &str, gf_connect: &gfapi::GuruFocusConnector) {
6    let financials = gf_connect.get_financials(ticker).await.unwrap();
7    let financials: gfapi::FinancialData = serde_json::from_value(financials).unwrap();
8    println!(
9        "Financial figures of {}'s Enterprice value\n==================\n{:#?}\n\n",
10        ticker, financials
11    );
12}
Source

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?
examples/03_keyratios.rs (line 11)
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}
Source

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

Examples found in repository?
examples/04_quotes.rs (line 11)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10    let ticker = ["NAS:AAPL", "FRA:APC", "LTS:0JQ4"];
11    let prices = gf_connect.get_quotes(&ticker).await.unwrap();
12
13    let prices: QuoteList = serde_json::from_value(prices).unwrap();
14    println!("Compare latest quotes of Apple stock prices and three different exchanges:");
15    println!("{:#?}", prices);
16}
Source

pub async fn get_price_hist(&self, stock: &str) -> Result<Value, GuruFocusError>

Returns the history of (adjusted) quoted prices for symbol given as argument

Examples found in repository?
examples/05a_price_history.rs (line 12)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10
11    let stock = "NYSE:DIS";
12    let prices = gf_connect.get_price_hist(stock).await.unwrap();
13
14    let prices: PriceHistory = serde_json::from_value(prices).unwrap();
15    println!("Price history for Walt Disney\n{:#?}", prices);
16}
Source

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

Examples found in repository?
examples/05b_price_history_unadj.rs (line 12)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10
11    let stock = "NYSE:DIS";
12    let prices = gf_connect.get_unadj_price_hist(stock).await.unwrap();
13
14    let prices: PriceHistory = serde_json::from_value(prices).unwrap();
15    println!("Unadjusted Price history for Walt Disney\n{:#?}", prices);
16}
Source

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?
examples/06_stock_summary.rs (line 10)
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}
Source

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

Examples found in repository?
examples/07_guru_trades.rs (line 11)
6async fn main() {
7    let token = env::var("GURUFOCUS_TOKEN").unwrap();
8    let gf_connect = gfapi::GuruFocusConnector::new(token);
9
10    let stock = "WMT";
11    let trades = gf_connect.get_guru_trades(stock).await.unwrap();
12
13    let trades: HashMap<String, gfapi::gurus::GuruTrades> = serde_json::from_value(trades).unwrap();
14    println!("List of real time guru trades in Walmart\n{:#?}", trades);
15}
Source

pub async fn get_insider_trades( &self, stock: &str, ) -> Result<Value, GuruFocusError>

Returns real-time insider trades for symbol given as argument

Examples found in repository?
examples/08_insider_trades.rs (line 13)
8async fn main() {
9    let token = env::var("GURUFOCUS_TOKEN").unwrap();
10    let gf_connect = gfapi::GuruFocusConnector::new(token);
11
12    let stock = "NAS:NVDA";
13    let trades = gf_connect.get_insider_trades(stock).await.unwrap();
14
15    let trades: InsiderTrades = serde_json::from_value(trades).unwrap();
16    println!("List of real time insider trades in NVDIA\n{:#?}", trades);
17}
Source

pub async fn get_gurus(&self) -> Result<Value, GuruFocusError>

Returns lists of all and personalized gurus

Examples found in repository?
examples/09_gurulist.rs (line 8)
5async fn main() {
6    let token = env::var("GURUFOCUS_TOKEN").unwrap();
7    let gf_connect = gfapi::GuruFocusConnector::new(token);
8    let gurus = gf_connect.get_gurus().await.unwrap();
9
10    // Print list of gurus
11    println!("List of all Gurus: {}", gurus);
12}
Source

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?
examples/10_guru_picks.rs (line 33)
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}
Source

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?
examples/11_guru_portfolios.rs (line 12)
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}
Source

pub async fn get_exchanges(&self) -> Result<Value, GuruFocusError>

Returns list of supported exchanges

Examples found in repository?
examples/12_exchanges.rs (line 11)
8async fn main() {
9    let token = env::var("GURUFOCUS_TOKEN").unwrap();
10    let gf_connect = gfapi::GuruFocusConnector::new(token);
11    let exchanges = gf_connect.get_exchanges().await.unwrap();
12    let exchange_map: ExchangeList = serde_json::from_value(exchanges).unwrap();
13    println!("{:#?}", exchange_map);
14}
Source

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?
examples/13_stocklist.rs (line 12)
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}
Source

pub async fn get_insider_updates(&self) -> Result<Value, GuruFocusError>

Returns list of latest insider trades ordered by insider transctions time

Examples found in repository?
examples/14_insider_updates.rs (line 11)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10
11    let updates = gf_connect.get_insider_updates().await.unwrap();
12
13    let updates: InsiderUpdaters = serde_json::from_value(updates).unwrap();
14    println!("List of lasted insider updates\n{:#?}", updates);
15}
Source

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?
examples/15_dividend_history.rs (line 12)
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}
Source

pub async fn get_analyst_estimate( &self, stock: &str, ) -> Result<Value, GuruFocusError>

Returns analyst estimate data of a stock

Examples found in repository?
examples/16_analyst_estimate.rs (line 10)
5async fn main() {
6    let token = env::var("GURUFOCUS_TOKEN").unwrap();
7    let gf_connect = gfapi::GuruFocusConnector::new(token);
8
9    let stock = "NAS:CSCO";
10    let estimates = gf_connect.get_analyst_estimate(stock).await.unwrap();
11
12    let estimates: gfapi::AnalystEstimates = serde_json::from_value(estimates).unwrap();
13    println!("Analyst estimates on Cisco\n{:#?}", estimates);
14}
Source

pub async fn get_personal_portfolio(&self) -> Result<Value, GuruFocusError>

Returns list of personal portfolios

Examples found in repository?
examples/17_personal_portfolio.rs (line 10)
7async fn main() {
8    let token = env::var("GURUFOCUS_TOKEN").unwrap();
9    let gf_connect = gfapi::GuruFocusConnector::new(token);
10    let portfolios = gf_connect.get_personal_portfolio().await.unwrap();
11
12    let portfolios: PersonalPortfolios = serde_json::from_value(portfolios).unwrap();
13    println!("Personal portfolios overview\n{:#?}", portfolios);
14}
Source

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?
examples/18_fundamentals_update.rs (line 31)
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}
Source

pub async fn get_politicians(&self) -> Result<Value, GuruFocusError>

Returns lists of politicians

Examples found in repository?
examples/19_politicianlist.rs (line 8)
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}
Source

pub async fn get_politician_transactions( &self, page: u32, asset_type: Option<AssetType>, ) -> Result<Value, GuruFocusError>

Examples found in repository?
examples/20_politician_transactions.rs (line 12)
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}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,