Pad and Align causing delisted stocks to have trades after delisting date

Hello again :slight_smile:

As part of my debugging and cross-checking efforts, I ran a rotational backtest on one stock that delisted 2006-06-01. With Pad and Align enabled, this stock produces trades after delisting date. Disabling P&A gives expected results - no trades after delisting date.

I added a second listed stock to the watchlist, and same results (I thought it may have been because rotational on a single stock watchlist)

In this image we can see delisted stock ABS-200606 from Norgate Data. There were three transactions after delisting date with Pad and Align enabled.

This is very open question... but could I have I inadvertently activated a setting that might cause this unexpected behavior?

2021-10-15 13_59_36-AmiBroker

Yes because 'Pad & Align' is doing exactly what it is designed to do!

You need to accommodate for delisted stocks in your 'PositionScore' when using Rotational mode.

See Norgate Data FAQ - Delisted Stock.

1 Like

Hi TrendSurfer, thanks for the reply. :slight_smile:

I am aware of accommodating for delisted stocks in your 'PositionScore' when using Rotational mode, and have been working on that separately.

This admittedly unrealistic exercise of mine was part of exploring various aspects of that work. And that is when I noticed delisted stocks producing trades after they are delisted, when they have no OHLCV time series. How is that by design? It influences P/L. Trades in stocks that no longer exist on the exchange.

[Obviously it would not be a problem in proper backtesting, as exits of delisted stocks are accommodated for, per that vey helpful Norgate code.]

See Pad & Align Reference.

As others mentioned, this is totally by design because padding is adding data in places there are data holes. It is exactly what this feature is supposed to do.

As to "have trades" statement - using "trades" word (plural) is overstatement. Normally (in regular backtest) you are very unlikely to generate more than just one trade (EXIT) on padded data (if any trade at all) because padded data don't change so indicators don't fire crosses and such things. Also since price does not change since very last "real" data point, from profit calculation point of view it is the same as you closed the trade on very last date (delisting date). In rotational mode things are a bit different since there are no signals at all, but if you want to prevent this simply assign zero to PositionScore after delisting date:

PositionScore = ... your original...
PositionScore = IIF( DateTimeDiff( DateTime(), GetFnData("DelistingDate") ) >= 0, 0, PositionScore );  // force exit on last listing date

and your "problem" is solved.

You need to keep in mind that DelistingDate (as other fundamental fields) is rarely ever used by people who do NOT have Norgate database. For most users this field is empty. AmiBroker can't assume that this field is relevant in everybody's setup, because it simply isn't. Some users even re-utilise certain fundamental fields for storing other unrelated data. If you have database that has this data AND data are correct (not always the case), you can use it the way described above.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.