Closed SamoPP closed 5 years ago
Thanks for the report! I will investigate.
Hi Samo. I'm trying to replicate this using the demo account, but I'm not able to. Can you try replicating this issue with the demo account? That would confirm whether my inability to replicate is due to the demo account, or something with my local setup.
Hi Joshua. Have you tried during regular trading hours (RTH) for SPY (form 09:30 to 16:00 EST)? Most of the time, if I run this outside RTH there is no data being sent from IB so therefore no error can be triggered/generated/replicated...
It's hard for me to test during regular trading hours, because I'm almost always at work and I don't have access to TWS. I tried to replicate this issue using ES futures, since that market is open before I go to work. I also tried it using a FX ticker. I assume this error occurs for instruments other than SPY?
I still wasn't able to reproduce the error using TWS, but the source of the problem is eWrapper.data.BID_ASK_OHLCV.R:L30, which is:
attr(data[[id]],"index") <- as.numeric(Sys.time())
That line assigns to the index directly, and does not include the required tclass
and tzone
attributes on the index. I could patch xts to work around that error, but the fix should be done in the twsInstrument
package. I'll reach out to @gsee to see how he would like to handle this.
My proposed patch would be to change the attr(data[[id]], "index") <-
to .index(data[[id]]) <-
, but even that wouldn't fix the error. .index<-
would need to ensure that the existing index attributes are added to the new numeric index value.
The error is thrown by this switch()
statement, because value[[1]]
(the first element of the class
attribute) is ""
.
There's a check to see if is.null(value[[1]])
is TRUE
. value
is the result of tclass(x)
, which will never be NULL
because tclass()
currently returns ""
if it can't find an index class attribute. The relevant lines of code start on tclass.R:38. I would have to investigate what might break if tclass()
returned NULL
instead of ""
in these cases.
I think the reason I made tclass()
return ""
instead of NULL
is because Sys.timezone()
returns ""
when it can't determine the operating system's TZ
.
Description
twsInstrument::get_quote()
fails using latest github version of xtsExpected behavior
Backward compatibility expected.
Minimal, reproducible example
Session Info