flex_web_service: Flex Web Service

View source: R/ib_hist_data.R

flex_web_serviceR Documentation

Flex Web Service

Description

Retrieve queries via the Flex Web Service.

Usage

flex_web_service(file, token, query, version = 3, delay = 2,
                 no.write.msg = TRUE, no.write.warn = TRUE,
                 verbose = TRUE)

Arguments

file

character: filename for the downloaded report

token

character (not numeric!)

query

integer

version

integer; currently only 3 is supported

delay

integer: number of seconds to wait between sending the token and retrieving the flex-data report

no.write.msg

logical: do not write file if it contains a message

no.write.warn

logical: do not write file if it contains a warning

verbose

logical: sets the 'quiet' argument of download.file

Details

Retrieve flex queries via download.file.

The function also checks whether the downloaded file contains messages from IB (lines that start with “MSG”).

Value

The function is called for its side effect: downloading and storing the flex query.

The function will first send token and query to IB. If the response does not contain a

<Status>Success</Status>

, the complete response will be printed and a value of 1 is invisibly returned.

Otherwise, an attempt to download the report is made, and the return value of download.file will be invisibly returned.

However, even if the download succeeds, the file may contain error messages or warnings. Even mere ‘messages’ often indicate that something did not work (e.g. particular accounts could not be included). flex_web_service will print messages or warnings that it finds in the files, and the return value will be invisible 1. The downloaded file will not be written in such a case, unless no.write.msg and no.write.warn are set to FALSE; both arguments default to TRUE.

Author(s)

Enrico Schumann

References

https://ibkrcampus.com/ibkr-api-page/flex-web-service/

See Also

ib_hist_data, download.file

Examples

## Not run: 
flex_web_service(file = "~/my_files/my_report.csv",
                 token = "12345678901234567890", ## character!
                 query = 123)

file <- "~/Downloads/Net_Asset_Value_NAV_in_Base"
ans <- read_flex_report(file)


## End(Not run)

enricoschumann/IButils documentation built on March 13, 2024, 3:36 p.m.