Hello,
I would like to obtain a dataframe with all my entry and exit points for trades after backtesting so that I can cross check my strategy. How should I achieve this?
Thank you
If you want to track the time and other details, you can create a dataframe in the context variable (as context.entry_exit) and fill in the details below.
If you are looking for details of transactions that has executed, you can analyze that by definiing the 'analyze' function - an example below where we just fetch all transactions for the last date of the backtest and print their details.
def analyze(context, perf):
txns = (perf['transactions'].iloc[-1])
for txn in txns:
if txn:
print('{}: traded {} units at {}'.format(
txn['dt'], txn['amount'], txn['price']))
Note: you have a limit on amount of prints (number of lines) you can use. I suggest you carry out your entry exit analysis and then print a summary instead.