SCM

SCM Repository

[blotter] View of /pkg/quantstrat/demo/luxor.4.Timespans.tradegraphs.R
ViewVC logotype

View of /pkg/quantstrat/demo/luxor.4.Timespans.tradegraphs.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1376 - (download) (annotate)
Mon Jan 21 23:41:11 2013 UTC (6 years, 6 months ago) by milktrader
File size: 1249 byte(s)
stubbed new in_test blocks
#!/usr/bin/Rscript --vanilla

require(quantstrat)

load('../data/luxor.timespan.24x24.2002-2008.RData')

names(stats)[names(stats)=='testPackListPRL[[k]]$parameters']<-'timespan'

stats$tmp = strsplit(as.character(stats$timespan),'/')

stats$from<-sapply(stats$tmp,FUN='[',1)
stats$to<-sapply(stats$tmp,FUN='[',2)

stats$start<-as.numeric(gsub('T([0-9]+):[0-9]+',x=stats$from,'\\1'))
stats$stop<-(as.numeric(gsub('T([0-9]+):[0-9]+',x=stats$to,'\\1'))+1)%%24

# trading data is in EST (GMT-4): move 4 hours to adjust to GMT
#stats$start<-(stats$start+4)%%24
#stats$stop<-(stats$stop+4)%%24

tradeGraphs(
	stats,
	free.params=c('start','stop'),
	statistics=c('Net.Trading.PL','maxDrawdown',"Avg.Trade.PL",'Num.Trades',"Profit.Factor"),
	title = 'Luxor Intraday TimeWindow Scan'
)

##### PLACE DEMO AND TEST DATES HERE #################
#
#if(isTRUE(options('in_test')$in_test))
#  # use test dates
#  {initDate="2011-01-01" 
#  endDate="2012-12-31"   
#  } else
#  # use demo defaults
#  {initDate="1999-12-31"
#  endDate=Sys.Date()}

##### PLACE THIS BLOCK AT END OF DEMO SCRIPT ################### 
# book  = getOrderBook(port)
# stats = tradeStats(port)
# rets  = PortfReturns(acct)
################################################################

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge