问题描述
目前,我正在尝试根据财务数据(例如资产负债表、损益表和现金流量表)创建股票筛选器。我在互联网“yahoofinancials”上找到了一个很棒的包,它可以从雅虎获取任何股票的数据并将其输出为字典。唯一的问题是,每当我尝试访问数据时,因为它在多个字典中,我不能。我已经在互联网上搜索了几天,但唯一的资源是没有锁定在其他人内部的字典。这是我正在尝试运行的代码,然后我将显示资产负债表字典。
from yahoofinancials import YahooFinancials
ticker = input("Enter exact stock ticker in upper-case lettering: ")
yahoo_financials = YahooFinancials(ticker)
balance_sheet_data_annual = yahoo_financials.get_financial_stmts('annual','balance')
cash_flow_sheet_data_annual = yahoo_financials.get_financial_stmts('annual','cash')
income_statement_data_annual = yahoo_financials.get_financial_stmts('annual','income')
all_statement_data_annual = yahoo_financials.get_financial_stmts('annual',['income','cash','balance'])
ten_yr_bond_yield = YahooFinancials(['^TNX'])
totalStockHolderEquity = {'balanceSheetHistory'}
totalStockHolderEquityi = balance_sheet_data_annual['totalStockHolderEquity']
# tests for dictionary navigation
print(totalStockHolderEquityi)
print(balance_sheet_data_annual)
这是字典
{'balanceSheetHistory': {'AAPL': [{'2020-09-26': {'totalLiab': 258549000000,'totalStockholderEquity': 65339000000,'otherCurrentLiab': 47867000000,'totalAssets': 323888000000,'commonStock': 50779000000,'otherCurrentAssets': 11264000000,'retainedEarnings': 14966000000,'otherLiab': 46108000000,'treasuryStock': -406000000,'otherAssets': 33952000000,'cash': 38016000000,'totalCurrentLiabilities': 105392000000,'shortLongTermDebt': 8773000000,'otherStockholderEquity': -406000000,'propertyPlantEquipment': 45336000000,'totalCurrentAssets': 143713000000,'longTermInvestments': 100887000000,'netTangibleAssets': 65339000000,'shortTermInvestments': 52927000000,'netReceivables': 37445000000,'longTermDebt': 98667000000,'inventory': 4061000000,'accountsPayable': 42296000000}},{'2019-09-28': {'totalLiab': 248028000000,'totalStockholderEquity': 90488000000,'otherCurrentLiab': 43242000000,'totalAssets': 338516000000,'commonStock': 45174000000,'otherCurrentAssets': 12352000000,'retainedEarnings': 45898000000,'otherLiab': 50503000000,'treasuryStock': -584000000,'otherAssets': 32978000000,'cash': 48844000000,'totalCurrentLiabilities': 105718000000,'shortLongTermDebt': 10260000000,'otherStockholderEquity': -584000000,'propertyPlantEquipment': 37378000000,'totalCurrentAssets': 162819000000,'longTermInvestments': 105341000000,'netTangibleAssets': 90488000000,'shortTermInvestments': 51713000000,'netReceivables': 45804000000,'longTermDebt': 91807000000,'inventory': 4106000000,'accountsPayable': 46236000000}},{'2018-09-29': {'totalLiab': 258578000000,'totalStockholderEquity': 107147000000,'otherCurrentLiab': 39293000000,'totalAssets': 365725000000,'commonStock': 40201000000,'otherCurrentAssets': 12087000000,'retainedEarnings': 70400000000,'otherLiab': 48914000000,'treasuryStock': -3454000000,'otherAssets': 22283000000,'cash': 25913000000,'totalCurrentLiabilities': 115929000000,'shortLongTermDebt': 8784000000,'otherStockholderEquity': -3454000000,'propertyPlantEquipment': 41304000000,'totalCurrentAssets': 131339000000,'longTermInvestments': 170799000000,'netTangibleAssets': 107147000000,'shortTermInvestments': 40388000000,'netReceivables': 48995000000,'longTermDebt': 93735000000,'inventory': 3956000000,'accountsPayable': 55888000000}},{'2017-09-30': {'totalLiab': 241272000000,'totalStockholderEquity': 134047000000,'otherCurrentLiab': 38099000000,'totalAssets': 375319000000,'commonStock': 35867000000,'otherCurrentAssets': 13936000000,'retainedEarnings': 98330000000,'otherLiab': 43251000000,'treasuryStock': -150000000,'otherAssets': 18177000000,'cash': 20289000000,'totalCurrentLiabilities': 100814000000,'shortLongTermDebt': 6496000000,'otherStockholderEquity': -150000000,'propertyPlantEquipment': 33783000000,'totalCurrentAssets': 128645000000,'longTermInvestments': 194714000000,'netTangibleAssets': 134047000000,'shortTermInvestments': 53892000000,'netReceivables': 35673000000,'longTermDebt': 97207000000,'inventory': 4855000000,'accountsPayable': 44242000000}}]}}
以示例代码或学习资源形式提供的任何帮助将不胜感激!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)