clean code
This commit is contained in:
parent
fd97c14b98
commit
f0bc3ce6bc
@ -74,9 +74,9 @@ def remove_duplicates(data, key):
|
|||||||
return new_data
|
return new_data
|
||||||
|
|
||||||
def adjust_scaled_score(scaled_score):
|
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
|
# 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
|
# Ensure the scaled_score stays within the range of 0 to 10
|
||||||
scaled_score = max(0, min(10, scaled_score))
|
scaled_score = max(0, min(10, scaled_score))
|
||||||
|
|||||||
@ -21,15 +21,12 @@ query_template = """
|
|||||||
symbol = ?
|
symbol = ?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def run():
|
async def run():
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
cursor.execute("PRAGMA journal_mode = wal")
|
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 = [row[0] for row in cursor.fetchall()]
|
||||||
#stocks_symbols = ['AMD']
|
for ticker in tqdm(stocks_symbols):
|
||||||
for ticker in stocks_symbols:
|
|
||||||
filtered_df = []
|
filtered_df = []
|
||||||
df = pd.read_sql_query(query_template, con, params=(ticker,))
|
df = pd.read_sql_query(query_template, con, params=(ticker,))
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import ujson
|
|||||||
import schedule
|
import schedule
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
from pocketbase import PocketBase # Client also works the same
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import pytz
|
import pytz
|
||||||
@ -21,26 +20,13 @@ from dotenv import load_dotenv
|
|||||||
import os
|
import os
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
api_key = os.getenv('FMP_API_KEY')
|
|
||||||
useast_ip_address = os.getenv('USEAST_IP_ADDRESS')
|
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
|
# Set the system's timezone to Berlin at the beginning
|
||||||
subprocess.run(["timedatectl", "set-timezone", "Europe/Berlin"])
|
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():
|
def run_json_job():
|
||||||
# Run the asynchronous function inside an asyncio loop
|
# Run the asynchronous function inside an asyncio loop
|
||||||
|
|||||||
@ -16,11 +16,6 @@ import numpy as np
|
|||||||
import threading # Import threading module for parallel execution
|
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')
|
berlin_tz = pytz.timezone('Europe/Berlin')
|
||||||
|
|
||||||
# Set the system's timezone to Berlin at the beginning
|
# Set the system's timezone to Berlin at the beginning
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user