Replies: 1 comment 1 reply
-
You can use Or you can use the strategy instance and access the list of remaining open trades directly: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am very new to backtesting.py, but I have looked for an answer to my question here, and I don't find a solution. A similar question to mine was asked by @cgdutoit and answered by @aliencaocao, but it was quite a while ago, and the answer doesn't explain what I see.
Here's what I observed: To learn about backtesting.py I ran a test strategy. According to the
bt.run()
result, 101 trades were entered, and they were all profitable (this is a strategy that would hold positions until profit is achieved). So far, so good. Thestats._trades
dataframe shows all 101 trades, and ALL ARE EXITED. Still ok.However, based on the employed indicator, I know that there should be open (and as yet unprofitable) lots. These would have been entered after the last closed trades were done. And the equity curve from the same run shows a drawdown since the last trades were closed, which I could not explain to myself, unless trades are indeed still open, and these long position are gradually losing value. Which would make sense, since the stock has lost value. But how do I find these trades?

Is there another dataframe that would contain trades that remain open at the end of a backtest?
Many thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions