ClimberMel / SMF_Add-in

Stock Market Functions for Excel using VBA
https://climbermel.github.io/SMF_Add-in/
14 stars 5 forks source link

smfGetYahooHistoryCSVData Function returning just blanks #65

Closed ClimberMel closed 3 days ago

ClimberMel commented 4 months ago

On Sunday, March 10, 2024 at 2:12:31 PM UTC-4 Joseph Keithley wrote:

The smfGetYahooHistory quit working for me today.  All I get are blank spaces. My request is:

={smfGetYahooHistoryCSV(B10,D10,C10)}

where B10 is IVV, D10 is 2/2/2024 and C10 is 3/8/24
the matrix {} function covers 40 rows and 7 columns.

Am I doing something wrong?

It seems to have error exited in the following routine:

Function smfGetYahooHistoryCSVData(Optional ByRef pURL As String = "https://query1.finance.yahoo.com/v7/finance/download/MMM?period1=1493610466&period2=1496202466&interval=1d&events=history&crumb=")

The code got to the folowing code and crashed when it asked for sCookie

            Select Case i1
               Case 1
                    sCrumb = smfStrExtr(smfStrExtr(.responseText, "CrumbStore", "~"), """:""", """")
                    sCookie = Split(.getResponseHeader("Set-Cookie"), ";")(0)
ClimberMel commented 4 months ago

If I remove the &crumb= it seems to work fine. I will test more and then create a new release.

ClimberMel commented 4 months ago

The functions smfGetYahooHistoryCSV_.smfGetYahooHistoryCSVData calls vData = smfGetCSVFile(sURL, ",", iRows, iCols) modGetCSVFile.smfGetCSVFile calls smfGetCSVFile = RCHGetYahooQuotes(pURL, "", pDelimiter:=pDelimiter, pDim1:=pDim1, pDim2:=pDim2)

In modGetYahooQuotes.RCHGetYahooQuotes

the error appears in the following if it tries to process the crumb '------------------> Download current quotes If InStr(sURL, "&crumb=") > 0 Then sqData = smfGetYahooHistoryCSVData(sURL) Else sqData = RCHGetURLData(sURL) '& Chr(13) End If vData(1 + pHeader, 1) = sqData

With the &crumb removed it skips the call to smfGetYahooHistoryCSVData which has crumb processing that seems to fail. Since it works without the &crumb, I won't be pursuing the error further at this time.