Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
MuslemRahimi committed May 27, 2024
1 parent fd97c14 commit f0bc3ce
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 27 deletions.
4 changes: 2 additions & 2 deletions app/cron_sentiment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 2 additions & 5 deletions app/cron_similar_stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ async def save_similar_stocks(symbol, data):
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:
Expand Down
16 changes: 1 addition & 15 deletions app/primary_cron_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import schedule
import time
import subprocess
from pocketbase import PocketBase # Client also works the same
import asyncio
import aiohttp
import pytz
Expand All @@ -21,26 +20,13 @@
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
Expand Down
5 changes: 0 additions & 5 deletions app/secondary_cron_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
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
Expand Down

0 comments on commit f0bc3ce

Please sign in to comment.