Back to Community
monument

monument

Clone Algorithm
7
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
# Put any initialization logic here.  The context object will be passed to
# the other methods in your algorithm.
# Zeke's Badass Momentum Trading
def initialize(context):
    
    context.xlf=sid(24)
    context.max_notional=1000000
    context.min_notional=-1000000

# Will be called on every trade event for the securities you specify. 
def handle_data(context, data):
    # Implement your algorithm logic here.
    
    vwap=data[context.xlf].vwap(1)
    price=data[context.xlf].price
    
    notional = context.portfolio.positions[context.xlf].amount * price
    
    if vwap is None:
           return
        
    if price < vwap * 0.995 and notional > context.min_notional:
        order(context.xlf,-100)
    elif price > vwap * 1.005 and notional < context.max_notional:
        order(context.xlf,+100)
There was a runtime error.