Update trade upsert example to strip seconds, microseconds, and timezone information from the trade entry time

This commit is contained in:
moshferatu 2024-02-03 05:34:51 -08:00
parent e02b2e59e1
commit 75a5682e46
2 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,5 @@
pandas pandas
psycopg2 psycopg2
python-dotenv python-dotenv
pytz
sqlalchemy sqlalchemy

View File

@ -1,12 +1,17 @@
import pandas as pd import pandas as pd
from database.trades import upsert from database.trades import upsert
from datetime import datetime
from pytz import timezone
now = datetime.now().astimezone(timezone('US/Eastern'))
now = now.replace(second = 0, microsecond = 0, tzinfo = None)
trade_data = { trade_data = {
'Date': ['2024-01-22'], 'Date': [now.date()],
'Symbol': ['SPX'], 'Symbol': ['SPX'],
'Strategy': ['Iron Condor @ Market Open'], 'Strategy': ['Iron Condor'],
'Entry Time': [pd.to_datetime('2024-01-22 09:30:00')], 'Entry Time': [now],
'Exit Time': [None], 'Exit Time': [None],
'Spreads': [ 'Spreads': [
[ [