Back

VXX Intraday Strategies

Hi guys,
This is a strategy for those who want more action :)
Uses VXX short/long - half of the time holding period is few hours, other times sells next day MarketOnOpen
I used 1000,000 as starting capital to overcome VXX, but in now days you can trade with few thousands.
If you want to trade it, check your brokers fees.
A word of caution: minutes data are different for different providers and sometimes sells on Open, so who knows what happens in real world.
Thamks
Nik
Update Backtest






The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.



0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


"to overcome VXX" - I meant the price of VXX during 2009 was in thousands, so you don't want your strategy to buy 5 shares...
0

Thanks for sharing nik milev! It's a shame VXX only started in 2009, it'd be interesting to see how it performs through an overall market crash.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Could you explain the position sizing? Also, how did it make so much money on Jan1, 2015? My backtest generated 17% return on that day. Thanks.
0

Nothing special in allocation - buying all possible shares every time.
I dont see trade on Jan 1st, I see Jan 2nd with gain 5.4%
Perhaps you made some changes in the algo...
The trades I see are below:

2014-12-31T09:32:00 VXX 29.08 263788 Market
2014-12-31T10:46:00 VXX 29.279 -263788 Market
2015-01-02T09:32:00 VXX 30.49 253225 Market 4 7720830.25
2015-01-02T10:46:00 VXX 32.27 -253225 Market 4 -8171570.75
gain=32.27-30.49=1.78 which is 5.838%

So, unless I am mistaken somewhere, the gain is 5.4% that day
According to BigCharts open=30.47 high=32.82, so this day was volatile, it seems that around 10:36 price was hoovering around the high, and 32.27 seems achievable.
1

sweet algo. I have a few questions though:

1. Why do you add the last trading minute to the rollingwindow? Then you have a duplicate of the last minute in the rolling window, correct? As far as I can tell it doesn't even matter?
2. What's up with the seemingly random days of the n week for checking for long/short position? (M-W-T-F for long and T-F for short) It does do better in the backtest using these days as constraints.
3. Why only sell at 10:45? (IsExit method)
4. it usually gives me the error:

OnData: 'VXX' wasn't found in the TradeBars object, likely because there was no-data at this moment in time and it wasn't possible to fillforward historical data. Please check the data exists before accessing it with data.ContainsKey("VXX") at QuantConnect.Data.Market.DataDictionary`1[QuantConnect.Data.Market.TradeBar].get_Item (System.String key) [0x00000] in :0 at QuantConnect.Algorithm.Examples.VIXIntraDay.OnData (QuantConnect.Data.Market.TradeBars data) [0x00000] in :0 (Open Stacktrace)

when I start the backtest, usually it keeps running, but sometimes it gets stuck. Haven't been able to figure out where/why this is happening.
0

The error above is from the code not checking the dictionary to see that VXX data exists. This probably happening at midnight when the daily data gets emitted, but there is no VXX minute data since we're outside of market hours.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Let me try to answer the questions.
I would be careful with conclusions since the algo has not ran on bear market (even it has long/shorts trades), so we may have data snooping issue here.
1. My understanding is that the algo itself builds the history, so this should be the only place to add last bar.
2. It seems that Tuesdays are not good for short - no predictability. I ran it by itself and did not like the result. Also for shorts, my general observation is that Thu/Fri markets are not that good and if the set up happened, it is more powerfull and predictable for shorts.
3. The 10:45 exit is based on observation that after 1-2 hours of trading VXX tends to go down (again careful, might be data snooping too :) )
4. This is just an example and there is leftover code - you can play with weekday exit time , entry time and etc to improve it. The error happens in the beginning and i did not bother to fix it since should not affect the result much.
What I particularly like is the CAGR/DD >2, so you can use half of your portfolio and reach 20% CAGR with 10% drawdown (if the algo really works of course, since it was not tested in bear market :) as MichaelH pointed out )
1

I see thanks. So is checking the dict to see if VXX data exists should ideally be done in the algo, or LEAN engine?
0

Try running it starting in 2010, without the days restriction for buy/sell. Sharpe of 2.1
0

I'm not sure the engine could perform that check, also, we always want to call the OnData method even if there is no data since it acts as the heartbeat for the algorithm.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


to avoid the exception, you could do something like this
TradeBar b = null;
data.TryGetValue(Symbol, out b);
and then put b!=null on the main "ifs" so execution passes them

For longs only including Tuesdays did not deliver good results for me, so I think it is better to exclude them
Total Trades 766
Compounding Annual Return 23.481%
Drawdown 13.700%
Sharpe Ratio 1.551

For shorts only removing check for the days and it looked good and it is as below
Total Trades 912
Compounding Annual Return 13.438%
Drawdown 14.600%
Sharpe Ratio 1.121

This brings another point:
It seems to me that would be valuable addition to have some stats for long and shorts separately:
Long win rate, Long loss rate, Long avg bars in trade, Long P/L, max loss (%), max gain (%) - and same for shorts

After the algo finishes, looking at the stats I can see if algos is hanging too long on the losers and sells winers quicker, or that I need to tighten my stop loss since max loss is too big and etc.
0

Here is an example of how TrailingStop might improve the return: the algorithm uses TrailingStop for shorts. Sharpie is higher and CAGR/Drawdown is better than 4:1 !
Also since expectancy is 0.46% you can start trading with 10-20k in your account.
You can play with different entry times, percent below open and etc. and can easily get better results.
When you get rich, don't forget to send a "thank you" letter :))
4


Have you attempted to trade this yet with success??
0

No, not yet - I was attempting other ideas (autotrading only). But in near future I plan to trade it (manually) on paper first. If you play with different parameters you can easily get better numbers. Just make sure you are not "over-fitting the curve".
0

Yeah, it's interesting. I would love to hear your outcomes if/when you start trading it on paper. I am going to mess with it a little, and see how the new vol approaching will affect it perhaps.
0

Just to get a better idea...is this a simple Long/Short strategy utilizing the VIX and VXX, or are you utilizing some exact parameter? Can you explain? ..apologies for all of the questions ha
0

Yes, it is simple long/short and only uses current VXX price compared to prices from 1-2 days ago. The entire logic for entering is in IsEntry() method . The IsExit() determines if we need to close the trade. One important thing to add - the strategy does not account for slippage!
0

@nik - i am still a nube at c++...how can we add a slippage control?
0

You can search the forum by typing slippage" and might be able to fins few more examples. Here is a simple one:

Assuming you want to trade SPY, somewhere in your Inititalization() method you need to have a line like below.

Securities["SPY"].TransactionModel = new ConstantSlippageModel (SlippagePr);

Where SlippagePr is decimal value of the slippage, e.g.: 0.001 (would mean 0.1%)

Here is a sample implementation for ConstantSlippageModel class - got it from Lean source:

public class ConstantSlippageModel : SpreadSlippageModel
{
private readonly decimal _slippagePercent;
///
/// Initializes a new instance of the class
///

/// The slippage percent for each order. Percent is ranged 0 to 1.
public ConstantSlippageModel(decimal slippagePercent)
{
_slippagePercent = slippagePercent;
}

///
/// Slippage Model. Return a decimal cash slippage approximation on the order.
///

public override decimal GetSlippageApproximation(Security asset, Order order)
{
var lastData = asset.GetLastData();
if (lastData == null) return 0;

return lastData.Value*_slippagePercent;
}
}

Good luck
0

Here's the link to the built in lean slippage models as an example.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed