backtesting.py
backtesting.py copied to clipboard
Automatic closing of the positions at the end of the simulation
This is just a question about whats in the title.
- Why is the framework closing the positions automatically at the end of the simulation?
- Is there any way to prevent that?
Why is the framework closing the positions automatically at the end of the simulation?
So the trades can produce some stats. See https://github.com/kernc/backtesting.py/issues/183, https://github.com/kernc/backtesting.py/commit/f77786e5216f536f4eb50475c750cdd7d438502f.
So the trades can produce some stats. See #183, f77786e.
I understand that the unclosed trades wouldn't appearing in the final stats but that could be also a stat. E.g.:
- still open positions
- allocated money in those positions
- return should be calculated only for the closed positions
Maybe a parameter like autoclose_open_positions
in bt.run()
would be useful, so people can decide if they want the feature or not.
I raised this question because the still open positions is also a good measure of a strategy. If the strategy fails to close the positions, this auto-closing can give the false feeling that the Strategy is working fine.
Still able to see open trades that are closed because they are the last ones.