module 'backtrader.stores' has no attribute 'IBStore'
-
ibpy2 is installed and it can import.
But when I test this code:
import ib import backtrader as bt store = bt.stores.IBStore(port=7497)'
I get the error:
AttributeError: module 'backtrader.stores' has no attribute 'IBStore'
Can someone help me?
-
You didnt import the module
ibstore
. Try e.g.import backtrader.stores.ibstore as ibstore store = ibstore.IBStore(port=7497)
-
Thx@vbs, I tried it but got the same error.
AttributeError: module 'backtrader.stores.ibstore' has no attribute 'IBStore'
-
@vbs said in module 'backtrader.stores' has no attribute 'IBStore':
import backtrader.stores.ibstore
Hm please open a python shell and do this:
import backtrader.stores.ibstore
and then
dir(backtrader.stores.ibstore)
and post the output.
-
python shell output
>>> import backtrader.stores.ibstore >>> dir(backtrader.stores.ibstore) ['AutoDict', 'Contract', 'IBStore', 'MetaParams', 'MetaSingleton', 'Position', 'RTVolume', 'TimeFrame', 'UTC', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_ts2dt', 'absolute_import', 'bstr', 'bytes', 'collections', 'copy', 'date', 'datetime', 'division', 'ibopt', 'ibregister', 'inspect', 'itertools', 'long', 'print_function', 'queue', 'random', 'threading', 'time', 'timedelta', 'unicode_literals', 'with_metaclass'] >>>
-
IBStore
is clearly in there, I can see it :PAnd you are sure that this does not work now? Well, it has to work
store = backtrader.stores.ibstore.IBStore(port=7497)
-
I think I found the problem, but I don't know how to fix it.
When I used the python shell, it didn't report an error.
But when I use python script, it gives an error.AttributeError: module 'backtrader.stores' has no attribute 'ibstore'
-
Finally, I found the problem and solved it.
My file name is ib.py, which is the same as the module name of ibpy.
Anyway, thank you all.