I'm working on a universe/Strategy combination. I'm using volume levels in the universe selection, but I am also using a strategy to select which symbols will be included daily. There is then supposed to be a sec, min, and hour strategy frame that are traded on more or less seperatly, with some values from the frame higher being included in some logic.
My current code builds without issue, but throws this error on compile time. "If using all scalar values, you must pass an index" seems like it's my main small issue:
Algorithm.Initialize() Error: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/main.pyc. AlgorithmPythonWrapper(): ValueError : If using all scalar values, you must pass an index
at __init__ in main.py:line 632
ValueError : If using all scalar values, you must pass an index Stack Trace: QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/main.pyc. AlgorithmPythonWrapper(): ValueError : If using all scalar values, you must pass an index
at __init__ in main.py:line 632
ValueError : If using all scalar values, you must pass an index at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x0006c] in :0
at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath) [0x0015d] in :0
I can include more code, but there is a lot. Below is an example of the hour class init, which is where my error says the code triggers. when called it is
Hour.Initialize(symbol,frame)
I understand that I can restructure to the reccommended framework and inits, but I would also like to see if there is a solution to this, cause I feel like there's potential to play with it.
Many thanks.
class Hour(QCAlgorithm):
def __init__(self):
self.params = pd.DataFrame({'is_up': False,'is_down': False,
' trade': False,'tolerance':1.01,
'strength': 0})
self.data = pd.DatFrame({'open':[],
'high':[],
'low':[],
'close':[],
'volume':[],
'closeTime':[]})
self.trades = pd.DataFrame({'long':[],
'short':[]})
def Initialize(self, symbol, frame):
self.symbol = symbol
self.inds = {'ALMA':{'fast':ALMA(symbol, 20, 6, .15),
'slow':ALMA(symbol, 100, 6, .85),
'alma':inds['ALMA']['fast'] - (
inds['ALMA']['slow'] *
self.params['tolerance'])},
'ATR':{'AATR':ATR(
symgbol, period = 20,
type = Alma),
'EATR':ATR(
symgbol, period = 20,
type = Exponential),
'atr':(
inds['ATR']['AATR'] +
inds['ATR']['EART']) /2},
'AROON':AROON(symbol, 50),
'ADOSC':ADOSC(symbol, 100, 200)}
Jack Simonson
Hi Brent,
Could you provide more of your code or a backtest, even if some of the code needs to be commented out? This will better help me identify the source of the error and provide you with a solution.
Brent Lewis
I cut out a portion of the logic just to try and keep it short. Fixed the initial error, and added the data consolidator to the main file (it had previously been in Symbolbox) Mostly just trying to figure out the best way to update the indicators and what structure to put the mutli-timeframe objects into.
https://www.quantconnect.com/forum/discussion/5843/how-to-create-and-add-to-pandas-dataframe-from-tradebar/p1Found this from yesterday, seems interesting, but I haven't digested it.
Brent Lewis
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!