Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Fetch, warmup, history -- need a working example?

Is there an example algo that implements the following?

  • Fetch data for an signal index, such as VIX
  • get history() / 200 day warmup on traded security
  • start the benchmark and algo trading at the same point in time
  • Run at a reasonable speed and not crash
    A number of posts touch on some of these issues and then trail off without including the successful example.
    Thanks

I was running a modified clone of Trading on the RSI of VIX and SPY. I had added Yahoo as my fetch source of ^VIX, and a check for open orders. It was running slowly and losing money in backtests. I was running minutely, in quick backtest mode.

So, I reverted to and exact copy of Trading on the RSI of VIX and SPY, and ran a full backtest, beginning in 2002 with $10,000. I let it run overnight, and it produced the "Something went wrong" error message, and no log output.

Try CREATED  BACKTEST DATE RANGE     FREQUENCY   BACKTEST OVERALL RETURN     STATUS  
8   Jul 26 2014, 11:19 PM    Jan 03 2002 - Jun 23 2014   Minute  -55.9%  Exception  

Algo transactions begin 200 days late 2002-10-18 08:31:00
and end about 3 years in (2005-06-03 08:56:00), presumably when the Exception was thrown.

For comparison, I just launched a full backtest of the modified clone.

3 responses

Oddly, the vix_rsi remained 0 throughout testing of both algos.

Hey Monte,
The original version of this algorithm only works on daily data, that's why the rsi is 0 through backtests run on minute data. The reason was that we currently can't use history to get trailing windows of fetched data. However, I recently found a workaround, you can preform calculations in a pre_func and append new columns to fetched dataframe.

This version works with minute data and has no warm-up period. I also cleaned up a lot of the logic, the context.invested and context.short variables are brittle so it now uses the current position size to determine if it's invested/short. It makes some pretty insane returns in backtests, but the bulk of them are from short positions through the financial crisis when short selling was banned, so take it with a grain of salt.

There is also still some issues that might make this difficult to live trade, the fetched file is updated daily, but it is most likely updated after the market is closed, so there might be some inherent look-ahead bias. Maybe having it trade at the open using the previous days close price will be doable in a live trading situation.

David

Hi,
Find attached a different SMA and VIX included. The VIX RSI changes very fast. I have the feeling the VIX data is not always correct. Sometimes also wrong position is choosen. If this is out, it will be interesting algo to run.
J.