bugfixing

This commit is contained in:
MuslemRahimi 2025-01-01 15:48:22 +01:00
parent e925490f9f
commit 925c706246
3 changed files with 13 additions and 40 deletions

View File

@ -9,15 +9,9 @@ class GetStartEndDate:
def check_if_holiday(self):
holiday_dates = {
datetime(2024, 9, 2): 'labor_day',
datetime(2024, 9, 2): 'labor_day+1',
datetime(2023, 11, 23): 'thanks_giving',
datetime(2023, 12, 25): 'christmas',
datetime(2024, 1, 1): 'new_year',
datetime(2024, 1, 15): 'martin_luther_king',
datetime(2024, 2, 19): 'washington_birthday',
datetime(2024, 5, 27): 'memorial_day',
datetime(2024, 7, 4): 'independence_day',
datetime(2025, 1, 1): 'new_year',
datetime(2025, 1, 2): 'new_year+1',
}
for date, name in holiday_dates.items():
@ -26,20 +20,8 @@ class GetStartEndDate:
return None
def correct_1d_interval(self, holiday):
if holiday in ('labor_day', 'labor_day+1'):
start_date_1d = datetime(2024, 8, 30)
elif holiday == 'thanks_giving':
start_date_1d = datetime(2023, 11, 22)
elif holiday == 'new_year':
start_date_1d = datetime(2023, 12, 29)
elif holiday == 'martin_luther_king':
start_date_1d = datetime(2023, 1, 12)
elif holiday == 'washington_birthday':
start_date_1d = datetime(2024, 2, 16)
elif holiday == 'memorial_day':
start_date_1d = datetime(2024, 5, 24)
elif holiday in ('independence_day', 'independence_day+1'):
start_date_1d = datetime(2024, 7, 3)
if holiday in ('new_year', 'new_year+1'):
start_date_1d = datetime(2024, 12, 31)
else:
current_time_new_york = datetime.now(self.new_york_tz)
current_weekday = current_time_new_york.weekday()
@ -61,20 +43,13 @@ class GetStartEndDate:
is_afternoon = current_time_new_york.hour > 9 or (current_time_new_york.hour == 9 and current_time_new_york.minute >= 30)
if holiday:
holiday_dates = {
'labor_day': datetime(2024, 8, 30),
'labor_day+1': datetime(2024, 8, 30),
'thanks_giving': datetime(2023, 11, 22),
'christmas': datetime(2023, 12, 22),
'new_year': datetime(2023, 12, 29),
'martin_luther_king': datetime(2024, 1, 12),
'washington_birthday': datetime(2024, 2, 16),
'memorial_day': datetime(2024, 5, 24),
'independence_day': datetime(2024, 7, 3),
'new_year': datetime(2024, 12, 31),
'new_year+1': datetime(2024, 12, 31),
}
if holiday in holiday_dates:
end_date_1d = holiday_dates[holiday]
elif holiday in ['independence_day+1','labor_day+1', 'christmas_day+1'] and not is_afternoon:
elif holiday in ['new_year+1'] and not is_afternoon:
end_date_1d = holiday_dates[holiday]
else:
end_date_1d = self.current_datetime

View File

@ -161,13 +161,15 @@ async def get_spy_chart_data():
data = sorted(data, key=lambda x: x['date'])
return data
else:
raise Exception(f"Error fetching SPY chart data: {response.status}")
return []
def get_market_tide():
# Fetch SPY chart data
price_list = asyncio.run(get_spy_chart_data())
if len(price_list) == 0:
with open(f"json/one-day-price/SPY.json") as file:
price_list = orjson.loads(file.read())
# Fetch market tide data
querystring = {"interval_5m": "false"}
@ -182,10 +184,7 @@ def get_market_tide():
data = add_close_to_data(price_list, data)
data = convert_timestamps(data)
'''
with open(f"json/one-day-price/SPY.json") as file:
price_list = orjson.loads(file.read())
'''
return data

View File

@ -39,7 +39,6 @@ async def get_todays_data(ticker):
start_date = start_date_1d.strftime("%Y-%m-%d")
end_date = end_date_1d.strftime("%Y-%m-%d")
url = f"https://financialmodelingprep.com/api/v3/historical-chart/1min/{ticker}?from={start_date}&to={end_date}&apikey={api_key}"
df_1d = pd.DataFrame()