Convert datetime object to date on clients' behalf

This commit is contained in:
moshferatu 2024-03-16 05:39:04 -07:00
parent 46f53ff9af
commit fadb01b2a4
2 changed files with 4 additions and 4 deletions

View File

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

View File

@ -1,4 +1,4 @@
from database.procedures import backtest_profit
from datetime import datetime
print(backtest_profit(datetime(2024, 2, 2).date()))
print(backtest_profit(datetime(2024, 2, 2)))