I could not get optstrategy to work
so I put the cerebro calls inside of a loop that varies the parameters I send to the
addstrategy call.
I could not get optstrategy to work
so I put the cerebro calls inside of a loop that varies the parameters I send to the
addstrategy call.
OK, dunno what I'm missing on this. It seems I am unclear on how to "fix" the collections.iterable problem.
I put in
from collections.abc import Callable, Iterable
and nothing changed. Python 3.1 and latest backtrader
and all of this still comes our screaming in RED at me.
File "C:/Users/cawort01/AppData/Local/Programs/Python/Python310/BT-Rookie_A.py", line 31, in <module>
cerebro.optstrategy(firstStrategy, period=range(14,21))
File "C:\Users\cawort01\AppData\Local\Programs\Python\Python310\lib\site-packages\backtrader\cerebro.py", line 895, in optstrategy
vals = self.iterize(kwargs.values())
File "C:\Users\cawort01\AppData\Local\Programs\Python\Python310\lib\site-packages\backtrader\cerebro.py", line 335, in iterize
elif not isinstance(elem, collections.Iterable):
AttributeError: module 'collections' has no attribute 'Iterable'
what the hell am I misunderstanding??
Chris
Hello, I stumbled across backtader after creating a whole lot of PYTHON UDF's for Excel with XLWINGS (awesome library btw)
thinking I was spiffy, I thought I'd use my existing code to create a dataframe to pass to Cerebro and use the already calculated indicators at my disposal. I didn't get it to work. so I just "rebuilt" the indicators in BT's INIT
i am really really new to BackTrader. thinking starting last friday.
This guy seems to have done it. his trading logic was off, but I think he has done what you're trying to do. I think the key is to structure the data so that Cerebro "knows" where to look for the values it is trying to work with.
https://community.backtrader.com/topic/5217/simple-macd-strategy-with-long-short-and-close
Good Luck. this is an astounding package. considering I used to do all of this years ago in C and C++ before TALIB existed.