add countries to screener
This commit is contained in:
parent
9e9102cc46
commit
b6955293ac
@ -15,6 +15,7 @@ import re
|
|||||||
import hashlib
|
import hashlib
|
||||||
import glob
|
import glob
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
from utils.country_list import country_list
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
@ -25,6 +26,7 @@ api_key = os.getenv('FMP_API_KEY')
|
|||||||
|
|
||||||
berlin_tz = pytz.timezone('Europe/Berlin')
|
berlin_tz = pytz.timezone('Europe/Berlin')
|
||||||
|
|
||||||
|
|
||||||
# Replace NaN values with None in the resulting JSON object
|
# Replace NaN values with None in the resulting JSON object
|
||||||
def replace_nan_inf_with_none(obj):
|
def replace_nan_inf_with_none(obj):
|
||||||
if isinstance(obj, list):
|
if isinstance(obj, list):
|
||||||
@ -165,6 +167,12 @@ def get_financial_statements(item, symbol):
|
|||||||
|
|
||||||
return item
|
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):
|
async def get_stock_screener(con):
|
||||||
#Stock Screener Data
|
#Stock Screener Data
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
@ -235,7 +243,7 @@ async def get_stock_screener(con):
|
|||||||
res = orjson.loads(file.read())[0]
|
res = orjson.loads(file.read())[0]
|
||||||
item['employees'] = int(res['fullTimeEmployees'])
|
item['employees'] = int(res['fullTimeEmployees'])
|
||||||
item['sharesOutStanding'] = int(res['sharesOutstanding'])
|
item['sharesOutStanding'] = int(res['sharesOutstanding'])
|
||||||
item['country'] = res['country']
|
item['country'] = get_country_name(res['country'])
|
||||||
item['sector'] = res['sector']
|
item['sector'] = res['sector']
|
||||||
except:
|
except:
|
||||||
item['employees'] = None
|
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