Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSymbols Oanda lexical error #387

Closed
macray76 opened this issue Jun 28, 2023 · 3 comments
Closed

getSymbols Oanda lexical error #387

macray76 opened this issue Jun 28, 2023 · 3 comments
Assignees
Labels

Comments

@macray76
Copy link

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
Copy link

A URL for oanda.com is made and fed into jsonlite::fromJSON here

quantmod/R/getSymbols.R

Lines 1152 to 1163 in f60b99d

oanda.URL <- paste0("https://www.oanda.com/fx-for-business/",
"historical-rates/api/data/update/",
"?&source=OANDA&adjustment=0",
"&base_currency=", currency.pair[1],
"&start_date=", from,
"&end_date=", to,
"&period=daily",
"&price=mid",
"&view=table",
"&quote_currency_0=", currency.pair[2])
# Fetch data (jsonlite::fromJSON will handle connection)
tbl <- jsonlite::fromJSON(oanda.URL, simplifyVector = FALSE)
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
Copy link

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
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants