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/

    Getting current equity from IB

    General Discussion
    1
    1
    19
    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.
    • G
      Gianlu last edited by

      Hello, I am able to retrieve current IB Account balance (only) during IB-live sessions with self.broker.getvalue() inside next function, when strategies are running (store + strategies + cerebro).

      Unfortunately I am not able to fetch the same outside strategies.

      For this purpose I found ib_insync library and with few lines (*) is possible to get what I am looking for.

      Is it possible get the same result with backtrader (without ib_insync)?


      (*)

      from ib_insync import *
      
      ib = IB()
      ib.connect('127.0.0.1', 4002, clientId=10)
      p = ib.positions()
      t = ib.openTrades()
      v = [v for v in ib.accountValues() if v.tag == 'NetLiquidationByCurrency' and v.currency == 'BASE']
      
      print(p, t, v)
      

      Thanks in advance

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