Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Robin Hood VIX Mix Rogue Trader

This is the most recent version of Robin Hood VIX Mix

That thread was getting a bit long. This version is enough different I thought it appropriate to move to a new thread.
Anybody following me on that thread the last several days knows I did manual trades since Monday 3 days ago June 26.

I've managed to increase my portfolio from $31,000 3 days ago to $41,000 as of this moment.
Must be said, you and I can and will lose a lot of money. Do your own research and make your own decisions.

This current version is a work in progress. It is a reasonable attempt to simulate what I did in the last 3 days. I did hedge a little against doing exactly what I did, because the hedged method / process seems more profitable long term per back testing.

What cannot be simulated is the rather profitable sense of timing that I experienced the last 3 days. There are so many things that can move the market. I see no alternative but to code for long term and hope the short term losses will be made up in the long run by the algo or perhaps the losses will be avoided by my intervention. Nobody has perfect timing. So I likely will lose large amounts again multiple times. But I am looking for long term results that improve my life. We shall see.

It would be wise to look at other algos for your own benefit.
I like, and I have been influenced by:

https://www.quantopian.com/posts/trade-xiv-based-on-vix-1
https://www.quantopian.com/posts/xiv-shotgun-trading-inverse-vix-with-wvf
https://www.quantopian.com/posts/deployed-two-xiv-slash-uvxy-slash-tqqq-strategies-for-paper-trading-dot-dot-dot-will-make-it-live-trading-after-a-month
https://www.quantopian.com/posts/vix-trading-algorithm-return-150-percent-a-year-over-past-5-years-but-has-50-percent-drawdown-from-2015-meltdown

Of course, it must be said, that if avoiding risk is your number one goal, then other algos are probably more appropriate.
Maybe the xiv-shotgun-trading-inverse-vix-with-wvf works well for low risk. Maybe.

By the way, I have started cloning / copying my current code to an algo I call Paper Trade. I paper trade that one starting at the same time that I start the live algo with Rh. So if the live algo Rh quits unexpectedly, I have a paper trade that keeps running, for reference.

152 responses

Hi Charles, I added some of the thresholds of the BigSignal sections. It improves it by 700% when stops are off (50%), by 400% when stops are at 30%. I have added code for trailing stops which are not useful for XIV but maybe for the other stocks. I put it at 30% now but it can should be tuned. Hope this helps

Charles, can this be implemented live through Quantopian? Or is it best to "paper trade" with Quantopian?

Is there any data delay with futures numbers?

In ib you can trade live, robinhood seems unstable.

Is it stable in paper trading through Quantopian

@Peter,
That looks promising. Like you said, it needs some tuning.

@Tyler,
Paper trading has a 15 minute delay, I think. Somebody correct me if I am wrong.
A real negative of paper trading is that it does not auto update your current positions when you start it or after you make manual trades.
Paper trading tends to be very stable from what I've seen.
Live through stock broker sometimes quits unexpectedly. That is why I paper trade an exact copy at the same time for reference and comparison.
Obviously trading live is probably worth it most of the time, because trades are automatically sent to stock broker.

Yes, it is 15 minute delay - To get live trades, couldn't I setup an IB "paper trading" account and just watch for trades on there?

Also the noko.csv file - what is that? Is this manually updated?

Actually, I do not know the answer to either of those questions about IB or the noko.csv file.
From what I understand, noko.csv is a necessary temporary thing until we can use futures to determine stock trades using the trading calendar.
I think I said that right.

Ok, some real credit goes to Peter, for the trailing stop loss code.

I did some code clean up and put the context.stoploss factor variable into RogueTrader section. The stoploss is now different based on UVXY or others.

This does appear to be an improvement. This is what I am now trading.

Sorry guys, difficult to avoid the horrible max drawdown. I made adjustments that fit my preferences.
This is what I am now trading.

Hey Charles, the VIX spike of 50% and the UVXY of 27% last Thursday, how did this fair through your program? Trying to see what this would do with a serious spike

@Nicholas,
I did very well with those by manually intervening. I turned $31,000 into $41,000 riding it both directions.
That was with me watching it every minute for several days and watching Fox Business News, etc.
It looks like it would not have done very well in that one if left on autopilot.
I had near perfect timing manually.
It is difficult to code that. There are so many factors that cause the direction to reverse either overnight or mid trading day.
I programmed it to do well on average. The very nature of that means there will be events that surprise and catch the algo flat footed. That is one that I would have lost some money if on autopilot. At least that is what the backtests show. This also illustrates the difficulty in trying to avoid all drawdowns.

Charles, if you test this back further - say 2013 the drawdowns are pretty big ~40% or so.

It is very challenging to minimize DDs and maximize profits.
xiv-shotgun-trading-inverse-vix-with-wvf is excellent at minimizing DD while still getting a very respectable return. I do recommend taking a good look at that algo and seriously consider using it.
However, if I am trying to maximize profits, it seems like I have to accept an occasional DD.
I have spent some time wondering how I could implement some of the ideas in that xiv shotgun algo in order to avoid some DDs.
So far, how to do that without losing large chunks of maximum profit, has escaped me. But I am very impressed with that algo!
I have a much higher risk tolerance than most. But I am sure that xiv shotgun algo will be just right for some.

Hi there, I tried algos with fetcher before. There was a 3-5 days delay before the algo would start trading. Is it still the case for this algo?
Thanks.

Ok, I really really tried to lower the DDs again. I ended up squeezing out some more profit, but lower DDs kept chopping down my returns. So I went for the bigger returns.

@Dat,
I believe it starts trading immediately as long as it sees some clear signals.

Hi Charles,
I am having difficulty understanding why you need the noko.csv file. It seems like you are trying to figure out if contracts are in contango. This task is accomplished easily internal to the Q environment. If you need any guide on how to do that take a look at this post by Jamie under Offset, he creates a normal history curve with the Futures prices inside the environment: https://www.quantopian.com/posts/futures-data-now-available-in-research.

Let me know if I have misinterpreted the problem, we at Quantopian are always trying to understand the communities pain points as best as possible.
Thanks!

Disclaimer

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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.

@Tanay,
Thanks for looking into this situation.
Please see this link: https://www.quantopian.com/posts/deployed-two-xiv-slash-uvxy-slash-tqqq-strategies-for-paper-trading-dot-dot-dot-will-make-it-live-trading-after-a-month#5938da6df4c19700101aa580
That is a verson that does not use noko.csv I believe.
However, it does not work for live trading.
"Futures not allowed for live trading" error is given upon attempt to paper trade or broker trade. Maybe that has changed since 4 weeks ago. That would be cool if it did.

No big change here. I just tweaked the custom graph stuff.

Hey Charles I'm pretty new does your code have training stop losses?

Also would this code be ideal for Robinhood under $25k?

@Nicholas,
trailing stop losses?
yes, for XIV is probably close to what you are expecting, even though is tuned to maximize profit
yes for UVXY, however is tuned to maximize profit, larger losses are definitely possible
yes, for TQQQ is probably reasonable for what you are expecting, same setting as XIV
Rh under $25k?
not specifically, but it works well enough. TURN ON Rh day trade protection for additional day trade protection
I started out with about $5,000 before I increased to $31,000, so yeah the little investor is probably ok for this. Not claiming $31k is a lot, just for me it is.

Make sure you customize the TarPer section to your preference, especially the Rh Gold margin code.

However, the nature of these investments is that they are volatile.
You and I can and will lose lots of money.
Do your own research and make your own decisions.

Looks like some solid stuff to look into. My opinion is u should not be too aggressive.

Most recent algo sold off the XIV position on close of business, let's see how this progresses.

Yep, mine sold all XIV by 29 minutes before market close today.

yep, times like these...
you feel like you may be going down with the ship

Earlier today I back tested with:
after stop loss, wait for change of signal before buy again
result was slightly less profit, but not much difference otherwise

so ... left it alone ... not clear what to do
wait and see is probably best, as long as your already in place plans are reasonable
manual intervention can be appropriate
but it is challenging, because you are 2nd guessing your already existing plans
best wishes to all and to all a good night!

by the way, I like Blue ' s PVR code,
it makes my custom graphs purrrrty!

Yes today was a little crazy, still paper trading this one, Do you know who to get the shotgun xiv to work on live trading mine just sits there and doesn't buy. Not sure if it just hasn't met the signals to buy or just not trading due to code. Also whats the lowest Max Drawdown you were able to get while still remaining fairly profitable? I know earlier you said you were messing around with it but would cut into profits

As far as shotgun xiv algo goes, I think Kory Hoang is willing to collaborate. It says at top of algo:

For collaboration requests, email

To make the ordering a little more similar to mine:

add TarPer and DataCanTrade functions at end

Replace every

order_target_percent(context.BOND, context.BONDpct)

with

TarPer(context, data, context.BOND, context.BONDpct)

Do similar with all the

order_target_percent  

As far as MDD goes, for sure not better than shotgun xiv algo.
I was able to lower DDs somewhat (and obviously profits as I previously said) by:
adding c.SellAndWait = 1 in handle_data function:

log.info(' ! '+str(position.asset.symbol)+'- (Long) has hit stoploss @ '+str(position.last_sale_price))
if get_open_orders(position.sid): cancel_open_orders_for(context, data, position.sid)
c.stoppedout.append(position.asset.symbol)
TarPer(context, data, position.sid, 0.00)
c.SellAndWait = 1

The 1 can be 2, 3, 4, whatever. You can also tighten up context.stoploss = 0.21 if stock is context.UVXY else 0.035 in RogueTrader function.
The problem with stop loss is that it either is locking in your loss or preventing further loss or in our case preventing higher profits because of difficult to avoid volatility.
If you get a series of stop losses in a row, then you just lost a lot of money.

I have not studied the signals in shotgun xiv algo. I will leave that to you and others.
However, I just now looked at a year long back test of the shotgun xiv algo. The last time it purchased was around May 25th, 2017. It buys at market close and sells the next morning at market open. There are things about that algo that are very appealing. You are in cash for most of the time. Check it out. You might like it. Here is the link to the shotgun xiv algo. I started paper trading it, so I can keep tabs on when it makes a move. Maybe that can inform our manual interventions. Or maybe not, the whole apples and oranges thing. But did I mention that I like that shotgun xiv algo?

Now that I seem to have this algo at a stable milestone, I am taking another look at my old algo Robin Hood Extreme Vetting

It tends to use very low leverage. If I could fit it in with this Robin Hood VIX Mix Rogue Trader, without breaking it or killing the returns, then I believe there could be some benefits to that arrangement.

Now that I think about it, maybe the shotgun xiv algo could be included. Or maybe shotgun xiv algo could be mixed with robin hood extreme vetting. Hmmmm.........

@Charles hi i'm pretty new to this but this looks very interesting!

If you were going to live trade with RH using this algo, is there a recommended minimum amount of money needed to invest? My RH has about 60 bucks in it which I've hooked up to the algorithm just for tests, but I have about $2500 in other trading accounts I feel comfortable working with. Right now the algorithm isn't doing anything with the 60 bucks I have in RH but I'm wondering if that's either because the algo hasn't deemed anything worth trading, or because it's trying to but I don't have enough money linked up.

Thanks for your hard work!

@ Matthew

You don't have enough money to even buy 1 share that's why it doesn't work for you.

@Charles @Jay

Re: the stop losses...the jury is out IMO as to whether or not they make sense here. I find that XIV will sometimes partially recover a given day's losses after and / or pre-market (e.g. its 1 point upside move from yesterday's close to today's open). Yesterday's triggered stop did not allow for recouping some of those losses because it exited XIV before close. Add to that the issue that Q had this morning whereby I had to restart the algo (in RH live trading) only to find out after open that the restart failed...so the algo missed today's XIV run-up, though I manually traded it this morning which helped.

So, at least in this case, the stop loss virtually locked in yesterday's XIV losses as Charles mentioned. I almost got taken out to the wood shed on that one. :)

I don't claim to know the correct answer here re: stops; maybe just wait and see.

Charles - thank you for your work on this algo thus far.

@ Chris - Not sure what version you are running, but the latest went all in UVXY this morning and is still holding.

@Chris @Tyler

Probably the same version. I would guess that the live algo stopped and later was started again, .... after the scheduled rebalance. Situations like that, is why I also run a clone of the algo in paper trade. Not perfect, but it gives you something to double check in situations like this.

XIV obviously did better than UVXY on Friday. but the algo is in UVXY at the moment
I manually went even further in at $10.32.. so now average cost $10.47... We shall see if that hurts or helps me next week.
I think I have reasonable odds, that either the bears will raise their heads again, or news events may cause some volatility.
I may temporarily turn off the live algo before market open, and refer to the paper trade. Haven't decided yet.

@Charles - agreed. There seems to be more bearish chatter in the current climate. We shall see how things progress.

@Charles @Tyler

I'm running (one of) the latest versions and, yes, the algo was started after the scheduled re-balance so I missed the entry into UVXY. That turned out to be a good thing on Friday, but I have the algo running again so let's see what it does on Monday.

For those that have the algo live trading, do you currently have the stops enabled?

I am considering, setting a manual limit sell of UVXY to cause the rebalance orders to be rejected. That way I can leave the algo running. After the rebalance orders get rejected, I would then cancel the manual limit sell of UVXY. That way the Rogue Trader limit sells will still be placed 1 hour after market open. That has the effect of delaying the rebalance by 1 day. And I could manually intervene if seems appropriate.

Feeling a bit wishy washy about it at the moment though. We shall see, as we get closer to market open.

Have you ever considered adding a buy rejection if contango is too high? For UVXY.. Just a thought!

Just an update from me: if you recall, I manually opened a position in XIV on Friday. Today XIV performed well and the algo sold my position around midday, locking in some profits. So I'm currently flat.

I have the latest version of the algo running live in both RH and paper, so we'll see what tomorrow brings.

@Chris
My paper trade is doing just like you described.
My live algo, I did as I said. I placed a limit sell for UVXY to cause the rebalance orders to be rejected. Then just before 1 hour after open (Rogue Trader), I cancelled my limit order, to allow the algo to place limit sell orders. I will have to do that each morning that I want to delay the rebalance.

By the way, this is the handle_data code that activated today and sold XIV, locking in some profits, and hopefully avoiding some losses from tomorrow.
if (
(position.sid is c.XIV and 0 < position.amount)
and
(10.76 < c.vix < 12) and (position.last_sale_price > 1.013 * c.XIVprice)
):
c.SellAndWait = 1

The SellAndWait = 1 means sell everything and skip 1 rebalance. So I believe it is going to skip tomorrow morning's rebalance in my paper trade. That code helped the back test results.

Feel free to manually intervene when rebalance is skipped.

The August recess for the US Congress begins July 31st. Between now and then could be interesting.

@Nick G
Do you have any proposed settings or code? This algo is largely crowd sourced, so if you have any ideas.

@Charles

Thanks for the info. Skipping rebalance are (for me) tough, especially after a day or two of big losses. But I agree with the general approach, as it does improve backtest results as you had indicated, and so I am live trading that code. It's just that the market has been all over the place lately.

Maybe the key here is to stick to the strategy and let the algo do its job, with perhaps some manual intervention on big down days. I know that I need to learn to follow that rule!

Charles,

I will try to see if I can get you any real time contango percentages.. best strategy I've had is anything under 4-5%, I simply do not play UVXY short. I'll be looking into it for you.

Continuing, I never play UVXY long unless VIX hits a 2.85-3 standard deviation event.

@Nick G
Forgive me if my questions are amateurish.
Would that be for strictly day to day deviation? Or intraday? Because I believe so far we only have access to one VIX read per day in the algos. And that is only for VIX up deviation not down deviation right?

Manually got out of a long XIV pos right before that recent jump. This might be too much risk for me to handle for a while, might consider the Shotgun algo for a period.

You could always combine the algos into one and make it so you can allocate percentages of your cash to either algo ex 60/40 0/100 and so on.

Charles,

This is exactly my formula

Long XIV: 5-day average of [VIX index – (2-day historical volatility of S&P 500 * 100)] > 1.25
Long VXX or UVXY : 5-day average of [VIX index – (2-day historical volatility of S&P 500 * 100)] < 1.25

I have made amazing gains from this with 10k back in 2004, you would have near 24M a decade later with 47% max DD (being in the drawdown only 210 days).. A return of 109% annualized

Have had 74% winning months, Sharpe Ratio of approx 1.65

Still trying to learn code here.. But this is a great strategy that, for me, has been time tested.

This strategy had actually made money during the the Global Financial Meltdown 08-09. Very promisiing for the coming years as market conditions may change quickly.

If there is a possibility of you entering/modifying this into your code I'd be very excited to see the results.

@ Nick G, help me out here

Can you give an example of your calculation - say for trading today?

What is the 2 day historical volatility of S&P500?

XIV Long
VXX/UVXY Long

@Tyler Search "Volatility Risk Premium". Here is an old thread on Q.

If you want to go down the rabbit hole of strategies, check out tons of them at volatilitymadesimple. Bring something for the eventual headache.

http://volatilitymadesimple.com/blog/page/3/

Here is another strategy similar to mine. Great results. Just looking to automate something similar.

@Charles Witt
Looking for standard deviation jumps in the VIX is likely intra-day. It's unfortunate that we can't get minute ticks on CBOE:VIX... we'd be picking up some pretty good gains!

You could use Synthetic VIX, based on SPY. SPY MACD crosses and volume momentum do give a couple minute lead time on VIX (and derivative ETFs) but I haven't had much luck coding for those conditions. Sucks when you have a chart with great technicals set up, but can't translate "signal smoothing" to talib.MACDEXT. It's also difficult to reproduce signals per tick because there are minute differences in Q data and other sources.

@Nick G,
This algo might be close to what you are asking for.

Take a look at it. I tried the 2 days with it,... but it does better with the 5 days setting that is already in there.
Let us know if that is close to what you are seeking. If it is, then maybe, if it seems appropriate we will try to add that signal to this algo. We already have Synthetic VIX integrated. At this point, I am not sure that adding that VRP signal will help. But I suppose we can brainstorm it. I am not an expert at this stuff.

Charles, thanks for all the updates on the evolution of this interesting algo over this thread and the previous thread.

How often does the algo fail in live trading with RH? What do you believe is causing the failure?

Have you found a way to backtest over periods of economic stress, such as 2007-08? If not, how do you anticipate it to fare? DD is quite large during stable times, albeit with great returns.

@Nick - I manually backtesting your strategy and there is a huge drawdown in 2015 - greater than 60%

So I noticed that the algorithm didn't sell my shares of XIV and TQQQ last night before markets closed on my paper trading account. It also bought about $1500 over the amount I allocated for trading with this. With my IB account I had the funds in the account so the algo took it but my buddy who's live trading with RH got an error that he didn't have enough funds in his account when it did the same for him. Anyone else run into this this morning?

Matthew - I did notice that my paper trading algo also goes into negative cash. Seems to be consistent that this dips into a little leverage, which is why your buddy's RH threw an error - unless he has GOLD.

My algo is holding TQQQ and XIV - there are some take profit limit orders for today, but none have hit yet

@Tyler

Is that planned or an error on the algorithms part? I was under the impression that the algorithm is set to sell off all shares before market closes. I guess I'm just a little confused on what the strategy here is. Is there any documentation that discusses what this algorithm is going for here? I'm hesitant to start adjusting code until I get a better sense of the strategy.

It's dipping because the code has margin you need to change to 0 if you do not have a margin account in Robinhood

I believe it has a percentage it uses on a limit take profit. You can always manually intervene and sell

@Tyler

If your friend is trading RH, he may have pattern day trading protection enabled. It is this way by default. In order to pattern day trade you need to have an excess of $25000.00 in equity in the RH account. A day trade is counted as buying and selling a position in the same day. If your algo takes several transactions to fill or sell, each of these count as a "day-trade". With that said, the pattern day trading protection kicks in quick if you are using an algo that trades at open and close.

Did anyone see that UVXY is 1:4 reverse splitting, effective 7/17 (Monday)? https://finance.yahoo.com/news/proshares-announces-etf-share-splits-201500038.html

I'm wondering if we'll need to update the ratio / threshold values in the signals of this algo. Thoughts?

I saw it. My Rh phone app says my
UVXY average cost per share is $41.83 (was $10.46).
The current price per said app says $8.45. I assume that will change to $33.80 between now and Monday morning.
It also says, this stock is temporarily untradeable.

As far as adjustments, I doubt it. Has anybody been through one of these before? If so, share your wisdom.

I am fairly impressed with how well the algo did through this last several weeks, considering all the craziness.
I also noticed that XIV Shotgun purchased XIV at $85.66 at market close 2012-07-12. It has not sold yet. Pretty good cherry pick so far!

I need to review the code in more detail for my own sanity, but you may be right.

Agreed, the algo has been performing well, all things considered. I'm waiting for XIV to drop more than a few points, though. On an unbelievable tear since Feb 2016.

I added a Cherry Picker function. It is 90 something % derived from XIV Shotgun algo.
I don't go essentially no risk with bonds like XIV Shotgun does. I just use the signal mostly to sell everything except XIV and go all in XIV for a short number of days, often just overnight. The profit is noticeably improved, but not huge. The DDs are occasionally trimmed, but just barely from what I have seen. The aforementioned XIV Shotgun algo is an excellent algo in my opinion.

Make sure you adjust the TarPer section for Rh Gold and DoNotSpend.

You and I can and will lose a lot of money. Do your own research. Make your own decisions.

Still new and trying to figure out how everything works. How does the algorithm grow returns exponentially over time? It seems that we sit between 150% - 300% returns the first year and then at some point it skyrockets to 1000% returns. I'm probably being naive but how does that work exactly?

The VIX: Using The "Uncertainty Index" For Profit And Hedging Google search for
fear index
uncertainty index
volatility trading

If you just wanna dip your toes in the water. Maybe XIV Shotgun algo
However, you may fall into a coma waiting for it to do something. However, that is the beauty of it. It sits in bonds 90 something percent of the time. It cherry picks apparently maybe 3 or 4 times per year some high probability plays with VIX related ETFs. The rest of the time, you are in bonds.

Keep in mind, there is plenty of risk. You can and will lose a lot of money. Do your own research. Make your own decisions.

@Matthew Keep in mind that backtests are done with compounding funds. If an algo actually pulls off 100% gains every year and no money is taken out, it's going to look like a rocketship.

Until UVXY is publicly available for purchase again, what will be everyone's substitute, TVIX?

I am expecting UVXY to be available before trading begins Monday morning because there are not supposed to be gaps caused by splits. How is that possible unless the splits are timely and the stock remains tradeable during all trading hours.

The bottom line is that a stock split causes no change in the value of
a company or in the value of an investor's shares, nor does it cause
any gaps in a stock's chart, because past price movements are adjusted
for the split.

Read more: Does a stock split lead to the gapping up/down of the
stock?
http://www.investopedia.com/ask/answers/05/splitleadgapping.asp#ixzz4n2aH8TC5

I am not a professional and I do not advise one way or the other.
However, I do suggest to be careful. If you are risk averse, maybe stay away from my algo.

From https://seekingalpha.com/article/4087880-crash-cometh-4-6-weeks

For conservative investors, what needs to be done starting today is to
scale out of all equities on up days (except special situation stocks
with very short-term catalysts) over the next 3 weeks. There isn’t
much more time than that. By mid-to-late August, conservative
investors should be mostly cash.

For risk takers, please keep in mind that these predictions may still
be wrong, so do not bet the farm. For those who cannot trade options,
scaling into the Credit Suisse AG - VelocityShares Daily 2x VIX Short
Term ETN (TVIX) or the ProShares Ultra VIX Short Term Futures ETF
(UVXY) is the best choice if you’re playing the indexes and the VIX.
The VIX is likely to shoot past 40 by September. In 2015, TVIX and
UVXY both more than tripled from mid-July to Black Monday August 24th.
Whatever happens, these positions should be liquidated before October
at the very latest, whether they pay off or not.

No change.

I just changed the benchmark to XIV. I actually find this more useful than SPY as benchmark.

The Seeking Alpha article is interesting yet very concerning. Do you back the articles claims? Have you been able to find other articles claiming the same? How was the algo able to predict the 2015 event? Could it predict it again this time around?

I personally am convinced that there will be enough lack of progress and slowness in implementing President Trump's agenda, that at least temporarily there are likely to be significant pullbacks / DDs. There are factors and opinions pushing in both directions. So nothing is certain, especially the timing of pullbacks. Beyond that, I am as much a fool as the worst of them. One thing I have learned is that the market has a way of surprising in both directions. So, again, what do I know? As far as 2015, there were DDs, but there were many more surges. I posted that article because I know that DDs can be shockingly fast as well as a total surprise to most people. Keep in mind, that bears also lose money when they are surprised by extended bull markets.

Hi, I am using a version of your algorithm with 1k in a regular robin hood account. I have ran it for a week but keep running into a problem. After the first day my daily orders are being rejected. The algorithm is trying to buy 1 or 2 shares more than I have money for. How might I go about fixing this? I changed the margin number to 0 and made a few other minor adjustments but having no luck. Thanks for all your insights!

^ I have literally the same problem as the above poster (regular Robinhood, and margin is set to 0). Any thoughts you could provide would be appreciated. In my specific case, it tried to buy 4 more shares of UVXY than I had funds for. Should I complete the transaction manually and reload the algo?

Hey guys, it sounds like you should increase DoNotSpend in the TarPer function. Increase it enough to make sure there is enough cushion to prevent rejected orders. Then stop / start the algo. Then manually purchase a reasonable number of shares. Then manually place some reasonable limit sell orders. Also, if there are big gains today in your share price, you should probably sell the remainder of your shares to take profit. Tomorrow, the algo will be on schedule to hopefully do those things automatically for you.

Thanks, I figured that's what it was but I wanted to be sure before I changed it - I'm obviously relatively new to Quantopian and even with my programming background it's never wise to fiddle with cloned code unless you ask someone who knows more first.

I'd read that Seeking Alpha article already...

Seeking Alpha will publish anything, and I think there's a lot of market manipulation going on through that site. That said, a lot of novel insights can also be gleaned from SA articles, but for me it's the comments section that is absolutely invaluable. Almost all of the comments on that article are calling bullshit on his rationale.

How do you think this would do in a bear market? Does UVXY off set?

First, Charles, thank you for all the development and the help of the community.

Did the algo purchase UVXY for anyone today? My algo cashed out all my XIV and TQQQ position and longed on UVXY this morning. I'm trading the Jul 3rd version and not the latest. On the other end, the Shotgun algo only made one trade on XIV since 7/12. I'm trying to understand the rationale for going long on UVXY. Thank you!

Mine also purchased UVXY. I am also trading using the July 3rd version.

From what I understand from the code, there's 12 scenarios for target security, and 4 of them point to UVXY, including the catch-all #9. I'm not entirely sure which one was triggered, I might add logging for that to my personal modifications of it next time I deploy it.

Mine tried to buy UVXY but failed with the message "Unkown security" ...

My basic Robinhood account was definitely able to buy it. I'm not sure that it should have, but it definitely could.

Right now it says UVXY not traceable on Robinhood?

tradeable

I fired up the latest version in IB today. With VIX so low I expected UVXY to trade. It bought XIV and rejected tqqq. It appears that the algo did not compute the cash available correctly. Any thoughts?

@Nicholas Johnson: my RH is showing UVXY as available. Were you checking before markets opened?

All,

Please try to keep personal comments of UVXY/ stock availibility to a minimum! I mean this as nicely as possible. These are naturally occuring problems that wont improve the formula-- less clutter to see/improve the mechanics as the algo was intended, thank you!!

But it's just my .02

@nickg its a bit of a odd comment Nick, if an algo creates a signal that is not tradeable we need to know and we need to protect the algo from it and improve the algo. It’s highly relevant!

There was an issue with my Robinhood app today I had to close it and reopen and then it let me trade it so weird

I am new to Quantopian and I am trying to wrap my head around this algorithm, so sorry in advance if this question is obvious. I am wondering why you fetch the csv files in the initialize() function when the files are updated daily? Wouldn't you need to fetch them with a daily scheduled function?

@Dan Codos
from https://www.quantopian.com/help

If your algorithm uses fetch_csv(), it is important that all
historical data in your fetched data be accessible and unchanged. We
do not keep a copy of fetched data; it is reloaded at the start of
every trading day. If historical data in the fetched file is altered
or removed, the algorithm will not run properly. Providing additional,
new data in the file for dates in the future is fine. If you are
updating the CSV, add new data before midnight Eastern Time so the
file is ready for the next trading day.

Ok folks, manually intervening, not letting the algo switch back and forth, I just now lost about $20,000. I am now down to $21,000.
A fool and his money are soon parted.
On the upside, I was watching the algo paper trade, which seemed to be profitable nearly every day.
So, in the future, if I manually intervene, it will only be intraday or at most 2 days, to prevent boneheaded large losses.
Having said that, the algo will not always be right and will sometimes have a large drawdown.
It is very possible that you and I will lose a lot of money.

I added trailing stop loss buys for both XIV and UVXY. More profit squeezed out. Minimal impact on max DD.

@Charles Sorry to hear that. Similarly, I sometimes try to offset algo losses manually with varying success, and I try not to hold longer than intraday. The hard part (for me at least) is that the volatility in XIV, UVXY, etc. is such that when I try to play them on an intraday basis, I often get stopped out at a loss only to find out that I was right had I sat in the position a bit longer.

I like your latest version of this algo. I'm now live trading it in RH. I'm also live trading another VIX algo (the one from which you sourced the 'more signals' code) in IB. I think prefer Rogue Trader, though I haven't tried it in IB just yet.

Ok, I am trying a strategy that might be a good fit for me, since I tend to keep close watch of the market.

Live trade https://www.quantopian.com/posts/robin-hood-extreme-vetting (only zero commissions work for this one)

Manual trade (by referring to paper trades of):
https://www.quantopian.com/posts/robin-hood-vix-mix-rogue-trader
and
https://www.quantopian.com/posts/xiv-shotgun-trading-inverse-vix-with-wvf

Automatic trailing stop loss buys and sells will be missed. But I think I will be ok by making manual trades after the fact.

If I want a break from watching it, then I could
stay in XIV and TQQQ which both tend to do well most of the time
or
switch live trade from RH Extreme Vetting to RH VIX Mix Rogue Trader

As a side note, if you have a position that you don't want the live trade algo to sell:
Manually place a GTC sell limit order at a price
that you like
or
that will not fill because it is extreme
Manually placed orders never get replaced by algo placed orders.

While collaborating with Nick Sulzer, I discovered that the TarPer function had logic errors in it. I fixed it. So now it should get closer to desired margin usage.

@ Charles - My paper trade is up 6-7% right now. Are you saying your manual intervention lost that money?

@Tyler
exactly right
if I had left it on autopilot, instead of preventing the auto trades, then it would have made a profit nearly every day

Live trading on IB account selected UVXY today. The order was rejected. I think it is placing the buy order before selling the current positions. Any thoughts?

One of the issues are sells happening before buys, causes very quick margin - if you don't have a margin account.

update your version
that is a logic error
it does try to order UVXY before selling TQQQ
it is fixed in the latest version

Edited: I had yet another typo in there... sorry

Sorry guys! Thank you Chris Ricciuti for pinpointing the probable fix right away!
I added to initialize:
context.PriceXIV = context.PriceUVXY = 0.00
context.BoughtShortVIX = context.BoughtLongVIX = False
and I fixed the ordering in Rebalance which also had some logic errors

I am going to watch movie Valerian. Hopefully, I finally fixed all the problems because I won't be able to fix it for a few hours.

@Charles, Looks promising, do you live trade it right now?

Thanks for sharing guys!
Where can I set the leverage? For example 25% of portfolio_value.

@Terry
In the TarPer function,
PV = context.portfolio.portfolio_value
DoNotSpend = 0.75 * PV # How much cash for withdrawals

Thanks Charles!

My latest version of Robin Hood VIX Mix Rogue Trader is at Robin Hood VIX Mix Extreme Vetting.

Low volume stocks are a component of it. They are difficult to accurately backtest. The only real test is live trading.
If that worries you, then you should probably stay with Robin Hood VIX Mix Rogue Trader.

Hey Charles I want to change the threshold on this while I'm live trading if I stop it change it then make it live again while in a position will it cause an error? It's crazy as the Vix is in the mid 9's I think the threshold in this was 10.76

no error, but the change may cause a surprise sell probably the next morning if you are in UVXY

Updated the TarPer function to the same code that is in VIX Mix Extreme Vetting. Also added to Initialize function: context.Agree = False
Hopefully, fewer rejected orders will be the result.

I just joined the community recently and want to thank you guys for all these amazing links. There is so much material to learn from, it is going to be a loooong weekend lol

I posted my version of XIV Shotgun at https://www.quantopian.com/posts/xiv-shotgun-trading-inverse-vix-with-wvf

It includes TarPer function and margin. Hopefully it just works, so I don't have to fix it.

Tiny change. It does not automatically market sell other stocks in your portfolio. It still may sell them at limit price for profit though. Place your own manual limit sell orders to reject the algo placed trades.

I am live trading this at this moment. I have temporarily abandoned Robin Hood VIX Mix Extreme Vetting which is still a work in progress.

Do NOT get too excited. I am back live trading Robin Hood VIX Mix Extreme Vetting. It is still a work in progress. However, it does have a more reasonable feel to it.

You guys still on this algorithm or are you trading with a different one? I'm trying to figure out the signals between the switch from XIV and UVXY. The algo didn't seem to catch something and UVXY is up like 8% right now. It just sold XIV

I turned it off a few days ago when XIV started to get really stagnant, I'll turn it back on again in the future. If you look at the code, most of the signal checking and rebalancing is done in the morning, excepting some stop-loss code that might have just triggered when XIV dropped so much. It does this to take advantage of UVXY's frequent AM spikes.

I hopped out of it because it does tend to sometimes get creamed during crises, which are obviously hard to predict. I'm not really sure volatility can go lower, and I didn't want a sudden reversal to kill me if the algo was just holding XIV.

I'm still live trading as well. Same behavior as Matthew experienced. Hard to predict a day like this.

Trading as well it sold XIV on a stop loss due to the falling price of XIV. I bought myself UVXY manually but unfortunatley got it near top of today so i lost a few. Will see what happen soon tomm if it wasn't an ok choice. It basically spiked due to Trump North Korea comment. How that's be going rock go over tomm I'm not sure. I wonder I though if the also will buy UVXY tomm morning? Anyone know?

Commenting on my to phone sorry for the grammar it's autocorrecting

Nicholas, I think it will be I am trying not to touch it. I will let you know. When it sold XIV today it sold a portion of shares at a limit price 96.60 then the rest towards the end of the day for like 92 something. My question is how can we tell it to sell a slightly larger portion at the first limit price?

@Michael,
in def RogueTrader function:
RemainingFactor = 0.50 if stock is c.UVXY else 0.22
change 0.22 to a bigger number (not bigger than 1)

Going to bed now. Tomorrow should be interesting.

Macro Trader has a post for an algorithm that uses the new VNIM instead of XIV. It looks really good, DD is significantly lower but at the cost of lower returns. It's a bit hard to tell if its truly a safer option yet since it is so new but so far it looks promising. Overall I think we could learn from what he has and maybe use it here to help with those DDs. Maybe to use it during uncertainty periods like now.

Algo is here: https://www.quantopian.com/posts/another-vix-trading-algorithm-using-the-new-etf-vmin

For reference here is the latest version I am currently running with RH Gold off at the same time frame of his test.

How's everyone else doing? UVXY is up 30% over the last 2 days and the algo hasn't seen any flags for it. Keeps investing in XIV

Its a painful lesson I have learned few times with various algos. You have to go in manual override mode. You can't price in armageddon as they say.

It's simply that an algo can not cover all kinds of market scenarios.

Don't understand what everyone is upset about - the paper trading version sold XIV/TQQQ this morning without taking a loss.

Yes, mine is flat at this point, so did not get caught in the bulk of today's move lower.

Mine was down 5.88% before it got out

I managed to "manually" lock in 15% on UVXY today because of a stop loss buy order I forgot I'd set yesterday. Lucky. Helped offset some of my other losses ... a tiny bit.

Anyways, anybody else's paper trading graph showing a 100% flash crash in XIV (that did not actually happen)?
XIV Flash crash?

My graph shows such a 100% drop at 11:25 today, which prompted a sell off of VIX

If it's a bug that's triggering erroneous trading signals that's something Q might want to fix. I sent an email to support to let them know about it.

Hi Viridian, Nathan

During live trading, benchmark returns are calculated minutely using 'close' price. The way we are currently handling missing values (NaN) causes the benchmark to show losses of -%100 when we don't receive pricing data for a given minute bar. This blip in the graph usually fixes itself on subsequent days since benchmark returns during warmup are calculated using the 'price' field, which forward-fills for missing bars. We currently have an open report on this bug, pending review from our team.

However, this blip on benchmark returns would not cause signals in algorithms to be triggered. If your algorithm uses 'close' in its calculations, it could be mishandling missing data (NaN). In general, you should use 'price' instead to get forward-filled pricing for missing bars.

Disclaimer

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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.

Charles thanks for everything with the also I'm trying to work out ways the also would catch huge jumps like this anyway I've been looking into adding a threshold if SPY falls by .40% close if in XIV and tqqq and buy UVXY anyway you can add that and I can take a look?

For anyone live trading, a question: I'm running this algo in both RH and IB. Today in RH the algo went long UVXY, but in IB it went long XIV / TQQQ. Has anyone else experienced this behavior?

For me, today in RH, it went long XIV and TQQQ, then took some profit as a limit sell of a portion of XIV later in the day.

Interesting. In paper trading mine sold XIV yesterday at 15:50, got in UVXY at 13:38 today, and tried to sell half via a limit order at 14:30, but the limit order never filled. I think I'm running the Aug. 2nd version. Could it be that we're running different versions/revisions og the algo?

Strange. I'm running the same version (Aug 2) in both RH and IB. Also, looking at the algo logs from this morning, the RH version got a long VIX signal, while IB got a short VIX.

You're probably right, but I don't recall when I last updated it.

Theres got to be a way we can code something if VIX spikes mid day or something close all and go to UVXY, the algo is missing the big UVXY spikes recently, also if vix mid day sharp down if in UVXY close and go to XIV

Test change to the 3.0:

Code to capture profit on price jump - Quantopian
https://www.quantopian.com/posts/code-to-capture-profit-on-price-jump
Mar 1, 2017 - Looking for a price jump over 3.0x, adding to watch_list, and
processing ...

@Chris, Oh that's super weird! You're sure you're running the same version on both? If so I would guess the prices in live trading come from the corresponding broker and there's some inconsistency between them. That's super strange that the data would be different enough to trigger totally opposite signals, huh? I wonder if the data from Robinhood is worse. I assume your IB version made money today and the Robinhood one lost money? I'd be curious how future discrepancies play out on days where there's a clearer better trade -- today was more or less a wash, relatively speaking.

@Nicholas -- Of course you can, and I think the algorithm already does this, but I haven't studied it closely enough to see whether it's intraday or what. It's very difficult to differentiate between a zig zag, a spike, and a jump that continues in the same direction, and combinations thereof. If you can crack that puzzle you can be a gazillionaire. We also haven't had any massive spikes in Vix lately -- just little ones that might not have passed threshold anyway.

@Vhawk Yes, I ran a file compare to confirm. They're the same except that I changed the commission and margin to reflect that of my IB account. Shouldn't make a difference. As to the data quality, I thought that the signal data (or at least part of it) originates from the csv files that are loaded daily. If that's the case, there shouldn't be a difference between RH and IB data quality.

Correct, today IB made money and RH took a loss. I'll be running this algo on both accounts in parallel for a bit, so I'll let folks know if any see any future discrepancies.

Thanks Peter Bakker for resurrecting this algo! I really really really missed it! Only additional change I just now made was to change benchmark to SVXY so can compare to Aug 2015 and Feb 05, 2018 SVXY movements.
Refer to https://www.quantopian.com/posts/robinhood-vix-mix#5a812fb9fb806d0011faedd0

Charles back in the house! Are you currently implementing this on a custom system for brokerage integration? Have seen some frameworks floating around but have not ported anything yet. https://github.com/codesociety/friartuck

@Jay, yes

Made the SVXY and UVXY buying mechanism slightly more patient.
Moved CherryPickerClose to earlier than market close so that I have time to act on it.
Slight improvement in Max DD.

I combined the MoreSignals part of this algo with Kory Hoang's Ballistic XIV.
The new algo is called Robin Hood VIX Asylum.
See https://www.quantopian.com/posts/robin-hood-vix-asylum

Hi, @Charles Witt. What is noko? I can't open the website of http://52.15.233.150/noko.csv, so the code doesn't work? How to solve this? Thank you very much.

@ jimmy huang Thank you so much.

How to trade options by using private API?