And we can use a Google Apps script to import data from Yahoo Finance into a Google sheet. Since Yahoo Finance operates on JavaScript, running the code through this method pulls all of the data and saves it as if it were a static website. I noticed that there was a single piece of data missing (volume for AAPL210709P00146000), so the Yahoo options data isn't infallible. Yahoo Finance contains a much more comprehensive data set for stock tickers. The above code will open the page in a dummy browser and pull all of the data within the body of the website. The following code shows the whole program being put to use: Sub OptionTest() You now have a function that takes in the ticker symbol and sheet that's being printed to. Set JSON = JsonConverter.ParseJson(REGEX(XMLPage.responseText, strPattern, "$1"))Ĭells(2, 10).value = "Implied Volatility"įor Each Key In JSON("context")("dispatcher")("stores")("OptionContractsStore")("contracts")("calls")Ĭells(i, 1).value = Key("contractSymbol")Ĭells(i, 2).value = Key("lastTradeDate")("fmt")Ĭells(i, 4).value = Key("lastPrice")("raw")Ĭells(i, 7).value = Key("percentChange")("fmt")Ĭells(i, 9).value = Key("openInterest")("raw")Ĭells(i, 10).value = Key("impliedVolatility")("fmt")Ĭells(i, 10).value = "Implied Volatility"įor Each Key In JSON("context")("dispatcher")("stores")("OptionContractsStore")("contracts")("puts")įINALLY, we arrive at the ending. XMLPage.Open "GET", ""
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |