add countries to screener
This commit is contained in:
parent
9e9102cc46
commit
b6955293ac
@ -15,6 +15,7 @@ import re
|
||||
import hashlib
|
||||
import glob
|
||||
from tqdm import tqdm
|
||||
from utils.country_list import country_list
|
||||
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
@ -25,6 +26,7 @@ api_key = os.getenv('FMP_API_KEY')
|
||||
|
||||
berlin_tz = pytz.timezone('Europe/Berlin')
|
||||
|
||||
|
||||
# Replace NaN values with None in the resulting JSON object
|
||||
def replace_nan_inf_with_none(obj):
|
||||
if isinstance(obj, list):
|
||||
@ -165,6 +167,12 @@ def get_financial_statements(item, symbol):
|
||||
|
||||
return item
|
||||
|
||||
def get_country_name(country_code):
|
||||
for country in country_list:
|
||||
if country['short'] == country_code:
|
||||
return country['long']
|
||||
return None
|
||||
|
||||
async def get_stock_screener(con):
|
||||
#Stock Screener Data
|
||||
cursor = con.cursor()
|
||||
@ -235,7 +243,7 @@ async def get_stock_screener(con):
|
||||
res = orjson.loads(file.read())[0]
|
||||
item['employees'] = int(res['fullTimeEmployees'])
|
||||
item['sharesOutStanding'] = int(res['sharesOutstanding'])
|
||||
item['country'] = res['country']
|
||||
item['country'] = get_country_name(res['country'])
|
||||
item['sector'] = res['sector']
|
||||
except:
|
||||
item['employees'] = None
|
||||
|
||||
BIN
app/utils/__pycache__/country_code.cpython-310.pyc
Normal file
BIN
app/utils/__pycache__/country_code.cpython-310.pyc
Normal file
Binary file not shown.
BIN
app/utils/__pycache__/country_list.cpython-310.pyc
Normal file
BIN
app/utils/__pycache__/country_list.cpython-310.pyc
Normal file
Binary file not shown.
1
app/utils/country_list.py
Normal file
1
app/utils/country_list.py
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user