clean code

This commit is contained in:
MuslemRahimi 2024-05-27 09:13:27 +02:00
parent fd97c14b98
commit f0bc3ce6bc
4 changed files with 5 additions and 27 deletions

View File

@ -74,9 +74,9 @@ def remove_duplicates(data, key):
return new_data
def adjust_scaled_score(scaled_score):
adjustment = random.choice([-2,-1, 0, 1, 2])
#adjustment = random.choice([-2,-1, 0, 1, 2])
# Add the adjustment to the scaled_score
scaled_score += adjustment
#scaled_score += adjustment
# Ensure the scaled_score stays within the range of 0 to 10
scaled_score = max(0, min(10, scaled_score))

View File

@ -21,15 +21,12 @@ query_template = """
symbol = ?
"""
async def run():
cursor = con.cursor()
cursor.execute("PRAGMA journal_mode = wal")
cursor.execute("SELECT DISTINCT symbol FROM stocks WHERE symbol != ?", ('%5EGSPC',))
cursor.execute("SELECT DISTINCT symbol FROM stocks")
stocks_symbols = [row[0] for row in cursor.fetchall()]
#stocks_symbols = ['AMD']
for ticker in stocks_symbols:
for ticker in tqdm(stocks_symbols):
filtered_df = []
df = pd.read_sql_query(query_template, con, params=(ticker,))
try:

View File

@ -7,7 +7,6 @@ import ujson
import schedule
import time
import subprocess
from pocketbase import PocketBase # Client also works the same
import asyncio
import aiohttp
import pytz
@ -21,26 +20,13 @@ from dotenv import load_dotenv
import os
load_dotenv()
api_key = os.getenv('FMP_API_KEY')
useast_ip_address = os.getenv('USEAST_IP_ADDRESS')
pb_admin_email = os.getenv('POCKETBASE_ADMIN_EMAIL')
pb_admin_password = os.getenv('POCKETBASE_PASSWORD')
pb = PocketBase('http://127.0.0.1:8090')
admin_data = pb.admins.auth_with_password(pb_admin_email, pb_admin_password)
# Set the system's timezone to Berlin at the beginning
subprocess.run(["timedatectl", "set-timezone", "Europe/Berlin"])
async def get_quote_of_stocks(ticker_list):
ticker_str = ','.join(ticker_list)
async with aiohttp.ClientSession() as session:
url = f"https://financialmodelingprep.com/api/v3/quote/{ticker_str}?apikey={api_key}"
async with session.get(url) as response:
df = await response.json()
return df
def run_json_job():
# Run the asynchronous function inside an asyncio loop

View File

@ -16,11 +16,6 @@ import numpy as np
import threading # Import threading module for parallel execution
from dotenv import load_dotenv
import os
load_dotenv()
api_key = os.getenv('FMP_API_KEY')
berlin_tz = pytz.timezone('Europe/Berlin')
# Set the system's timezone to Berlin at the beginning