Australian (ASX) Stock Market Forum

Dealing with delisted securities when backtesting

Joined
21 December 2010
Posts
240
Reactions
0
Does anyone have any strategies for dealing with delisted securities in backtests?

What happens is that in some cases, a delisted security is entered but the position is not closed before it delists, so you end up with an open position that never ever closes. This creates inaccuracies in the backtest results.

I'm using amibroker. Any help is greatly appreciated.
 
Re: Dealing with delisted securities

I guess I need to code into amibroker something along the lines of:

"if data for tomorrow does not exist, exit the position today".

I'm just not sure how to code that in amibroker.
 
Re: Dealing with delisted securities

I guess I need to code into amibroker something along the lines of:

"if data for tomorrow does not exist, exit the position today".

I'm just not sure how to code that in amibroker.

That won't work because you can't know what will happen tomorrow. Just buy some good quality historical data and allow for the probability of it happening at some point. So long as you're trading a portfolio of stocks and so long as your position sizing is reasonable, you'll be ok.

If you're desperate to avoid it, add a fundamental scan. Lots of cash, good management, liquid, etc.

There is such a thing as survivorship-adjusted historical data but I wouldn't worry about that.
 
Re: Dealing with delisted securities

That won't work because you can't know what will happen tomorrow. Just buy some good quality historical data and allow for the probability of it happening at some point. So long as you're trading a portfolio of stocks and so long as your position sizing is reasonable, you'll be ok.

If you're desperate to avoid it, add a fundamental scan. Lots of cash, good management, liquid, etc.

There is such a thing as survivorship-adjusted historical data but I wouldn't worry about that.

Hey Gringott's, thanks for your reply.

You can't know what's going to happen tomorrow, but if you own a stock that delists, isn't it the same as selling it on the day it delists? I want amibroker to simulate this by exiting the position on the same day a delisting occurs.

Like you say, Survivship bias may not be such a huge issue if the system is robust and it's accounted for but I still would like to test it.

The problem is that if I run a backtest over the hsitorical constituents over a longer period of time, some stocks get 'stuck' (because the sell signal did not occur before the delisting date) and dont ever get exited. They then take up valuable 'dead equity' that would otherwise be used to enter new positions. On the system I'm testing, 'stuck' securities are taking up about 40% of equity. So the results I'm getting for survivorship-adjusted data is pretty worthless until I find a way to fix this issue.

I'm certain there is a way around this, I just need to figure out a way to code in amibroker language:
"Exit the stock if this is the last day that data exists for this stock".

I'm not sure what you mean by a fundamental scan?
 
Re: Dealing with delisted securities

I've always used Tradesim
I can set close all Positions
At the date used to end the scan
(include open positions)

The best adjusted data is Premium data for EOD.

As far as survivorship basis goes you can now get
Data from Premium data which as all stocks including those delisted and with
Code changes.
Ask Richard Dale by email if you need to know specifics,
Just google Premium Data.
 
Re: Dealing with delisted securities

Then of course you have the problem of including a sale price of a delisted stock which has a liquidated value of Zero.

If I had one in a systems test I would remove the stock completely from the universe and run the tests including Montecarlo testing to see if it effected results appreciably.

If Anyone has a better idea as the Amibroker solution offered up doesn't seem to address it either---I'm all ears!
 
Re: Dealing with delisted securities

Then of course you have the problem of including a sale price of a delisted stock which has a liquidated value of Zero.

If I had one in a systems test I would remove the stock completely from the universe and run the tests including Montecarlo testing to see if it effected results appreciably.

If Anyone has a better idea as the Amibroker solution offered up doesn't seem to address it either---I'm all ears!

The major issue is that nobody has fully evaluated the "liquidation value" of a stock that no longer trades. Whilst there is nothing stopping you from doing so, it's a very big task. In recent times Norgate has been researching historical corporate actions by looking up annual reports and announcement microfiche in libraries/universities... these are records the ASX just doesn't have available any more.

Typically stocks that are in an uptrend have been taken over and will close near their takeover value - which is probably good enough for a system test. Stocks in a severe downtrend sideways movement with serious downtrend that have been delisted have gone because they have failed. Any decent system with a trailing stop should have already got you out anyway. But there is the other scenario of rapid delisting perhaps with little prior notice.

It's worth evaluating your systems and see how many exits you get on the final bar of the available data and do some research on those positions. You might find you re-evaluate a large-percentage-of-capital-as-position-size.

That being said, here is some nice simple code to get you out of a position that has not been trading since X calendar days from the final bar of the chart... This was submitted to us by one of our users. The code assumes you exit the trade on the last bar of the chart if the date of the last bar's date is beyond a given threshold of calendar days.

Code:
Sell = <your sell condition here>;

// Check to see if security has been delisted
NonTradedPeriod = 30;
SymbolDT = DateTimeAdd(DateTime(), NonTradedPeriod, inDaily);
Delisted = BarIndex() == (LastValue(BarIndex()) -1) AND DateTimeDiff(Now(5), SymbolDT) >= 0;

Sell = Sell or Delisted;

Of course you need a data supplier with delisted data... Feedback from our users is that some systems are heavily affected, others not so much, but you don't know until you test it.
 
Re: Dealing with delisted securities

I'm not sure what you mean by a fundamental scan?

There's this thread. Some people posted really useful answers.

"Avoiding capital raisings in short term trading"

Most brokers have a way of filtering by fundamental data. But backtesting this could be very hard. Maybe Lincoln Stock Doc people could help. They are expensive though.
 
Of course you need a data supplier with delisted data...

Can you help here or have any suggestions?

Not wanting to self promote here, but this is what we offer in Premium Data. We're also testing some nifty new few features that will be of interest to backtesters such as historical index constituents, initially within AmiBroker. I don't think anybody else offers those capabilities on a retail level.
 
Top