Hi everyone,

I tried to implement the Kalman Filter for Bitcoin, unfortunately it is not working.

I hope you can give me some advide, to fix the problem.

There is always an error when trying to run a backtest.

 

from datetime import datetime
import itertools

import pandas as pd
from pykalman import KalmanFilter
import pywt

import matplotlib.pyplot as plt
import seaborn as sns

 

class EnergeticFluorescentOrangeElephant(QCAlgorithm):

   def Initialize(self):
       self.SetStartDate(2019, 1, 1)
       self.SetEndDate(2019, 12, 31)
       btc = self.AddCrypto("BTCUSD", Resolution.Daily).Symbol
     
       

       self.kf = KalmanFilter(transition_matrices = [1],
                 observation_matrices = [1],
                 initial_state_mean = 0,
                 initial_state_covariance = 1,
                 observation_covariance=1,
                 transition_covariance=.01)


   
     
       #btc_price = self.kf.filter(btc)
       
   def OnData(self, data):
       
       #self.Plot("Grafik", "BTC-Kalman", btc_price)
       self.Plot("Grafik", "BTC", btc)

 

 

I hope you can help me.

 

Best reagards

Marcel