Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Combining Strategic and Tactical Asset Allocation

Brandon VanLandingham requested help to create a core satellite strategy which is a combination of static portfolio and tactical portfolio with a different set of assets that trade on a moving average crossover.

Here is a simple version to play with.

Quantopian, for more then a month I unable to attach backtest to any post reply, please respond.

2 responses

Slightly modified version:

# Core-satellite strategy v2  
# ---------------------------------------------------------------------------------  
core_etf, proportion = symbols('QQQ', 'XLP', 'TLT', 'IEF'), [0.25, 0.25, 0.25, 0.25]  
tact_etf, ma_s, ma_f = symbols('XLV', 'XLY', 'TLO', 'GLD'), 200, 20  
lev, wt_core = 1.0, 0.25  
# ---------------------------------------------------------------------------------  
def initialize(context):  
     schedule_function(trade, date_rules.week_start(2), time_rules.market_open(minutes=65)) 

def trade(context,data):  
    if get_open_orders(): return 

    for i in range(len(core_etf)):  
        if data.can_trade(core_etf[i]):  
            order_target_percent(core_etf[i], lev*wt_core*proportion[i])

    ma_fast = data.history(tact_etf, 'price', ma_f, '1d').mean()  
    ma_slow = data.history(tact_etf, 'price', ma_s, '1d').mean()  
    ratio   = ma_fast/ma_slow  
    pos_mom = ratio[ratio >= 1.0]  
    wt      = lev*(1.0 - wt_core) / len(pos_mom) if len(pos_mom) !=0 else 0

    for etf in tact_etf:  
        if data.can_trade(etf):  
            if etf in pos_mom.index:  
                order_target_percent(etf, wt)  
            else:  
                order_target(etf, 0)  

def before_trading_start(context,data):  
    record(leverage = context.account.leverage)  

Total Returns
205.2%
Benchmark Returns
90.5%
Alpha
0.10
Beta
0.16
Sharpe
1.21
Sortino
1.77
Volatility
0.10
Max Drawdown
-13.6%

You should comment your code. But nice read anyway