joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
794 stars 219 forks source link

getSymbols Oanda lexical error #387

Closed macray76 closed 1 year ago

macray76 commented 1 year ago

When executing any getSymbols command to Oanda results in a json error rather than extracting the daily rate.

getSymbols("EUR/GBP", src="oanda", from="2023-06-26", to="2023-06-26", auto.assign=FALSE)

Result:

Error in getSymbols.oanda(Symbols = "EUR/GBP", env = <environment>, verbose = FALSE,  : 
  Unable to import “EUR/GBP”.
lexical error: invalid char in json text.
                                       <!DOCTYPE html> <html lang="en"
                     (right here) ------^
jrwishart commented 1 year ago

A URL for oanda.com is made and fed into jsonlite::fromJSON here https://github.com/joshuaulrich/quantmod/blob/f60b99dcac55036580c14c840c5c0763d9c97f88/R/getSymbols.R#L1152-L1163 This is now rejected by fromJSON with

Error in parse_con(txt, bigint_as_char) : 
  lexical error: invalid char in json text.
                                       <!DOCTYPE html> <html lang="en"
                     (right here) ------^

I am guessing the structure of the oanda website has changed and an update to this code is required?

QuinHsieh commented 1 year ago

If I implement the following commend, such like getFX("USD/JPY") or getMetals(c("gold","XPD")), it responds some the errors that can not understand.

1688020510249 1688020542581

Could everyone solve these problems?

JimboMahoney commented 1 year ago

Also seeing this and suspect it's an issue with Oanda - looks like they have changed URL (as @jrwishart mentions) and/or changed their data access for some / most datasets to premium / pro

.·´¯(>▂<)´¯·.