Hi,
I'm new to QC platform.
I want to incorporate my ML model saved as pkl file in backtesting and later live trading on quantconnect.
My first ptoblem is that I don't know how to calculate ta_lib indicators. I create simple example that does not work:
import pandas as pd
import numpy as np
from talib.abstract import (
DEMA, EMA, MIDPRICE, SMA, T3, TEMA, TRIMA, WMA,
ADX, ADXR, AROONOSC, BOP, CMO, DX, MFI, MINUS_DM, MOM, ROC, RSI,
TRIX , WILLR, ATR, NATR, BBANDS, AROON, STOCHRSI,
HT_TRENDLINE, AD, OBV, HT_DCPERIOD, HT_DCPHASE, HT_TRENDMODE,
TRANGE, AVGPRICE, MEDPRICE, TYPPRICE, WCLPRICE, ULTOSC,
MAMA, SAR, SAREXT, APO, MACD, ADOSC,
HT_PHASOR, HT_SINE, STOCHF, STOCH
)
# GLOBALS
periods = [5, 30, 60, 300, 480, 2400, 12000, 96000]
class CalibratedResistanceAtmosphericScrubbers(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 12, 31) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddEquity("SPY", Resolution.Minute)
model = self.Download("https://github.com/MislavSag/trademl/blob/master/trademl/modeling/rf_model.pkl")
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
open_ = self.Securities["SPY"].Open
high_ = self.Securities["SPY"].High
low_ = self.Securities["SPY"].Low
close_ = self.Securities["SPY"].Close
volume_ = self.Securities["SPY"].Volume
dema = DEMA(np.array(close_), 30)
self.Debug(f'DEMA value is equal to: {dema}')
If I ran this, it returns an error:
Runtime Error: TypeError : Argument 'real' has incorrect type (expected numpy.ndarray, got NoneType) at OnData in main.py:line 81 TypeError : Argument 'real' has incorrect type (expected numpy.ndarray, got NoneType)
Mislav Sagovac
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!