Start of day balance in IB

Discussion in 'Automated Trading' started by N2M, Nov 26, 2021.

  1. N2M

    N2M

    Does anyone know where I can find the start of day balance?

    I'm trying to code a killswitch if the value of the account drops by a certain percentage from the start of day value.

    Thanks

    P.S. I'm also open to any ideas that accomplish the same thing with the available IB api requests.
     
  2. Use current balance + realized + unrealized pnl to get original probably.
     
    N2M likes this.
  3. N2M

    N2M

    Thanks for this.. this was the same suggestion I got from IB.

    Along these lines I scripted my code to assign the cash value to a variable that only happens once a day at 930 so as my cash changes, that one variable stays static.

    all is well once again!

    N2M
     
  4. IB calls this the Net Liquidation Value. It is calculated and updated constantly and can be requested via the API.
     
    murray t turtle likes this.
  5. N2M

    N2M

    Still open to ideas, my solution is really just a shitty bandaid, ive already found holes in it, that are too cumbersome to adjust on the fly.
     
  6. Yeah sorry I meant current balance - realized daily - unrealized daily that should get you to the starting point but I"m very bad at arithmetic.
     
  7. nlv = starting balance + realized pnl + unrealized pnl
    nlv - realized pnl - unrealized pnl = starting balance

    math checks out, nobel prize in the mail.
     
  8. Kalanim

    Kalanim

    You can never really catch it.
    The guys have correctly advised you that the only option that works is an order you have prepared in advance, anything else will already be a bit of a missed opportunity.
    You should understand that the market will always "cheat" you and it will be hard for you to control everything that happens, which is why all you can do is properly allocate the capital you will keep safe so that you always have some chance to reassure yourself or change your mind if something unexpected happens or something that was not anticipated before.
    This is one of the most difficult things in our business, but it is definitely important to accept and understand.
     
  9. KevinBB

    KevinBB

    Why don't you just look at the previous day's closing balance, from the statement?
    KH
     
    #10     Nov 30, 2021
    murray t turtle and N2M like this.