4
$\begingroup$

I'm trying to create a dashboard where I can show my clients their account positions, updated on a daily basis. I know IB offers the TWS/IB Gateway solution however I'm looking for a more lightweight way to automate the collection of account position data on a daily basis. My issue with TWS/IB Gateway is that they need to be installed and run with a GUI, which makes it difficult to do so using a headless server (e.g. using AWS).

I've considered parsing account statements using ib-flex-analyzer (I believe they are HTML) however I'm not sure how I would automatically download all individual the account statements in the first place.

$\endgroup$

1 Answer 1

8
$\begingroup$

IB has something called "Flex Web Service", which allows you to download flex queries without being logged in; see Using the Flex Web Service. The R package IButils, which I maintain, has a function flex_web_service, which allows you to download queries. In R, you could write:

library("IButils")
flex_web_service(file = "~/my_files/my_report.csv",
                 token = "12345678901234567890",
                 query = 123)

This would download your flex query 123 and store it under the specifed file name.

$\endgroup$
4
  • $\begingroup$ Interesting. What is the "token"? $\endgroup$
    – nbbo2
    Jan 11, 2018 at 14:30
  • 1
    $\begingroup$ You get it from IB: before you can use the service, you need to activate it in account management; then you receive the token. $\endgroup$ Jan 11, 2018 at 15:47
  • $\begingroup$ Interesting. I hadn't heard of Flex Web Service but I'll look into this! So if I understand correctly, I define the query on IB's website and then I run the query like you did here, like a bonafide Web API? $\endgroup$
    – Jad S
    Jan 11, 2018 at 16:37
  • $\begingroup$ Yes; in account management, define a flex query, to which IB will assign some number (argument query in the above function). Also in account management, activate Flex Web Service and note the token. With query number and token you can now download the flex query without being logged in. $\endgroup$ Jan 11, 2018 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.