database/insert_backtest_results_example.py

38 lines
1.0 KiB
Python

import pandas as pd
from database.backtest import insert
backtest_data = {
'Date': ['2024-01-08'],
'Symbol': ['SPX'],
'Strategy': ['Iron Condor @ Market Open'],
'Entry Time': [pd.Timestamp('2024-01-08 09:30:00')],
'Exit Time': [pd.Timestamp('2024-01-08 16:00:00')],
'Spreads': [
[
{
'Legs': [
{'Action': 'BUY', 'Strike': 150, 'Type': 'CALL'},
{'Action': 'SELL', 'Strike': 155, 'Type': 'CALL'}
],
'Open': 1.5,
'High': 2.0,
'Low': 1.0,
'Close': 1.8
},
{
'Legs': [
{'Action': 'SELL', 'Strike': 160, 'Type': 'PUT'},
{'Action': 'BUY', 'Strike': 155, 'Type': 'PUT'}
],
'Open': 2.5,
'High': 3.0,
'Low': 2.0,
'Close': 2.8
}
]
],
'Profit': [100.00]
}
insert(pd.DataFrame(backtest_data))