joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
794 stars 219 forks source link

fix_382 #383

Closed ethanbsmith closed 1 year ago

ethanbsmith commented 1 year ago

adds a lightweight session for use on yahoo quote requests session is needed for both the cookies and the "crumb" field the handle from the session must also be used for subsequent requests fixes #382

pstadler commented 1 year ago

I thought I'd be a nice neighbor and let you know that certain regions (probably EU) seem to get redirected to a consent page during the initial call, thus failing to obtain a session. We're currently investigating possible solutions: https://github.com/pstadler/ticker.sh/issues/33#issuecomment-1517340591

ethanbsmith commented 1 year ago

thx @pstadler. it looks like the cookies and crumbs are no longer needed again for v7 (at least for now). r u seeing the redirects on calls to the v7 api w/out simulating a session?

pstadler commented 1 year ago

it‘s happening over at my project using something very similar to your fix. Going to remove it again if it‘s working again without crumb. Wondering for how long though, it‘s been flaky for a while.

pstadler commented 1 year ago

I gladly reverted the change on my end. Fingers crossed that it won't happen again.

ethanbsmith commented 1 year ago

im currently testing an update that caches the yahoo handle. i dont know what the error will ben when the handle becomes invalid, as this is probably driven by a timeout on the yahoo server side, so i cant force the error condition. will push once i have that part worked out

pstadler commented 1 year ago

my assumption is that you‘ll get a 401 Unauthorized if the session expires (if this is what you’re referring to). In this case I‘d simply try to obtain a new session and fetch the quotes again. See https://github.com/pstadler/ticker.sh/blob/54b73a3f57432b5efd102754c48f20ed246f8ed2/ticker.sh#L53

ethanbsmith commented 1 year ago

josh, with the handle caching, performance is now pretty much on par w/ the prior version. also, when yahoo removed this check last week, passing in the crumb still worked fine. so, i dont think there is any downside to having this code in production as it should work either way.