Back to Community
Deprecation Warning Help

Can a Quantopian Great Samaritan take a look at this deprecation warning and offer a fix?

Clone Algorithm
3
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
import pandas as pd

def initialize(context):
    context.stocks = [symbol('SPXL')]
    
    set_commission(commission.PerShare(cost=0, min_trade_cost=0.00))
    set_slippage(slippage.FixedSlippage(0))

    schedule_function(go_long, date_rules.every_day(), time_rules.market_close(minutes=30))
    schedule_function(go_short, date_rules.every_day(), time_rules.market_close(minutes=15))
    schedule_function(close_all, date_rules.every_day(), time_rules.market_close(minutes=1))

def get_time():
    return pd.Timestamp(get_datetime()).tz_convert('US/Eastern')

def close_all(context, data):
    log.debug("%s Closing" % get_time().strftime('%H:%M'))
    for sec in data:
        order_target(sec, 0)

def go_long(context, data):
    log.debug("%s Going long" % get_time().strftime('%H:%M'))
    for sec in data:
        order_target_percent(sec, 1)

def go_short(context, data):
    log.debug("%s Going short" % get_time().strftime('%H:%M'))
    for sec in data:
        order_target_percent(sec, -1)

def handle_data(context,data):
    pass
There was a runtime error.
2 responses

Here it is.

Clone Algorithm
11
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# 15:30 buy, 15:45 short, 15:59 cover

import pandas as pd

def initialize(context):
    context.stocks = [symbol('SPXL')]
    
    set_commission(commission.PerShare(cost=0, min_trade_cost=0.00))
    set_slippage(slippage.FixedSlippage(0))

    schedule_function(go_long, date_rules.every_day(), time_rules.market_close(minutes=30))
    schedule_function(go_short, date_rules.every_day(), time_rules.market_close(minutes=15))
    schedule_function(close_all, date_rules.every_day(), time_rules.market_close(minutes=1))

def get_time():
    return pd.Timestamp(get_datetime()).tz_convert('US/Eastern')

def go_long(context, data):
    log.debug("%s Going long" % get_time().strftime('%H:%M'))
    for sec in context.stocks:
        if data.can_trade(sec):
            order_target_percent(sec, 1)

def go_short(context, data):
    log.debug("%s Going short" % get_time().strftime('%H:%M'))
    for sec in context.stocks:
        if data.can_trade(sec):
            order_target_percent(sec, -1)

def close_all(context, data):
    log.debug("%s Closing" % get_time().strftime('%H:%M'))
    for sec in context.stocks:
        if data.can_trade(sec):
            order_target(sec, 0)            
There was a runtime error.

Very grateful.