Using Delisted Data

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
Post Reply
huss1652
Roundtable Fellow
Roundtable Fellow
Posts: 73
Joined: Tue Mar 01, 2011 4:49 pm
Location: Columbus, OH - USA

Using Delisted Data

Post by huss1652 »

I was wondering if anyone here uses delisted data? I am curious on how you go about telling tradingblox when and how to dump the position when the data ends so that equity will not be frozen in that position until the end of the test.
Jake Carriker
Site Admin
Site Admin
Posts: 1493
Joined: Fri Sep 12, 2003 10:32 am
Location: Austin, Texas

Post by Jake Carriker »

Yes, for stocks delisted data is necessary in order to avoid survivorship bias. In historical testing you can look ahead to see when the last bar of trading is and exit on or ahead of that. This is postdictive, but tolerable given that it is rare that a stock stops trading unannounced. In live trading, we don't get "stuck" in a stock that quits trading, we either liquidate the shares or receive shares of another company if it is a merger or whatnot. There is the occasional case (fraud, etc.) where a stock halts trading unexpectedly and never resumes. This might be a total loss...
huss1652
Roundtable Fellow
Roundtable Fellow
Posts: 73
Joined: Tue Mar 01, 2011 4:49 pm
Location: Columbus, OH - USA

Post by huss1652 »

Is this function built into TradingBlox or is it something that needs to be coded manually?
Jake Carriker
Site Admin
Site Admin
Posts: 1493
Joined: Fri Sep 12, 2003 10:32 am
Location: Austin, Texas

Post by Jake Carriker »

There is nothing built-in to TB that handles these items. It is done in scripting.
Ghost11365
Roundtable Knight
Roundtable Knight
Posts: 112
Joined: Wed Jul 31, 2013 3:33 pm

Post by Ghost11365 »

Jake, I was wondering if you could point me in the direction of using script to avoid survivorship bias. Thank you.
Jake Carriker
Site Admin
Site Admin
Posts: 1493
Joined: Fri Sep 12, 2003 10:32 am
Location: Austin, Texas

Post by Jake Carriker »

In order to avoid survivorship bias, you shouldn't need a special script. You will need a survivorship bias free database with the issues that no longer trade marked as inactive in the stock dictionary. The current release of Trading Blox exits stocks marked as inactive in historical testing on the close of the final bar if the system holds a position at that time.
Ghost11365
Roundtable Knight
Roundtable Knight
Posts: 112
Joined: Wed Jul 31, 2013 3:33 pm

Post by Ghost11365 »

He's my issue:

i'm downloading the current S&P 500 from CSI. It includes Facebook Inc. (FB). FB was not added to the S&P until Dec 21st 2013, however, in a backtest I entered the trade on Dec 16th 2013 which would be inaccurate. So I was wondering if I code to ignore FB when date is <20131221 - would this suffice as performing a surviorship free portfolio (I realize i'd have to do this for numerous securities but I need my backtests to be as accurate as possible)
Jake Carriker
Site Admin
Site Admin
Posts: 1493
Joined: Fri Sep 12, 2003 10:32 am
Location: Austin, Texas

Post by Jake Carriker »

That is correct, since your aim is to recreate the historical membership of an index, you have to know the members of the index for each date in your test and communicate that to TB. One way to do this is to "hard code" a line (sometimes more than one) for each stock setting the dates it is allowed to trade. Another is to create an external file listing the stocks and dates of membership, and read that into Blox.
Ghost11365
Roundtable Knight
Roundtable Knight
Posts: 112
Joined: Wed Jul 31, 2013 3:33 pm

Post by Ghost11365 »

OK - thanks Jake - guess i'm on the right track.
huss1652
Roundtable Fellow
Roundtable Fellow
Posts: 73
Joined: Tue Mar 01, 2011 4:49 pm
Location: Columbus, OH - USA

Post by huss1652 »

Jake Carriker wrote:In order to avoid survivorship bias, you shouldn't need a special script. You will need a survivorship bias free database with the issues that no longer trade marked as inactive in the stock dictionary. The current release of Trading Blox exits stocks marked as inactive in historical testing on the close of the final bar if the system holds a position at that time.
Does Tradingblox get the active/inactive information from the stockInfo.txt? Also, can this be programming into the script, such as Before Test, X, Y and Z stock is inactive?
Jake Carriker
Site Admin
Site Admin
Posts: 1493
Joined: Fri Sep 12, 2003 10:32 am
Location: Austin, Texas

Post by Jake Carriker »

Yes, the active status is read from the stock dictionary. It can be accessed from scripting (instrument.activeStatus), but there is no function to set or change active status in scripting.
huss1652
Roundtable Fellow
Roundtable Fellow
Posts: 73
Joined: Tue Mar 01, 2011 4:49 pm
Location: Columbus, OH - USA

Post by huss1652 »

Thanks Jake.
Post Reply