add countries to screener

This commit is contained in:
MuslemRahimi 2024-09-05 17:41:08 +02:00
parent 9e9102cc46
commit b6955293ac
4 changed files with 10 additions and 1 deletions

View File

@ -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

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long