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

RCHGetYahooHistory errors #2

Closed
ClimberMel opened this issue Jan 10, 2023 · 11 comments
Closed

RCHGetYahooHistory errors #2

ClimberMel opened this issue Jan 10, 2023 · 11 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ClimberMel
Copy link
Owner

The formula RCHGetYahooHistory(C7,C8,C9,C10,C11,C12,C13,C14,C15,C16,C17,C18) is array entered and showing #NAME in all cells.
The data for C7 to C18 for the example is as follows: aapl,1990,1,1,2025,1,1,w,,1,1,1
The fields for those are: Ticker:,Start Year:,Start Month:,Start Day:,End Year:,End Month:,End Day:,Period:,Items:,Header:,Adjust:,Resort:

@ClimberMel ClimberMel self-assigned this Jan 10, 2023
@ClimberMel
Copy link
Owner Author

I have traced the numerous modules that it goes through. The smfGetYahooHistory() is the problem module.

@aggie81
Copy link

aggie81 commented Jan 15, 2023

Hi, I am not much of a VBA programmer other than simple macros, but I am an engineer that does embedded firmware coding and can do a bit of debugging and testing. I stepped through the smfGetYahooHistory() code and it seems the current code is looking for the string "HistoricalPriceStore" in the web page data returned via sData = smfGetWebPage(sURL). It seems this string is no longer in the returned web data source. Next step would be to capture the curent web page source to locate a new string that would allow smfStrExtr to find and return the stock data JSON it is looking for. Unfortunately I am not a HTML programmer either, so not sure how to do this, but am googling it and willing to learn. Thanks for your efforts to keep SMF_Add-in going!

@ClimberMel
Copy link
Owner Author

In the function smfGetYahooHistory() it does a bunch of formatting and checking parameters… that all looks fine.
Then it get to the section:

'------------------> Create URL and retrieve data
sURL = "https://finance.yahoo.com/quote/" & pTicker & "/history?period1=" & dBegin & "&period2=" & dEnd & _
       "&interval=" & sInterval & "&filter=" & sfilter & "&frequency=" & sFreq
'sData = RCHGetURLData(sURL)
sData = smfGetWebPage(sURL)
sData = smfStrExtr(sData, "HistoricalPriceStore", "]")   ' Keep only the "HistoricalPriceStore" JSON data
vByDay = Split(sData, "},{")

The URL seems fine, it becomes this: https://finance.yahoo.com/quote/msft/history?period1=1641081600&period2=1672444800&interval=1d&filter=history&frequency=1d
sData = smfStrExtr is where the problem is, the comment indicates it was looking for json data and the “HistoricalPriceStore" no longer exits.
There is a data-test="historical-prices" in the HTML, but I’m having trouble figuring out how to extract the data following that.
The vByDay = Split(sData, "},{") is also looking to split jason data based on the “},{“, but there is no json data here.

Thanks,
Mel

sample_html.txt

@aggie81
Copy link

aggie81 commented Jan 17, 2023

I see the same thing. Using Firefox and its code inspector tool, I grabbed two screen shots. One shows the start of the table marked by data-test="historical-prices" that you found. The second shows the first table entry (date, open, high, etc. data). You can see the data values in there but seems no longer in a simple JSON format.

screenshot1
screenshot2

@ClimberMel
Copy link
Owner Author

I have been mapping the modules and calls, it has been quite a lengthy process. I'm also slowly learning more about scaping data. I think now that I have the block of data I need, I should be able to figure out how the module parses that data and re-write it accordingly.

@ClimberMel ClimberMel added bug Something isn't working help wanted Extra attention is needed labels Jan 29, 2023
@ClimberMel
Copy link
Owner Author

I have the function smfGetYahooHistory in module smfGetYahooHistory_ working with returned data. It can again select which items / columns and the order in which to return the data.
I will test with returning the RCHGetYahooHistory to the way it was since the fix to it was to bypass the failing smfGetYahooHistory function.

@aggie81
Copy link

aggie81 commented Feb 8, 2023

Sweet! Eager to give it a try! Has the SMF download page been updated? Thanks!

@ClimberMel
Copy link
Owner Author

ClimberMel commented Feb 9, 2023 via email

@ClimberMel
Copy link
Owner Author

The data seems to be in reverse order from what it used to be. I'm not sure if that is really an issue since there is a resort parameter that will switch the order of the returned data.

@ClimberMel
Copy link
Owner Author

The remaining issue was reported by Lew. He had an array of 20000 rows and it brought back from inception date, but stopped at 2020-12-31. That seemed odd.
The formula is = RCHGetYahooHistory("TQQQ", , , , , , , , "DA", 1, 1, 1, 20000, 2) but I switched it to = RCHGetYahooHistory("TQQQ", , , , , , , , "DA", 1, 1, 0, 20000, 2) to check the resort and yes switching the resort from 1 to 0 reversed the order, but still stops at 2020-12-31. That is 2743 rows, so it isn't a limit issue as that should be an even 1000 or 10000 depending.

@ClimberMel
Copy link
Owner Author

I'll close this issue as fixed. Most of these are fixed in the 3.0.2023.02.09 version and the sorting will be addressed in the 3.0.2023.02.15 version soon to be released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants