[Blotter-commits] r115 - pkg/instrument/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 13 14:26:37 CET 2009
Author: braverock
Date: 2009-11-13 14:26:36 +0100 (Fri, 13 Nov 2009)
New Revision: 115
Modified:
pkg/instrument/R/instrument.R
Log:
- update environment handling
Modified: pkg/instrument/R/instrument.R
===================================================================
--- pkg/instrument/R/instrument.R 2009-11-13 13:11:07 UTC (rev 114)
+++ pkg/instrument/R/instrument.R 2009-11-13 13:26:36 UTC (rev 115)
@@ -14,7 +14,7 @@
## we should probably assign instruments into a special namespace and create get* functions. Jeff?
is.instrument <- function( x ) {
- x <- get(x,pos=".instrument",inherits=TRUE)
+ x <- get(x,pos=.instrument,inherits=TRUE)
inherits( x, "instrument" )
}
@@ -40,7 +40,7 @@
),
class = tclass
), # end structure
- pos=".instrument",inherits=TRUE
+ pos=.instrument,inherits=TRUE
)
}
@@ -54,7 +54,7 @@
),
class=c("stock","instrument")
), # end structure
- pos=".instrument",inherits=TRUE
+ pos=.instrument,inherits=TRUE
)
}
@@ -63,7 +63,7 @@
if(is.null(underlying_id)) warning("underlying_id should only be NULL for cash-settled futures")
- if(!exists(underlying_id, pos=".instrument",inherits=TRUE)) warning("underlying_id not found") # assumes that we know where to look
+ if(!exists(underlying_id, pos=.instrument,inherits=TRUE)) warning("underlying_id not found") # assumes that we know where to look
## now structure and return
assign(primary_id, structure( list(primary_id = future_temp$primary_id,
currency = future_temp$currency,
@@ -73,7 +73,7 @@
),
class=c("future","instrument")
), # end structure
- pos=".instrument",inherits=TRUE
+ pos=.instrument,inherits=TRUE
)
}
@@ -101,7 +101,7 @@
) # end structure
}
- assign(paste(primary_id, suffix_id), temp_series, pos=".instrument",inherits=TRUE)
+ assign(paste(primary_id, suffix_id), temp_series, pos=.instrument,inherits=TRUE)
}
option <- function(primary_id , currency , multiplier , identifiers = NULL, ..., underlying_id){
@@ -109,7 +109,7 @@
if(is.null(underlying_id)) warning("underlying_id should only be NULL for cash-settled options")
- if(!exists(underlying_id, pos=".instrument",inherits=TRUE)) warning("underlying_id not found") # assumes that we know where to look
+ if(!exists(underlying_id, pos=.instrument,inherits=TRUE)) warning("underlying_id not found") # assumes that we know where to look
## now structure and return
assign(primary_id, structure( list(primary_id = option_temp$primary_id,
currency = option_temp$currency,
@@ -119,7 +119,7 @@
),
class=c("option","instrument")
), # end structure
- pos=".instrument",inherits=TRUE
+ pos=.instrument,inherits=TRUE
)
}
@@ -144,11 +144,10 @@
) # end structure
}
- assign(paste(primary_id, suffix_id), temp_series, pos=".instrument",inherits=TRUE)
+ assign(paste(primary_id, suffix_id), temp_series, pos=.instrument,inherits=TRUE)
}
currency <- function(primary_id , currency=NULL , multiplier=1 , identifiers = NULL, ...){
- currency_temp = instrument(primary_id , currency=primary_id , multiplier=1 , identifiers = identifiers, ..., type="currency")
## now structure and return
assign(primary_id, structure( list(primary_id = primary_id,
type = "currency",
@@ -158,20 +157,20 @@
),
class=c("currency","instrument")
), # end structure
- pos=".instrument",inherits=TRUE
+ pos=.instrument,inherits=TRUE
)
}
is.currency <- function( x ) {
- x <- get(x,pos=".instrument",inherits=TRUE)
+ x <- get(x,pos=.instrument,inherits=TRUE)
inherits( x, "currency" )
}
exchange_rate <- function (primary_id , currency , second_currency, identifiers = NULL, ...){
exchange_rate_temp = instrument(primary_id , currency , multiplier=1 , identifiers = identifiers, ..., type="exchange_rate")
- if(!exists(currency, pos=".instrument",inherits=TRUE)) warning("currency not found") # assumes that we know where to look
- if(!exists(second_currency, pos=".instrument",inherits=TRUE)) warning("second_currency not found") # assumes that we know where to look
+ if(!exists(currency, pos=.instrument,inherits=TRUE)) warning("currency not found") # assumes that we know where to look
+ if(!exists(second_currency, pos=.instrument,inherits=TRUE)) warning("second_currency not found") # assumes that we know where to look
## now structure and return
assign(primary_id, structure( list(primary_id = primary_id,
@@ -181,10 +180,10 @@
),
class=c("exchange_rate","instrument")
), # end structure
- pos=".instrument",inherits=TRUE
+ pos=.instrument,inherits=TRUE
)
}
getInstrument <- function(x){
- get(x,pos=".instrument",inherits=TRUE)
+ get(x,pos=.instrument,inherits=TRUE)
}
\ No newline at end of file
More information about the Blotter-commits
mailing list