use serde::{Deserialize, Serialize};
pub mod screeners {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Screener {
AggressiveSmallCaps,
DayGainers,
DayLosers,
GrowthTechnologyStocks,
MostActives,
MostShortedStocks,
SmallCapGainers,
UndervaluedGrowthStocks,
UndervaluedLargeCaps,
ConservativeForeignFunds,
HighYieldBond,
PortfolioAnchors,
SolidLargeGrowthFunds,
SolidMidcapGrowthFunds,
TopMutualFunds,
}
impl Screener {
pub fn as_scr_id(&self) -> &'static str {
match self {
Screener::AggressiveSmallCaps => "aggressive_small_caps",
Screener::DayGainers => "day_gainers",
Screener::DayLosers => "day_losers",
Screener::GrowthTechnologyStocks => "growth_technology_stocks",
Screener::MostActives => "most_actives",
Screener::MostShortedStocks => "most_shorted_stocks",
Screener::SmallCapGainers => "small_cap_gainers",
Screener::UndervaluedGrowthStocks => "undervalued_growth_stocks",
Screener::UndervaluedLargeCaps => "undervalued_large_caps",
Screener::ConservativeForeignFunds => "conservative_foreign_funds",
Screener::HighYieldBond => "high_yield_bond",
Screener::PortfolioAnchors => "portfolio_anchors",
Screener::SolidLargeGrowthFunds => "solid_large_growth_funds",
Screener::SolidMidcapGrowthFunds => "solid_midcap_growth_funds",
Screener::TopMutualFunds => "top_mutual_funds",
}
}
pub fn parse(s: &str) -> Option<Self> {
s.parse().ok()
}
pub fn valid_types() -> &'static str {
"aggressive-small-caps, day-gainers, day-losers, growth-technology-stocks, \
most-actives, most-shorted-stocks, small-cap-gainers, undervalued-growth-stocks, \
undervalued-large-caps, conservative-foreign-funds, high-yield-bond, \
portfolio-anchors, solid-large-growth-funds, solid-midcap-growth-funds, \
top-mutual-funds"
}
pub fn all() -> &'static [Screener] {
&[
Screener::AggressiveSmallCaps,
Screener::DayGainers,
Screener::DayLosers,
Screener::GrowthTechnologyStocks,
Screener::MostActives,
Screener::MostShortedStocks,
Screener::SmallCapGainers,
Screener::UndervaluedGrowthStocks,
Screener::UndervaluedLargeCaps,
Screener::ConservativeForeignFunds,
Screener::HighYieldBond,
Screener::PortfolioAnchors,
Screener::SolidLargeGrowthFunds,
Screener::SolidMidcapGrowthFunds,
Screener::TopMutualFunds,
]
}
}
impl std::str::FromStr for Screener {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().replace('_', "-").as_str() {
"aggressive-small-caps" => Ok(Screener::AggressiveSmallCaps),
"day-gainers" | "gainers" => Ok(Screener::DayGainers),
"day-losers" | "losers" => Ok(Screener::DayLosers),
"growth-technology-stocks" | "growth-tech" => Ok(Screener::GrowthTechnologyStocks),
"most-actives" | "actives" => Ok(Screener::MostActives),
"most-shorted-stocks" | "most-shorted" => Ok(Screener::MostShortedStocks),
"small-cap-gainers" => Ok(Screener::SmallCapGainers),
"undervalued-growth-stocks" | "undervalued-growth" => {
Ok(Screener::UndervaluedGrowthStocks)
}
"undervalued-large-caps" | "undervalued-large" => {
Ok(Screener::UndervaluedLargeCaps)
}
"conservative-foreign-funds" => Ok(Screener::ConservativeForeignFunds),
"high-yield-bond" => Ok(Screener::HighYieldBond),
"portfolio-anchors" => Ok(Screener::PortfolioAnchors),
"solid-large-growth-funds" => Ok(Screener::SolidLargeGrowthFunds),
"solid-midcap-growth-funds" => Ok(Screener::SolidMidcapGrowthFunds),
"top-mutual-funds" => Ok(Screener::TopMutualFunds),
_ => Err(()),
}
}
}
}
pub mod sectors {
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum Sector {
Technology,
FinancialServices,
ConsumerCyclical,
CommunicationServices,
Healthcare,
Industrials,
ConsumerDefensive,
Energy,
BasicMaterials,
RealEstate,
Utilities,
}
impl Sector {
pub fn as_api_path(&self) -> &'static str {
match self {
Sector::Technology => "technology",
Sector::FinancialServices => "financial-services",
Sector::ConsumerCyclical => "consumer-cyclical",
Sector::CommunicationServices => "communication-services",
Sector::Healthcare => "healthcare",
Sector::Industrials => "industrials",
Sector::ConsumerDefensive => "consumer-defensive",
Sector::Energy => "energy",
Sector::BasicMaterials => "basic-materials",
Sector::RealEstate => "real-estate",
Sector::Utilities => "utilities",
}
}
pub fn display_name(&self) -> &'static str {
match self {
Sector::Technology => "Technology",
Sector::FinancialServices => "Financial Services",
Sector::ConsumerCyclical => "Consumer Cyclical",
Sector::CommunicationServices => "Communication Services",
Sector::Healthcare => "Healthcare",
Sector::Industrials => "Industrials",
Sector::ConsumerDefensive => "Consumer Defensive",
Sector::Energy => "Energy",
Sector::BasicMaterials => "Basic Materials",
Sector::RealEstate => "Real Estate",
Sector::Utilities => "Utilities",
}
}
pub fn valid_types() -> &'static str {
"technology, financial-services, consumer-cyclical, communication-services, \
healthcare, industrials, consumer-defensive, energy, basic-materials, \
real-estate, utilities"
}
pub fn all() -> &'static [Sector] {
&[
Sector::Technology,
Sector::FinancialServices,
Sector::ConsumerCyclical,
Sector::CommunicationServices,
Sector::Healthcare,
Sector::Industrials,
Sector::ConsumerDefensive,
Sector::Energy,
Sector::BasicMaterials,
Sector::RealEstate,
Sector::Utilities,
]
}
}
impl std::str::FromStr for Sector {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().replace('_', "-").as_str() {
"technology" | "tech" => Ok(Sector::Technology),
"financial-services" | "financials" | "financial" => Ok(Sector::FinancialServices),
"consumer-cyclical" => Ok(Sector::ConsumerCyclical),
"communication-services" | "communication" => Ok(Sector::CommunicationServices),
"healthcare" | "health" => Ok(Sector::Healthcare),
"industrials" | "industrial" => Ok(Sector::Industrials),
"consumer-defensive" => Ok(Sector::ConsumerDefensive),
"energy" => Ok(Sector::Energy),
"basic-materials" | "materials" => Ok(Sector::BasicMaterials),
"real-estate" | "realestate" => Ok(Sector::RealEstate),
"utilities" | "utility" => Ok(Sector::Utilities),
_ => Err(()),
}
}
}
impl std::fmt::Display for Sector {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.display_name())
}
}
impl From<Sector> for String {
fn from(v: Sector) -> Self {
v.display_name().to_string()
}
}
}
pub mod indices {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Region {
Americas,
Europe,
AsiaPacific,
MiddleEastAfrica,
Currencies,
}
impl std::str::FromStr for Region {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().replace(['-', '_'], "").as_str() {
"americas" | "america" => Ok(Region::Americas),
"europe" | "eu" => Ok(Region::Europe),
"asiapacific" | "asia" | "apac" => Ok(Region::AsiaPacific),
"middleeastafrica" | "mea" | "emea" => Ok(Region::MiddleEastAfrica),
"currencies" | "currency" | "fx" => Ok(Region::Currencies),
_ => Err(()),
}
}
}
impl Region {
pub fn parse(s: &str) -> Option<Self> {
s.parse().ok()
}
pub fn symbols(&self) -> &'static [&'static str] {
match self {
Region::Americas => AMERICAS,
Region::Europe => EUROPE,
Region::AsiaPacific => ASIA_PACIFIC,
Region::MiddleEastAfrica => MIDDLE_EAST_AFRICA,
Region::Currencies => CURRENCIES,
}
}
pub fn as_str(&self) -> &'static str {
match self {
Region::Americas => "americas",
Region::Europe => "europe",
Region::AsiaPacific => "asia-pacific",
Region::MiddleEastAfrica => "middle-east-africa",
Region::Currencies => "currencies",
}
}
pub fn all() -> &'static [Region] {
&[
Region::Americas,
Region::Europe,
Region::AsiaPacific,
Region::MiddleEastAfrica,
Region::Currencies,
]
}
}
pub const AMERICAS: &[&str] = &[
"^GSPC", "^DJI", "^IXIC", "^NYA", "^XAX", "^RUT", "^VIX", "^GSPTSE", "^BVSP", "^MXX", "^IPSA", "^MERV", ];
pub const EUROPE: &[&str] = &[
"^FTSE", "^GDAXI", "^FCHI", "^STOXX50E", "^N100", "^BFX", "^BUK100P", "MOEX.ME", "^125904-USD-STRD", ];
pub const ASIA_PACIFIC: &[&str] = &[
"^N225", "^HSI", "000001.SS", "^KS11", "^TWII", "^STI", "^AXJO", "^AORD", "^NZ50", "^BSESN", "^JKSE", "^KLSE", ];
pub const MIDDLE_EAST_AFRICA: &[&str] = &[
"^TA125.TA", "^CASE30", "^JN0U.JO", ];
pub const CURRENCIES: &[&str] = &[
"DX-Y.NYB", "^XDB", "^XDE", "^XDN", "^XDA", ];
pub fn all_symbols() -> Vec<&'static str> {
Region::all()
.iter()
.flat_map(|r| r.symbols().iter().copied())
.collect()
}
}
#[allow(missing_docs)]
pub mod fundamental_types {
pub const TOTAL_REVENUE: &str = "TotalRevenue";
pub const OPERATING_REVENUE: &str = "OperatingRevenue";
pub const COST_OF_REVENUE: &str = "CostOfRevenue";
pub const GROSS_PROFIT: &str = "GrossProfit";
pub const OPERATING_EXPENSE: &str = "OperatingExpense";
pub const SELLING_GENERAL_AND_ADMIN: &str = "SellingGeneralAndAdministration";
pub const RESEARCH_AND_DEVELOPMENT: &str = "ResearchAndDevelopment";
pub const OPERATING_INCOME: &str = "OperatingIncome";
pub const NET_INTEREST_INCOME: &str = "NetInterestIncome";
pub const INTEREST_EXPENSE: &str = "InterestExpense";
pub const INTEREST_INCOME: &str = "InterestIncome";
pub const NET_NON_OPERATING_INTEREST_INCOME_EXPENSE: &str =
"NetNonOperatingInterestIncomeExpense";
pub const OTHER_INCOME_EXPENSE: &str = "OtherIncomeExpense";
pub const PRETAX_INCOME: &str = "PretaxIncome";
pub const TAX_PROVISION: &str = "TaxProvision";
pub const NET_INCOME_COMMON_STOCKHOLDERS: &str = "NetIncomeCommonStockholders";
pub const NET_INCOME: &str = "NetIncome";
pub const DILUTED_EPS: &str = "DilutedEPS";
pub const BASIC_EPS: &str = "BasicEPS";
pub const DILUTED_AVERAGE_SHARES: &str = "DilutedAverageShares";
pub const BASIC_AVERAGE_SHARES: &str = "BasicAverageShares";
pub const EBIT: &str = "EBIT";
pub const EBITDA: &str = "EBITDA";
pub const RECONCILED_COST_OF_REVENUE: &str = "ReconciledCostOfRevenue";
pub const RECONCILED_DEPRECIATION: &str = "ReconciledDepreciation";
pub const NET_INCOME_FROM_CONTINUING_OPERATION_NET_MINORITY_INTEREST: &str =
"NetIncomeFromContinuingOperationNetMinorityInterest";
pub const NORMALIZED_EBITDA: &str = "NormalizedEBITDA";
pub const TOTAL_EXPENSES: &str = "TotalExpenses";
pub const TOTAL_OPERATING_INCOME_AS_REPORTED: &str = "TotalOperatingIncomeAsReported";
pub const TOTAL_ASSETS: &str = "TotalAssets";
pub const CURRENT_ASSETS: &str = "CurrentAssets";
pub const CASH_CASH_EQUIVALENTS_AND_SHORT_TERM_INVESTMENTS: &str =
"CashCashEquivalentsAndShortTermInvestments";
pub const CASH_AND_CASH_EQUIVALENTS: &str = "CashAndCashEquivalents";
pub const CASH_FINANCIAL: &str = "CashFinancial";
pub const RECEIVABLES: &str = "Receivables";
pub const ACCOUNTS_RECEIVABLE: &str = "AccountsReceivable";
pub const INVENTORY: &str = "Inventory";
pub const PREPAID_ASSETS: &str = "PrepaidAssets";
pub const OTHER_CURRENT_ASSETS: &str = "OtherCurrentAssets";
pub const TOTAL_NON_CURRENT_ASSETS: &str = "TotalNonCurrentAssets";
pub const NET_PPE: &str = "NetPPE";
pub const GROSS_PPE: &str = "GrossPPE";
pub const ACCUMULATED_DEPRECIATION: &str = "AccumulatedDepreciation";
pub const GOODWILL: &str = "Goodwill";
pub const GOODWILL_AND_OTHER_INTANGIBLE_ASSETS: &str = "GoodwillAndOtherIntangibleAssets";
pub const OTHER_INTANGIBLE_ASSETS: &str = "OtherIntangibleAssets";
pub const INVESTMENTS_AND_ADVANCES: &str = "InvestmentsAndAdvances";
pub const LONG_TERM_EQUITY_INVESTMENT: &str = "LongTermEquityInvestment";
pub const OTHER_NON_CURRENT_ASSETS: &str = "OtherNonCurrentAssets";
pub const TOTAL_LIABILITIES_NET_MINORITY_INTEREST: &str = "TotalLiabilitiesNetMinorityInterest";
pub const CURRENT_LIABILITIES: &str = "CurrentLiabilities";
pub const PAYABLES_AND_ACCRUED_EXPENSES: &str = "PayablesAndAccruedExpenses";
pub const ACCOUNTS_PAYABLE: &str = "AccountsPayable";
pub const CURRENT_DEBT: &str = "CurrentDebt";
pub const CURRENT_DEFERRED_REVENUE: &str = "CurrentDeferredRevenue";
pub const OTHER_CURRENT_LIABILITIES: &str = "OtherCurrentLiabilities";
pub const TOTAL_NON_CURRENT_LIABILITIES_NET_MINORITY_INTEREST: &str =
"TotalNonCurrentLiabilitiesNetMinorityInterest";
pub const LONG_TERM_DEBT: &str = "LongTermDebt";
pub const LONG_TERM_DEBT_AND_CAPITAL_LEASE_OBLIGATION: &str =
"LongTermDebtAndCapitalLeaseObligation";
pub const NON_CURRENT_DEFERRED_REVENUE: &str = "NonCurrentDeferredRevenue";
pub const NON_CURRENT_DEFERRED_TAXES_LIABILITIES: &str = "NonCurrentDeferredTaxesLiabilities";
pub const OTHER_NON_CURRENT_LIABILITIES: &str = "OtherNonCurrentLiabilities";
pub const STOCKHOLDERS_EQUITY: &str = "StockholdersEquity";
pub const COMMON_STOCK_EQUITY: &str = "CommonStockEquity";
pub const COMMON_STOCK: &str = "CommonStock";
pub const RETAINED_EARNINGS: &str = "RetainedEarnings";
pub const ADDITIONAL_PAID_IN_CAPITAL: &str = "AdditionalPaidInCapital";
pub const TREASURY_STOCK: &str = "TreasuryStock";
pub const TOTAL_EQUITY_GROSS_MINORITY_INTEREST: &str = "TotalEquityGrossMinorityInterest";
pub const WORKING_CAPITAL: &str = "WorkingCapital";
pub const INVESTED_CAPITAL: &str = "InvestedCapital";
pub const TANGIBLE_BOOK_VALUE: &str = "TangibleBookValue";
pub const TOTAL_DEBT: &str = "TotalDebt";
pub const NET_DEBT: &str = "NetDebt";
pub const SHARE_ISSUED: &str = "ShareIssued";
pub const ORDINARY_SHARES_NUMBER: &str = "OrdinarySharesNumber";
pub const OPERATING_CASH_FLOW: &str = "OperatingCashFlow";
pub const CASH_FLOW_FROM_CONTINUING_OPERATING_ACTIVITIES: &str =
"CashFlowFromContinuingOperatingActivities";
pub const NET_INCOME_FROM_CONTINUING_OPERATIONS: &str = "NetIncomeFromContinuingOperations";
pub const DEPRECIATION_AND_AMORTIZATION: &str = "DepreciationAndAmortization";
pub const DEFERRED_INCOME_TAX: &str = "DeferredIncomeTax";
pub const CHANGE_IN_WORKING_CAPITAL: &str = "ChangeInWorkingCapital";
pub const CHANGE_IN_RECEIVABLES: &str = "ChangeInReceivables";
pub const CHANGES_IN_ACCOUNT_RECEIVABLES: &str = "ChangesInAccountReceivables";
pub const CHANGE_IN_INVENTORY: &str = "ChangeInInventory";
pub const CHANGE_IN_ACCOUNT_PAYABLE: &str = "ChangeInAccountPayable";
pub const CHANGE_IN_OTHER_WORKING_CAPITAL: &str = "ChangeInOtherWorkingCapital";
pub const STOCK_BASED_COMPENSATION: &str = "StockBasedCompensation";
pub const OTHER_NON_CASH_ITEMS: &str = "OtherNonCashItems";
pub const INVESTING_CASH_FLOW: &str = "InvestingCashFlow";
pub const CASH_FLOW_FROM_CONTINUING_INVESTING_ACTIVITIES: &str =
"CashFlowFromContinuingInvestingActivities";
pub const NET_PPE_PURCHASE_AND_SALE: &str = "NetPPEPurchaseAndSale";
pub const PURCHASE_OF_PPE: &str = "PurchaseOfPPE";
pub const SALE_OF_PPE: &str = "SaleOfPPE";
pub const CAPITAL_EXPENDITURE: &str = "CapitalExpenditure";
pub const NET_BUSINESS_PURCHASE_AND_SALE: &str = "NetBusinessPurchaseAndSale";
pub const PURCHASE_OF_BUSINESS: &str = "PurchaseOfBusiness";
pub const SALE_OF_BUSINESS: &str = "SaleOfBusiness";
pub const NET_INVESTMENT_PURCHASE_AND_SALE: &str = "NetInvestmentPurchaseAndSale";
pub const PURCHASE_OF_INVESTMENT: &str = "PurchaseOfInvestment";
pub const SALE_OF_INVESTMENT: &str = "SaleOfInvestment";
pub const NET_OTHER_INVESTING_CHANGES: &str = "NetOtherInvestingChanges";
pub const FINANCING_CASH_FLOW: &str = "FinancingCashFlow";
pub const CASH_FLOW_FROM_CONTINUING_FINANCING_ACTIVITIES: &str =
"CashFlowFromContinuingFinancingActivities";
pub const NET_ISSUANCE_PAYMENTS_OF_DEBT: &str = "NetIssuancePaymentsOfDebt";
pub const NET_LONG_TERM_DEBT_ISSUANCE: &str = "NetLongTermDebtIssuance";
pub const LONG_TERM_DEBT_ISSUANCE: &str = "LongTermDebtIssuance";
pub const LONG_TERM_DEBT_PAYMENTS: &str = "LongTermDebtPayments";
pub const NET_SHORT_TERM_DEBT_ISSUANCE: &str = "NetShortTermDebtIssuance";
pub const NET_COMMON_STOCK_ISSUANCE: &str = "NetCommonStockIssuance";
pub const COMMON_STOCK_ISSUANCE: &str = "CommonStockIssuance";
pub const COMMON_STOCK_PAYMENTS: &str = "CommonStockPayments";
pub const REPURCHASE_OF_CAPITAL_STOCK: &str = "RepurchaseOfCapitalStock";
pub const CASH_DIVIDENDS_PAID: &str = "CashDividendsPaid";
pub const COMMON_STOCK_DIVIDEND_PAID: &str = "CommonStockDividendPaid";
pub const NET_OTHER_FINANCING_CHARGES: &str = "NetOtherFinancingCharges";
pub const END_CASH_POSITION: &str = "EndCashPosition";
pub const BEGINNING_CASH_POSITION: &str = "BeginningCashPosition";
pub const CHANGESIN_CASH: &str = "ChangesinCash";
pub const EFFECT_OF_EXCHANGE_RATE_CHANGES: &str = "EffectOfExchangeRateChanges";
pub const FREE_CASH_FLOW: &str = "FreeCashFlow";
pub const CAPITAL_EXPENDITURE_REPORTED: &str = "CapitalExpenditureReported";
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum StatementType {
Income,
Balance,
CashFlow,
}
impl StatementType {
pub fn as_str(&self) -> &'static str {
match self {
StatementType::Income => "income",
StatementType::Balance => "balance",
StatementType::CashFlow => "cashflow",
}
}
pub fn get_fields(&self) -> &'static [&'static str] {
match self {
StatementType::Income => &INCOME_STATEMENT_FIELDS,
StatementType::Balance => &BALANCE_SHEET_FIELDS,
StatementType::CashFlow => &CASH_FLOW_FIELDS,
}
}
}
const INCOME_STATEMENT_FIELDS: [&str; 30] = [
fundamental_types::TOTAL_REVENUE,
fundamental_types::OPERATING_REVENUE,
fundamental_types::COST_OF_REVENUE,
fundamental_types::GROSS_PROFIT,
fundamental_types::OPERATING_EXPENSE,
fundamental_types::SELLING_GENERAL_AND_ADMIN,
fundamental_types::RESEARCH_AND_DEVELOPMENT,
fundamental_types::OPERATING_INCOME,
fundamental_types::NET_INTEREST_INCOME,
fundamental_types::INTEREST_EXPENSE,
fundamental_types::INTEREST_INCOME,
fundamental_types::NET_NON_OPERATING_INTEREST_INCOME_EXPENSE,
fundamental_types::OTHER_INCOME_EXPENSE,
fundamental_types::PRETAX_INCOME,
fundamental_types::TAX_PROVISION,
fundamental_types::NET_INCOME_COMMON_STOCKHOLDERS,
fundamental_types::NET_INCOME,
fundamental_types::DILUTED_EPS,
fundamental_types::BASIC_EPS,
fundamental_types::DILUTED_AVERAGE_SHARES,
fundamental_types::BASIC_AVERAGE_SHARES,
fundamental_types::EBIT,
fundamental_types::EBITDA,
fundamental_types::RECONCILED_COST_OF_REVENUE,
fundamental_types::RECONCILED_DEPRECIATION,
fundamental_types::NET_INCOME_FROM_CONTINUING_OPERATION_NET_MINORITY_INTEREST,
fundamental_types::NORMALIZED_EBITDA,
fundamental_types::TOTAL_EXPENSES,
fundamental_types::TOTAL_OPERATING_INCOME_AS_REPORTED,
fundamental_types::DEPRECIATION_AND_AMORTIZATION,
];
const BALANCE_SHEET_FIELDS: [&str; 48] = [
fundamental_types::TOTAL_ASSETS,
fundamental_types::CURRENT_ASSETS,
fundamental_types::CASH_CASH_EQUIVALENTS_AND_SHORT_TERM_INVESTMENTS,
fundamental_types::CASH_AND_CASH_EQUIVALENTS,
fundamental_types::CASH_FINANCIAL,
fundamental_types::RECEIVABLES,
fundamental_types::ACCOUNTS_RECEIVABLE,
fundamental_types::INVENTORY,
fundamental_types::PREPAID_ASSETS,
fundamental_types::OTHER_CURRENT_ASSETS,
fundamental_types::TOTAL_NON_CURRENT_ASSETS,
fundamental_types::NET_PPE,
fundamental_types::GROSS_PPE,
fundamental_types::ACCUMULATED_DEPRECIATION,
fundamental_types::GOODWILL,
fundamental_types::GOODWILL_AND_OTHER_INTANGIBLE_ASSETS,
fundamental_types::OTHER_INTANGIBLE_ASSETS,
fundamental_types::INVESTMENTS_AND_ADVANCES,
fundamental_types::LONG_TERM_EQUITY_INVESTMENT,
fundamental_types::OTHER_NON_CURRENT_ASSETS,
fundamental_types::TOTAL_LIABILITIES_NET_MINORITY_INTEREST,
fundamental_types::CURRENT_LIABILITIES,
fundamental_types::PAYABLES_AND_ACCRUED_EXPENSES,
fundamental_types::ACCOUNTS_PAYABLE,
fundamental_types::CURRENT_DEBT,
fundamental_types::CURRENT_DEFERRED_REVENUE,
fundamental_types::OTHER_CURRENT_LIABILITIES,
fundamental_types::TOTAL_NON_CURRENT_LIABILITIES_NET_MINORITY_INTEREST,
fundamental_types::LONG_TERM_DEBT,
fundamental_types::LONG_TERM_DEBT_AND_CAPITAL_LEASE_OBLIGATION,
fundamental_types::NON_CURRENT_DEFERRED_REVENUE,
fundamental_types::NON_CURRENT_DEFERRED_TAXES_LIABILITIES,
fundamental_types::OTHER_NON_CURRENT_LIABILITIES,
fundamental_types::STOCKHOLDERS_EQUITY,
fundamental_types::COMMON_STOCK_EQUITY,
fundamental_types::COMMON_STOCK,
fundamental_types::RETAINED_EARNINGS,
fundamental_types::ADDITIONAL_PAID_IN_CAPITAL,
fundamental_types::TREASURY_STOCK,
fundamental_types::TOTAL_EQUITY_GROSS_MINORITY_INTEREST,
fundamental_types::WORKING_CAPITAL,
fundamental_types::INVESTED_CAPITAL,
fundamental_types::TANGIBLE_BOOK_VALUE,
fundamental_types::TOTAL_DEBT,
fundamental_types::NET_DEBT,
fundamental_types::SHARE_ISSUED,
fundamental_types::ORDINARY_SHARES_NUMBER,
fundamental_types::DEPRECIATION_AND_AMORTIZATION,
];
const CASH_FLOW_FIELDS: [&str; 47] = [
fundamental_types::OPERATING_CASH_FLOW,
fundamental_types::CASH_FLOW_FROM_CONTINUING_OPERATING_ACTIVITIES,
fundamental_types::NET_INCOME_FROM_CONTINUING_OPERATIONS,
fundamental_types::DEPRECIATION_AND_AMORTIZATION,
fundamental_types::DEFERRED_INCOME_TAX,
fundamental_types::CHANGE_IN_WORKING_CAPITAL,
fundamental_types::CHANGE_IN_RECEIVABLES,
fundamental_types::CHANGES_IN_ACCOUNT_RECEIVABLES,
fundamental_types::CHANGE_IN_INVENTORY,
fundamental_types::CHANGE_IN_ACCOUNT_PAYABLE,
fundamental_types::CHANGE_IN_OTHER_WORKING_CAPITAL,
fundamental_types::STOCK_BASED_COMPENSATION,
fundamental_types::OTHER_NON_CASH_ITEMS,
fundamental_types::INVESTING_CASH_FLOW,
fundamental_types::CASH_FLOW_FROM_CONTINUING_INVESTING_ACTIVITIES,
fundamental_types::NET_PPE_PURCHASE_AND_SALE,
fundamental_types::PURCHASE_OF_PPE,
fundamental_types::SALE_OF_PPE,
fundamental_types::CAPITAL_EXPENDITURE,
fundamental_types::NET_BUSINESS_PURCHASE_AND_SALE,
fundamental_types::PURCHASE_OF_BUSINESS,
fundamental_types::SALE_OF_BUSINESS,
fundamental_types::NET_INVESTMENT_PURCHASE_AND_SALE,
fundamental_types::PURCHASE_OF_INVESTMENT,
fundamental_types::SALE_OF_INVESTMENT,
fundamental_types::NET_OTHER_INVESTING_CHANGES,
fundamental_types::FINANCING_CASH_FLOW,
fundamental_types::CASH_FLOW_FROM_CONTINUING_FINANCING_ACTIVITIES,
fundamental_types::NET_ISSUANCE_PAYMENTS_OF_DEBT,
fundamental_types::NET_LONG_TERM_DEBT_ISSUANCE,
fundamental_types::LONG_TERM_DEBT_ISSUANCE,
fundamental_types::LONG_TERM_DEBT_PAYMENTS,
fundamental_types::NET_SHORT_TERM_DEBT_ISSUANCE,
fundamental_types::NET_COMMON_STOCK_ISSUANCE,
fundamental_types::COMMON_STOCK_ISSUANCE,
fundamental_types::COMMON_STOCK_PAYMENTS,
fundamental_types::REPURCHASE_OF_CAPITAL_STOCK,
fundamental_types::CASH_DIVIDENDS_PAID,
fundamental_types::COMMON_STOCK_DIVIDEND_PAID,
fundamental_types::NET_OTHER_FINANCING_CHARGES,
fundamental_types::END_CASH_POSITION,
fundamental_types::BEGINNING_CASH_POSITION,
fundamental_types::CHANGESIN_CASH,
fundamental_types::EFFECT_OF_EXCHANGE_RATE_CHANGES,
fundamental_types::FREE_CASH_FLOW,
fundamental_types::CAPITAL_EXPENDITURE_REPORTED,
fundamental_types::DEPRECIATION_AND_AMORTIZATION,
];
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Frequency {
Annual,
Quarterly,
}
impl Frequency {
pub fn as_str(&self) -> &'static str {
match self {
Frequency::Annual => "annual",
Frequency::Quarterly => "quarterly",
}
}
pub fn prefix(&self, field: &str) -> String {
format!("{}{}", self.as_str(), field)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Interval {
#[serde(rename = "1m")]
OneMinute,
#[serde(rename = "5m")]
FiveMinutes,
#[serde(rename = "15m")]
FifteenMinutes,
#[serde(rename = "30m")]
ThirtyMinutes,
#[serde(rename = "1h")]
OneHour,
#[serde(rename = "1d")]
OneDay,
#[serde(rename = "1wk")]
OneWeek,
#[serde(rename = "1mo")]
OneMonth,
#[serde(rename = "3mo")]
ThreeMonths,
}
impl Interval {
pub fn as_str(&self) -> &'static str {
match self {
Interval::OneMinute => "1m",
Interval::FiveMinutes => "5m",
Interval::FifteenMinutes => "15m",
Interval::ThirtyMinutes => "30m",
Interval::OneHour => "1h",
Interval::OneDay => "1d",
Interval::OneWeek => "1wk",
Interval::OneMonth => "1mo",
Interval::ThreeMonths => "3mo",
}
}
}
impl std::fmt::Display for Interval {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TimeRange {
#[serde(rename = "1d")]
OneDay,
#[serde(rename = "5d")]
FiveDays,
#[serde(rename = "1mo")]
OneMonth,
#[serde(rename = "3mo")]
ThreeMonths,
#[serde(rename = "6mo")]
SixMonths,
#[serde(rename = "1y")]
OneYear,
#[serde(rename = "2y")]
TwoYears,
#[serde(rename = "5y")]
FiveYears,
#[serde(rename = "10y")]
TenYears,
#[serde(rename = "ytd")]
YearToDate,
#[serde(rename = "max")]
Max,
}
impl TimeRange {
pub fn as_str(&self) -> &'static str {
match self {
TimeRange::OneDay => "1d",
TimeRange::FiveDays => "5d",
TimeRange::OneMonth => "1mo",
TimeRange::ThreeMonths => "3mo",
TimeRange::SixMonths => "6mo",
TimeRange::OneYear => "1y",
TimeRange::TwoYears => "2y",
TimeRange::FiveYears => "5y",
TimeRange::TenYears => "10y",
TimeRange::YearToDate => "ytd",
TimeRange::Max => "max",
}
}
}
impl std::fmt::Display for TimeRange {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Region {
Argentina,
Australia,
Brazil,
Canada,
China,
Denmark,
Finland,
France,
Germany,
Greece,
HongKong,
India,
Israel,
Italy,
Malaysia,
NewZealand,
Norway,
Portugal,
Russia,
Singapore,
Spain,
Sweden,
Taiwan,
Thailand,
Turkey,
UnitedKingdom,
#[default]
UnitedStates,
Vietnam,
}
impl Region {
pub fn lang(&self) -> &'static str {
match self {
Region::Argentina => "es-AR",
Region::Australia => "en-AU",
Region::Brazil => "pt-BR",
Region::Canada => "en-CA",
Region::China => "zh-CN",
Region::Denmark => "da-DK",
Region::Finland => "fi-FI",
Region::France => "fr-FR",
Region::Germany => "de-DE",
Region::Greece => "el-GR",
Region::HongKong => "zh-Hant-HK",
Region::India => "en-IN",
Region::Israel => "he-IL",
Region::Italy => "it-IT",
Region::Malaysia => "ms-MY",
Region::NewZealand => "en-NZ",
Region::Norway => "nb-NO",
Region::Portugal => "pt-PT",
Region::Russia => "ru-RU",
Region::Singapore => "en-SG",
Region::Spain => "es-ES",
Region::Sweden => "sv-SE",
Region::Taiwan => "zh-TW",
Region::Thailand => "th-TH",
Region::Turkey => "tr-TR",
Region::UnitedKingdom => "en-GB",
Region::UnitedStates => "en-US",
Region::Vietnam => "vi-VN",
}
}
pub fn region(&self) -> &'static str {
match self {
Region::Argentina => "AR",
Region::Australia => "AU",
Region::Brazil => "BR",
Region::Canada => "CA",
Region::China => "CN",
Region::Denmark => "DK",
Region::Finland => "FI",
Region::France => "FR",
Region::Germany => "DE",
Region::Greece => "GR",
Region::HongKong => "HK",
Region::India => "IN",
Region::Israel => "IL",
Region::Italy => "IT",
Region::Malaysia => "MY",
Region::NewZealand => "NZ",
Region::Norway => "NO",
Region::Portugal => "PT",
Region::Russia => "RU",
Region::Singapore => "SG",
Region::Spain => "ES",
Region::Sweden => "SE",
Region::Taiwan => "TW",
Region::Thailand => "TH",
Region::Turkey => "TR",
Region::UnitedKingdom => "GB",
Region::UnitedStates => "US",
Region::Vietnam => "VN",
}
}
pub fn cors_domain(&self) -> &'static str {
match self {
Region::Argentina => "ar.finance.yahoo.com",
Region::Australia => "au.finance.yahoo.com",
Region::Brazil => "br.financas.yahoo.com",
Region::Canada => "ca.finance.yahoo.com",
Region::China => "cn.finance.yahoo.com",
Region::Denmark => "dk.finance.yahoo.com",
Region::Finland => "fi.finance.yahoo.com",
Region::France => "fr.finance.yahoo.com",
Region::Germany => "de.finance.yahoo.com",
Region::Greece => "gr.finance.yahoo.com",
Region::HongKong => "hk.finance.yahoo.com",
Region::India => "in.finance.yahoo.com",
Region::Israel => "il.finance.yahoo.com",
Region::Italy => "it.finance.yahoo.com",
Region::Malaysia => "my.finance.yahoo.com",
Region::NewZealand => "nz.finance.yahoo.com",
Region::Norway => "no.finance.yahoo.com",
Region::Portugal => "pt.finance.yahoo.com",
Region::Russia => "ru.finance.yahoo.com",
Region::Singapore => "sg.finance.yahoo.com",
Region::Spain => "es.finance.yahoo.com",
Region::Sweden => "se.finance.yahoo.com",
Region::Taiwan => "tw.finance.yahoo.com",
Region::Thailand => "th.finance.yahoo.com",
Region::Turkey => "tr.finance.yahoo.com",
Region::UnitedKingdom => "uk.finance.yahoo.com",
Region::UnitedStates => "finance.yahoo.com",
Region::Vietnam => "vn.finance.yahoo.com",
}
}
pub const fn utc_offset_secs(&self) -> i64 {
match self {
Region::UnitedStates | Region::Canada => -18_000,
Region::Argentina | Region::Brazil => -10_800,
Region::UnitedKingdom | Region::Portugal => 0,
Region::France
| Region::Germany
| Region::Italy
| Region::Spain
| Region::Norway
| Region::Sweden
| Region::Denmark
| Region::Finland => 3_600,
Region::Greece | Region::Israel => 7_200,
Region::Turkey | Region::Russia => 10_800,
Region::India => 19_800,
Region::Thailand | Region::Vietnam => 25_200,
Region::China
| Region::HongKong
| Region::Singapore
| Region::Malaysia
| Region::Taiwan => 28_800,
Region::Australia => 36_000,
Region::NewZealand => 43_200,
}
}
}
impl std::str::FromStr for Region {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_uppercase().as_str() {
"AR" => Ok(Region::Argentina),
"AU" => Ok(Region::Australia),
"BR" => Ok(Region::Brazil),
"CA" => Ok(Region::Canada),
"CN" => Ok(Region::China),
"DK" => Ok(Region::Denmark),
"FI" => Ok(Region::Finland),
"FR" => Ok(Region::France),
"DE" => Ok(Region::Germany),
"GR" => Ok(Region::Greece),
"HK" => Ok(Region::HongKong),
"IN" => Ok(Region::India),
"IL" => Ok(Region::Israel),
"IT" => Ok(Region::Italy),
"MY" => Ok(Region::Malaysia),
"NZ" => Ok(Region::NewZealand),
"NO" => Ok(Region::Norway),
"PT" => Ok(Region::Portugal),
"RU" => Ok(Region::Russia),
"SG" => Ok(Region::Singapore),
"ES" => Ok(Region::Spain),
"SE" => Ok(Region::Sweden),
"TW" => Ok(Region::Taiwan),
"TH" => Ok(Region::Thailand),
"TR" => Ok(Region::Turkey),
"GB" | "UK" => Ok(Region::UnitedKingdom),
"US" => Ok(Region::UnitedStates),
"VN" => Ok(Region::Vietnam),
_ => Err(()),
}
}
}
impl From<Region> for String {
fn from(v: Region) -> Self {
v.region().to_lowercase()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum ValueFormat {
#[default]
Raw,
Pretty,
Both,
}
impl std::str::FromStr for ValueFormat {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"raw" => Ok(ValueFormat::Raw),
"pretty" | "fmt" => Ok(ValueFormat::Pretty),
"both" | "full" => Ok(ValueFormat::Both),
_ => Err(()),
}
}
}
impl ValueFormat {
pub fn parse(s: &str) -> Option<Self> {
s.parse().ok()
}
pub fn as_str(&self) -> &'static str {
match self {
ValueFormat::Raw => "raw",
ValueFormat::Pretty => "pretty",
ValueFormat::Both => "both",
}
}
pub fn transform(&self, value: serde_json::Value) -> serde_json::Value {
match self {
ValueFormat::Both => value, _ => self.transform_recursive(value),
}
}
fn transform_recursive(&self, value: serde_json::Value) -> serde_json::Value {
use serde_json::Value;
match value {
Value::Object(map) => {
if self.is_formatted_value(&map) {
return self.extract_value(&map);
}
let transformed: serde_json::Map<String, Value> = map
.into_iter()
.map(|(k, v)| (k, self.transform_recursive(v)))
.collect();
Value::Object(transformed)
}
Value::Array(arr) => Value::Array(
arr.into_iter()
.map(|v| self.transform_recursive(v))
.collect(),
),
other => other,
}
}
fn is_formatted_value(&self, map: &serde_json::Map<String, serde_json::Value>) -> bool {
if !map.contains_key("raw") {
return false;
}
let known_keys = ["raw", "fmt", "longFmt"];
let unknown_keys = map
.keys()
.filter(|k| !known_keys.contains(&k.as_str()))
.count();
unknown_keys == 0
}
fn extract_value(&self, map: &serde_json::Map<String, serde_json::Value>) -> serde_json::Value {
match self {
ValueFormat::Raw => {
map.get("raw").cloned().unwrap_or(serde_json::Value::Null)
}
ValueFormat::Pretty => {
map.get("fmt")
.or_else(|| map.get("longFmt"))
.cloned()
.unwrap_or(serde_json::Value::Null)
}
ValueFormat::Both => {
serde_json::Value::Object(map.clone())
}
}
}
}
pub mod industries {
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Industry {
AgriculturalInputs,
Aluminum,
Coal,
Copper,
FarmProducts,
ForestProducts,
Gold,
LumberAndWoodProduction,
OtherIndustrialMetalsAndMining,
OtherPreciousMetalsAndMining,
Silver,
Steel,
ThermalCoal,
Uranium,
ApparelManufacturing,
ApparelRetail,
AutoAndTruckDealerships,
AutoManufacturers,
AutoParts,
BeveragesBrewers,
BeveragesNonAlcoholic,
BeveragesWineriesAndDistilleries,
Confectioners,
DepartmentStores,
DiscountStores,
ElectronicGamingAndMultimedia,
FoodDistribution,
FootwearAndAccessories,
FurnishingsFixturesAndAppliances,
Gambling,
GroceryStores,
HomeImprovementRetail,
HouseholdAndPersonalProducts,
InternetRetail,
Leisure,
Lodging,
LuxuryGoods,
PackagedFoods,
PersonalServices,
ResidentialConstruction,
ResortsAndCasinos,
Restaurants,
SpecialtyRetail,
TextileManufacturing,
Tobacco,
TravelServices,
OilAndGasDrilling,
OilAndGasEAndP,
OilAndGasEquipmentAndServices,
OilAndGasIntegrated,
OilAndGasMidstream,
OilAndGasRefiningAndMarketing,
Solar,
AssetManagement,
BanksDiversified,
BanksRegional,
CapitalMarkets,
CreditServices,
FinancialDataAndStockExchanges,
InsuranceBrokers,
InsuranceDiversified,
InsuranceLife,
InsurancePropertyAndCasualty,
InsuranceReinsurance,
InsuranceSpecialty,
MortgageFinance,
ShellCompanies,
Biotechnology,
DiagnosticsAndResearch,
DrugManufacturersGeneral,
DrugManufacturersSpecialtyAndGeneric,
HealthInformationServices,
HealthcarePlans,
MedicalCareFacilities,
MedicalDevices,
MedicalDistribution,
MedicalInstrumentsAndSupplies,
PharmaceuticalRetailers,
AerospaceAndDefense,
BuildingMaterials,
BuildingProductsAndEquipment,
BusinessEquipmentAndSupplies,
ChemicalManufacturing,
Chemicals,
Conglomerates,
ConsultingServices,
ElectricalEquipmentAndParts,
EngineeringAndConstruction,
FarmAndHeavyConstructionMachinery,
IndustrialDistribution,
InfrastructureOperations,
IntegratedFreightAndLogistics,
ManufacturingDiversified,
MarinePortsAndServices,
MarineShipping,
MetalFabrication,
PaperAndPaperProducts,
PollutionAndTreatmentControls,
Railroads,
RentalAndLeasingServices,
SecurityAndProtectionServices,
SpecialtyBusinessServices,
SpecialtyChemicals,
SpecialtyIndustrialMachinery,
StaffingAndEmploymentServices,
ToolsAndAccessories,
Trucking,
WasteManagement,
RealEstateDevelopment,
RealEstateDiversified,
RealEstateServices,
ReitDiversified,
ReitHealthcareFacilities,
ReitHotelAndMotel,
ReitIndustrial,
ReitMortgage,
ReitOffice,
ReitResidential,
ReitRetail,
ReitSpecialty,
CommunicationEquipment,
ComputerHardware,
ConsumerElectronics,
DataAnalytics,
ElectronicComponents,
ElectronicsAndComputerDistribution,
HardwareAndSoftwareDistribution,
InformationTechnologyServices,
InternetContentAndInformation,
ScientificAndTechnicalInstruments,
SemiconductorEquipmentAndMaterials,
Semiconductors,
SoftwareApplication,
SoftwareInfrastructure,
Broadcasting,
Entertainment,
Publishing,
TelecomServices,
UtilitiesDiversified,
UtilitiesIndependentPowerProducers,
UtilitiesRegulatedElectric,
UtilitiesRegulatedGas,
UtilitiesRegulatedWater,
UtilitiesRenewable,
ClosedEndFundDebt,
ClosedEndFundEquity,
ClosedEndFundForeign,
ExchangeTradedFund,
}
impl Industry {
pub fn as_slug(self) -> &'static str {
match self {
Industry::AgriculturalInputs => "agricultural-inputs",
Industry::Aluminum => "aluminum",
Industry::Coal => "coal",
Industry::Copper => "copper",
Industry::FarmProducts => "farm-products",
Industry::ForestProducts => "forest-products",
Industry::Gold => "gold",
Industry::LumberAndWoodProduction => "lumber-wood-production",
Industry::OtherIndustrialMetalsAndMining => "other-industrial-metals-mining",
Industry::OtherPreciousMetalsAndMining => "other-precious-metals-mining",
Industry::Silver => "silver",
Industry::Steel => "steel",
Industry::ThermalCoal => "thermal-coal",
Industry::Uranium => "uranium",
Industry::ApparelManufacturing => "apparel-manufacturing",
Industry::ApparelRetail => "apparel-retail",
Industry::AutoAndTruckDealerships => "auto-truck-dealerships",
Industry::AutoManufacturers => "auto-manufacturers",
Industry::AutoParts => "auto-parts",
Industry::BeveragesBrewers => "beverages-brewers",
Industry::BeveragesNonAlcoholic => "beverages-non-alcoholic",
Industry::BeveragesWineriesAndDistilleries => "beverages-wineries-distilleries",
Industry::Confectioners => "confectioners",
Industry::DepartmentStores => "department-stores",
Industry::DiscountStores => "discount-stores",
Industry::ElectronicGamingAndMultimedia => "electronic-gaming-multimedia",
Industry::FoodDistribution => "food-distribution",
Industry::FootwearAndAccessories => "footwear-accessories",
Industry::FurnishingsFixturesAndAppliances => "furnishings-fixtures-appliances",
Industry::Gambling => "gambling",
Industry::GroceryStores => "grocery-stores",
Industry::HomeImprovementRetail => "home-improvement-retail",
Industry::HouseholdAndPersonalProducts => "household-personal-products",
Industry::InternetRetail => "internet-retail",
Industry::Leisure => "leisure",
Industry::Lodging => "lodging",
Industry::LuxuryGoods => "luxury-goods",
Industry::PackagedFoods => "packaged-foods",
Industry::PersonalServices => "personal-services",
Industry::ResidentialConstruction => "residential-construction",
Industry::ResortsAndCasinos => "resorts-casinos",
Industry::Restaurants => "restaurants",
Industry::SpecialtyRetail => "specialty-retail",
Industry::TextileManufacturing => "textile-manufacturing",
Industry::Tobacco => "tobacco",
Industry::TravelServices => "travel-services",
Industry::OilAndGasDrilling => "oil-gas-drilling",
Industry::OilAndGasEAndP => "oil-gas-ep",
Industry::OilAndGasEquipmentAndServices => "oil-gas-equipment-services",
Industry::OilAndGasIntegrated => "oil-gas-integrated",
Industry::OilAndGasMidstream => "oil-gas-midstream",
Industry::OilAndGasRefiningAndMarketing => "oil-gas-refining-marketing",
Industry::Solar => "solar",
Industry::AssetManagement => "asset-management",
Industry::BanksDiversified => "banks-diversified",
Industry::BanksRegional => "banks-regional",
Industry::CapitalMarkets => "capital-markets",
Industry::CreditServices => "credit-services",
Industry::FinancialDataAndStockExchanges => "financial-data-stock-exchanges",
Industry::InsuranceBrokers => "insurance-brokers",
Industry::InsuranceDiversified => "insurance-diversified",
Industry::InsuranceLife => "insurance-life",
Industry::InsurancePropertyAndCasualty => "insurance-property-casualty",
Industry::InsuranceReinsurance => "insurance-reinsurance",
Industry::InsuranceSpecialty => "insurance-specialty",
Industry::MortgageFinance => "mortgage-finance",
Industry::ShellCompanies => "shell-companies",
Industry::Biotechnology => "biotechnology",
Industry::DiagnosticsAndResearch => "diagnostics-research",
Industry::DrugManufacturersGeneral => "drug-manufacturers-general",
Industry::DrugManufacturersSpecialtyAndGeneric => {
"drug-manufacturers-specialty-generic"
}
Industry::HealthInformationServices => "health-information-services",
Industry::HealthcarePlans => "healthcare-plans",
Industry::MedicalCareFacilities => "medical-care-facilities",
Industry::MedicalDevices => "medical-devices",
Industry::MedicalDistribution => "medical-distribution",
Industry::MedicalInstrumentsAndSupplies => "medical-instruments-supplies",
Industry::PharmaceuticalRetailers => "pharmaceutical-retailers",
Industry::AerospaceAndDefense => "aerospace-defense",
Industry::BuildingMaterials => "building-materials",
Industry::BuildingProductsAndEquipment => "building-products-equipment",
Industry::BusinessEquipmentAndSupplies => "business-equipment-supplies",
Industry::ChemicalManufacturing => "chemical-manufacturing",
Industry::Chemicals => "chemicals",
Industry::Conglomerates => "conglomerates",
Industry::ConsultingServices => "consulting-services",
Industry::ElectricalEquipmentAndParts => "electrical-equipment-parts",
Industry::EngineeringAndConstruction => "engineering-construction",
Industry::FarmAndHeavyConstructionMachinery => "farm-heavy-construction-machinery",
Industry::IndustrialDistribution => "industrial-distribution",
Industry::InfrastructureOperations => "infrastructure-operations",
Industry::IntegratedFreightAndLogistics => "integrated-freight-logistics",
Industry::ManufacturingDiversified => "manufacturing-diversified",
Industry::MarinePortsAndServices => "marine-ports-services",
Industry::MarineShipping => "marine-shipping",
Industry::MetalFabrication => "metal-fabrication",
Industry::PaperAndPaperProducts => "paper-paper-products",
Industry::PollutionAndTreatmentControls => "pollution-treatment-controls",
Industry::Railroads => "railroads",
Industry::RentalAndLeasingServices => "rental-leasing-services",
Industry::SecurityAndProtectionServices => "security-protection-services",
Industry::SpecialtyBusinessServices => "specialty-business-services",
Industry::SpecialtyChemicals => "specialty-chemicals",
Industry::SpecialtyIndustrialMachinery => "specialty-industrial-machinery",
Industry::StaffingAndEmploymentServices => "staffing-employment-services",
Industry::ToolsAndAccessories => "tools-accessories",
Industry::Trucking => "trucking",
Industry::WasteManagement => "waste-management",
Industry::RealEstateDevelopment => "real-estate-development",
Industry::RealEstateDiversified => "real-estate-diversified",
Industry::RealEstateServices => "real-estate-services",
Industry::ReitDiversified => "reit-diversified",
Industry::ReitHealthcareFacilities => "reit-healthcare-facilities",
Industry::ReitHotelAndMotel => "reit-hotel-motel",
Industry::ReitIndustrial => "reit-industrial",
Industry::ReitMortgage => "reit-mortgage",
Industry::ReitOffice => "reit-office",
Industry::ReitResidential => "reit-residential",
Industry::ReitRetail => "reit-retail",
Industry::ReitSpecialty => "reit-specialty",
Industry::CommunicationEquipment => "communication-equipment",
Industry::ComputerHardware => "computer-hardware",
Industry::ConsumerElectronics => "consumer-electronics",
Industry::DataAnalytics => "data-analytics",
Industry::ElectronicComponents => "electronic-components",
Industry::ElectronicsAndComputerDistribution => "electronics-computer-distribution",
Industry::HardwareAndSoftwareDistribution => "hardware-software-distribution",
Industry::InformationTechnologyServices => "information-technology-services",
Industry::InternetContentAndInformation => "internet-content-information",
Industry::ScientificAndTechnicalInstruments => "scientific-technical-instruments",
Industry::SemiconductorEquipmentAndMaterials => "semiconductor-equipment-materials",
Industry::Semiconductors => "semiconductors",
Industry::SoftwareApplication => "software-application",
Industry::SoftwareInfrastructure => "software-infrastructure",
Industry::Broadcasting => "broadcasting",
Industry::Entertainment => "entertainment",
Industry::Publishing => "publishing",
Industry::TelecomServices => "telecom-services",
Industry::UtilitiesDiversified => "utilities-diversified",
Industry::UtilitiesIndependentPowerProducers => {
"utilities-independent-power-producers"
}
Industry::UtilitiesRegulatedElectric => "utilities-regulated-electric",
Industry::UtilitiesRegulatedGas => "utilities-regulated-gas",
Industry::UtilitiesRegulatedWater => "utilities-regulated-water",
Industry::UtilitiesRenewable => "utilities-renewable",
Industry::ClosedEndFundDebt => "closed-end-fund-debt",
Industry::ClosedEndFundEquity => "closed-end-fund-equity",
Industry::ClosedEndFundForeign => "closed-end-fund-foreign",
Industry::ExchangeTradedFund => "exchange-traded-fund",
}
}
pub fn screener_value(self) -> &'static str {
match self {
Industry::AgriculturalInputs => "Agricultural Inputs",
Industry::Aluminum => "Aluminum",
Industry::Coal => "Coal",
Industry::Copper => "Copper",
Industry::FarmProducts => "Farm Products",
Industry::ForestProducts => "Forest Products",
Industry::Gold => "Gold",
Industry::LumberAndWoodProduction => "Lumber & Wood Production",
Industry::OtherIndustrialMetalsAndMining => "Other Industrial Metals & Mining",
Industry::OtherPreciousMetalsAndMining => "Other Precious Metals & Mining",
Industry::Silver => "Silver",
Industry::Steel => "Steel",
Industry::ThermalCoal => "Thermal Coal",
Industry::Uranium => "Uranium",
Industry::ApparelManufacturing => "Apparel Manufacturing",
Industry::ApparelRetail => "Apparel Retail",
Industry::AutoAndTruckDealerships => "Auto & Truck Dealerships",
Industry::AutoManufacturers => "Auto Manufacturers",
Industry::AutoParts => "Auto Parts",
Industry::BeveragesBrewers => "Beverages - Brewers",
Industry::BeveragesNonAlcoholic => "Beverages - Non-Alcoholic",
Industry::BeveragesWineriesAndDistilleries => "Beverages - Wineries & Distilleries",
Industry::Confectioners => "Confectioners",
Industry::DepartmentStores => "Department Stores",
Industry::DiscountStores => "Discount Stores",
Industry::ElectronicGamingAndMultimedia => "Electronic Gaming & Multimedia",
Industry::FoodDistribution => "Food Distribution",
Industry::FootwearAndAccessories => "Footwear & Accessories",
Industry::FurnishingsFixturesAndAppliances => "Furnishings, Fixtures & Appliances",
Industry::Gambling => "Gambling",
Industry::GroceryStores => "Grocery Stores",
Industry::HomeImprovementRetail => "Home Improvement Retail",
Industry::HouseholdAndPersonalProducts => "Household & Personal Products",
Industry::InternetRetail => "Internet Retail",
Industry::Leisure => "Leisure",
Industry::Lodging => "Lodging",
Industry::LuxuryGoods => "Luxury Goods",
Industry::PackagedFoods => "Packaged Foods",
Industry::PersonalServices => "Personal Services",
Industry::ResidentialConstruction => "Residential Construction",
Industry::ResortsAndCasinos => "Resorts & Casinos",
Industry::Restaurants => "Restaurants",
Industry::SpecialtyRetail => "Specialty Retail",
Industry::TextileManufacturing => "Textile Manufacturing",
Industry::Tobacco => "Tobacco",
Industry::TravelServices => "Travel Services",
Industry::OilAndGasDrilling => "Oil & Gas Drilling",
Industry::OilAndGasEAndP => "Oil & Gas E&P",
Industry::OilAndGasEquipmentAndServices => "Oil & Gas Equipment & Services",
Industry::OilAndGasIntegrated => "Oil & Gas Integrated",
Industry::OilAndGasMidstream => "Oil & Gas Midstream",
Industry::OilAndGasRefiningAndMarketing => "Oil & Gas Refining & Marketing",
Industry::Solar => "Solar",
Industry::AssetManagement => "Asset Management",
Industry::BanksDiversified => "Banks - Diversified",
Industry::BanksRegional => "Banks - Regional",
Industry::CapitalMarkets => "Capital Markets",
Industry::CreditServices => "Credit Services",
Industry::FinancialDataAndStockExchanges => "Financial Data & Stock Exchanges",
Industry::InsuranceBrokers => "Insurance Brokers",
Industry::InsuranceDiversified => "Insurance - Diversified",
Industry::InsuranceLife => "Insurance - Life",
Industry::InsurancePropertyAndCasualty => "Insurance - Property & Casualty",
Industry::InsuranceReinsurance => "Insurance - Reinsurance",
Industry::InsuranceSpecialty => "Insurance - Specialty",
Industry::MortgageFinance => "Mortgage Finance",
Industry::ShellCompanies => "Shell Companies",
Industry::Biotechnology => "Biotechnology",
Industry::DiagnosticsAndResearch => "Diagnostics & Research",
Industry::DrugManufacturersGeneral => "Drug Manufacturers - General",
Industry::DrugManufacturersSpecialtyAndGeneric => {
"Drug Manufacturers - Specialty & Generic"
}
Industry::HealthInformationServices => "Health Information Services",
Industry::HealthcarePlans => "Healthcare Plans",
Industry::MedicalCareFacilities => "Medical Care Facilities",
Industry::MedicalDevices => "Medical Devices",
Industry::MedicalDistribution => "Medical Distribution",
Industry::MedicalInstrumentsAndSupplies => "Medical Instruments & Supplies",
Industry::PharmaceuticalRetailers => "Pharmaceutical Retailers",
Industry::AerospaceAndDefense => "Aerospace & Defense",
Industry::BuildingMaterials => "Building Materials",
Industry::BuildingProductsAndEquipment => "Building Products & Equipment",
Industry::BusinessEquipmentAndSupplies => "Business Equipment & Supplies",
Industry::ChemicalManufacturing => "Chemical Manufacturing",
Industry::Chemicals => "Chemicals",
Industry::Conglomerates => "Conglomerates",
Industry::ConsultingServices => "Consulting Services",
Industry::ElectricalEquipmentAndParts => "Electrical Equipment & Parts",
Industry::EngineeringAndConstruction => "Engineering & Construction",
Industry::FarmAndHeavyConstructionMachinery => {
"Farm & Heavy Construction Machinery"
}
Industry::IndustrialDistribution => "Industrial Distribution",
Industry::InfrastructureOperations => "Infrastructure Operations",
Industry::IntegratedFreightAndLogistics => "Integrated Freight & Logistics",
Industry::ManufacturingDiversified => "Manufacturing - Diversified",
Industry::MarinePortsAndServices => "Marine Ports & Services",
Industry::MarineShipping => "Marine Shipping",
Industry::MetalFabrication => "Metal Fabrication",
Industry::PaperAndPaperProducts => "Paper & Paper Products",
Industry::PollutionAndTreatmentControls => "Pollution & Treatment Controls",
Industry::Railroads => "Railroads",
Industry::RentalAndLeasingServices => "Rental & Leasing Services",
Industry::SecurityAndProtectionServices => "Security & Protection Services",
Industry::SpecialtyBusinessServices => "Specialty Business Services",
Industry::SpecialtyChemicals => "Specialty Chemicals",
Industry::SpecialtyIndustrialMachinery => "Specialty Industrial Machinery",
Industry::StaffingAndEmploymentServices => "Staffing & Employment Services",
Industry::ToolsAndAccessories => "Tools & Accessories",
Industry::Trucking => "Trucking",
Industry::WasteManagement => "Waste Management",
Industry::RealEstateDevelopment => "Real Estate - Development",
Industry::RealEstateDiversified => "Real Estate - Diversified",
Industry::RealEstateServices => "Real Estate Services",
Industry::ReitDiversified => "REIT - Diversified",
Industry::ReitHealthcareFacilities => "REIT - Healthcare Facilities",
Industry::ReitHotelAndMotel => "REIT - Hotel & Motel",
Industry::ReitIndustrial => "REIT - Industrial",
Industry::ReitMortgage => "REIT - Mortgage",
Industry::ReitOffice => "REIT - Office",
Industry::ReitResidential => "REIT - Residential",
Industry::ReitRetail => "REIT - Retail",
Industry::ReitSpecialty => "REIT - Specialty",
Industry::CommunicationEquipment => "Communication Equipment",
Industry::ComputerHardware => "Computer Hardware",
Industry::ConsumerElectronics => "Consumer Electronics",
Industry::DataAnalytics => "Data Analytics",
Industry::ElectronicComponents => "Electronic Components",
Industry::ElectronicsAndComputerDistribution => {
"Electronics & Computer Distribution"
}
Industry::HardwareAndSoftwareDistribution => "Hardware & Software Distribution",
Industry::InformationTechnologyServices => "Information Technology Services",
Industry::InternetContentAndInformation => "Internet Content & Information",
Industry::ScientificAndTechnicalInstruments => "Scientific & Technical Instruments",
Industry::SemiconductorEquipmentAndMaterials => {
"Semiconductor Equipment & Materials"
}
Industry::Semiconductors => "Semiconductors",
Industry::SoftwareApplication => "Software - Application",
Industry::SoftwareInfrastructure => "Software - Infrastructure",
Industry::Broadcasting => "Broadcasting",
Industry::Entertainment => "Entertainment",
Industry::Publishing => "Publishing",
Industry::TelecomServices => "Telecom Services",
Industry::UtilitiesDiversified => "Utilities - Diversified",
Industry::UtilitiesIndependentPowerProducers => {
"Utilities - Independent Power Producers"
}
Industry::UtilitiesRegulatedElectric => "Utilities - Regulated Electric",
Industry::UtilitiesRegulatedGas => "Utilities - Regulated Gas",
Industry::UtilitiesRegulatedWater => "Utilities - Regulated Water",
Industry::UtilitiesRenewable => "Utilities - Renewable",
Industry::ClosedEndFundDebt => "Closed-End Fund - Debt",
Industry::ClosedEndFundEquity => "Closed-End Fund - Equity",
Industry::ClosedEndFundForeign => "Closed-End Fund - Foreign",
Industry::ExchangeTradedFund => "Exchange Traded Fund",
}
}
}
impl AsRef<str> for Industry {
fn as_ref(&self) -> &str {
self.as_slug()
}
}
impl From<Industry> for String {
fn from(v: Industry) -> Self {
v.screener_value().to_string()
}
}
}
pub mod exchange_codes {
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ExchangeCode {
Ase,
Bts,
Ncm,
Ngm,
Nms,
Nyq,
Pcx,
Pnk,
Nas,
Asx,
Bse,
Hkg,
Krx,
Lse,
Nsi,
Shh,
Shz,
Tyo,
Tor,
Ger,
}
impl ExchangeCode {
pub fn as_str(self) -> &'static str {
match self {
ExchangeCode::Ase => "ASE",
ExchangeCode::Bts => "BTS",
ExchangeCode::Ncm => "NCM",
ExchangeCode::Ngm => "NGM",
ExchangeCode::Nms => "NMS",
ExchangeCode::Nyq => "NYQ",
ExchangeCode::Pcx => "PCX",
ExchangeCode::Pnk => "PNK",
ExchangeCode::Nas => "NAS",
ExchangeCode::Asx => "ASX",
ExchangeCode::Bse => "BSE",
ExchangeCode::Hkg => "HKG",
ExchangeCode::Krx => "KRX",
ExchangeCode::Lse => "LSE",
ExchangeCode::Nsi => "NSI",
ExchangeCode::Shh => "SHH",
ExchangeCode::Shz => "SHZ",
ExchangeCode::Tyo => "TYO",
ExchangeCode::Tor => "TOR",
ExchangeCode::Ger => "GER",
}
}
}
impl From<ExchangeCode> for String {
fn from(v: ExchangeCode) -> Self {
v.as_str().to_string()
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_interval_as_str() {
assert_eq!(Interval::OneMinute.as_str(), "1m");
assert_eq!(Interval::FiveMinutes.as_str(), "5m");
assert_eq!(Interval::OneDay.as_str(), "1d");
assert_eq!(Interval::OneWeek.as_str(), "1wk");
}
#[test]
fn test_time_range_as_str() {
assert_eq!(TimeRange::OneDay.as_str(), "1d");
assert_eq!(TimeRange::OneMonth.as_str(), "1mo");
assert_eq!(TimeRange::OneYear.as_str(), "1y");
assert_eq!(TimeRange::Max.as_str(), "max");
}
}