I am following the following tutorial to import stock options data into a Google sheet.
https://www.youtube.com/watch?v=Be7z9YeeVY0&ab_channel=daneshj
The following formula will import data from yahoo finance into the sheet:
=iferror(TRANSPOSE(IMPORTXML(CONCATENATE("https://finance.yahoo.com/quote/",A2,"?p=",A2),"//tr")),"You have to add a contract name in column A")
At first glance, everything looks fine, as it seems to be pulling data back from the webpage; however, all the values are incorrect.
The URL it is pulling data from in this example is below. Note that that the data changes frequently.
https://finance.yahoo.com/quote/NKLA220121C00002500?p=NKLA220121C00002500
The numbers are not only wrong in this specific example, they are wrong every time, and with a great enough margin of error that I don't believe it is due to IMPORTXML caching the page. I have searched through the HTML source of the webpage and can't find the values from IMPORTXML anywhere.
google-apps-script
is included. By this, I proposed a workaround using Google Apps Script as an answer. Could you please confirm it? If that was not the same with your direction, I apologize. – Tanaike