getIBForexHist: Download FX Historical Data

Description Usage Arguments Details Value Examples

View source: R/IBrokersInstrument.R

Description

Makes a request to the Interactive Brokers Trader Workstation (TWS), and returns an xts object containing the results of the request if successful.

Usage

1
2
getIBForexHist(tws = NULL, duration = "5 Y", barsize = "1 day",
  Cur1 = "USD", Cur2 = "CAD")

Arguments

tws

connection to current TWS account, if NULL, a new connection will be created within the function

duration

time span the request will cover

barsize

bar size to retrieve

Cur1

symbol of the first currency

Cur2

symbol of the second currency

Details

Legal barSize settings are technically '1 secs','5 secs','15 secs','30 mins','1 min','2 mins', '3 mins','5 mins','15 mins', '30 mins','1 hour','1 day', '1 week','1 month','3 months', and '1 year'. They must be specified exactly and there is no guarantee from the API that all will work for all securities or durations. The duration string must be of the form 'n S' where the last character may be any one of 'S' (seconds), 'D' (days), 'W' (weeks), 'M' (months), and 'Y' (year). At present the limit for years is 1.

Value

A list of Bid, Ask and Bid_Ask prices

Examples

1
2
3
4
library(IBrokers)
tws <- twsConnect(port = 7497)
USDCAD <- getIBForexHist(tws, "10 Y", "1 day", "USD", "CAD")
USDAUD <- getIBForexHist(tws, "10 Y", "1 day", "AUD", "USD")

ivanliu1989/RQuantAPI documentation built on Sept. 13, 2019, 11:54 a.m.