Hi Q,

Is this strategy worth investing? If yes, what is the process to get it funded?

Best regards,

Pravin

Clone Algorithm

65

Loading...

There was an error loading this backtest.

Backtest from
to
with
initial capital

Cumulative performance:

Algorithm
Benchmark

Custom data:

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 numpy as np import pandas as pd import scipy.stats as st from scipy.optimize import minimize def initialize(context): context.SPY = sid(8554) set_symbol_lookup_date('2015-01-01') context.stocks = symbols('XLE','AAPL','AAP','ABC','ADS','AGN','ALXN','AMG','AMGN','AMP','AMZN','ANTM','APD','AVB','AZO','BA','BCR','BDX','BIIB','BLK','BMRN','BXP','CB','CELG','CF','CHTR','CI','CLX','CMG','CMI','COST','CVS','CVX','CXO','DIS','ECL','EQIX','ESS','EW','FDX','FLT','GD','GILD','GMCR','GS','GWW','GOOG','HBI','HD','HON','HSIC','HSY','HUM','IBM','ICE','IEP','ILMN','ISRG','IVV','KMB','KSU','LLL','LMT','LNKD','MCK','MHFI','MHK','MJN','MKL','MMM','MNST','MON','MPC','MTB','NEE','NFLX','NOC','NSC','ORLY','PANW','PCLN','PCP','PCYC','PH','PII','PLL','PPG','PSA','PX','PXD','REGN','RL','ROK','ROP','RTN','SBAC','SHW','SIAL','SJM','SLG','SPG','SRCL','SRE','STZ','TDG','TMO','TRV','TRW','TSLA','TWC','UHS','UNH','UNP','UPS','UTX','V','VNO','VRTX','WDC','WHR','WYNN') context.first = True context.days = 9 set_slippage(slippage.FixedSlippage(spread=0.00)) schedule_function(trade,date_rules.every_day(),time_rules.market_open(minutes=15)) def handle_data(context, data): record(leverage=context.account.leverage) def trade(context, data): if context.days < 5: context.days += 1 return context.days = 0 prices = history(600, "1d", "price") prices = prices.dropna(axis=1) prices = prices.drop([context.SPY], axis=1) copy = prices.copy(True) for sid in copy: if sid not in data: prices = prices.drop([sid], axis=1) context.prices = prices.values x0 = [1. / np.shape(context.prices)[1]] * np.shape(context.prices)[1] b = tuple((0, None) for x in x0) res = minimize(variance_ratio, x0, args=(context), bounds=b) p = np.dot(context.prices, res.x) sign = np.sign(p[-1] - p[0]) wsum = 0 for i, sid in enumerate(prices): val = sign * res.x[i] / np.sum(np.abs(res.x)) * context.portfolio.portfolio_value if sid in data: order_target_value(sid, val) wsum += val order_target_value(context.SPY, -wsum) def variance_ratio(X, context): P = np.dot(context.prices, X) r = 0 ratio = [] for i in range(1,5): r += np.corrcoef(P[:-i], P[i:])[0,1] * (1 - i / 5.) ratio.append(r) total = 0 for i in range(1, len(ratio)): total += ratio[i] - ratio[i-1] s,i,r,p,e = st.linregress(range(0, len(P)), P) return -total * r