yahooquery is a Python api to the Yahoo! finance site.
This file resides at /c/cs458/www/lectures/yquery.ipynb
The fundamental law of finance is:
Buy low, sell high.
But what do you buy? When they think of finance and investing, most people think about the Dow Jones Industrial Average, which comprises 30 large cap US stocks, traded on the New York Stock Exchange (NYSE) and the NASDAQ exchange. (A large cap stock has a market capitalization greater than $10 billion. The market cap is simply the price of a share of stock times the number of shares outstanding.)
By owning a share of stock, you become an owner of the company. You have an equity stake in running the company. Major decisions by the company are ratified by a shareholder vote. If you own more than 50% of the stock in a company, you control the company. Stock is also known as equity which is just one asset class in which you might choose to invest. Others include bonds (aka, fixed income or debt), real estate, commodities (e.g., wheat, oil, gold), foreign exchance (currency, like dollars, euros, and yen), derivatives (such as mortgage back securities), and infrastructure (such as roads and airports).
We are going to focus on equity, that is, stocks. The yfinance Python module provides a boatload of information about US stocks and other securities.
As we learned from Tversky and Kahnemann and behavioral economists, people are risk averse. They don't like losing money. In 1952, Harry Markowitz came up with Modern Portfolio Theory which, among other things, showed how you can construct a collection or portfolio of stocks to reduce or even minimize the risk of the overall investment. One of Markowitz's insights was that the volatility of a stock's price was a suitable measure of the risk of the investment. You can reduce the overall volatility of a portfolio by investing stocks that are not correlated with each other. Thus, one stock may go up with inflation and another might go down. These movements can offset each other and reduce the portfolio's volatility or risk.
You can fully diversify your portfolio by holding 30 or so stocks - assuming that they are not correlated. One hundred years ago, investors thought they were diversified if they owned 20 different railroad stocks. Go figure.
These days we measure volatility of the entire stock market with the volatility index or VIX. It is also known as the fear index or fear gauge. The higher the VIX, the riskier the market. A rule of thumb is if the VIX is below 14, the market is not risky.
We assume that everyone wants to avoid losing money. However, there are many different ways to make money. Many stocks pay dividends (usually quarterly) which can provide income to the investor. Usually companies that pay dividends are older and more stable and established, such as banks and utilities. These stocks are often called value stocks.
Many stocks do not pay dividends. Instead they reinvest that money in the company to help it grow and expand. These stocks are often called growth stocks.
Usually, growth stocks are more volatile than value stocks, which is to say that they are more risky.
These categories are not always clear cut.
Another metric that relates to MPT, is beta, a measure of a stock's volatility relative to the market as a whole. A beta of 1 means that the stock has the same volatility as the entire market (usually the S and P 500). A stable stock will have a beta below 1. A risky stock will have a beta over 1.
To diversify the risk in a portfolio, you need to buy stocks with different volatility patterns. One common way to do this is by investing in different sectors or industries.
Different sectors respond differently to market conditions. In recent years, technology has outperformed sectors like materials or real estate. However, there is no clear pattern over time.
Many Wall Street firms, like Morgan Stanley, Goldman Sachs, and Merrill Lynch, employ finance professionals who advise investors which stocks to buy and sell. For example, see a recent Merrill Lynch report on Apple (AAPL). An analysis will usually assign a recommendation of buy, sell, or hold, as well as a price target or price objective - their prediction of the price within the next 12 months. Merrill Lynch assigns Apple a BUY rating and a price objective of 215 from the current price of 172. This is pretty bullish. Note that Merrill Lynch also reports an ESGMeter score of high for Apple. ESG stands for Environmant, Social, and Governance which measures a company's commitment to climate change, diversity and related initiatives. The hope is that a company can do well by doing good. According to Merrill Lynch, Apple is one of the good guys.
One focus of a security analyst is to predict future earnings. This figure becomes
part of price/earnings ratio or simply p/e ratio. A low PE suggest that the stock is cheap. A high PE suggests that the stock is expensive.
However, the PE ratio varies considerably across industries.
Also, there are quantitative models that can value a stock based on future earnings or discounted cash flows (DCF). This approach can be used on other assets in addition to stock. A security analyst can project company earnings and then plug those numbers into a DCF model to get a valuation for the company. Using earnings per share, the valuation is the estimated current price of the company. If that price is higher than the market price, then the stock is a BUY. If the valuation price is lower than the market price, the stock is a SELL.
In the homework, you are to write some code that could replace a security analyst.
In addition to analyzing companies, Merrill Lynch also provides sample model portfolios, namely:
Each of these portfolios comprise 30 or so individual stocks across a dozen industrial sectors. The portfolio specifies the weightings of each holding. Every few weeks or months, Merrill Lynch will publish changes to weightings or holdings to recalibrate the portfolio. See the Research Portfolio Holdings and Primer.
Merrill Lynch publishes a primer which explains the investment philosophy and process used to construct these portfolios. The basic premise is that each portfolio has its own risk profile, with Large Cap Defensive being safer than Income, and so forth.
As a machine learning exercise, you could use the holdings of these portfolios as training data to learn the properties of an income stock versus a growth stock.
We get started by loading yfinance and some other useful modules. These are available on the zoo. If you do not have them on you personal machine, you can probably install them with
pip install
import pandas as pd
import yahooquery as yq
yq.__version__
'2.3.7'
The documentation for yahooquery is at https://yahooquery.dpguthrie.com/
import numpy
numpy.version.version
'1.24.4'
dir(yq)
['Research', 'Screener', 'Ticker', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'base', 'get_currencies', 'get_exchanges', 'get_market_summary', 'get_trending', 'headless', 'misc', 'name', 'research', 'screener', 'search', 'ticker', 'utils']
for x in dir(yq):
if x.startswith('_'):
next
else:
print (x, '\t', getattr(yq,x))
Research <class 'yahooquery.research.Research'> Screener <class 'yahooquery.screener.Screener'> Ticker <class 'yahooquery.ticker.Ticker'> base <module 'yahooquery.base' from '/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/base.py'> get_currencies <function get_currencies at 0x7f10d1511c60> get_exchanges <function get_exchanges at 0x7f10d1511d00> get_market_summary <function get_market_summary at 0x7f10d1511da0> get_trending <function get_trending at 0x7f10d1511e40> headless <module 'yahooquery.headless' from '/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/headless.py'> misc <module 'yahooquery.misc' from '/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/misc.py'> name yahooquery research <module 'yahooquery.research' from '/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/research.py'> screener <module 'yahooquery.screener' from '/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/screener.py'> search <function search at 0x7f10d1511bc0> ticker <module 'yahooquery.ticker' from '/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/ticker.py'> utils <module 'yahooquery.utils' from '/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/utils/__init__.py'>
from yahooquery import Ticker
dir(Ticker)
['CHUNK', 'CORPORATE_EVENTS', 'FUNDAMENTALS_OPTIONS', 'FUNDAMENTALS_TIME_ARGS', 'INTERVALS', 'MODULES', 'PERIODS', '_CONFIG', '_FUND_DETAILS', '_MODULES_DICT', '_STYLE_BOX', '_VIZ_CONFIG', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_adjust_ohlc', '_async_requests', '_chunk_symbols', '_construct_data', '_construct_params', '_construct_urls', '_financials', '_financials_dataframes', '_format_data', '_fund_holdings', '_get_data', '_get_symbol', '_historical_data_to_dataframe', '_history_1m', '_option_dataframe', '_quote_summary', '_quote_summary_dataframe', '_sync_requests', '_to_dataframe', '_validate_response', 'all_financial_data', 'all_modules', 'asset_profile', 'balance_sheet', 'calendar_events', 'cash_flow', 'company_officers', 'corporate_events', 'corporate_guidance', 'country', 'default_query_params', 'dividend_history', 'earning_history', 'earnings', 'earnings_trend', 'esg_scores', 'financial_data', 'fund_bond_holdings', 'fund_bond_ratings', 'fund_category_holdings', 'fund_equity_holdings', 'fund_holding_info', 'fund_ownership', 'fund_performance', 'fund_profile', 'fund_sector_weightings', 'fund_top_holdings', 'get_financial_data', 'get_modules', 'grading_history', 'history', 'income_statement', 'index_trend', 'industry_trend', 'insider_holders', 'insider_transactions', 'institution_ownership', 'key_stats', 'login', 'major_holders', 'news', 'option_chain', 'p_all_financial_data', 'p_balance_sheet', 'p_cash_flow', 'p_company_360', 'p_corporate_events', 'p_fair_value', 'p_get_financial_data', 'p_ideas', 'p_income_statement', 'p_portal', 'p_reports', 'p_technical_events', 'p_technical_insights', 'p_valuation_measures', 'p_value_analyzer', 'p_value_analyzer_drilldown', 'page_views', 'price', 'quote_type', 'quotes', 'recommendation_trend', 'recommendations', 'sec_filings', 'share_purchase_activity', 'summary_detail', 'summary_profile', 'symbols', 'technical_insights', 'validation', 'valuation_measures']
for x in dir(Ticker):
if x.startswith('_'):
next
else:
print (x, '\t', getattr(Ticker, x))
CHUNK 1500 CORPORATE_EVENTS ['sigdev_corporate_guidance', 'sigdev_performance', 'sigdev_corporate_deals', 'sigdev_expansion_new_markets_new_units', 'sigdev_products', 'sigdev_ownership_control', 'sigdev_financing', 'sigdev_litigation_regulatory', 'sigdev_accounting_issues', 'sigdev_restructuring_reorganization_related', 'sigdev_reference', 'sigdev_special_events', 'sigdev_environment'] FUNDAMENTALS_OPTIONS {'income_statement': ['Amortization', 'AmortizationOfIntangiblesIncomeStatement', 'AverageDilutionEarnings', 'BasicAccountingChange', 'BasicAverageShares', 'BasicContinuousOperations', 'BasicDiscontinuousOperations', 'BasicEPS', 'BasicEPSOtherGainsLosses', 'BasicExtraordinary', 'ContinuingAndDiscontinuedBasicEPS', 'ContinuingAndDiscontinuedDilutedEPS', 'CostOfRevenue', 'DepletionIncomeStatement', 'DepreciationAmortizationDepletionIncomeStatement', 'DepreciationAndAmortizationInIncomeStatement', 'DepreciationIncomeStatement', 'DilutedAccountingChange', 'DilutedAverageShares', 'DilutedContinuousOperations', 'DilutedDiscontinuousOperations', 'DilutedEPS', 'DilutedEPSOtherGainsLosses', 'DilutedExtraordinary', 'DilutedNIAvailtoComStockholders', 'DividendPerShare', 'EBIT', 'EBITDA', 'EarningsFromEquityInterest', 'EarningsFromEquityInterestNetOfTax', 'ExciseTaxes', 'GainOnSaleOfBusiness', 'GainOnSaleOfPPE', 'GainOnSaleOfSecurity', 'GeneralAndAdministrativeExpense', 'GrossProfit', 'ImpairmentOfCapitalAssets', 'InsuranceAndClaims', 'InterestExpense', 'InterestExpenseNonOperating', 'InterestIncome', 'InterestIncomeNonOperating', 'MinorityInterests', 'NetIncome', 'NetIncomeCommonStockholders', 'NetIncomeContinuousOperations', 'NetIncomeDiscontinuousOperations', 'NetIncomeExtraordinary', 'NetIncomeFromContinuingAndDiscontinuedOperation', 'NetIncomeFromContinuingOperationNetMinorityInterest', 'NetIncomeFromTaxLossCarryforward', 'NetIncomeIncludingNoncontrollingInterests', 'NetInterestIncome', 'NetNonOperatingInterestIncomeExpense', 'NormalizedBasicEPS', 'NormalizedDilutedEPS', 'NormalizedEBITDA', 'NormalizedIncome', 'OperatingExpense', 'OperatingIncome', 'OperatingRevenue', 'OtherGandA', 'OtherIncomeExpense', 'OtherNonOperatingIncomeExpenses', 'OtherOperatingExpenses', 'OtherSpecialCharges', 'OtherTaxes', 'OtherunderPreferredStockDividend', 'PreferredStockDividends', 'PretaxIncome', 'ProvisionForDoubtfulAccounts', 'ReconciledCostOfRevenue', 'ReconciledDepreciation', 'RentAndLandingFees', 'RentExpenseSupplemental', 'ReportedNormalizedBasicEPS', 'ReportedNormalizedDilutedEPS', 'ResearchAndDevelopment', 'RestructuringAndMergernAcquisition', 'SalariesAndWages', 'SecuritiesAmortization', 'SellingAndMarketingExpense', 'SellingGeneralAndAdministration', 'SpecialIncomeCharges', 'TaxEffectOfUnusualItems', 'TaxLossCarryforwardBasicEPS', 'TaxLossCarryforwardDilutedEPS', 'TaxProvision', 'TaxRateForCalcs', 'TotalExpenses', 'TotalOperatingIncomeAsReported', 'TotalOtherFinanceCost', 'TotalRevenue', 'TotalUnusualItems', 'TotalUnusualItemsExcludingGoodwill', 'WriteOff'], 'balance_sheet': ['AccountsPayable', 'AccountsReceivable', 'AccruedInterestReceivable', 'AccumulatedDepreciation', 'AdditionalPaidInCapital', 'AllowanceForDoubtfulAccountsReceivable', 'AssetsHeldForSaleCurrent', 'AvailableForSaleSecurities', 'BuildingsAndImprovements', 'CapitalLeaseObligations', 'CapitalStock', 'CashAndCashEquivalents', 'CashCashEquivalentsAndShortTermInvestments', 'CashEquivalents', 'CashFinancial', 'CommercialPaper', 'CommonStock', 'CommonStockEquity', 'ConstructionInProgress', 'CurrentAccruedExpenses', 'CurrentAssets', 'CurrentCapitalLeaseObligation', 'CurrentDebt', 'CurrentDebtAndCapitalLeaseObligation', 'CurrentDeferredAssets', 'CurrentDeferredLiabilities', 'CurrentDeferredRevenue', 'CurrentDeferredTaxesAssets', 'CurrentDeferredTaxesLiabilities', 'CurrentLiabilities', 'CurrentNotesPayable', 'CurrentProvisions', 'DefinedPensionBenefit', 'DerivativeProductLiabilities', 'DividendsPayable', 'DuefromRelatedPartiesCurrent', 'DuefromRelatedPartiesNonCurrent', 'DuetoRelatedPartiesCurrent', 'DuetoRelatedPartiesNonCurrent', 'EmployeeBenefits', 'FinancialAssets', 'FinancialAssetsDesignatedasFairValueThroughProfitorLossTotal', 'FinishedGoods', 'FixedAssetsRevaluationReserve', 'ForeignCurrencyTranslationAdjustments', 'GainsLossesNotAffectingRetainedEarnings', 'GeneralPartnershipCapital', 'Goodwill', 'GoodwillAndOtherIntangibleAssets', 'GrossAccountsReceivable', 'GrossPPE', 'HedgingAssetsCurrent', 'HeldToMaturitySecurities', 'IncomeTaxPayable', 'InterestPayable', 'InventoriesAdjustmentsAllowances', 'Inventory', 'InvestedCapital', 'InvestmentProperties', 'InvestmentinFinancialAssets', 'InvestmentsAndAdvances', 'InvestmentsInOtherVenturesUnderEquityMethod', 'InvestmentsinAssociatesatCost', 'InvestmentsinJointVenturesatCost', 'InvestmentsinSubsidiariesatCost', 'LandAndImprovements', 'Leases', 'LiabilitiesHeldforSaleNonCurrent', 'LimitedPartnershipCapital', 'LineOfCredit', 'LoansReceivable', 'LongTermCapitalLeaseObligation', 'LongTermDebt', 'LongTermDebtAndCapitalLeaseObligation', 'LongTermEquityInvestment', 'LongTermProvisions', 'MachineryFurnitureEquipment', 'MinimumPensionLiabilities', 'MinorityInterest', 'NetDebt', 'NetPPE', 'NetTangibleAssets', 'NonCurrentAccountsReceivable', 'NonCurrentAccruedExpenses', 'NonCurrentDeferredAssets', 'NonCurrentDeferredLiabilities', 'NonCurrentDeferredRevenue', 'NonCurrentDeferredTaxesAssets', 'NonCurrentDeferredTaxesLiabilities', 'NonCurrentNoteReceivables', 'NonCurrentPensionAndOtherPostretirementBenefitPlans', 'NonCurrentPrepaidAssets', 'NotesReceivable', 'OrdinarySharesNumber', 'OtherCapitalStock', 'OtherCurrentAssets', 'OtherCurrentBorrowings', 'OtherCurrentLiabilities', 'OtherEquityAdjustments', 'OtherEquityInterest', 'OtherIntangibleAssets', 'OtherInventories', 'OtherInvestments', 'OtherNonCurrentAssets', 'OtherNonCurrentLiabilities', 'OtherPayable', 'OtherProperties', 'OtherReceivables', 'OtherShortTermInvestments', 'Payables', 'PayablesAndAccruedExpenses', 'PensionandOtherPostRetirementBenefitPlansCurrent', 'PreferredSecuritiesOutsideStockEquity', 'PreferredSharesNumber', 'PreferredStock', 'PreferredStockEquity', 'PrepaidAssets', 'Properties', 'RawMaterials', 'Receivables', 'ReceivablesAdjustmentsAllowances', 'RestrictedCash', 'RestrictedCommonStock', 'RetainedEarnings', 'ShareIssued', 'StockholdersEquity', 'TangibleBookValue', 'TaxesReceivable', 'TotalAssets', 'TotalCapitalization', 'TotalDebt', 'TotalEquityGrossMinorityInterest', 'TotalLiabilitiesNetMinorityInterest', 'TotalNonCurrentAssets', 'TotalNonCurrentLiabilitiesNetMinorityInterest', 'TotalPartnershipCapital', 'TotalTaxPayable', 'TradeandOtherPayablesNonCurrent', 'TradingSecurities', 'TreasurySharesNumber', 'TreasuryStock', 'UnrealizedGainLoss', 'WorkInProcess', 'WorkingCapital'], 'cash_flow': ['AdjustedGeographySegmentData', 'AmortizationCashFlow', 'AmortizationOfIntangibles', 'AmortizationOfSecurities', 'AssetImpairmentCharge', 'BeginningCashPosition', 'CapitalExpenditure', 'CapitalExpenditureReported', 'CashDividendsPaid', 'CashFlowFromContinuingFinancingActivities', 'CashFlowFromContinuingInvestingActivities', 'CashFlowFromContinuingOperatingActivities', 'CashFlowFromDiscontinuedOperation', 'CashFlowsfromusedinOperatingActivitiesDirect', 'CashFromDiscontinuedFinancingActivities', 'CashFromDiscontinuedInvestingActivities', 'CashFromDiscontinuedOperatingActivities', 'ChangeInAccountPayable', 'ChangeInAccruedExpense', 'ChangeInCashSupplementalAsReported', 'ChangeInDividendPayable', 'ChangeInIncomeTaxPayable', 'ChangeInInterestPayable', 'ChangeInInventory', 'ChangeInOtherCurrentAssets', 'ChangeInOtherCurrentLiabilities', 'ChangeInOtherWorkingCapital', 'ChangeInPayable', 'ChangeInPayablesAndAccruedExpense', 'ChangeInPrepaidAssets', 'ChangeInReceivables', 'ChangeInTaxPayable', 'ChangeInWorkingCapital', 'ChangesInAccountReceivables', 'ChangesInCash', 'ClassesofCashPayments', 'ClassesofCashReceiptsfromOperatingActivities', 'CommonStockDividendPaid', 'CommonStockIssuance', 'CommonStockPayments', 'DeferredIncomeTax', 'DeferredTax', 'Depletion', 'Depreciation', 'DepreciationAmortizationDepletion', 'DepreciationAndAmortization', 'DividendPaidCFO', 'DividendReceivedCFO', 'DividendsPaidDirect', 'DividendsReceivedCFI', 'DividendsReceivedDirect', 'DomesticSales', 'EarningsLossesFromEquityInvestments', 'EffectOfExchangeRateChanges', 'EndCashPosition', 'ExcessTaxBenefitFromStockBasedCompensation', 'FinancingCashFlow', 'ForeignSales', 'FreeCashFlow', 'GainLossOnInvestmentSecurities', 'GainLossOnSaleOfBusiness', 'GainLossOnSaleOfPPE', 'IncomeTaxPaidSupplementalData', 'InterestPaidCFF', 'InterestPaidCFO', 'InterestPaidDirect', 'InterestPaidSupplementalData', 'InterestReceivedCFI', 'InterestReceivedCFO', 'InterestReceivedDirect', 'InvestingCashFlow', 'IssuanceOfCapitalStock', 'IssuanceOfDebt', 'LongTermDebtIssuance', 'LongTermDebtPayments', 'NetBusinessPurchaseAndSale', 'NetCommonStockIssuance', 'NetForeignCurrencyExchangeGainLoss', 'NetIncome', 'NetIncomeFromContinuingOperations', 'NetIntangiblesPurchaseAndSale', 'NetInvestmentPropertiesPurchaseAndSale', 'NetInvestmentPurchaseAndSale', 'NetIssuancePaymentsOfDebt', 'NetLongTermDebtIssuance', 'NetOtherFinancingCharges', 'NetOtherInvestingChanges', 'NetPPEPurchaseAndSale', 'NetPreferredStockIssuance', 'NetShortTermDebtIssuance', 'OperatingCashFlow', 'OperatingGainsLosses', 'OtherCashAdjustmentInsideChangeinCash', 'OtherCashAdjustmentOutsideChangeinCash', 'OtherCashPaymentsfromOperatingActivities', 'OtherCashReceiptsfromOperatingActivities', 'OtherNonCashItems', 'PaymentsonBehalfofEmployees', 'PaymentstoSuppliersforGoodsandServices', 'PensionAndEmployeeBenefitExpense', 'PreferredStockDividendPaid', 'PreferredStockIssuance', 'PreferredStockPayments', 'ProceedsFromStockOptionExercised', 'ProvisionandWriteOffofAssets', 'PurchaseOfBusiness', 'PurchaseOfIntangibles', 'PurchaseOfInvestment', 'PurchaseOfInvestmentProperties', 'PurchaseOfPPE', 'ReceiptsfromCustomers', 'ReceiptsfromGovernmentGrants', 'RepaymentOfDebt', 'RepurchaseOfCapitalStock', 'SaleOfBusiness', 'SaleOfIntangibles', 'SaleOfInvestment', 'SaleOfInvestmentProperties', 'SaleOfPPE', 'ShortTermDebtIssuance', 'ShortTermDebtPayments', 'StockBasedCompensation', 'TaxesRefundPaid', 'TaxesRefundPaidDirect', 'UnrealizedGainLossOnInvestmentSecurities'], 'valuation': ['ForwardPeRatio', 'PsRatio', 'PbRatio', 'EnterprisesValueEBITDARatio', 'EnterprisesValueRevenueRatio', 'PeRatio', 'MarketCap', 'EnterpriseValue', 'PegRatio']} FUNDAMENTALS_TIME_ARGS {'a': {'prefix': 'annual', 'period_type': '12M'}, 'q': {'prefix': 'quarterly', 'period_type': '3M'}, 'm': {'prefix': 'monthly', 'period_type': '1M'}} INTERVALS ['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo'] MODULES ['assetProfile', 'balanceSheetHistory', 'balanceSheetHistoryQuarterly', 'calendarEvents', 'cashflowStatementHistory', 'cashflowStatementHistoryQuarterly', 'defaultKeyStatistics', 'earnings', 'earningsHistory', 'earningsTrend', 'esgScores', 'financialData', 'fundOwnership', 'fundPerformance', 'fundProfile', 'indexTrend', 'incomeStatementHistory', 'incomeStatementHistoryQuarterly', 'industryTrend', 'insiderHolders', 'insiderTransactions', 'institutionOwnership', 'majorHoldersBreakdown', 'pageViews', 'price', 'quoteType', 'recommendationTrend', 'secFilings', 'netSharePurchaseActivity', 'sectorTrend', 'summaryDetail', 'summaryProfile', 'topHoldings', 'upgradeDowngradeHistory'] PERIODS ['1d', '5d', '7d', '60d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max'] all_financial_data <function Ticker.all_financial_data at 0x7f10d156b740> all_modules <property object at 0x7f10d13701d0> asset_profile <property object at 0x7f10d13702c0> balance_sheet <function Ticker.balance_sheet at 0x7f10d156ba60> calendar_events <property object at 0x7f10d1370360> cash_flow <function Ticker.cash_flow at 0x7f10d156bb00> company_officers <property object at 0x7f10d13718a0> corporate_events <property object at 0x7f10d1371530> corporate_guidance <property object at 0x7f10d1371760> country <property object at 0x7f10d154e0c0> default_query_params <property object at 0x7f10d154e020> dividend_history <function Ticker.dividend_history at 0x7f10d1381260> earning_history <property object at 0x7f10d13719e0> earnings <property object at 0x7f10d1370400> earnings_trend <property object at 0x7f10d1370450> esg_scores <property object at 0x7f10d13704f0> financial_data <property object at 0x7f10d1370590> fund_bond_holdings <property object at 0x7f10d13722f0> fund_bond_ratings <property object at 0x7f10d13730b0> fund_category_holdings <property object at 0x7f10d1372390> fund_equity_holdings <property object at 0x7f10d13727a0> fund_holding_info <property object at 0x7f10d1372f20> fund_ownership <property object at 0x7f10d1371a80> fund_performance <property object at 0x7f10d1372840> fund_profile <property object at 0x7f10d1372e80> fund_sector_weightings <property object at 0x7f10d1373290> fund_top_holdings <property object at 0x7f10d1373010> get_financial_data <function Ticker.get_financial_data at 0x7f10d156b7e0> get_modules <function Ticker.get_modules at 0x7f10d156a8e0> grading_history <property object at 0x7f10d1371b70> history <function Ticker.history at 0x7f10d1381300> income_statement <function Ticker.income_statement at 0x7f10d156be20> index_trend <property object at 0x7f10d1370680> industry_trend <property object at 0x7f10d1370720> insider_holders <property object at 0x7f10d1371c60> insider_transactions <property object at 0x7f10d1371d50> institution_ownership <property object at 0x7f10d1371e90> key_stats <property object at 0x7f10d13707c0> login <function _YahooFinance.login at 0x7f10d155bf60> major_holders <property object at 0x7f10d1370860> news <function Ticker.news at 0x7f10d156ad40> option_chain <property object at 0x7f10d1373c90> p_all_financial_data <function Ticker.p_all_financial_data at 0x7f10d1380900> p_balance_sheet <function Ticker.p_balance_sheet at 0x7f10d1380a40> p_cash_flow <function Ticker.p_cash_flow at 0x7f10d1380ae0> p_company_360 <property object at 0x7f10d1373ab0> p_corporate_events <property object at 0x7f10d1373a60> p_fair_value <property object at 0x7f10d1373380> p_get_financial_data <function Ticker.p_get_financial_data at 0x7f10d13809a0> p_ideas <function Ticker.p_ideas at 0x7f10d1380f40> p_income_statement <function Ticker.p_income_statement at 0x7f10d1380c20> p_portal <property object at 0x7f10d1373b50> p_reports <function Ticker.p_reports at 0x7f10d1380ea0> p_technical_events <property object at 0x7f10d1373ba0> p_technical_insights <property object at 0x7f10d1373b00> p_valuation_measures <function Ticker.p_valuation_measures at 0x7f10d1381080> p_value_analyzer <property object at 0x7f10d1373bf0> p_value_analyzer_drilldown <property object at 0x7f10d1373c40> page_views <property object at 0x7f10d1370900> price <property object at 0x7f10d13709a0> quote_type <property object at 0x7f10d13709f0> quotes <property object at 0x7f10d1370b30> recommendation_trend <property object at 0x7f10d1372110> recommendations <property object at 0x7f10d1370bd0> sec_filings <property object at 0x7f10d1372200> share_purchase_activity <property object at 0x7f10d1370cc0> summary_detail <property object at 0x7f10d1370d60> summary_profile <property object at 0x7f10d1370e00> symbols <property object at 0x7f10d154e070> technical_insights <property object at 0x7f10d1371170> validation <property object at 0x7f10d154dfd0> valuation_measures <property object at 0x7f10d1371800>
aapl = Ticker('aapl')
dir(aapl)
['CHUNK', 'CORPORATE_EVENTS', 'FUNDAMENTALS_OPTIONS', 'FUNDAMENTALS_TIME_ARGS', 'INTERVALS', 'MODULES', 'PERIODS', '_CONFIG', '_FUND_DETAILS', '_MODULES_DICT', '_STYLE_BOX', '_VIZ_CONFIG', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_adjust_ohlc', '_async_requests', '_chunk_symbols', '_construct_data', '_construct_params', '_construct_urls', '_country', '_country_params', '_financials', '_financials_dataframes', '_format_data', '_fund_holdings', '_get_data', '_get_symbol', '_historical_data_to_dataframe', '_history_1m', '_option_dataframe', '_quote_summary', '_quote_summary_dataframe', '_setup_url', '_symbols', '_sync_requests', '_to_dataframe', '_validate_response', 'all_financial_data', 'all_modules', 'asset_profile', 'balance_sheet', 'calendar_events', 'cash_flow', 'company_officers', 'corporate_events', 'corporate_guidance', 'country', 'crumb', 'default_query_params', 'dividend_history', 'earning_history', 'earnings', 'earnings_trend', 'esg_scores', 'financial_data', 'formatted', 'fund_bond_holdings', 'fund_bond_ratings', 'fund_category_holdings', 'fund_equity_holdings', 'fund_holding_info', 'fund_ownership', 'fund_performance', 'fund_profile', 'fund_sector_weightings', 'fund_top_holdings', 'get_financial_data', 'get_modules', 'grading_history', 'history', 'income_statement', 'index_trend', 'industry_trend', 'insider_holders', 'insider_transactions', 'institution_ownership', 'invalid_symbols', 'key_stats', 'login', 'major_holders', 'news', 'option_chain', 'p_all_financial_data', 'p_balance_sheet', 'p_cash_flow', 'p_company_360', 'p_corporate_events', 'p_fair_value', 'p_get_financial_data', 'p_ideas', 'p_income_statement', 'p_portal', 'p_reports', 'p_technical_events', 'p_technical_insights', 'p_valuation_measures', 'p_value_analyzer', 'p_value_analyzer_drilldown', 'page_views', 'password', 'price', 'progress', 'quote_type', 'quotes', 'recommendation_trend', 'recommendations', 'sec_filings', 'session', 'share_purchase_activity', 'summary_detail', 'summary_profile', 'symbols', 'technical_insights', 'username', 'validation', 'valuation_measures']
aapl.summary_detail
{'aapl': {'maxAge': 1, 'priceHint': 2, 'previousClose': 191.73, 'open': 190.94, 'dayLow': 187.47, 'dayHigh': 191.8, 'regularMarketPreviousClose': 191.73, 'regularMarketOpen': 190.94, 'regularMarketDayLow': 187.47, 'regularMarketDayHigh': 191.8, 'dividendRate': 0.96, 'dividendYield': 0.005, 'exDividendDate': '2023-11-09 19:00:00', 'payoutRatio': 0.1533, 'fiveYearAvgDividendYield': 0.8, 'beta': 1.29, 'trailingPE': 30.630407, 'forwardPE': 28.409472, 'volume': 39137973, 'regularMarketVolume': 39137973, 'averageVolume': 53818939, 'averageVolume10days': 56220600, 'averageDailyVolume10Day': 56220600, 'bid': 187.81, 'ask': 187.81, 'bidSize': 1300, 'askSize': 1200, 'marketCap': 2907930361856, 'fiftyTwoWeekLow': 141.32, 'fiftyTwoWeekHigh': 199.62, 'priceToSalesTrailing12Months': 7.586862, 'fiftyDayAverage': 190.9246, 'twoHundredDayAverage': 182.0785, 'trailingAnnualDividendRate': 0.94, 'trailingAnnualDividendYield': 0.004902728, 'currency': 'USD', 'fromCurrency': None, 'toCurrency': None, 'lastMarket': None, 'coinMarketCapLink': None, 'algorithm': None, 'tradeable': False}}
aapl.asset_profile
{'aapl': {'address1': 'One Apple Park Way', 'city': 'Cupertino', 'state': 'CA', 'zip': '95014', 'country': 'United States', 'phone': '408 996 1010', 'website': 'https://www.apple.com', 'industry': 'Consumer Electronics', 'industryKey': 'consumer-electronics', 'industryDisp': 'Consumer Electronics', 'sector': 'Technology', 'sectorKey': 'technology', 'sectorDisp': 'Technology', 'longBusinessSummary': 'Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide. The company offers iPhone, a line of smartphones; Mac, a line of personal computers; iPad, a line of multi-purpose tablets; and wearables, home, and accessories comprising AirPods, Apple TV, Apple Watch, Beats products, and HomePod. It also provides AppleCare support and cloud services; and operates various platforms, including the App Store that allow customers to discover and download applications and digital content, such as books, music, video, games, and podcasts. In addition, the company offers various services, such as Apple Arcade, a game subscription service; Apple Fitness+, a personalized fitness service; Apple Music, which offers users a curated listening experience with on-demand radio stations; Apple News+, a subscription news and magazine service; Apple TV+, which offers exclusive original content; Apple Card, a co-branded credit card; and Apple Pay, a cashless payment service, as well as licenses its intellectual property. The company serves consumers, and small and mid-sized businesses; and the education, enterprise, and government markets. It distributes third-party applications for its products through the App Store. The company also sells its products through its retail and online stores, and direct sales force; and third-party cellular network carriers, wholesalers, retailers, and resellers. Apple Inc. was founded in 1976 and is headquartered in Cupertino, California.', 'fullTimeEmployees': 161000, 'companyOfficers': [{'maxAge': 1, 'name': 'Mr. Timothy D. Cook', 'age': 62, 'title': 'CEO & Director', 'yearBorn': 1961, 'fiscalYear': 2023, 'totalPay': 16239562, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Luca Maestri', 'age': 60, 'title': 'CFO & Senior VP', 'yearBorn': 1963, 'fiscalYear': 2023, 'totalPay': 4612242, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Jeffrey E. Williams', 'age': 59, 'title': 'Chief Operating Officer', 'yearBorn': 1964, 'fiscalYear': 2023, 'totalPay': 4637585, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Ms. Katherine L. Adams', 'age': 59, 'title': 'Senior VP, General Counsel & Secretary', 'yearBorn': 1964, 'fiscalYear': 2023, 'totalPay': 4618064, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': "Ms. Deirdre O'Brien", 'age': 56, 'title': 'Senior Vice President of Retail', 'yearBorn': 1967, 'fiscalYear': 2023, 'totalPay': 4613369, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Chris Kondo', 'title': 'Senior Director of Corporate Accounting', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. James Wilson', 'title': 'Chief Technology Officer', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Suhasini Chandramouli', 'title': 'Director of Investor Relations', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Greg Joswiak', 'title': 'Senior Vice President of Worldwide Marketing', 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Adrian Perica', 'age': 49, 'title': 'Head of Corporate Development', 'yearBorn': 1974, 'fiscalYear': 2023, 'exercisedValue': 0, 'unexercisedValue': 0}], 'auditRisk': 4, 'boardRisk': 1, 'compensationRisk': 5, 'shareHolderRightsRisk': 1, 'overallRisk': 1, 'governanceEpochDate': '2024-01-27 19:00:00', 'compensationAsOfEpochDate': '2023-12-30 19:00:00', 'maxAge': 86400}}
aapl.calendar_events
{'aapl': {'maxAge': 1, 'earnings': {'earningsDate': ['2024-01-31 05:59:S', '2024-02-05 07:00:S'], 'earningsAverage': 1.93, 'earningsLow': 1.86, 'earningsHigh': 1.99, 'revenueAverage': 108768000000, 'revenueLow': 107508000000, 'revenueHigh': 114394000000}, 'exDividendDate': '2023-11-09 19:00:00', 'dividendDate': '2023-11-15 19:00:00'}}
aapl.esg_scores
{'aapl': {'maxAge': 86400, 'totalEsg': 17.22, 'environmentScore': 0.46, 'socialScore': 7.39, 'governanceScore': 9.37, 'ratingYear': 2023, 'ratingMonth': 9, 'highestControversy': 3.0, 'peerCount': 55, 'esgPerformance': 'UNDER_PERF', 'peerGroup': 'Technology Hardware', 'relatedControversy': ['Social Supply Chain Incidents', 'Customer Incidents', 'Business Ethics Incidents'], 'peerEsgScorePerformance': {'min': 6.37, 'avg': 15.565636363636367, 'max': 27.47}, 'peerGovernancePerformance': {'min': 3.44, 'avg': 6.928431372549018, 'max': 11.13}, 'peerSocialPerformance': {'min': 1.75, 'avg': 5.536862745098038, 'max': 9.76}, 'peerEnvironmentPerformance': {'min': 0.11, 'avg': 3.0588235294117636, 'max': 9.54}, 'peerHighestControversyPerformance': {'min': 0.0, 'avg': 1.5454545454545454, 'max': 4.0}, 'percentile': 17.82, 'environmentPercentile': None, 'socialPercentile': None, 'governancePercentile': None, 'adult': False, 'alcoholic': False, 'animalTesting': False, 'catholic': False, 'controversialWeapons': False, 'smallArms': False, 'furLeather': False, 'gambling': False, 'gmo': False, 'militaryContract': False, 'nuclear': False, 'pesticides': False, 'palmOil': False, 'coal': False, 'tobacco': False}}
aapl.key_stats
{'aapl': {'maxAge': 1, 'priceHint': 2, 'enterpriseValue': 3044304224256, 'forwardPE': 28.4358, 'profitMargins': 0.25305998, 'floatShares': 15535332918, 'sharesOutstanding': 15461900288, 'sharesShort': 101263039, 'sharesShortPriorMonth': 120233720, 'sharesShortPreviousMonthDate': '2023-12-14 19:00:00', 'dateShortInterest': '2024-01-11 19:00:00', 'sharesPercentSharesOut': 0.0064999997, 'heldPercentInsiders': 0.00072999997, 'heldPercentInstitutions': 0.61806, 'shortRatio': 1.83, 'shortPercentOfFloat': 0.0066000004, 'beta': 1.29, 'impliedSharesOutstanding': 15552799744, 'category': None, 'bookValue': 3.997, 'priceToBook': 47.096573, 'fundFamily': None, 'legalType': None, 'lastFiscalYearEnd': '2023-09-29 20:00:00', 'nextFiscalYearEnd': '2024-09-29 20:00:00', 'mostRecentQuarter': '2023-09-29 20:00:00', 'earningsQuarterlyGrowth': 0.108, 'netIncomeToCommon': 96995000320, 'trailingEps': 6.14, 'forwardEps': 6.62, 'pegRatio': 5.58, 'lastSplitFactor': '4:1', 'lastSplitDate': '2020-08-30 20:00:00', 'enterpriseToRevenue': 7.943, 'enterpriseToEbitda': 24.196, '52WeekChange': 0.32878232, 'SandP52WeekChange': 0.20883334, 'lastDividendValue': 0.24, 'lastDividendDate': 1699574400}}
aapl.price
{'aapl': {'maxAge': 1, 'preMarketChangePercent': -0.00412034, 'preMarketChange': -0.789993, 'preMarketTime': '2024-01-30 09:29:58', 'preMarketPrice': 190.94, 'preMarketSource': 'FREE_REALTIME', 'regularMarketChangePercent': -0.018359093, 'regularMarketChange': -3.519989, 'regularMarketTime': '2024-01-30 15:01:26', 'priceHint': 2, 'regularMarketPrice': 188.21, 'regularMarketDayHigh': 191.8, 'regularMarketDayLow': 187.47, 'regularMarketVolume': 39837931, 'regularMarketPreviousClose': 191.73, 'regularMarketSource': 'FREE_REALTIME', 'regularMarketOpen': 190.94, 'exchange': 'NMS', 'exchangeName': 'NasdaqGS', 'exchangeDataDelayedBy': 0, 'marketState': 'REGULAR', 'quoteType': 'EQUITY', 'symbol': 'AAPL', 'underlyingSymbol': None, 'shortName': 'Apple Inc.', 'longName': 'Apple Inc.', 'currency': 'USD', 'quoteSourceName': 'Nasdaq Real Time Price', 'currencySymbol': '$', 'fromCurrency': None, 'toCurrency': None, 'lastMarket': None, 'marketCap': 2910084399104}}
The recommendation trend shows the change in analyst calls in the past 3 months.
aapl.recommendation_trend
period | strongBuy | buy | hold | sell | strongSell | ||
---|---|---|---|---|---|---|---|
symbol | row | ||||||
aapl | 0 | 0m | 11 | 21 | 6 | 0 | 0 |
1 | -1m | 10 | 20 | 12 | 1 | 0 | |
2 | -2m | 10 | 21 | 12 | 1 | 0 | |
3 | -3m | 10 | 24 | 7 | 1 | 0 |
aapl.corporate_events
id | significance | headline | description | parentTopics | ||
---|---|---|---|---|---|---|
symbol | date | |||||
aapl | 2014-04-23 | 2972429 | 1 | Apple announces share repurchase and increase ... | Apple Inc:Increased its share repurchase autho... | Ownership/Control |
2014-07-22 | 3034175 | 3 | Apple Inc declares cash dividend | Apple Inc:Declares a cash dividend of $.47 per... | Performance | |
2014-10-20 | 3088795 | 3 | Apple Inc declares cash dividend | Apple Inc:Declares cash dividend of $.47 per s... | Performance | |
2015-01-27 | 3142676 | 3 | Apple Inc declares cash dividend | Apple Inc:Declared cash dividend of $.47 per s... | Performance | |
2015-04-27 | 3200725 | 1 | Apple expands capital return program to $200 b... | Apple:AuthorizeS an increase of more than 50 p... | Ownership/Control | |
... | ... | ... | ... | ... | ... | |
2022-10-27 | 4613461 | 1 | Apple Inc Reports Q4 Earnings Per Share Of $1.29 | Oct 27 (Reuters) - Apple Inc <AAPL.O>::QTRLY E... | Corporate Guidance | |
2023-06-30 | 4729098 | 1 | Nokia And Apple Sign Long-Term Patent License ... | June 30 (Reuters) - Nokia Oyj <NOKIA.HE>::NOKI... | Corporate Deals | |
2023-06-30 | 4729108 | 1 | Nokia And Apple Sign Long-Term Patent License ... | Nokia Oyj <NOKIA.HE>::NOKIA AND APPLE SIGN LON... | Corporate Guidance | |
2023-07-26 | 4738309 | 1 | LG Display expects to turn to profit in Q4 | July 26 (Reuters) - LG Display Co Ltd <034220.... | Corporate Guidance | |
2023-08-14 | 4750625 | 1 | Ford Hires Apple Veteran Peter Stern As Presid... | Aug 14 (Reuters) - Ford Motor Co <F.N>::FORD H... | Restructuring/Reorganization/Related |
179 rows × 5 columns
tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies")
sp500 = tables[0]['Symbol'].tolist()
sp500 = [symbol.replace(".", "-") for symbol in sp500]
%%time
tickers = Ticker(aapl, asynchronous=True)
yq_data = tickers.history(period='ytd', interval='1d')
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) File <timed exec>:2 File ~/.local/lib/python3.11/site-packages/yahooquery/ticker.py:1293, in Ticker.history(self, period, interval, start, end, adj_timezone, adj_ohlc) 1291 df = self._history_1m(adj_timezone, adj_ohlc) 1292 else: -> 1293 data = self._get_data("chart", params) 1294 df = self._historical_data_to_dataframe(data, params, adj_timezone) 1295 if adj_ohlc and "adjclose" in df: File ~/.local/lib/python3.11/site-packages/yahooquery/base.py:1096, in _YahooFinance._get_data(self, key, params, **kwargs) 1094 config = self._CONFIG[key] 1095 params = self._construct_params(config, params) -> 1096 urls = self._construct_urls(config, params, **kwargs) 1097 response_field = config["response_field"] 1098 try: File ~/.local/lib/python3.11/site-packages/yahooquery/base.py:1169, in _YahooFinance._construct_urls(self, config, params, **kwargs) 1163 else: 1164 ls = ( 1165 self._symbols 1166 if isinstance(self.session, FuturesSession) 1167 else tqdm(self._symbols, disable=not self.progress) 1168 ) -> 1169 urls = [ 1170 self.session.get( 1171 url=config["path"].format(**{"symbol": symbol}), params=params 1172 ) 1173 for symbol in ls 1174 ] 1175 return urls TypeError: 'Ticker' object is not iterable
aapl_df.tail()
high | low | open | close | volume | adjclose | |
---|---|---|---|---|---|---|
formatted_date | ||||||
2019-11-26 | 67.062500 | 65.625000 | 66.735001 | 66.040001 | 311548000 | 64.338287 |
2019-12-03 | 67.750000 | 64.072502 | 64.577499 | 66.730003 | 490154400 | 65.010506 |
2019-12-10 | 70.197502 | 66.464996 | 67.150002 | 69.964996 | 568261200 | 68.162148 |
2019-12-17 | 71.062500 | 69.639999 | 69.892502 | 71.000000 | 703106000 | 69.170471 |
2019-12-24 | 73.492500 | 70.730003 | 71.172501 | 72.879997 | 431980400 | 71.002037 |
import matplotlib
ticker = Ticker('AAPL')
aapl_df = ticker.history(period="5y")
aapl_df['Close'].plot(title="APPLE's stock price")
/home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/utils/__init__.py:1470: FutureWarning: 'S' is deprecated and will be removed in a future version. Please use 's' instead of 'S'. has_live_indice = index_utc[-1] >= last_trade - pd.Timedelta(2, "S") /home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/ticker.py:1333: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy. For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object. df["dividends"].fillna(0, inplace=True) /home/accts/sbs5/.local/lib/python3.11/site-packages/yahooquery/ticker.py:1335: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy. For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object. df["splits"].fillna(0, inplace=True)
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) File ~/.local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3802, in Index.get_loc(self, key) 3801 try: -> 3802 return self._engine.get_loc(casted_key) 3803 except KeyError as err: File index.pyx:153, in pandas._libs.index.IndexEngine.get_loc() File index.pyx:182, in pandas._libs.index.IndexEngine.get_loc() File pandas/_libs/hashtable_class_helper.pxi:7081, in pandas._libs.hashtable.PyObjectHashTable.get_item() File pandas/_libs/hashtable_class_helper.pxi:7089, in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'Close' The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) Cell In[28], line 3 1 ticker = Ticker('AAPL') 2 aapl_df = ticker.history(period="5y") ----> 3 aapl_df['Close'].plot(title="APPLE's stock price") File ~/.local/lib/python3.11/site-packages/pandas/core/frame.py:4090, in DataFrame.__getitem__(self, key) 4088 if self.columns.nlevels > 1: 4089 return self._getitem_multilevel(key) -> 4090 indexer = self.columns.get_loc(key) 4091 if is_integer(indexer): 4092 indexer = [indexer] File ~/.local/lib/python3.11/site-packages/pandas/core/indexes/base.py:3809, in Index.get_loc(self, key) 3804 if isinstance(casted_key, slice) or ( 3805 isinstance(casted_key, abc.Iterable) 3806 and any(isinstance(x, slice) for x in casted_key) 3807 ): 3808 raise InvalidIndexError(key) -> 3809 raise KeyError(key) from err 3810 except TypeError: 3811 # If we have a listlike key, _check_indexing_error will raise 3812 # InvalidIndexError. Otherwise we fall through and re-raise 3813 # the TypeError. 3814 self._check_indexing_error(key) KeyError: 'Close'
from yahoofinancials import YahooFinancials
yahoo_financials = YahooFinancials('AAPL')
data = yahoo_financials.get_historical_price_data(start_date='2019-01-01',
end_date='2019-12-31',
time_interval='weekly')
aapl_df = pd.DataFrame(data['AAPL']['prices'])
aapl_df = aapl_df.drop('date', axis=1).set_index('formatted_date')
aapl_df.head()
high | low | open | close | volume | adjclose | |
---|---|---|---|---|---|---|
formatted_date | ||||||
2019-01-01 | 39.712502 | 35.500000 | 38.722500 | 36.982498 | 966947200 | 35.496208 |
2019-01-08 | 38.632500 | 37.130001 | 37.389999 | 37.500000 | 725470000 | 35.992908 |
2019-01-15 | 39.470001 | 37.512501 | 37.567501 | 39.205002 | 491411200 | 37.629391 |
2019-01-22 | 39.532501 | 37.924999 | 39.102501 | 39.075001 | 554774800 | 37.504620 |
2019-01-29 | 42.915001 | 38.527500 | 39.062500 | 42.812500 | 830400800 | 41.091908 |
dir(yahoo_financials)
['YAHOO_FINANCIAL_TYPES', '_BASE_YAHOO_URL', '_INTERVAL_DICT', '_MIN_INTERVAL', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_build_api_url', '_build_historical_url', '_cache', '_clean_api_data', '_clean_data_process', '_clean_earnings_data', '_clean_historical_data', '_clean_reports', '_convert_to_utc', '_create_dict_ent', '_determine_numeric_value', '_encode_ticker', '_financial_statement_data', '_format_time', '_get_api_data', '_get_cleaned_sub_dict_ent', '_get_proxy', '_get_stmt_id', '_get_sub_dict_ent', '_get_worker_count', '_handle_api_dividend_request', '_recursive_api_request', '_reformat_stmt_data_process', '_request_handler', '_run_financial_stmt', '_scrape_data', '_stock_price_data', '_stock_summary_data', 'concurrent', 'country', 'format_date', 'get_200day_moving_avg', 'get_50day_moving_avg', 'get_annual_avg_div_rate', 'get_annual_avg_div_yield', 'get_beta', 'get_book_value', 'get_clean_data', 'get_cost_of_revenue', 'get_currency', 'get_current_change', 'get_current_percent_change', 'get_current_price', 'get_current_volume', 'get_daily_dividend_data', 'get_daily_high', 'get_daily_low', 'get_dividend_rate', 'get_dividend_yield', 'get_earnings_per_share', 'get_ebit', 'get_exdividend_date', 'get_financial_data', 'get_financial_stmts', 'get_five_yr_avg_div_yield', 'get_gross_profit', 'get_historical_price_data', 'get_income_before_tax', 'get_income_tax_expense', 'get_interest_expense', 'get_key_statistics_data', 'get_market_cap', 'get_net_income', 'get_net_income_from_continuing_ops', 'get_num_shares_outstanding', 'get_open_price', 'get_operating_income', 'get_payout_ratio', 'get_pe_ratio', 'get_prev_close_price', 'get_price_to_sales', 'get_reformatted_stmt_data', 'get_report_type', 'get_research_and_development', 'get_stock_data', 'get_stock_dividend_data', 'get_stock_earnings_data', 'get_stock_exchange', 'get_stock_price_data', 'get_stock_profile_data', 'get_stock_quote_type_data', 'get_stock_summary_url', 'get_stock_tech_data', 'get_summary_data', 'get_ten_day_avg_daily_volume', 'get_three_month_avg_daily_volume', 'get_time_code', 'get_total_operating_expense', 'get_total_revenue', 'get_yearly_high', 'get_yearly_low', 'max_workers', 'proxies', 'ticker', 'timeout']
dir(yahoo_financials.get_clean_data.__func__)
['__annotations__', '__builtins__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__getstate__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
hasattr(yahoo_financials.get_beta, '__call__')
True
for p in dir(yahoo_financials):
print (p, '\t', getattr(yahoo_financials, p), '\n')
YAHOO_FINANCIAL_TYPES {'income': ['financials', 'incomeStatementHistory', 'incomeStatementHistoryQuarterly'], 'balance': ['balance-sheet', 'balanceSheetHistory', 'balanceSheetHistoryQuarterly', 'balanceSheetStatements'], 'cash': ['cash-flow', 'cashflowStatementHistory', 'cashflowStatementHistoryQuarterly', 'cashflowStatements'], 'keystats': ['key-statistics'], 'history': ['history'], 'profile': ['profile']} _BASE_YAHOO_URL https://finance.yahoo.com/quote/ _INTERVAL_DICT {'daily': '1d', 'weekly': '1wk', 'monthly': '1mo'} _MIN_INTERVAL 7 __class__ <class 'yahoofinancials.yf.YahooFinancials'> __delattr__ <method-wrapper '__delattr__' of YahooFinancials object at 0x7f10c89a3c50> __dict__ {'ticker': 'AAPL', 'country': 'US', 'concurrent': False, 'max_workers': 8, 'timeout': 30, 'proxies': None, '_cache': {}} __dir__ <built-in method __dir__ of YahooFinancials object at 0x7f10c89a3c50> __doc__ Arguments ---------- tickers: str or list Ticker or listed collection of tickers Keyword Arguments ----------------- concurrent: bool, default False, optional Defines whether the requests are made synchronously or asynchronously. country: str, default 'US', optional This allows you to alter the region, lang, corsDomain parameter sent with each request based on selected country max_workers: int, default 8, optional Defines the number of workers used to make concurrent requests. Only relevant if concurrent=True timeout: int, default 30, optional Defines how long a request will stay open. proxies: str or list, default None, optional Defines any proxies to use during this instantiation. __eq__ <method-wrapper '__eq__' of YahooFinancials object at 0x7f10c89a3c50> __format__ <built-in method __format__ of YahooFinancials object at 0x7f10c89a3c50> __ge__ <method-wrapper '__ge__' of YahooFinancials object at 0x7f10c89a3c50> __getattribute__ <method-wrapper '__getattribute__' of YahooFinancials object at 0x7f10c89a3c50> __getstate__ <built-in method __getstate__ of YahooFinancials object at 0x7f10c89a3c50> __gt__ <method-wrapper '__gt__' of YahooFinancials object at 0x7f10c89a3c50> __hash__ <method-wrapper '__hash__' of YahooFinancials object at 0x7f10c89a3c50> __init__ <bound method YahooFinanceETL.__init__ of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> __init_subclass__ <built-in method __init_subclass__ of type object at 0x55ef1adc0560> __le__ <method-wrapper '__le__' of YahooFinancials object at 0x7f10c89a3c50> __lt__ <method-wrapper '__lt__' of YahooFinancials object at 0x7f10c89a3c50> __module__ yahoofinancials.yf __ne__ <method-wrapper '__ne__' of YahooFinancials object at 0x7f10c89a3c50> __new__ <built-in method __new__ of type object at 0x7f118d0df0c0> __reduce__ <built-in method __reduce__ of YahooFinancials object at 0x7f10c89a3c50> __reduce_ex__ <built-in method __reduce_ex__ of YahooFinancials object at 0x7f10c89a3c50> __repr__ <method-wrapper '__repr__' of YahooFinancials object at 0x7f10c89a3c50> __setattr__ <method-wrapper '__setattr__' of YahooFinancials object at 0x7f10c89a3c50> __sizeof__ <built-in method __sizeof__ of YahooFinancials object at 0x7f10c89a3c50> __str__ <method-wrapper '__str__' of YahooFinancials object at 0x7f10c89a3c50> __subclasshook__ <built-in method __subclasshook__ of type object at 0x55ef1adc0560> __weakref__ None _build_api_url <bound method YahooFinanceETL._build_api_url of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _build_historical_url <bound method YahooFinanceETL._build_historical_url of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _cache {} _clean_api_data <bound method YahooFinanceETL._clean_api_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _clean_data_process <bound method YahooFinanceETL._clean_data_process of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _clean_earnings_data <bound method YahooFinanceETL._clean_earnings_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _clean_historical_data <bound method YahooFinanceETL._clean_historical_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _clean_reports <bound method YahooFinanceETL._clean_reports of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _convert_to_utc <function YahooFinanceETL._convert_to_utc at 0x7f10c898a0c0> _create_dict_ent <bound method YahooFinanceETL._create_dict_ent of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _determine_numeric_value <function YahooFinanceETL._determine_numeric_value at 0x7f10c898b1a0> _encode_ticker <function YahooFinanceETL._encode_ticker at 0x7f10c898b4c0> _financial_statement_data <bound method YahooFinancials._financial_statement_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _format_time <bound method YahooFinanceETL._format_time of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _get_api_data <bound method YahooFinanceETL._get_api_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _get_cleaned_sub_dict_ent <bound method YahooFinanceETL._get_cleaned_sub_dict_ent of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _get_proxy <bound method YahooFinanceETL._get_proxy of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _get_stmt_id <bound method YahooFinanceETL._get_stmt_id of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _get_sub_dict_ent <bound method YahooFinanceETL._get_sub_dict_ent of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _get_worker_count <bound method YahooFinanceETL._get_worker_count of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _handle_api_dividend_request <bound method YahooFinanceETL._handle_api_dividend_request of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _recursive_api_request <bound method YahooFinanceETL._recursive_api_request of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _reformat_stmt_data_process <bound method YahooFinanceETL._reformat_stmt_data_process of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _request_handler <bound method YahooFinanceETL._request_handler of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _run_financial_stmt <bound method YahooFinancials._run_financial_stmt of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _scrape_data <bound method YahooFinanceETL._scrape_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _stock_price_data <bound method YahooFinancials._stock_price_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> _stock_summary_data <bound method YahooFinancials._stock_summary_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> concurrent False country US format_date <function YahooFinanceETL.format_date at 0x7f10c898a020> get_200day_moving_avg <bound method YahooFinancials.get_200day_moving_avg of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_50day_moving_avg <bound method YahooFinancials.get_50day_moving_avg of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_annual_avg_div_rate <bound method YahooFinancials.get_annual_avg_div_rate of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_annual_avg_div_yield <bound method YahooFinancials.get_annual_avg_div_yield of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_beta <bound method YahooFinancials.get_beta of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_book_value <bound method YahooFinancials.get_book_value of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_clean_data <bound method YahooFinanceETL.get_clean_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_cost_of_revenue <bound method YahooFinancials.get_cost_of_revenue of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_currency <bound method YahooFinancials.get_currency of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_current_change <bound method YahooFinancials.get_current_change of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_current_percent_change <bound method YahooFinancials.get_current_percent_change of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_current_price <bound method YahooFinancials.get_current_price of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_current_volume <bound method YahooFinancials.get_current_volume of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_daily_dividend_data <bound method YahooFinancials.get_daily_dividend_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_daily_high <bound method YahooFinancials.get_daily_high of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_daily_low <bound method YahooFinancials.get_daily_low of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_dividend_rate <bound method YahooFinancials.get_dividend_rate of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_dividend_yield <bound method YahooFinancials.get_dividend_yield of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_earnings_per_share <bound method YahooFinancials.get_earnings_per_share of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_ebit <bound method YahooFinancials.get_ebit of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_exdividend_date <bound method YahooFinancials.get_exdividend_date of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_financial_data <bound method YahooFinancials.get_financial_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_financial_stmts <bound method YahooFinancials.get_financial_stmts of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_five_yr_avg_div_yield <bound method YahooFinancials.get_five_yr_avg_div_yield of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_gross_profit <bound method YahooFinancials.get_gross_profit of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_historical_price_data <bound method YahooFinancials.get_historical_price_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_income_before_tax <bound method YahooFinancials.get_income_before_tax of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_income_tax_expense <bound method YahooFinancials.get_income_tax_expense of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_interest_expense <bound method YahooFinancials.get_interest_expense of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_key_statistics_data <bound method YahooFinancials.get_key_statistics_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_market_cap <bound method YahooFinancials.get_market_cap of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_net_income <bound method YahooFinancials.get_net_income of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_net_income_from_continuing_ops <bound method YahooFinancials.get_net_income_from_continuing_ops of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_num_shares_outstanding <bound method YahooFinancials.get_num_shares_outstanding of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_open_price <bound method YahooFinancials.get_open_price of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_operating_income <bound method YahooFinancials.get_operating_income of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_payout_ratio <bound method YahooFinancials.get_payout_ratio of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_pe_ratio <bound method YahooFinancials.get_pe_ratio of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_prev_close_price <bound method YahooFinancials.get_prev_close_price of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_price_to_sales <bound method YahooFinancials.get_price_to_sales of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_reformatted_stmt_data <bound method YahooFinanceETL.get_reformatted_stmt_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_report_type <function YahooFinanceETL.get_report_type at 0x7f10c8989f80> get_research_and_development <bound method YahooFinancials.get_research_and_development of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_data <bound method YahooFinanceETL.get_stock_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_dividend_data <bound method YahooFinanceETL.get_stock_dividend_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_earnings_data <bound method YahooFinancials.get_stock_earnings_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_exchange <bound method YahooFinancials.get_stock_exchange of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_price_data <bound method YahooFinancials.get_stock_price_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_profile_data <bound method YahooFinancials.get_stock_profile_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_quote_type_data <bound method YahooFinancials.get_stock_quote_type_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_summary_url <bound method YahooFinancials.get_stock_summary_url of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_stock_tech_data <bound method YahooFinanceETL.get_stock_tech_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_summary_data <bound method YahooFinancials.get_summary_data of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_ten_day_avg_daily_volume <bound method YahooFinancials.get_ten_day_avg_daily_volume of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_three_month_avg_daily_volume <bound method YahooFinancials.get_three_month_avg_daily_volume of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_time_code <bound method YahooFinanceETL.get_time_code of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_total_operating_expense <bound method YahooFinancials.get_total_operating_expense of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_total_revenue <bound method YahooFinancials.get_total_revenue of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_yearly_high <bound method YahooFinancials.get_yearly_high of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> get_yearly_low <bound method YahooFinancials.get_yearly_low of <yahoofinancials.yf.YahooFinancials object at 0x7f10c89a3c50>> max_workers 8 proxies None ticker AAPL timeout 30
yahoo_financials = YahooFinancials('BTC-USD')
data=yahoo_financials.get_historical_price_data("2019-07-10", "2022-01-31", "monthly")
btc_df = pd.DataFrame(data['BTC-USD']['prices'])
btc_df = btc_df.drop('date', axis=1).set_index('formatted_date')
btc_df.head()
high | low | open | close | volume | adjclose | |
---|---|---|---|---|---|---|
formatted_date | ||||||
2019-08-01 | 12273.821289 | 9421.629883 | 10077.442383 | 9630.664062 | 533984971734 | 9630.664062 |
2019-09-01 | 10898.761719 | 7830.758789 | 9630.592773 | 8293.868164 | 480544963230 | 8293.868164 |
2019-10-01 | 10021.744141 | 7446.988770 | 8299.720703 | 9199.584961 | 595205134748 | 9199.584961 |
2019-11-01 | 9505.051758 | 6617.166992 | 9193.992188 | 7569.629883 | 676919523650 | 7569.629883 |
2019-12-01 | 7743.431641 | 6540.049316 | 7571.616211 | 7193.599121 | 633790373416 | 7193.599121 |
btc_df.tail()
high | low | open | close | volume | adjclose | |
---|---|---|---|---|---|---|
formatted_date | ||||||
2021-09-01 | 52853.765625 | 39787.609375 | 47099.773438 | 43790.894531 | 1102139678824 | 43790.894531 |
2021-10-01 | 66930.390625 | 43320.023438 | 43816.742188 | 61318.957031 | 1153077903534 | 61318.957031 |
2021-11-01 | 68789.625000 | 53569.765625 | 61320.449219 | 57005.425781 | 1053270271383 | 57005.425781 |
2021-12-01 | 59041.683594 | 42874.617188 | 56907.964844 | 46306.445312 | 957047184722 | 46306.445312 |
2022-01-01 | 47881.406250 | 33184.058594 | 46311.746094 | 38483.125000 | 923979037681 | 38483.125000 |