Open isomorphisms opened 7 years ago
Can you please provide an example that doesn't depend on an external package? I don't understand the %>%
logic here, and I think it may be leading to your difficulty/misunderstanding.
It's also unclear what behavior you're expecting. "xts.thing %>% merge.xts %>% OpCl
should go through each symbol and OpCl
it." I don't understand why you would call merge()
on a single object. And I don't understand what you mean by (essentially OpCl(xts_object)
) "should go through each symbol".
require(quantmod)
getSymbols( c('^GDAXI','GLD') )
merge.xts( GDAXI, GLD, join='inner') -> gld.gdaxi
cbind(Op(gld.gdaxi),Cl(gld.gdaxi)) -> gld.gdaxi.opcl
OpCl(gld.gdaxi.opcl)
Here is the error message:
> OpCl(gld.gdaxi.opcl)
Error in xts(new.x, x.index) : NROW(x) must match length(order.by)
In addition: Warning message:
In `dim<-.zoo`(`*tmp*`, value = NULL) :
setting this dimension may lead to an invalid zoo object
Looking around in the code for quantmod::Delt
there is a line that sets dim(x2) <- NULL
. In my limited debugging attempts I think that line may be operative here.
By "go through each symbol" I mean that I would like to add something like an xtApply
or apply.xts
(even just as an alias for existing functionality) which, when given something like a cbind( GDAXI, GLD, SPY )
(properly classed and structured), can OpCl( cbind( GDAXI, GLD, SPY ) )
and return three Delt
s, cbind
ed together.
Here is a related problem (maybe needs separate issue, maybe not).
require(quantmod)
getSymbols( '^GDAXI', 'GLD' )
merge.xts(GDAXI,GLD, join='inner') -> gdaxi.gld
apply(gdaxi.gld.opcl,2,OpCl)
This raises an error of:
Error in Op(x) :
subscript out of bounds: no column name containing "Open"
Now, whether I’m using the correctly *ply
or not, it is the case that the column names contain Open, as seen by:
> names(gdaxi.gld.opcl)
[1] "GDAXI.Open" "GLD.Open" "GDAXI.Close" "GLD.Close"
Running lapply
instead of apply(..., 2, ...)
gives a similar (wrong) error about no columns having Close
in the name.
Description
OpCl
norsapply(OpCl)
don’t work oncbind
ed xxts data.frames the way I expectExpected behavior
xts.thing %>% merge.xts %>% OpCl
should go through each symbol andOpCl
it.Minimal, reproducible example
but if I subbed
OpCl
for{function(x) cbind(Op(x),Cl(x))}()
I would getSession Info