Overall Statistics |
Total Trades 53 Average Win 42.80% Average Loss -4.75% Compounding Annual Return 237.024% Drawdown 38.500% Expectancy 2.463 Net Profit 835.779% Sharpe Ratio 3.206 Probabilistic Sharpe Ratio 93.352% Loss Rate 65% Win Rate 35% Profit-Loss Ratio 9.00 Alpha 1.551 Beta 0.441 Annual Standard Deviation 0.509 Annual Variance 0.259 Information Ratio 2.816 Tracking Error 0.514 Treynor Ratio 3.698 Total Fees $0.00 Estimated Strategy Capacity $13000000.00 Lowest Capacity Asset BTCUSD XJ |
# Trading Kalman Filter # https://www.quantconnect.com/project/9975790 from pykalman import KalmanFilter import numpy as np # ---------------------------------------- CRYPTO = 'BTCUSD'; PERIOD = 42; LEV = 1.0; # ---------------------------------------- class EnergeticFluorescentOrangeElephant(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetEndDate(2021, 11, 1) self.crypto = self.AddCrypto(CRYPTO, Resolution.Daily).Symbol self.rollingWindow = RollingWindow[TradeBar](PERIOD) self.Consolidate(self.crypto, Resolution.Daily, self.CustomBarHandler) self.SetWarmUp(5*PERIOD, Resolution.Daily) def OnData(self, data): if not self.rollingWindow.IsReady: return L = np.flipud(np.array([self.rollingWindow[i].Low for i in range(PERIOD)])) self.kf = KalmanFilter(transition_matrices = [1], observation_matrices = [1], initial_state_mean = 0, initial_state_covariance = 1, observation_covariance=1, transition_covariance=.01) price = self.Securities[self.crypto].Price kf_l,_ = self.kf.filter(L) self.Plot(self.crypto, "Price", price) self.Plot(self.crypto, "Kalman L", kf_l[-1]) if price >= kf_l[-1]: self.SetHoldings(self.crypto, LEV) elif price < kf_l[-1]: self.SetHoldings(self.crypto, 0) def CustomBarHandler(self, bar): self.rollingWindow.Add(bar)