add ttm to financial statements
This commit is contained in:
parent
cfe08096ff
commit
731216cecb
@ -68,7 +68,7 @@ async def add_ratio_elements(symbol):
|
|||||||
with open(ratios_path, "r") as file:
|
with open(ratios_path, "r") as file:
|
||||||
ratio_data = ujson.load(file)
|
ratio_data = ujson.load(file)
|
||||||
|
|
||||||
if income_data and cash_flow_data and ratio_data and key_metrics_data:
|
if ratio_data and key_metrics_data:
|
||||||
for ratio_item, key_metrics_item in zip(ratio_data,key_metrics_data):
|
for ratio_item, key_metrics_item in zip(ratio_data,key_metrics_data):
|
||||||
try:
|
try:
|
||||||
ratio_item['returnOnEquity'] = round(key_metrics_item.get('returnOnEquity',0),2)
|
ratio_item['returnOnEquity'] = round(key_metrics_item.get('returnOnEquity',0),2)
|
||||||
@ -95,6 +95,7 @@ async def get_financial_statements(session, symbol, semaphore, rate_limiter):
|
|||||||
periods = ['quarter', 'annual']
|
periods = ['quarter', 'annual']
|
||||||
financial_data_types = ['key-metrics', 'income-statement', 'balance-sheet-statement', 'cash-flow-statement', 'ratios']
|
financial_data_types = ['key-metrics', 'income-statement', 'balance-sheet-statement', 'cash-flow-statement', 'ratios']
|
||||||
growth_data_types = ['income-statement-growth', 'balance-sheet-statement-growth', 'cash-flow-statement-growth']
|
growth_data_types = ['income-statement-growth', 'balance-sheet-statement-growth', 'cash-flow-statement-growth']
|
||||||
|
ttm_data_types = ['income-statement-ttm', 'balance-sheet-statement-ttm', 'cash-flow-statement-ttm', 'ratios-ttm']
|
||||||
|
|
||||||
async with semaphore:
|
async with semaphore:
|
||||||
for period in periods:
|
for period in periods:
|
||||||
@ -112,6 +113,13 @@ async def get_financial_statements(session, symbol, semaphore, rate_limiter):
|
|||||||
if growth_data:
|
if growth_data:
|
||||||
await save_json(symbol, period, growth_type, growth_data)
|
await save_json(symbol, period, growth_type, growth_data)
|
||||||
|
|
||||||
|
for ttm_type in ttm_data_types:
|
||||||
|
url = f"{base_url}/{ttm_type}/?symbol={symbol}&limit=2000&apikey={api_key}"
|
||||||
|
data = await fetch_data(session, url, symbol, rate_limiter)
|
||||||
|
if data:
|
||||||
|
await save_json(symbol, 'ttm', ttm_type.replace("-ttm",''), data)
|
||||||
|
|
||||||
|
|
||||||
# Fetch TTM metrics
|
# Fetch TTM metrics
|
||||||
url = f"https://financialmodelingprep.com/stable/key-metrics-ttm/?symbol={symbol}&limit=2000&apikey={api_key}"
|
url = f"https://financialmodelingprep.com/stable/key-metrics-ttm/?symbol={symbol}&limit=2000&apikey={api_key}"
|
||||||
data = await fetch_data(session, url, symbol, rate_limiter)
|
data = await fetch_data(session, url, symbol, rate_limiter)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user