#ValueError #Invalid #literal for #int() while running #cereber.run()
-
Pasting part of my code here . Which is simple moving average crossover. When I run cerebro.run(). I get the following error
Code:
cerebro = bt.Cerebro()
data = bt.feeds.YahooFinanceCSVData(dataname='NIFTYBEES.NS.csv')
cerebro.adddata(data)
cerebro.optstrategy(smacross,ma100=100,ma200=200)
cerebro.broker.setcash(100000)
cerebro.addsizer(bt.sizers.percents_sizer,percent=25)
cerebro.addanalyzer(bt.analyzers.SharpeRatio,_name = "Sharpe")
cerebro.addanalyzer(bt.analyzers.AnnualReturn,_name = "Annual Return")
cerebro.addanalyzer(bt.analyzers.DrawDown,_name = "Drawdown")
cerebro.addanalyzer(bt.analyzers.Returns,_name = "Returns")
cerebro.addanalyzer(bt.analyzers.standarddev,_name= "StdDev")
cerebro.addanalyzer(bt.analyzers.TimeDrawDown,_name = "Drawdown Time")bktest = cerebro.run()
cerebro.broker.get_value()Error that I get is :
ValueError -> 14 cerebro.run()
ValueError: invalid literal for int() with base 10: '28-0'
Seeking guidance on what has gone wrong and how can this be course corrected .
-
@nsananguly
Have you tried setting maxcpus=1?
cerebro.run(maxcpus=1)
I think this is needed when optimising, but I don't know if it's related to your error. -
@tony-shacklock said in #ValueError #Invalid #literal for #int() while running #cereber.run():
maxcpus=1
I actually tried it out. It worked a few times and then started throwing error.
What I did was give the int() function
self.adjclose = int(self.data[0].Adjclose)
and its working for now. Not sure if this will throw up error going further. -
@tony-shacklock said in #ValueError #Invalid #literal for #int() while running #cereber.run():
@nsananguly
Have you tried setting maxcpus=1?
cerebro.run(maxcpus=1)
I think this is needed when optimising, but I don't know if it's related to your error.I tried it out. Didnt work. But I am sure your suggestion will come handy further down the line. Thanks on that