Back to Community
Attn Live Traders of UWTI/DWTI
8 responses

Simon,
I was looking for a programmatic way to access delisting information, like you link to above.

For NASDAQ and NYSE, they seems to show up at:
https://listingcenter.nasdaq.com/IssuersPendingSuspensionDelisting.aspx
https://www.nyse.com/regulation/delistings

but is there a programmatic way to get at this info from SEC Edgar's 25-NSE filings ?
Thanks,
alan

I'm not sure. Perhaps this is something Quantopian actually implements - maybe they set the end date of the security prior to it being delisted?

Well, I wrote a little test program:

-Buys and maintains exactly 100 shares of a list of tradable stocks. (EMC, UWTI, and SPY in this case)
-Tracks the variables end_date and auto_close_date (which is the Q var forcing liquidation of delisted assets)

As you can see from the log, the var "sec.end_date" is the number of days till either the date the backtest ends,
or the number of days till the asset is ended.

The var "sec.auto_close_date" is when Q will liquidate the sec,
and is either 3 or 6 days from the sec.end_date, depending on whether the delisting happened during the backtested period.

I had been following EMC and it's split into DVMT and cash on Sept 6, 2016.
SPY is in there just to give a baseline of an asset that doesn't end.

The Edgar 25-NSE for EMC was exactly on the date it delisted(even though the plans were out there for months),
and this is reflected in the Q database, but that update happened last week in the Q database.

The UWTI 25-NSE happened on 2016-11-16, but the delisting itself is in a while, so this is some form of "look-ahead-to-delist-event".

I tracked UWTI, and as you can see, there is no database update of the end_date or auto_close_date for that asset in the Q db.
This is probably too much to ask, as you'd have to scour the Edgar/NSYE/NASDAQ delisting data somehow, and update the databases.

Not sure how this is done with live algorithms, but certainly is something to monitor manually, and indicates that you'd have to be on top of it manually,
as from what I'm reading, if you're trading less that 500K shares, it's a PITA to cash out your delisted asset, let alone get a reasonable price for it!

Guess this is part of the risk for being able to trade.
alan
----- Portion of log -----

2016-09-01 05:45 before_trading_start:17 INFO sec=EMC IsEndDt=4 IsAclDt=7 Diff=3  
2016-09-01 05:45 before_trading_start:17 INFO sec=UWTI IsEndDt=82 IsAclDt=88 Diff=6  
2016-09-01 05:45 before_trading_start:17 INFO sec=SPY IsEndDt=82 IsAclDt=88 Diff=6  
2016-09-01 06:31 rebalance:29 INFO ActiveBuy:100 of EMC  
2016-09-01 06:31 rebalance:29 INFO ActiveBuy:100 of UWTI  
2016-09-01 06:31 rebalance:29 INFO ActiveBuy:100 of SPY  
2016-09-02 05:45 before_trading_start:17 INFO sec=EMC IsEndDt=3 IsAclDt=6 Diff=3  
2016-09-02 05:45 before_trading_start:17 INFO sec=UWTI IsEndDt=81 IsAclDt=87 Diff=6  
2016-09-02 05:45 before_trading_start:17 INFO sec=SPY IsEndDt=81 IsAclDt=87 Diff=6  
2016-09-02 05:45 before_trading_start:21 INFO asset[SPY] = 100  
2016-09-02 05:45 before_trading_start:21 INFO asset[EMC] = 100  
2016-09-02 05:45 before_trading_start:21 INFO asset[UWTI] = 100  
2016-09-02 06:31 rebalance:29 INFO ActiveBuy:100 of EMC  
2016-09-02 06:31 rebalance:29 INFO ActiveBuy:100 of UWTI  
2016-09-02 06:31 rebalance:29 INFO ActiveBuy:100 of SPY  
2016-09-06 05:45 before_trading_start:17 INFO sec=EMC IsEndDt=-1 IsAclDt=2 Diff=3  
2016-09-06 05:45 before_trading_start:17 INFO sec=UWTI IsEndDt=77 IsAclDt=83 Diff=6  
2016-09-06 05:45 before_trading_start:17 INFO sec=SPY IsEndDt=77 IsAclDt=83 Diff=6  
2016-09-06 05:45 before_trading_start:21 INFO asset[SPY] = 100  
2016-09-06 05:45 before_trading_start:21 INFO asset[EMC] = 100  
2016-09-06 05:45 before_trading_start:21 INFO asset[UWTI] = 100  
2016-09-06 06:31 rebalance:29 INFO ActiveBuy:100 of EMC  
2016-09-06 06:31 rebalance:29 INFO ActiveBuy:100 of UWTI  
2016-09-06 06:31 rebalance:29 INFO ActiveBuy:100 of SPY  
2016-09-07 05:45 before_trading_start:17 INFO sec=EMC IsEndDt=-2 IsAclDt=1 Diff=3  
2016-09-07 05:45 before_trading_start:17 INFO sec=UWTI IsEndDt=76 IsAclDt=82 Diff=6  
2016-09-07 05:45 before_trading_start:17 INFO sec=SPY IsEndDt=76 IsAclDt=82 Diff=6  
2016-09-07 05:45 before_trading_start:21 INFO asset[SPY] = 100  
2016-09-07 05:45 before_trading_start:21 INFO asset[DVMT] = 11  
2016-09-07 05:45 before_trading_start:21 INFO asset[EMC] = 100  
2016-09-07 05:45 before_trading_start:21 INFO asset[UWTI] = 100  
2016-09-07 06:31 rebalance:32 INFO CantTrade:0 of EMC  
2016-09-07 06:31 rebalance:29 INFO ActiveBuy:100 of UWTI  
2016-09-07 06:31 rebalance:29 INFO ActiveBuy:100 of SPY  
2016-09-08 05:45 before_trading_start:17 INFO sec=EMC IsEndDt=-3 IsAclDt=0 Diff=3  
2016-09-08 05:45 before_trading_start:17 INFO sec=UWTI IsEndDt=75 IsAclDt=81 Diff=6  
2016-09-08 05:45 before_trading_start:17 INFO sec=SPY IsEndDt=75 IsAclDt=81 Diff=6  
Clone Algorithm
2
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5835fcc3d8f7e26324736cca
There was a runtime error.

How do I obtain the date on which before_trading_start() was called in back testing? I need it to get US pricing of some security on that date upto some years.

thanks
-kamal

Doesn't before_trading_start() run every morning at 8:45 AM EST?

Kamal,

Sean is right...
Josh Payne, at the end of the thread
https://www.quantopian.com/posts/at-what-specific-time-does-before-trading-start-run
sez
845 AM ET is when before_trading_start runs.
alan

Hello,
I need the date on which the routine was called to do some other calculations inside before_tradeing_start(). So, pl tell me how to extract that in my python code.

thanks
-kamal

The post I mentioned above has the code to add to and above before_trading_start

import datetime  
def before_trading_start:  
         current_time = get_datetime('US/Eastern')  
         print current_time