Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Backtests are the same even though I change code

I am working on an SPY trader with a VXX hedge algorithm that adjusts its positions based on the first hour of trading. It is a relatively simple program with two securities and four functions. I am trying to see what returns would look like if I changed the percentage at which I decided to be bearish or bullish for that day. My first code returned 110% with a -.006 threshold and I am currently live paper trading that. I came back to try -0.002, -0.003, -0.004, and -0.005 thresholds but I keep getting the same return for each strategy. My code is posted below. Is there anyone that can tell me why this is happening?

def initialize (context):  
    context.spy = sid(8554)  
    context.vxx = sid(38054)  
    schedule_function(opening_trades, date_rules.every_day(), time_rules.market_open())  
    schedule_function(midday_trades, date_rules.every_day(), time_rules.market_open(hours=1))  
    schedule_function(closing_trades, date_rules.every_day(), time_rules.market_close())

def percent_change(context, data):

    hist_spy = data.history(context.spy, 'price', 2, '1d')  
    yest_close = hist_spy[-2]  
    current_price = hist_spy[-1]  
    percent_change = (current_price - yest_close) / yest_close  
def opening_trades(context, data):  
    if data.can_trade(context.spy):  
        order_target_percent(context.spy, 0.50)  
    if data.can_trade(context.vxx):  
        order_target_percent(context.vxx, 0.50)  
def midday_trades(context, data):

    percent_change(context, data)  
    if percent_change > 0 and data.can_trade(context.vxx):  
        order_target_percent(context.vxx, -0.50)  
    if percent_change < -0.003 and data.can_trade(context.spy):  
        order_target_percent(context.spy, -0.50)  
def closing_trades(context, data):

    for security in context.portfolio.positions:  
        order_target_percent(security, 0)  
2 responses

for the record, longing vix futures have historically been a terrible hedge. i think once shorting futures becomes uber crowded that will change but in the mean time it makes no sense to put any money in vix futures due to the massive contango.

your thresholds are for the most part basically the same values. try a much larger one as a sanity check and check out what they are compared against either by logging or using the debugger

Please excuse the name "hedge." I don't actually believe that it acts as a hedge. I just didn't know what else to call it.