Hello,
Trying to backrest a strategy which goes long the ETF 'SVXY' when the VIX futures are in backwardation. This is indicated by a negative value in the 5th column titled "ContBackw". The code currently throws an error when attempting to record the values.
I am having some trouble importing my CSV file containing the data and implementing this strategy. Any help would be appreciated.
Code is as follows:
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
import datetime
import pytz
import pandas as pd
import numpy as np
import zipline
import math
import talib
url = 'https://dl.dropboxusercontent.com/u/1172699/data.csv'
fetch_csv(url,
date_column = 'date',
date_format = '%m/%d/%y',
symbol = 'ContBackw')
pass
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
# data[sid(X)] holds the trade event data for that security.
# context.portfolio holds the current portfolio state.
# Place orders with the order(SID, amount) method.
# TODO: implement your own logic here.
current_bwd = data['ContBackw']['ContBackw']
# plot it
record(bwd=current_bwd)