Hello,
I created a backtest that rebalances every early January. It consists of 30% TLT and 70% SPY. This backtest works.
I then turn it into a 2x leverage portfolio (60% TLT, 140% SPY), but the backtest gave results that makes no sense.
Can someone please help?
Below the code.
Thank you in advanced.
def initialize (context):
context.TLT = sid(23921)
context.SPY = sid(8554)
schedule_function(rebalance, date_rules.month_start(), time_rules.market_open())
def rebalance(context, data):
today = get_datetime('US/Eastern')
if today.month == 1:
if data.can_trade(context.TLT):
order_target_percent(context.TLT, 0.60)
if data.can_trade(context.SPY):
order_target_percent(context.SPY, 1.40)