Skip to content

Commit

Permalink
Close 2 stocks fa issues with polygon (OpenBB-finance#5217)
Browse files Browse the repository at this point in the history
* Fix OpenBB-finance#5190

* Add quarterly back to polygon cash flow

* Add some to stocks statics

* lint

* Fix tests + balance all of a sudden not working
  • Loading branch information
jmaslek committed Jul 14, 2023
1 parent adab625 commit d4d6e68
Show file tree
Hide file tree
Showing 11 changed files with 945 additions and 809 deletions.
31 changes: 13 additions & 18 deletions openbb_terminal/stocks/fundamental_analysis/polygon_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ def get_financials(
f"&apiKey={get_current_user().credentials.API_POLYGON_KEY}"
).json()

if statement == "cash" and quarterly:
console.print(
"[red]Quarterly information not available for statement of cash flows[/red]\n"
)
if statement not in ["balance", "income", "cash"]:
console.print("financial must be 'balance' or 'income'.\n")
return pd.DataFrame()
Expand Down Expand Up @@ -94,19 +90,18 @@ def get_financials(
income_statements = income_statements[["value"]]
income_statements.columns = [single_thing["filing_date"]]

if not quarterly:
cash_flows = pd.concat(
[
pd.DataFrame(),
pd.DataFrame.from_dict(
single_thing["financials"]["cash_flow_statement"],
orient="index",
),
],
axis=1,
)
cash_flows = cash_flows[["value"]]
cash_flows.columns = [single_thing["filing_date"]]
cash_flows = pd.concat(
[
pd.DataFrame(),
pd.DataFrame.from_dict(
single_thing["financials"]["cash_flow_statement"],
orient="index",
),
],
axis=1,
)
cash_flows = cash_flows[["value"]]
cash_flows.columns = [single_thing["filing_date"]]

first = False
else:
Expand All @@ -125,7 +120,7 @@ def get_financials(
)
values.columns = [single_thing["filing_date"]]
income_statements = pd.concat([income_statements, values], axis=1)
if not quarterly:
if "cash_flow_statement" in single_thing["financials"]:
values = pd.DataFrame(
pd.DataFrame.from_dict(
single_thing["financials"]["cash_flow_statement"],
Expand Down
5 changes: 5 additions & 0 deletions openbb_terminal/stocks/stock_statics.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
"noninterest_expense": "noninterest_expense",
"interest_and_dividend_income_operating": "interest_and_dividend_income_operating",
"provision_for_loan_lease_and_other_losses": "provision_for_loan_lease_and_other_losses",
"income_loss_from_discontinued_operations_net_of_tax": "income_loss_from_discontinued_operations_net_of_tax",
"cost_of_revenue_services": "cost_of_revenue_services",
"income_loss_from_discontinued_operations_net_of_tax_gain_loss_on_disposal": "income"
"_loss_from_discontinued_operations_net_of_tax_gain_loss_on_disposal",
},
"YahooFinance": {
"total_revenue": "total_revenue",
Expand Down Expand Up @@ -292,6 +296,7 @@
"fixed_assets": "fixed_assets",
"other_than_fixed_noncurrent_assets": "other_than_fixed_non_current_assets",
"liabilities_and_equity": "liabilities_and_equity",
"commitments_and_contingencies": "commitments_and_contingencies",
},
"YahooFinance": {
"cash_and_cash_equivalents": "cash_and_cash_equivalents",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interactions:
response:
body:
string: !!binary |
H4sIAAAAAAAA/6pWKkotLs0pKVayio7VUSouSSwpLVayUvL3VtJRKkotLE0tLonPTFGyUkqxMEtJ
NDKySDM1sDBITjJIMjQ2TDI1NrcwMLFMsTRLU6oFBAAA//8s+NrJTAAAAA==
H4sIAAAAAAAA/6pWKkotLs0pKVayio7VUSouSSwpLVayUvL3VtJRKkotLE0tLonPTFGyUrJItTSw
TLZMMjU0SktKMjdKtLA0Sk0yNTEwMbNMMjczVKoFBAAA//9EO1c6TAAAAA==
headers:
Connection:
- keep-alive
Expand All @@ -25,7 +25,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 03 Feb 2023 13:54:59 GMT
- Fri, 14 Jul 2023 13:22:21 GMT
Server:
- nginx/1.19.2
Strict-Transport-Security:
Expand All @@ -35,7 +35,7 @@ interactions:
X-Item-Count:
- '0'
X-Request-Id:
- d86da228f5080cb0b131b5378049d96f
- 8e909c9b512fbb72a892eb540469b761
status:
code: 200
message: OK
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
,2022-07-29,2022-04-29,2022-01-28,2021-07-28,2021-04-29,2021-01-28,2020-07-31,2020-05-01,2020-01-29,2019-07-31,2019-05-01,2019-01-30,2018-08-01,2018-05-02,2018-02-02,2017-08-02,2017-05-03,2017-02-01,2016-07-27,2016-04-27,2016-01-27,2015-07-22,2015-04-28,2015-01-28,2014-07-23,2014-04-24,2014-01-28,2013-07-24,2013-04-24,2013-01-24,2012-07-25,2012-04-25,2012-01-25,2011-07-20,2011-04-21,2011-01-19,2010-07-21,2010-04-21,2010-01-25,2009-07-22
noncurrent_assets,224017000000.0,232482000000.0,228037000000.0,215417000000.0,215693000000.0,199948000000.0,177279000000.0,176647000000.0,177387000000.0,187266000000.0,218652000000.0,232891000000.0,233436000000.0,237449000000.0,262984000000.0,232298000000.0,232542000000.0,227809000000.0,211841000000.0,217685000000.0,217065000000.0,202198000000.0,193303000000.0,178491000000.0,154571000000.0,135448000000.0,144837000000.0,131637000000.0,131406000000.0,123740000000.0,110953000000.0,100222000000.0,83910000000.0,59860000000.0,47907000000.0,42815000000.0,28692000000.0,24721000000.0,20594000000.0,12970000000.0
liabilities_and_equity,336309000000.0,350662000000.0,381191000000.0,329840000000.0,337158000000.0,354054000000.0,317344000000.0,320400000000.0,340618000000.0,322239000000.0,341998000000.0,373719000000.0,349197000000.0,367502000000.0,406794000000.0,345173000000.0,334532000000.0,331141000000.0,305602000000.0,305277000000.0,293284000000.0,273151000000.0,261194000000.0,261894000000.0,222520000000.0,205989000000.0,225184000000.0,199856000000.0,194743000000.0,196088000000.0,162896000000.0,150934000000.0,138681000000.0,106758000000.0,94904000000.0,86742000000.0,64725000000.0,57057000000.0,53926000000.0,48140000000.0
fixed_assets,40335000000.0,39304000000.0,39245000000.0,38615000000.0,37815000000.0,37933000000.0,35687000000.0,35889000000.0,37031000000.0,37636000000.0,38746000000.0,39597000000.0,38117000000.0,35077000000.0,33679000000.0,29286000000.0,27163000000.0,26510000000.0,25448000000.0,23203000000.0,22300000000.0,21149000000.0,20151000000.0,20392000000.0,17585000000.0,15120000000.0,15488000000.0,16327000000.0,15026000000.0,15422000000.0,10487000000.0,8847000000.0,,,,,,,,
equity_attributable_to_noncontrolling_interest,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
liabilities,278202000000.0,283263000000.0,309259000000.0,265560000000.0,267980000000.0,287830000000.0,245062000000.0,241975000000.0,251087000000.0,225783000000.0,236138000000.0,255827000000.0,234248000000.0,240624000000.0,266595000000.0,212748000000.0,200450000000.0,198751000000.0,179061000000.0,174820000000.0,165017000000.0,147474000000.0,132188000000.0,138566000000.0,101580000000.0,85810000000.0,95500000000.0,76502000000.0,59253000000.0,68742000000.0,51150000000.0,48436000000.0,48627000000.0,37415000000.0,33427000000.0,32076000000.0,21614000000.0,17709000000.0,18158000000.0,22252000000.0
current_liabilities,129873000000.0,127508000000.0,147574000000.0,107754000000.0,106385000000.0,132507000000.0,95318000000.0,96094000000.0,102161000000.0,89704000000.0,93772000000.0,108283000000.0,88548000000.0,89320000000.0,115788000000.0,81302000000.0,73342000000.0,84130000000.0,71486000000.0,68265000000.0,76092000000.0,65285000000.0,58729000000.0,73611000000.0,46205000000.0,43208000000.0,53769000000.0,36319000000.0,35508000000.0,46879000000.0,33060000000.0,32036000000.0,34607000000.0,26859000000.0,24327000000.0,23795000000.0,15612000000.0,12229000000.0,13097000000.0,16661000000.0
current_assets,112292000000.0,118180000000.0,153154000000.0,114423000000.0,121465000000.0,154106000000.0,140065000000.0,143753000000.0,163231000000.0,134973000000.0,123346000000.0,140828000000.0,115761000000.0,130053000000.0,143810000000.0,112875000000.0,101990000000.0,103332000000.0,93761000000.0,87592000000.0,76219000000.0,70953000000.0,67891000000.0,83403000000.0,67949000000.0,70541000000.0,80347000000.0,68219000000.0,63337000000.0,72348000000.0,51943000000.0,50712000000.0,54771000000.0,46898000000.0,46997000000.0,43927000000.0,36033000000.0,32336000000.0,33332000000.0,35170000000.0
equity_attributable_to_parent,58107000000.0,67399000000.0,71932000000.0,64280000000.0,69178000000.0,66224000000.0,72282000000.0,78425000000.0,89531000000.0,96456000000.0,105860000000.0,117892000000.0,114949000000.0,126878000000.0,140199000000.0,132425000000.0,134082000000.0,132390000000.0,126541000000.0,130457000000.0,128267000000.0,125677000000.0,129006000000.0,123328000000.0,120940000000.0,120179000000.0,129684000000.0,123354000000.0,135490000000.0,127346000000.0,111746000000.0,102498000000.0,90054000000.0,69343000000.0,61477000000.0,54666000000.0,43111000000.0,39348000000.0,35768000000.0,25888000000.0
equity,58107000000.0,67399000000.0,71932000000.0,64280000000.0,69178000000.0,66224000000.0,72282000000.0,78425000000.0,89531000000.0,96456000000.0,105860000000.0,117892000000.0,114949000000.0,126878000000.0,140199000000.0,132425000000.0,134082000000.0,132390000000.0,126541000000.0,130457000000.0,128267000000.0,125677000000.0,129006000000.0,123328000000.0,120940000000.0,120179000000.0,129684000000.0,123354000000.0,135490000000.0,127346000000.0,111746000000.0,102498000000.0,90054000000.0,69343000000.0,61477000000.0,54666000000.0,43111000000.0,39348000000.0,35768000000.0,25888000000.0
noncurrent_liabilities,148329000000.0,155755000000.0,161685000000.0,157806000000.0,161595000000.0,155323000000.0,149744000000.0,145881000000.0,148926000000.0,136079000000.0,142366000000.0,147544000000.0,145700000000.0,151304000000.0,150807000000.0,131446000000.0,127108000000.0,114621000000.0,107575000000.0,106555000000.0,88925000000.0,82189000000.0,73459000000.0,64955000000.0,55375000000.0,42602000000.0,41731000000.0,40183000000.0,23745000000.0,21863000000.0,18090000000.0,16400000000.0,14020000000.0,10556000000.0,9100000000.0,8281000000.0,6002000000.0,5480000000.0,5061000000.0,5591000000.0
assets,336309000000.0,350662000000.0,381191000000.0,329840000000.0,337158000000.0,354054000000.0,317344000000.0,320400000000.0,340618000000.0,322239000000.0,341998000000.0,373719000000.0,349197000000.0,367502000000.0,406794000000.0,345173000000.0,334532000000.0,331141000000.0,305602000000.0,305277000000.0,293284000000.0,273151000000.0,261194000000.0,261894000000.0,222520000000.0,205989000000.0,225184000000.0,199856000000.0,194743000000.0,196088000000.0,162896000000.0,150934000000.0,138681000000.0,106758000000.0,94904000000.0,86742000000.0,64725000000.0,57057000000.0,53926000000.0,48140000000.0
other_than_fixed_noncurrent_assets,224017000000.0,232482000000.0,228037000000.0,215417000000.0,215693000000.0,199948000000.0,177279000000.0,176647000000.0,177387000000.0,187266000000.0,218652000000.0,232891000000.0,195319000000.0,202372000000.0,229305000000.0,203012000000.0,205379000000.0,201299000000.0,186393000000.0,194482000000.0,194765000000.0,181049000000.0,173152000000.0,158099000000.0,136986000000.0,120328000000.0,129349000000.0,115310000000.0,116380000000.0,108318000000.0,100466000000.0,91375000000.0,,,,,,,,
commitments_and_contingencies,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.0
,2023-05-05,2023-02-03,2022-07-29,2022-04-29,2022-01-28,2021-07-28,2021-04-29,2021-01-28,2020-07-31,2020-05-01,2020-01-29,2019-07-31,2019-05-01,2019-01-30,2018-08-01,2018-05-02,2018-02-02,2017-08-02,2017-05-03,2017-02-01,2016-07-27,2016-04-27,2016-01-27,2015-07-22,2015-04-28,2015-01-28,2014-07-23,2014-04-24,2014-01-28,2013-07-24,2013-04-24,2013-01-24,2012-07-25,2012-04-25,2012-01-25,2011-07-20,2011-04-21,2011-01-19,2010-07-21,2010-04-21,2010-01-25,2009-07-22
noncurrent_liabilities,149927000000.0,152734000000.0,148329000000.0,155755000000.0,161685000000.0,157806000000.0,161595000000.0,155323000000.0,149744000000.0,145881000000.0,148926000000.0,136079000000.0,142366000000.0,147544000000.0,145700000000.0,151304000000.0,150807000000.0,131446000000.0,127108000000.0,114621000000.0,107575000000.0,106555000000.0,88925000000.0,82189000000.0,73459000000.0,64955000000.0,55375000000.0,42602000000.0,41731000000.0,40183000000.0,23745000000.0,21863000000.0,18090000000.0,16400000000.0,14020000000.0,10556000000.0,9100000000.0,8281000000.0,6002000000.0,5480000000.0,5061000000.0,5591000000.0
equity,62158000000.0,56727000000.0,58107000000.0,67399000000.0,71932000000.0,64280000000.0,69178000000.0,66224000000.0,72282000000.0,78425000000.0,89531000000.0,96456000000.0,105860000000.0,117892000000.0,114949000000.0,126878000000.0,140199000000.0,132425000000.0,134082000000.0,132390000000.0,126541000000.0,130457000000.0,128267000000.0,125677000000.0,129006000000.0,123328000000.0,120940000000.0,120179000000.0,129684000000.0,123354000000.0,135490000000.0,127346000000.0,111746000000.0,102498000000.0,90054000000.0,69343000000.0,61477000000.0,54666000000.0,43111000000.0,39348000000.0,35768000000.0,25888000000.0
assets,332160000000.0,346747000000.0,336309000000.0,350662000000.0,381191000000.0,329840000000.0,337158000000.0,354054000000.0,317344000000.0,320400000000.0,340618000000.0,322239000000.0,341998000000.0,373719000000.0,349197000000.0,367502000000.0,406794000000.0,345173000000.0,334532000000.0,331141000000.0,305602000000.0,305277000000.0,293284000000.0,273151000000.0,261194000000.0,261894000000.0,222520000000.0,205989000000.0,225184000000.0,199856000000.0,194743000000.0,196088000000.0,162896000000.0,150934000000.0,138681000000.0,106758000000.0,94904000000.0,86742000000.0,64725000000.0,57057000000.0,53926000000.0,48140000000.0
fixed_assets,43398000000.0,42951000000.0,40335000000.0,39304000000.0,39245000000.0,38615000000.0,37815000000.0,37933000000.0,35687000000.0,35889000000.0,37031000000.0,37636000000.0,38746000000.0,39597000000.0,38117000000.0,35077000000.0,33679000000.0,29286000000.0,27163000000.0,26510000000.0,25448000000.0,23203000000.0,22300000000.0,21149000000.0,20151000000.0,20392000000.0,17585000000.0,15120000000.0,15488000000.0,16327000000.0,15026000000.0,15422000000.0,10487000000.0,8847000000.0,,,,,,,,
current_assets,112913000000.0,128777000000.0,112292000000.0,118180000000.0,153154000000.0,114423000000.0,121465000000.0,154106000000.0,140065000000.0,143753000000.0,163231000000.0,134973000000.0,123346000000.0,140828000000.0,115761000000.0,130053000000.0,143810000000.0,112875000000.0,101990000000.0,103332000000.0,93761000000.0,87592000000.0,76219000000.0,70953000000.0,67891000000.0,83403000000.0,67949000000.0,70541000000.0,80347000000.0,68219000000.0,63337000000.0,72348000000.0,51943000000.0,50712000000.0,54771000000.0,46898000000.0,46997000000.0,43927000000.0,36033000000.0,32336000000.0,33332000000.0,35170000000.0
other_than_fixed_noncurrent_assets,219247000000.0,217970000000.0,224017000000.0,232482000000.0,228037000000.0,215417000000.0,215693000000.0,199948000000.0,177279000000.0,176647000000.0,177387000000.0,187266000000.0,218652000000.0,232891000000.0,195319000000.0,202372000000.0,229305000000.0,203012000000.0,205379000000.0,201299000000.0,186393000000.0,194482000000.0,194765000000.0,181049000000.0,173152000000.0,158099000000.0,136986000000.0,120328000000.0,129349000000.0,115310000000.0,116380000000.0,108318000000.0,100466000000.0,91375000000.0,,,,,,,,
equity_attributable_to_parent,62158000000.0,56727000000.0,58107000000.0,67399000000.0,71932000000.0,64280000000.0,69178000000.0,66224000000.0,72282000000.0,78425000000.0,89531000000.0,96456000000.0,105860000000.0,117892000000.0,114949000000.0,126878000000.0,140199000000.0,132425000000.0,134082000000.0,132390000000.0,126541000000.0,130457000000.0,128267000000.0,125677000000.0,129006000000.0,123328000000.0,120940000000.0,120179000000.0,129684000000.0,123354000000.0,135490000000.0,127346000000.0,111746000000.0,102498000000.0,90054000000.0,69343000000.0,61477000000.0,54666000000.0,43111000000.0,39348000000.0,35768000000.0,25888000000.0
current_liabilities,120075000000.0,137286000000.0,129873000000.0,127508000000.0,147574000000.0,107754000000.0,106385000000.0,132507000000.0,95318000000.0,96094000000.0,102161000000.0,89704000000.0,93772000000.0,108283000000.0,88548000000.0,89320000000.0,115788000000.0,81302000000.0,73342000000.0,84130000000.0,71486000000.0,68265000000.0,76092000000.0,65285000000.0,58729000000.0,73611000000.0,46205000000.0,43208000000.0,53769000000.0,36319000000.0,35508000000.0,46879000000.0,33060000000.0,32036000000.0,34607000000.0,26859000000.0,24327000000.0,23795000000.0,15612000000.0,12229000000.0,13097000000.0,16661000000.0
equity_attributable_to_noncontrolling_interest,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
noncurrent_assets,219247000000.0,217970000000.0,224017000000.0,232482000000.0,228037000000.0,215417000000.0,215693000000.0,199948000000.0,177279000000.0,176647000000.0,177387000000.0,187266000000.0,218652000000.0,232891000000.0,233436000000.0,237449000000.0,262984000000.0,232298000000.0,232542000000.0,227809000000.0,211841000000.0,217685000000.0,217065000000.0,202198000000.0,193303000000.0,178491000000.0,154571000000.0,135448000000.0,144837000000.0,131637000000.0,131406000000.0,123740000000.0,110953000000.0,100222000000.0,83910000000.0,59860000000.0,47907000000.0,42815000000.0,28692000000.0,24721000000.0,20594000000.0,12970000000.0
liabilities_and_equity,332160000000.0,346747000000.0,336309000000.0,350662000000.0,381191000000.0,329840000000.0,337158000000.0,354054000000.0,317344000000.0,320400000000.0,340618000000.0,322239000000.0,341998000000.0,373719000000.0,349197000000.0,367502000000.0,406794000000.0,345173000000.0,334532000000.0,331141000000.0,305602000000.0,305277000000.0,293284000000.0,273151000000.0,261194000000.0,261894000000.0,222520000000.0,205989000000.0,225184000000.0,199856000000.0,194743000000.0,196088000000.0,162896000000.0,150934000000.0,138681000000.0,106758000000.0,94904000000.0,86742000000.0,64725000000.0,57057000000.0,53926000000.0,48140000000.0
liabilities,270002000000.0,290020000000.0,278202000000.0,283263000000.0,309259000000.0,265560000000.0,267980000000.0,287830000000.0,245062000000.0,241975000000.0,251087000000.0,225783000000.0,236138000000.0,255827000000.0,234248000000.0,240624000000.0,266595000000.0,212748000000.0,200450000000.0,198751000000.0,179061000000.0,174820000000.0,165017000000.0,147474000000.0,132188000000.0,138566000000.0,101580000000.0,85810000000.0,95500000000.0,76502000000.0,59253000000.0,68742000000.0,51150000000.0,48436000000.0,48627000000.0,37415000000.0,33427000000.0,32076000000.0,21614000000.0,17709000000.0,18158000000.0,22252000000.0
commitments_and_contingencies,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.0
Loading

0 comments on commit d4d6e68

Please sign in to comment.