For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

backtrader connection errors



  • am getting the error''ModuleNotFoundError: No module named 'backtrader'
    anytime i run any code in the ide

    from future import (absolute_import, division, print_function,
    unicode_literals)

    import backtrader as bt

    if name == 'main':
    cerebro = bt.Cerebro()

    print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())
    
    cerebro.run()
    
    print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
    

    ModuleNotFoundError Traceback (most recent call last)
    <ipython-input-1-bd9375d3f4ab> in <module>
    2 unicode_literals)
    3
    ----> 4 import backtrader as bt
    5
    6 if name == 'main':

    ModuleNotFoundError: No module named 'backtrader'



  • First guess would be that the script you try to run has backtrader.py name. Rename it. If it doesn't fix the error, than you have some issue swith the installation. Feel free to google how to fix ModuleNotFoundError: error. Correctly installed and used bt doesn't return this error.


Log in to reply
 

});