Back to Community
My experiment

Just experimenting and thought it would be interesting to get feedback.

Seems to work well in a few other stocks I tried too (google, citigroup and some steel company), although I know once I add commission and stuff it could be a very different picture lol

Clone Algorithm
90
Loading...
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
def initialize(context):
    context.stock = sid(24)
    context.max_notional = 1000000.1
    context.min_notional = -1000000.0

def handle_data(context, data):
    opening_price = data[context.stock].open_price
    closing_price = data[context.stock].close_price
    vwap = data[context.stock].vwap(14)
    # stddev = data[context.stock].stddev(0.000695)
    
    notional = context.portfolio.positions[context.stock].amount * closing_price
    if opening_price*1.0005 < closing_price and closing_price > vwap*1.005 and notional < context.max_notional:
	    order(context.stock,+100)
    elif opening_price*0.9995 > closing_price and closing_price < vwap*0.995 and notional > context.min_notional:
	    order(context.stock,-100)
    # if 1 == 1:
    #     print opening_price
This backtest was created using an older version of the backtester. Please re-run this backtest to see results using the latest backtester. Learn more about the recent changes.
There was a runtime error.
1 response

haha looking at the sample, I seem to have made something only slightly different :P (after I removed my failed attempts at using datetime and standard deviation)