[R-SIG-Finance] blotter on 15 min data
Brian G. Peterson
brian at braverock.com
Tue Apr 13 23:29:17 CEST 2010
On 04/13/2010 04:15 PM, kafkaz wrote:
> Q: can I use blotter on 5 min. data?
>
A: Yes. I use it on high frequency irregular and bar data all the time,
but I do not use updateEndEq (it's not really important for what I do)
so the problem may lie there.
Use dput() to output your data, str() does not create a reproducible
example. (Thank you for trying.)
Please update to current R-Forge code for blotter (there have been
several changes recently) and related/required dependencies, and re-post
a reproducible example.
I'm a little busy leading up to R/Finance in Chicago this week, but I'll
take a look at it in detail on Monday and we'll work with you to get it
fixed if you provide something we can run to reproduce your error.
Regards,
- Brian
> In my case, equity goes to 0 after first call of:
> updatePortf(ltportfolio, Dates = currentDate)
> updateAcct(ltaccount, Dates = currentDate)
> updateEndEq(ltaccount, Dates = currentDate)
>
> My data looks like this:
>
>> head(eu5min)
>>
> Open High Low Close
> 2007-01-02 02:05:00 1.3232 1.3234 1.3230 1.3234
> 2007-01-02 02:10:00 1.3233 1.3233 1.3230 1.3232
> 2007-01-02 02:15:00 1.3233 1.3234 1.3232 1.3232
> 2007-01-02 02:20:00 1.3233 1.3234 1.3229 1.3230
> 2007-01-02 02:25:00 1.3229 1.3232 1.3229 1.3231
> 2007-01-02 02:30:00 1.3230 1.3232 1.3229 1.3230
>
> Here is blotter related code:
> Sys.setenv(TZ="GMT")
> initDate=index(eu5min[1])
> rm(list=ls(envir=.blotter),envir=.blotter)
> symbols<-c('eu5min')
> initPortf(ltportfolio,symbols, initDate=initDate)
>
> initAcct(ltaccount,portfolios=c(ltportfolio),
> initDate=initDate,initEq=100000)
> currency("USD")
> stock('eu5min',currency="USD",multiplier=1)
> equity = getEndEq(ltaccount, initDate)
> print(paste('equity ',equity))
>
> for(i in 2:length(signal))
> {
> currentDate= time(signal)[i]
> print(paste('currentDate ',currentDate))
> updatePortf(ltportfolio, Dates = currentDate)
> updateAcct(ltaccount, Dates = currentDate)
> updateEndEq(ltaccount, Dates = currentDate)
> equity = getEndEq(ltaccount, currentDate)
>
> print(paste('equity ',equity))
> }
>
> Output of this code is:
> [1] "equity 1e+05"
> [1] "currentDate 2007-01-02 02:10:00"
> [1] "equity 0"
> [1] "currentDate 2007-01-02 02:15:00"
> [1] "equity 0"
> [1] "currentDate 2007-01-02 02:20:00"
> [1] "equity 0"
> [1] "currentDate 2007-01-02 02:25:00"
> [1] "equity 0"
> [1] "currentDate 2007-01-02 02:30:00"
> [1] "equity 0"
> [1] "currentDate 2007-01-02 02:35:00"
> [1] "equity 0"
>
> As you can see, equity goes down without any transaction.
>
> str(eu5min)
> An ‘xts’ object from 2007-01-02 02:05:00 to 2007-02-01 23:55:00 containing:
> Data: num [1:6509, 1:4] 1.32 1.32 1.32 1.32 1.32 ...
> - attr(*, "dimnames")=List of 2
> ..$ : NULL
> ..$ : chr [1:4] "Open" "High" "Low" "Close"
> Indexed by objects of class: [POSIXt,POSIXct] TZ: GMT
> xts Attributes:
> NULL
>
> str(signal)
> An ‘xts’ object from 2007-01-02 02:05:00 to 2007-02-01 23:55:00 containing:
> Data: num [1:6509, 1] 0 0 0 0 0 0 0 0 0 0 ...
> - attr(*, "dimnames")=List of 2
> ..$ : NULL
> ..$ : chr "Close"
> Indexed by objects of class: [POSIXt,POSIXct] TZ: GMT
> xts Attributes:
> NULL
>
> Any ideas about this? Thank you in advance.
>
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list