pub mod analytics;
pub mod company;
pub mod compliance;
pub mod corporate_actions;
pub mod estimates;
pub mod filings;
pub mod financials;
pub mod historical;
pub mod insider;
pub mod market;
pub mod ownership;
pub mod price;
pub mod sentiment;
use crate::{client::FinnhubClient, error::Result, models::stock::*};
pub struct StockEndpoints<'a> {
client: &'a FinnhubClient,
}
impl<'a> StockEndpoints<'a> {
pub fn new(client: &'a FinnhubClient) -> Self {
Self { client }
}
pub async fn quote(&self, symbol: &str) -> Result<Quote> {
price::PriceEndpoints::new(self.client).quote(symbol).await
}
pub async fn candles(
&self,
symbol: &str,
resolution: CandleResolution,
from: i64,
to: i64,
) -> Result<StockCandles> {
price::PriceEndpoints::new(self.client)
.candles(symbol, resolution, from, to)
.await
}
pub async fn bid_ask(&self, symbol: &str) -> Result<BidAsk> {
price::PriceEndpoints::new(self.client)
.bid_ask(symbol)
.await
}
pub async fn tick_data(
&self,
symbol: &str,
date: &str,
limit: i64,
skip: i64,
) -> Result<TickData> {
price::PriceEndpoints::new(self.client)
.tick_data(symbol, date, limit, skip)
.await
}
pub async fn price_metrics(&self, symbol: &str) -> Result<PriceMetrics> {
price::PriceEndpoints::new(self.client)
.price_metrics(symbol)
.await
}
pub async fn company_profile(&self, symbol: &str) -> Result<CompanyProfile> {
company::CompanyEndpoints::new(self.client)
.profile(symbol)
.await
}
pub async fn peers(&self, symbol: &str, grouping: Option<&str>) -> Result<Vec<String>> {
company::CompanyEndpoints::new(self.client)
.peers(symbol, grouping)
.await
}
pub async fn symbols(&self, exchange: &str) -> Result<Vec<Symbol>> {
company::CompanyEndpoints::new(self.client)
.symbols(exchange)
.await
}
pub async fn financials(
&self,
symbol: &str,
statement: StatementType,
frequency: StatementFrequency,
) -> Result<FinancialStatements> {
financials::FinancialsEndpoints::new(self.client)
.statements(symbol, statement, frequency)
.await
}
pub async fn metrics(&self, symbol: &str) -> Result<BasicFinancials> {
financials::FinancialsEndpoints::new(self.client)
.metrics(symbol)
.await
}
pub async fn earnings(&self, symbol: &str, limit: Option<i64>) -> Result<Vec<Earnings>> {
financials::FinancialsEndpoints::new(self.client)
.earnings(symbol, limit)
.await
}
pub async fn financials_reported(
&self,
symbol: Option<&str>,
cik: Option<&str>,
access_number: Option<&str>,
freq: Option<&str>,
) -> Result<FinancialsAsReported> {
financials::FinancialsEndpoints::new(self.client)
.as_reported(symbol, cik, access_number, freq)
.await
}
pub async fn price_target(&self, symbol: &str) -> Result<PriceTarget> {
analytics::AnalyticsEndpoints::new(self.client)
.price_target(symbol)
.await
}
pub async fn recommendations(&self, symbol: &str) -> Result<Vec<RecommendationTrend>> {
analytics::AnalyticsEndpoints::new(self.client)
.recommendations(symbol)
.await
}
pub async fn revenue_breakdown(&self, symbol: &str) -> Result<RevenueBreakdown> {
analytics::AnalyticsEndpoints::new(self.client)
.revenue_breakdown(symbol)
.await
}
pub async fn upgrade_downgrade(
&self,
symbol: Option<&str>,
from: Option<&str>,
to: Option<&str>,
) -> Result<Vec<UpgradeDowngrade>> {
analytics::AnalyticsEndpoints::new(self.client)
.upgrade_downgrade(symbol, from, to)
.await
}
pub async fn insider_transactions(&self, symbol: &str) -> Result<InsiderTransactions> {
insider::InsiderEndpoints::new(self.client)
.transactions(symbol)
.await
}
pub async fn insider_sentiment(
&self,
symbol: &str,
from: &str,
to: &str,
) -> Result<InsiderSentimentData> {
insider::InsiderEndpoints::new(self.client)
.sentiment(symbol, from, to)
.await
}
pub async fn dividends(&self, symbol: &str, from: &str, to: &str) -> Result<Vec<Dividend>> {
corporate_actions::CorporateActionsEndpoints::new(self.client)
.dividends(symbol, from, to)
.await
}
pub async fn splits(&self, symbol: &str, from: &str, to: &str) -> Result<Vec<StockSplit>> {
corporate_actions::CorporateActionsEndpoints::new(self.client)
.splits(symbol, from, to)
.await
}
pub async fn dividends_v2(&self, symbol: &str) -> Result<DividendsV2> {
corporate_actions::CorporateActionsEndpoints::new(self.client)
.dividends_v2(symbol)
.await
}
pub async fn historical_market_cap(
&self,
symbol: &str,
from: &str,
to: &str,
) -> Result<HistoricalMarketCapData> {
historical::HistoricalEndpoints::new(self.client)
.market_cap(symbol, from, to)
.await
}
pub async fn historical_employee_count(
&self,
symbol: &str,
from: &str,
to: &str,
) -> Result<HistoricalEmployeeCount> {
historical::HistoricalEndpoints::new(self.client)
.employee_count(symbol, from, to)
.await
}
pub async fn historical_esg(
&self,
symbol: &str,
from: &str,
to: &str,
) -> Result<HistoricalESG> {
historical::HistoricalEndpoints::new(self.client)
.esg(symbol, from, to)
.await
}
pub async fn historical_nbbo(
&self,
symbol: &str,
date: &str,
limit: i64,
skip: i64,
) -> Result<HistoricalNBBO> {
historical::HistoricalEndpoints::new(self.client)
.nbbo(symbol, date, limit, skip)
.await
}
pub async fn social_sentiment(
&self,
symbol: &str,
from: &str,
to: &str,
) -> Result<SocialSentiment> {
sentiment::SentimentEndpoints::new(self.client)
.social(symbol, from, to)
.await
}
pub async fn filing_sentiment(&self, access_number: &str) -> Result<FilingSentiment> {
sentiment::SentimentEndpoints::new(self.client)
.filing(access_number)
.await
}
pub async fn market_status(&self, exchange: &str) -> Result<MarketStatus> {
market::MarketEndpoints::new(self.client)
.status(exchange)
.await
}
pub async fn market_holiday(&self, exchange: &str) -> Result<MarketHoliday> {
market::MarketEndpoints::new(self.client)
.holiday(exchange)
.await
}
pub async fn investment_theme(&self, theme: &str) -> Result<InvestmentTheme> {
market::MarketEndpoints::new(self.client)
.investment_theme(theme)
.await
}
pub async fn ownership(&self, symbol: &str, limit: Option<i64>) -> Result<OwnershipData> {
ownership::OwnershipEndpoints::new(self.client)
.institutional(symbol, limit)
.await
}
pub async fn fund_ownership(&self, symbol: &str, limit: Option<i64>) -> Result<FundOwnership> {
ownership::OwnershipEndpoints::new(self.client)
.fund(symbol, limit)
.await
}
pub async fn sec_filings(
&self,
symbol: Option<&str>,
cik: Option<&str>,
access_number: Option<&str>,
form: Option<&str>,
from: Option<&str>,
to: Option<&str>,
) -> Result<Vec<Filing>> {
filings::FilingsEndpoints::new(self.client)
.sec(symbol, cik, access_number, form, from, to)
.await
}
pub async fn international_filings(
&self,
symbol: Option<&str>,
country: Option<&str>,
from: Option<&str>,
to: Option<&str>,
) -> Result<Vec<InternationalFiling>> {
filings::FilingsEndpoints::new(self.client)
.international(symbol, country, from, to)
.await
}
pub async fn transcripts(&self, id: &str) -> Result<EarningsCallTranscript> {
filings::FilingsEndpoints::new(self.client)
.transcript(id)
.await
}
pub async fn transcripts_list(&self, symbol: &str) -> Result<EarningsCallTranscriptsList> {
filings::FilingsEndpoints::new(self.client)
.transcripts_list(symbol)
.await
}
pub async fn earnings_call_live(&self, from: &str, to: &str) -> Result<EarningsCallLive> {
filings::FilingsEndpoints::new(self.client)
.earnings_call_live(from, to)
.await
}
pub async fn presentations(&self, symbol: &str) -> Result<InvestorPresentations> {
filings::FilingsEndpoints::new(self.client)
.presentations(symbol)
.await
}
pub async fn similarity_index(
&self,
symbol: Option<&str>,
cik: Option<&str>,
freq: Option<&str>,
) -> Result<SimilarityIndex> {
filings::FilingsEndpoints::new(self.client)
.similarity_index(symbol, cik, freq)
.await
}
pub async fn eps_estimates(&self, symbol: &str, freq: Option<&str>) -> Result<EPSEstimates> {
estimates::EstimatesEndpoints::new(self.client)
.eps(symbol, freq)
.await
}
pub async fn revenue_estimates(
&self,
symbol: &str,
freq: Option<&str>,
) -> Result<RevenueEstimates> {
estimates::EstimatesEndpoints::new(self.client)
.revenue(symbol, freq)
.await
}
pub async fn ebitda_estimates(
&self,
symbol: &str,
freq: Option<&str>,
) -> Result<EBITDAEstimates> {
estimates::EstimatesEndpoints::new(self.client)
.ebitda(symbol, freq)
.await
}
pub async fn ebit_estimates(&self, symbol: &str, freq: Option<&str>) -> Result<EBITEstimates> {
estimates::EstimatesEndpoints::new(self.client)
.ebit(symbol, freq)
.await
}
pub async fn earnings_quality_score(
&self,
symbol: &str,
freq: &str,
) -> Result<EarningsQualityScore> {
estimates::EstimatesEndpoints::new(self.client)
.earnings_quality_score(symbol, freq)
.await
}
pub async fn executives(&self, symbol: &str) -> Result<CompanyExecutives> {
compliance::ComplianceEndpoints::new(self.client)
.executives(symbol)
.await
}
pub async fn congressional_trading(
&self,
symbol: &str,
from: Option<&str>,
to: Option<&str>,
) -> Result<CongressionalTrading> {
compliance::ComplianceEndpoints::new(self.client)
.congressional_trading(symbol, from, to)
.await
}
pub async fn lobbying(
&self,
symbol: &str,
from: Option<&str>,
to: Option<&str>,
) -> Result<Lobbying> {
compliance::ComplianceEndpoints::new(self.client)
.lobbying(symbol, from, to)
.await
}
pub async fn usa_spending(
&self,
symbol: &str,
from: Option<&str>,
to: Option<&str>,
) -> Result<USASpending> {
compliance::ComplianceEndpoints::new(self.client)
.usa_spending(symbol, from, to)
.await
}
pub async fn esg(&self, symbol: &str) -> Result<ESGScore> {
compliance::ComplianceEndpoints::new(self.client)
.esg(symbol)
.await
}
pub async fn supply_chain(&self, symbol: &str) -> Result<SupplyChainData> {
compliance::ComplianceEndpoints::new(self.client)
.supply_chain(symbol)
.await
}
pub async fn uspto_patents(&self, symbol: &str, from: &str, to: &str) -> Result<USPTOPatents> {
compliance::ComplianceEndpoints::new(self.client)
.uspto_patents(symbol, from, to)
.await
}
pub async fn visa_applications(
&self,
symbol: &str,
from: &str,
to: &str,
) -> Result<VisaApplications> {
compliance::ComplianceEndpoints::new(self.client)
.visa_applications(symbol, from, to)
.await
}
}