Over the weekend, the ActualPrice function returns the current date as opposed to the date the instrument last traded. For example, calling the ActualPrice function on a Saturday will return Saturday's date instead of the last date (the previous Friday usually) when the instrument traded.
The fix is straightforward and included below. Don't bother calling as.POSIXct when it isn't used later anyway.
Replace the line below...
DateTime <- as.POSIXct(substr(InstPrecjson[[1]]$time,12,19), format = "%H:%M:%S")
... with this line.
DateTime <- substr(InstPrecjson[[1]]$time,1,19)
Over the weekend, the ActualPrice function returns the current date as opposed to the date the instrument last traded. For example, calling the ActualPrice function on a Saturday will return Saturday's date instead of the last date (the previous Friday usually) when the instrument traded.
The fix is straightforward and included below. Don't bother calling as.POSIXct when it isn't used later anyway.
Replace the line below... DateTime <- as.POSIXct(substr(InstPrecjson[[1]]$time,12,19), format = "%H:%M:%S")
... with this line. DateTime <- substr(InstPrecjson[[1]]$time,1,19)