Page 1 of 1

Using Delisted Data

Posted: Tue Feb 11, 2014 8:44 am
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.

Posted: Tue Feb 11, 2014 8:50 am
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...

Posted: Tue Feb 11, 2014 8:54 am
by huss1652
Is this function built into TradingBlox or is it something that needs to be coded manually?

Posted: Tue Feb 11, 2014 8:57 am
by Jake Carriker
There is nothing built-in to TB that handles these items. It is done in scripting.

Posted: Tue Apr 01, 2014 9:05 pm
by Ghost11365
Jake, I was wondering if you could point me in the direction of using script to avoid survivorship bias. Thank you.

Posted: Wed Apr 02, 2014 11:52 am
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.

Posted: Wed Apr 02, 2014 12:14 pm
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)

Posted: Wed Apr 02, 2014 12:20 pm
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.

Posted: Wed Apr 02, 2014 12:21 pm
by Ghost11365
OK - thanks Jake - guess i'm on the right track.

Posted: Wed Jul 23, 2014 1:26 pm
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?

Posted: Thu Jul 24, 2014 8:05 am
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.

Posted: Thu Jul 24, 2014 8:07 am
by huss1652
Thanks Jake.