[Blotter-commits] r638 - in pkg/FinancialInstrument: R data man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jun 24 16:03:50 CEST 2011
Author: braverock
Date: 2011-06-24 16:03:50 +0200 (Fri, 24 Jun 2011)
New Revision: 638
Modified:
pkg/FinancialInstrument/R/instrument.R
pkg/FinancialInstrument/data/currencies.csv
pkg/FinancialInstrument/man/exchange_rate.Rd
Log:
- switch second_currency to counter_currency and update docs to avoid confusion with FX market convention. kudos to Garrett See for working through issues
Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R 2011-06-24 14:02:05 UTC (rev 637)
+++ pkg/FinancialInstrument/R/instrument.R 2011-06-24 14:03:50 UTC (rev 638)
@@ -334,20 +334,32 @@
}
#' constructor for spot exchange rate instruments
+#'
+#' Currency symbols (like any symbol) may be any combination of alphanumeric characters,
+#' but the FX market has a convention that says that the first currency in a
+#' currency pair is the 'target' and the second currency in the symbol pair
+#' is the currency the rate ticks in. So 'EURUSD' can be read as 'USD per 1 EUR'.
+#'
+#' In \code{FinancialInstrument} the \code{currency} of the instrument should
+#' be the currency that the spot rate ticks in, so it will typically be the second
+#' currency listed in the symbol.
+#'
+#' Thanks to Garrett See for helping sort out the inconsistencies in different naming and calculating conventions.
#' @param primary_id string identifier, usually expressed as a currency pair 'USDYEN' or 'EURGBP'
-#' @param currency string identifying front currency
-#' @param second_currency string identifying second currency
+#' @param currency string identifying the currency the exchange rate ticks in
+#' @param counter_currency string identifying the currency which the rate uses as the base 'per 1' multiplier
#' @param identifiers named list of any other identifiers that should also be stored for this instrument
#' @param ... any other passthru parameters
+#' @references http://financial-dictionary.thefreedictionary.com/Base+Currency
#' @export
-exchange_rate <- function (primary_id , currency , second_currency, identifiers = NULL, ...){
+exchange_rate <- function (primary_id , currency , counter_currency, identifiers = NULL, ...){
# exchange_rate_temp = instrument(primary_id , currency , multiplier=1 , tick_size=.01, identifiers = identifiers, ..., type="exchange_rate")
if(!exists(currency, where=.instrument,inherits=TRUE)) warning("currency not found") # assumes that we know where to look
- if(!exists(second_currency, where=.instrument,inherits=TRUE)) warning("second_currency not found") # assumes that we know where to look
+ if(!exists(counter_currency, where=.instrument,inherits=TRUE)) warning("counter_currency not found") # assumes that we know where to look
## now structure and return
- exrate_temp= instrument(primary_id=primary_id , currency=currency , multiplier=1 , tick_size=.01, identifiers = identifiers, ..., secon_currency=second_currency, type=c("exchange_rate","currency"), assign_i=TRUE)
+ exrate_temp= instrument(primary_id=primary_id , currency=currency , multiplier=1 , tick_size=.01, identifiers = identifiers, ..., counter_currency=counter_currency, type=c("exchange_rate","currency"), assign_i=TRUE)
}
#TODO auction dates, coupons, etc for govmt. bonds
Modified: pkg/FinancialInstrument/data/currencies.csv
===================================================================
--- pkg/FinancialInstrument/data/currencies.csv 2011-06-24 14:02:05 UTC (rev 637)
+++ pkg/FinancialInstrument/data/currencies.csv 2011-06-24 14:03:50 UTC (rev 638)
@@ -1,4 +1,4 @@
-"primary_id","description","type","currency","second_currency"
+"primary_id","description","type","currency","counter_currency"
"USD","US Dollar","currency",,
"JPY","Japanese Yen","currency",,
"CAD","Canadian Dollar","currency",,
@@ -12,14 +12,15 @@
"AED","United Arab Emirates, Dirhams","currency",,
"KRW","Korea (South), Won","currency",,
"HKD","Hong Kong Dollar","currency"," ",
-"USDEUR",,"exchange_rate","USD","EUR"
-"USDJPY",,"exchange_rate","USD","JPY"
-"JPYEUR",,"exchange_rate","JPY","EUR"
-"USDAUD",,"exchange_rate","USD","AUD"
-"USDSGD",,"exchange_rate","USD","SGD"
-"EURSGD",,"exchange_rate","EUR","SGD"
-"USDBRL",,"exchange_rate","USD","BRL"
-"EURZAR",,"exchange_rate","EUR","ZAR"
-"EURAED",,"exchange_rate","EUR","AED"
-"USDKRW",,"exchange_rate","USD","KRW"
-"USDHKD",,"exchange_rate","USD","HKD"
+"USDEUR",,"exchange_rate","EUR","USD"
+"EURUSD",,"exchange_rate","USD","EUR"
+"USDJPY",,"exchange_rate","JPY","USD"
+"JPYEUR",,"exchange_rate","EUR","JPY"
+"USDAUD",,"exchange_rate","AUD","USD"
+"USDSGD",,"exchange_rate","SGD","USD"
+"EURSGD",,"exchange_rate","SGD","EUR"
+"USDBRL",,"exchange_rate","BRL","USD"
+"EURZAR",,"exchange_rate","ZAR","EUR"
+"EURAED",,"exchange_rate","AED","EUR"
+"USDKRW",,"exchange_rate","KRW","USD"
+"USDHKD",,"exchange_rate","HKD","USD"
Modified: pkg/FinancialInstrument/man/exchange_rate.Rd
===================================================================
--- pkg/FinancialInstrument/man/exchange_rate.Rd 2011-06-24 14:02:05 UTC (rev 637)
+++ pkg/FinancialInstrument/man/exchange_rate.Rd 2011-06-24 14:03:50 UTC (rev 638)
@@ -1,10 +1,21 @@
\name{exchange_rate}
\alias{exchange_rate}
\title{constructor for spot exchange rate instruments...}
-\usage{exchange_rate(primary_id, currency, second_currency, identifiers, ...)}
+\usage{exchange_rate(primary_id, currency, counter_currency, identifiers, ...)}
\description{constructor for spot exchange rate instruments}
+\details{Currency symbols (like any symbol) may be any combination of alphanumeric characters,
+but the FX market has a convention that says that the first currency in a
+currency pair is the 'target' and the second currency in the symbol pair
+is the currency the rate ticks in. So 'EURUSD' can be read as 'USD per 1 EUR'.
+
+In \code{FinancialInstrument} the \code{currency} of the instrument should
+be the currency that the spot rate ticks in, so it will typically be the second
+currency listed in the symbol.
+
+Thanks to Garrett See for helping sort out the inconsistencies in different naming and calculating conventions.}
+\references{http://financial-dictionary.thefreedictionary.com/Base+Currency}
\arguments{\item{primary_id}{string identifier, usually expressed as a currency pair 'USDYEN' or 'EURGBP'}
-\item{currency}{string identifying front currency}
-\item{second_currency}{string identifying second currency}
+\item{currency}{string identifying the currency the exchange rate ticks in}
+\item{counter_currency}{string identifying the currency which the rate uses as the base 'per 1' multiplier}
\item{identifiers}{named list of any other identifiers that should also be stored for this instrument}
\item{...}{any other passthru parameters}}
More information about the Blotter-commits
mailing list