[R-SIG-Finance] BuildIBContract odd behavior

Mark Harrison harrisonmark1 at gmail.com
Fri Feb 10 00:19:54 CET 2012


I am using Interactive Brokers and R to download and maintain forex
data in addition to doing some analytics on each currency pair.  I
have setup Financial Instrument per Garrett's instructions and have
edited my rProfile site file to define all the available currencies
and exchange rate pairs.

Each day I run a script that connects to TWS using iBrokers and loop
through all the currency pairs defining a contract for each using
twsInstrument.  The script then requests data from IB and saves the
data into each currency pairs folder in my home directory.

The issue I am having is that for the Norwegian Krone I get a message
when I grab data for GBPNOK - the first Norwegian currency in my
symbol list - which is "Checking to see if other 'type's have a
pre-defined currency."  I am getting data for this pair as well as all
the other NOK currency pairs.

When my script completes I get the warning: "In
buildIBcontract(symbol) : Creating currency  NOK"

I have looked through my rProfile and script and can find no reason
why I should get this message and warning since I have both defined
the currency "NOK" and exchange rates using NOK - i.e. GBPNOK, EURNOK,
NOKSEK, etc..  I also get data for each 'NOK' pair so everything seems
like it is working.

I realize I am only getting a warning and I am still able to get the
data I am after but this is bugging me because I cannot figure it out
and it is making me think I have a bigger problem.

Any help would be appreciated.  By the way, I have been digging
through the support lists but finding no answer.

# Session Info
R version 2.14.0 (2011-10-31)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] datasets  grDevices utils     graphics  stats     methods   base

other attached packages:
 [1] fTrading_2100.76           fBasics_2110.79            MASS_7.3-16
 [4] timeSeries_2130.92         timeDate_2131.00
twsInstrument_1.2-9
 [7] IBrokers_0.9-3             qmao_1.1.6
FinancialInstrument_0.9.20
[10] quantmod_0.3-17            TTR_0.21-0                 xts_0.8-2
[13] zoo_1.7-6                  Defaults_1.1-1

loaded via a namespace (and not attached):
[1] blotter_0.8.4    grid_2.14.0      lattice_0.20-0
quantstrat_0.6.1 tools_2.14.0


#  rProfile
# Packages to load at startup
require(quantmod)
require(qmao)
require(IBrokers)
require(FinancialInstrument)
require(twsInstrument)
require(fTrading)

#Define Currencies
currency(c("AUD", "CAD", "CHF", "CZK", "DKK", "EUR", "GBP", "HKD",
"HUF", "ILS", "JPY", "KRW", "MXN", "NOK", "NZD", "PLN", "RUB", "SEK",
"SGD", "USD"))

#Define British Pound Based Exchange Rates
exchange_rate(c("GBPAUD", "GBPCAD", "GBPCHF", "GBPHKD", "GBPJPY",
"GBPNOK", "GBPNZD", "GBPUSD"))

--------------------------------------------------------


# Script code examples
symbols <- c("GBPJPY", "GBPMXN", "GBPNOK", "GBPNZD", "GBPUSD")

for(symbol in symbols){
# Build Contract
contract <- buildIBcontract(symbol)

# at this point I request data and save the files...I can provide the
code if needed.



More information about the R-SIG-Finance mailing list