Unlisted stocks handling
Can anyone say how Backtrader handles open positions for stocks that became unlisted during the backtesting period?
Say I'm backtesting stock ABC along with some other stocks, and ABC become unlisted (no more bar data) during the backtesting period, obviously, the positions cant stay open and should be treated somehow.
Any ideas how?
There is no handling of unlisted stocks, because that information is not part of the payload of data feeds.
Data feeds are extensible which means you can add a line named (for example)
delistedwhich has a value of (for example)
1if the stock becomes delisted (and
0if not). At that moment in time you can close the position.
The challenge here:
- If the
1is aligned with the end of the listing, the order won't be executed because there is no more data.
cheat-on-close. But this will affect the entire lifetime of all the listings
1just one days before the asset is delisted
- If the