Convert most recent trade date to a datetime object for the sake of consistency

This commit is contained in:
moshferatu 2024-03-16 06:00:15 -07:00
parent fadb01b2a4
commit 329086b578

View File

@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, time
from dotenv import load_dotenv
from os import getenv
from sqlalchemy import create_engine, text
@ -11,11 +11,11 @@ database_url = (
f"@{getenv('DATABASE_HOST')}:{getenv('DATABASE_PORT')}/{getenv('DATABASE_NAME')}"
)
def most_recent_trade_date() -> datetime.date:
def most_recent_trade_date() -> datetime:
with sessionmaker(bind = create_engine(database_url))() as session:
query = text('SELECT * FROM most_recent_trade_date()')
result = session.execute(query)
return result.scalar()
return datetime.combine(result.scalar(), time.min)
if __name__ == '__main__':
print(most_recent_trade_date())