2024-01-22 16:32:14 +00:00
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
from database.trades import upsert
|
2024-02-03 13:34:51 +00:00
|
|
|
from datetime import datetime
|
|
|
|
from pytz import timezone
|
|
|
|
|
|
|
|
now = datetime.now().astimezone(timezone('US/Eastern'))
|
|
|
|
now = now.replace(second = 0, microsecond = 0, tzinfo = None)
|
2024-01-22 16:32:14 +00:00
|
|
|
|
|
|
|
trade_data = {
|
2024-02-03 13:34:51 +00:00
|
|
|
'Date': [now.date()],
|
2024-01-22 16:32:14 +00:00
|
|
|
'Symbol': ['SPX'],
|
2024-02-03 13:34:51 +00:00
|
|
|
'Strategy': ['Iron Condor'],
|
|
|
|
'Entry Time': [now],
|
2024-01-22 16:32:14 +00: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))
|