ib_hist_data | R Documentation |
Download historical data from IB API and store them as text files.
ib_hist_data(Symbol, Security_Type, Exchange, Currency, id = NULL,
directory, barSize, durationStr = NULL,
whatToShow = "TRADES",
start = as.POSIXct(Sys.Date() - 30), end = Sys.time(),
useRTH = FALSE,
skip.from, skip.until, skip.tz = "",
verbose = TRUE, trim = TRUE, accumulate = FALSE,
port = 7496, sep = ",",
filename = "%id%__%start%__%end%",
filename.datetime.fmt = identity,
backend = "rib",
clientId = NULL)
Symbol |
character |
Security_Type |
character |
Exchange |
character |
Currency |
character |
id |
character; optional: the prefix for text files. If NULL, Symbol etc. are pasted together |
directory |
character: the directory in which the files are stored |
barSize |
character |
durationStr |
character. If NULL, the function attempts to set a long duration. (This argument may be removed in the future since it rarely makes sense to set it explicitly.) |
whatToShow |
character: TRADES, MIDPOINT, BID or ASK |
start |
POSIXct |
end |
POSIXct |
useRTH |
logical |
skip.from |
character |
skip.until |
character |
skip.tz |
character |
verbose |
logical |
accumulate |
logical |
trim |
logical |
sep |
character: the column separator |
port |
the TWS port |
clientId |
either |
filename |
character: pattern for the filenames
of the stored files. May include special patterns
such as ‘ |
backend |
a lowercase string or
|
See IB API documentation https://interactivebrokers.github.io/
The package uses functionality of either package IBrokers or rib, depending on the setting of backend.
If accumulate
is TRUE
, a data.frame
of the retrieved data. If accumulate
is FALSE
(the default), a character vector: the names of the file
(including the directory) that have been saved.
Files are written in tsdb format.
Enrico Schumann
combine_files
for aggregating files
## Not run:
contr <- rib::Contract
contr$secIdType <- "ISIN"
contr$secId <- isin <- "DE0005557508"
contr$exchange <- "IBIS"
contr <- contract_details(contr)[[1]]
contr <- contr$contract
download.dir <- "~/Trading/Data/IB_downloads/"
barSize <- "5 mins"
whatToShow <- "MIDPOINT"
start <- structure(Sys.time() - 86400 * 7,
class = c("POSIXct", "POSIXt"))
ib_hist_data(Symbol = Symbol,
Security_Type = Security_Type,
Exchange = Exchange,
Currency = Currency,
id = id,
directory = download_dir,
barSize = barSize,
whatToShow = whatToShow,
start = start,
end = Sys.time())
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.