Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -1.045 Tracking Error 0.185 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
# Kalman Filter from pykalman import KalmanFilter import numpy as np # ---------------------------------------- CRYPTO = 'BTCUSD'; PERIOD = 80; LEV = 1.0; # ---------------------------------------- class EnergeticFluorescentOrangeElephant(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 1, 1) self.SetEndDate(2021, 10, 31) 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 C = np.flipud(np.array([self.rollingWindow[i].Close 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) kf,_ = self.kf.filter(C) self.Plot(self.crypto, "Price", self.Securities[self.crypto].Price) self.Plot(self.crypto, "Kalman", kf[-1]) def CustomBarHandler(self, bar): self.rollingWindow.Add(bar)