Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Interactive Brokers "Broker" function issue

    General Code/Help
    2
    2
    502
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cwse last edited by

      Hi there!

      I am trying to connect to IB TWS and retrieve positions and balances.

      However, the IB script just returns "0.0" for both Value and Cash, which is incorrect. My script:

      import backtrader as bt
      
      cerebro = bt.Cerebro()
      ibstore = bt.stores.IBStore(port=7496, clientId=123,timeout=180,reconnect=3)
      cerebro.broker = ibstore.getbroker()  # or cerebro.setbroker(...)
      
      print(cerebro.broker.getvalue())
      print(cerebro.broker.getcash())
      
      

      What am I missing? How can I fix this to display the correct values and cash positions, instead of "0.0"?

      Thank you!
      CWSE

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        cerebro is not running, which means there is no communication with the broker. Anything other than 0.0 would be a surprise.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors