Code Monkey home page Code Monkey logo

Comments (6)

haavardhvarnes avatar haavardhvarnes commented on May 13, 2024

I have the same problem. Copying the yahoo function and made some changes and it works. But parsing csv sometimes fails. Hope more can take a look at this problem. My adjusted functions below:

function getyahoocrumb()
ustr = "https://ca.finance.yahoo.com/quote/^GSPC/history?p=^GSPC";
response = Requests.get(ustr);
str = readstring(response);
m = match(r""user":{"crumb":"(.*?)"", str) ;
crumb = m[1]
mcookies = cookies(response)
return crumb, mcookies
end

function yahoo2(symb::String;
from::String="1900-01-01",
thru::String=string(Dates.today()),
freq::Char='d', crumb = getyahoocrumb())
@Assert freq in ['d','w','m','v'] "Argument freq must be in ['d','w','m','v']"
@Assert from[5] == '-' && from[8] == '-' "Argument from has invalid date format."
@Assert thru[5] == '-' && thru[8] == '-' "Argument thru has invalid date format."
dtFrom = Dates.DateTime(from)
dtThru = Dates.DateTime(thru)

# symb = "XOM"
# dtFrom = Dates.DateTime("2016-01-01")
# dtThru = Dates.DateTime("2017-05-18")
per1 = Int(floor(Dates.datetime2unix(dtFrom)))
per2 = Int(floor(Dates.datetime2unix(dtThru)))

crumb = "Df1WvGdhjEg"
crumb, mcookies = getyahoocrumb()
qrystr= string("https://query1.finance.yahoo.com/v7/finance/download/",symb,"?period1=", per1, "&period2=", per2,"&interval=1d&events=history&crumb=", crumb)
# println(qrystr)

# indata = Temporal.csvresp(get(qrystr))
indata = Temporal.csvresp(get(qrystr, cookies = mcookies))

sleep(0.8)
return ts(indata[1], indata[2], indata[3][2:end])

end

from temporal.jl.

AntonioSaragga avatar AntonioSaragga commented on May 13, 2024

It seems that yahoo is discontinuing its service.

from temporal.jl.

dysonance avatar dysonance commented on May 13, 2024

@AntonioSaragga Could you provide a source suggesting this is the case? Best I've found is an answer on this forum. I know R's quantmod package has been experiencing this issue lately, but not sure if it's resolved (and given that Joshua Ulrich is a very proactive package maintainer, that would tell me this is a non-trivial issue).

from temporal.jl.

dysonance avatar dysonance commented on May 13, 2024

@haavardhvarnes Thanks for taking a crack at getting it to work again, that's much appreciated! I'll try it out see if it's possible to get it worked out. If Yahoo hasn't discontinued the service and we can get this solved I'll try to merge that into the package ASAP.

from temporal.jl.

dysonance avatar dysonance commented on May 13, 2024

Seeing some workarounds for packages in other languages out there. This project implements a "temporary fix" for the function in the Pandas package in Python that downloads data from the Yahoo Finance API. See this Stack Overflow thread for some insights around the work done on R's quantmod package to solve the issue. If anyone has experience with either of these please provide thoughts/feedback on how they've been working.

from temporal.jl.

dysonance avatar dysonance commented on May 13, 2024

Alright all, with the great help of @haavardhvarnes's initial workaround above, I have managed to get a fix put in place for the Yahoo Finance data downloading functionality. There are some changes to the arguments required to fit the new URL formatting needs:

  • freq argument now a String (not Char) that can be "d", "wk", or "mo"
  • new event argument specifies what kind of data you want, can be "history", "div", or "split"
  • new crumb_tuple argument in case you don't want to re-generate cookies every time you run it

I'm about to send through an update / PR to Julia's METADATA repo, so hopefully this fix should be available to the wider community with a Pkg.update() soon. Until then, feel free to pull the changes from git to your local package directory and you should be all set.

Thanks again everyone for the input on this issue and for helping out the legwork on a workaround. Hopefully this issue will be solved for the time being. However, it did also raise an interesting note in my mind that it would be good to have more options for market data sources going forward (Google, etc.). If anyone would like to contribute with any functionality for sources other than Yahoo and Quandl, I'd be happy to work with you on it. Cheers.

from temporal.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.