import pandas as pd from database.trades import upsert trade_data = { 'Date': ['2024-01-22'], 'Symbol': ['SPX'], 'Strategy': ['Iron Condor @ Market Open'], 'Entry Time': [pd.to_datetime('2024-01-22 09:30:00')], 'Exit Time': [None], 'Spreads': [ [ { 'Legs': [ {'Action': 'BUY', 'Strike': 150, 'Type': 'CALL'}, {'Action': 'SELL', 'Strike': 155, 'Type': 'CALL'} ], 'Open': 1.5 }, { 'Legs': [ {'Action': 'SELL', 'Strike': 160, 'Type': 'PUT'}, {'Action': 'BUY', 'Strike': 155, 'Type': 'PUT'} ], 'Open': 2.5 } ] ], 'Profit': [None] } upsert(pd.DataFrame(trade_data)) trade_data['Exit Time'] = [pd.to_datetime('2024-01-22 16:00:00')] trade_data['Spreads'][0][0]['High'] = 1.5 trade_data['Spreads'][0][0]['Low'] = 0.0 trade_data['Spreads'][0][0]['Close'] = 0.0 trade_data['Spreads'][0][1]['High'] = 2.5 trade_data['Spreads'][0][1]['Low'] = 0.0 trade_data['Spreads'][0][1]['Close'] = 0.0 trade_data['Profit'] = [400.0] upsert(pd.DataFrame(trade_data))