Convert datetime object to date on clients' behalf
This commit is contained in:
parent
46f53ff9af
commit
fadb01b2a4
@ -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())
|
@ -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)))
|
Loading…
Reference in New Issue
Block a user