Skip to content

Commit

Permalink
Close 2 stocks fa issues with polygon (#5217)
Browse files Browse the repository at this point in the history
* Fix #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 authored Jul 14, 2023
1 parent 92027a6 commit 52c560d
Show file tree
Hide file tree
Showing 12 changed files with 954 additions and 809 deletions.
9 changes: 9 additions & 0 deletions openbb_terminal/parent_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,15 @@ def call_load(self, other_args):
and ns_parser.vs == "usdt"
):
ns_parser.vs = "usd"
if ns_parser.source == "YahooFinance" and ns_parser.interval in [
"240",
"10080",
"43200",
]:
console.print(
f"[red]YahooFinance does not support {ns_parser.interval}min interval[/red]"
)
return
(self.current_df) = cryptocurrency_helpers.load(
symbol=ns_parser.coin.lower(),
to_symbol=ns_parser.vs,
Expand Down
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
Loading

0 comments on commit 52c560d

Please sign in to comment.