[Blotter-commits] r704 - pkg/FinancialInstrument/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jul 27 21:15:02 CEST 2011
Author: braverock
Date: 2011-07-27 21:15:01 +0200 (Wed, 27 Jul 2011)
New Revision: 704
Modified:
pkg/FinancialInstrument/R/build_symbols.R
Log:
- minor updates from Ilya
Modified: pkg/FinancialInstrument/R/build_symbols.R
===================================================================
--- pkg/FinancialInstrument/R/build_symbols.R 2011-07-27 12:41:38 UTC (rev 703)
+++ pkg/FinancialInstrument/R/build_symbols.R 2011-07-27 19:15:01 UTC (rev 704)
@@ -44,7 +44,9 @@
#' \code{contracts_ahead} should contain a comma-delimited string describing
#' the cycle on which the guaranteed calendar spreads are to be consructed,
#' e.g. '1' for one-month spreads, '1,3' for one and three month spreads,
-#' '1,6,12' for 1, 6, and 12 month spreads, etc.
+#' '1,6,12' for 1, 6, and 12 month spreads, etc.
+#' For quarterly symbols, the correct \code{contracts_ahead} may be
+#' something like '1,2,4' for quarterly, bi-annual, and annual spreads.
#'
#' \code{active_months} is a numeric field indicating how many months including
#' the month of the \code{start_date} the contract is available to trade.
@@ -109,7 +111,7 @@
contractName<-makeNameCal(Data$primary_id[i],workingContractMonthLet,workingContractYearNum,newCalMonthLetter,newCalYearNumber)
calRow<-cbind(contractName,dataRow$type[1])
#Other data would be added here. Take in a row from root contracts, add other details (EG timezone, currency, etc...)
- calFrame<-rbind(calFrame,contractName)
+ calFrame<-rbind(calFrame,calRow)
}
return(calFrame)
}
@@ -146,12 +148,12 @@
#rbind it to the contractFrame
}
- for(j in 1:(Data$active_months[i]-1)){
- yearsAhead=trunc(j/length(monthsTraded))%%10 #aka if it's 10+ years ahead, since the year is one digit, for contracts further out than 10 years, you'll get 0, 1, 2, 3 instead of 10, 11, 12, etc.
- monthContractsAhead=j%%length(monthsTraded)
- currentContractNum<-as.numeric(contractTable[which(contractTable[,1]==currentContractMonthLet),2])
- monthIndex=currentContractNum+monthContractsAhead
- if(monthIndex>length(monthsTraded)){
+ for(j in 1:(Data$active_months[i]-1)){
+ yearsAhead=trunc(j/length(monthsTraded))%%10 #aka if it's 10+ years ahead, since the year is one digit, for contracts further out than 10 years, you'll get 0, 1, 2, 3 instead of 10, 11, 12, etc.
+ monthContractsAhead=j%%length(monthsTraded)
+ currentContractNum<-as.numeric(contractTable[which(contractTable[,1]==currentContractMonthLet),2])
+ monthIndex=currentContractNum+monthContractsAhead
+ if(monthIndex>length(monthsTraded)){
yearsAhead<-(yearsAhead+1)%%10
monthIndex=monthIndex-length(monthsTraded)
}
@@ -166,16 +168,16 @@
#rbind it to the contractFrame
}
}
- }
+ }
- rownames(contractFrame)<-NULL
- colnames(contractFrame)<-c("RICs","type")
+ rownames(contractFrame)<-NULL
+ colnames(contractFrame)<-c("RICs","type")
- if(!is.null(outputfile)){
- write.csv(contractFrame,outputfile)
- } else {
- return(contractFrame)
- }
+ if(!is.null(outputfile)){
+ write.csv(contractFrame,outputfile)
+ } else {
+ return(contractFrame)
+ }
}
###############################################################################
More information about the Blotter-commits
mailing list