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/24b578628415111885d29ef97d5ab0eed1c7bb75
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