Search code examples
ibrokers

How to obtain Real FX Balance via IBroker


This question is related to IBroker package.

There is a difference between Virtual FX Position and Real FX Position.

One obtains the Virtual positions by twsPortfolioValue or nested in accDetails

library(ibrokers)

tws <- twsConnect()
accDetails <- reqAccountUpdates(tws)
twsPortfolioValue(accDetails)  

Is there a way to obtain the Real FX portfolio, or the net currency exposures?


Solution

  • You get the cash balance in each currency you have. This is python but I'm sure R has some way to print all the fields in accDetails, just look.

    <updateAccountValue key=TotalCashBalance, value=1281337, currency=CAD, accountName=DU000000>
    <updateAccountValue key=TotalCashBalance, value=-310, currency=USD, accountName=DU000000>