[R-SIG-Finance] Error in addTxn - Quantstrat

John Kumar rjkft at yahoo.com
Wed May 24 22:46:38 CEST 2017


Thanks for taking the time to look at this guys. Sorry for the verbose example but minimal means different things to different people depending on their skills, or lack thereof in my case. Cheers
John

-----Original Message-----
From: Joshua Ulrich [mailto:josh.m.ulrich at gmail.com] 
Sent: Wednesday, 24 May 2017 10:31 PM
To: Daniel Cegiełka <daniel.cegielka at gmail.com>
Cc: John Kumar <rjkft at yahoo.com>; r-sig-finance <R-SIG-Finance at r-project.org>
Subject: Re: [R-SIG-Finance] Error in addTxn - Quantstrat

On Wed, May 24, 2017 at 1:10 PM, Daniel Cegiełka <daniel.cegielka at gmail.com> wrote:
> 2017-05-24 19:45 GMT+02:00 Joshua Ulrich <josh.m.ulrich at gmail.com>:
>>
>> This is a bug that was introduced here:
>> https://github.com/braverock/blotter/commit/24b578628415111885d29ef97
>> d5ab0eed1c7bb75
>
>
> https://github.com/braverock/blotter/commit/24b578628415111885d29ef97d
> 5ab0eed1c7bb75#diff-7347fe5a0f184f79ef064e92e3beb297R69
>
> https://github.com/braverock/blotter/blob/master/R/addTxn.R#L85
>
> why end() from stats?
>
Because stats::end is the generic.

> https://github.com/braverock/blotter/blob/master/R/addTxn.R#L154
>
> Should be end.xts(), eg:
>
end.xts() is not exported from the xts namespace.  And it's generally a bad idea to call methods directly, because you do not know if that method will be able to handle objects of different classes.

> end.xts <- function (x, ...)
> {
>     if (!length(x)) {
>         index(x[length(.index(x)), ])
>     } else
>         index(x[NROW(x), ])
> }
>
> If I understood the problem correctly...
>
> Best,
> Daniel
>
>
>>
>>
>>
>> Here's a *minimal* reproducible example:
>> require(blotter)
>> currency("USD")
>> initPortf("test", symbols="AAPL", currency="USD")
>>
>> addTxn("test", "AAPL", as.Date("2017-01-01"),  1, 10) addTxn("test", 
>> "AAPL", as.Date("2017-01-02"), -1, 10)
>>
>> Thanks for the report!  I'll work on a fix.
>>
>> Best,
>> Josh
>>



--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2017 | www.rinfinance.com



More information about the R-SIG-Finance mailing list