Code Monkey home page Code Monkey logo

eohne / yfinance.jl Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 2.0 562 KB

Fetch stock market data from Yahoo Finance. Exposes stock, commodity, futures, currency (FX), mutual fund, and ETF prices, stock fundamental, summary data , and options data.

Home Page: https://eohne.github.io/YFinance.jl/

License: MIT License

Julia 100.00%
currency financial-data fundamental-data futures julia market-data options stock-data yahoo-finance yahoo-finance-api

yfinance.jl's People

Contributors

eohne avatar shayandavoodii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yfinance.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Change In API

The response of yahoo has changed leading to some tests to fail. This seems to impact only the quoteSummary object sofar.

Specifically:

  1. calendar events does not include exDividendDate anymore
  2. The majorHoldersBreakdown was removed
  3. The summaryProfile was removed.

To do:

Check if any other items are affected. See if these items have been renamed or moved somewhere else. If need be get rid of accessing these items as they seem not available through the yahoo response anymore.

[Question] `yfinance decrypt` Issue Parity with Python Equivalent

Greetings everyone,

At the outset I would like to thank eohne for bringing this functionality to Julia!

I noticed that this repo has been created quite recently, and therefore probably not enough time has passed for this to be an issue yet: periodically, Python's yfinance equivalent seems to face problems with response decryption. Most recently in the pinned issue, yahooquery seems to have been recommended as an alternative since it uses unofficial Yahoo Finance API frontends to retrieve its data.

After glancing over the source code for YFinance.jl, it appears to me that here we are authenticating the connection before pulling data. My question thus is: how does YFinance.jl fare in this regard? Is it more aligned with Python's yfinance in terms of web scraping, or with yahooquery owing to its proxy/authentication facilities?

My apologies for not understanding this completely and for what might seem an uninformed question, but any input is appreciated. Thanks once again for this Julia package, and for your time.

EDIT: clarified question a little more.

get_quoteSummary seems not to work

There seems to be a problem with an authorisation. Could you please check what the problem is?
Many thanks

get_quoteSummary("AAPL") |> get_summary_detail

HTTP.Exceptions.StatusError(401, "GET", "/v10/finance/quoteSummary/AAPL?modules=assetProfile%2CbalanceSheetHistory%2CbalanceSheetHistoryQuarterly%2CcalendarEvents%2CcashflowStatementHistory%2CcashflowStatementHistoryQuarterly%2CdefaultKeyStatistics%2Cearnings%2CearningsHistory%2CearningsTrend%2CesgScores%2CfinancialData%2CfundOwnership%2CfundPerformance%2CfundProfile%2CincomeStatementHistory%2CincomeStatementHistoryQuarterly%2CindexTrend%2CindustryTrend%2CinsiderHolders%2CinsiderTransactions%2CinstitutionOwnership%2CmajorDirectHolders%2CmajorHoldersBreakdown%2CnetSharePurchaseActivity%2Cprice%2CquoteType%2CrecommendationTrend%2CsecFilings%2CsectorTrend%2CsummaryDetail%2CsummaryProfile%2CtopHoldings%2CupgradeDowngradeHistory&formatted=false", HTTP.Messages.Response:
"""
HTTP/1.1 401 Unauthorized
content-type: application/json;charset=utf-8
vary: Origin
content-length: 90
x-envoy-upstream-service-time: 2
date: Sat, 02 Dec 2023 09:50:59 GMT
server: ATS
x-envoy-decorator-operation: finance-company-fundamentals-api--mtls-production-ir2.finance-k8s.svc.yahoo.local:4080/*
Cache-Control: max-age=0, private
Expires: -1
Age: 0
Strict-Transport-Security: max-age=31536000
Referrer-Policy: no-referrer-when-downgrade
Connection: keep-alive
Expect-CT: max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only"
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff

{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Cookie"}}}""")

Stacktrace:
[1] (::HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}})(req::HTTP.Messages.Request; proxy::Nothing, socket_type::Type, socket_type_tls::Type, readtimeout::Int64, connect_timeout::Int64, logerrors::Bool, logtag::Nothing, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
@ HTTP.ConnectionRequest C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\ConnectionRequest.jl:144
[2] (::Base.var"#90#92"{Base.var"#90#91#93"{ExponentialBackOff, HTTP.RetryRequest.var"#2#5"{Int64, typeof(HTTP.RetryRequest.FALSE), HTTP.Messages.Request, Base.RefValue{Int64}}, HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}})(args::HTTP.Messages.Request; kwargs::Base.Pairs{Symbol, Union{Nothing, Int64}, NTuple{4, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose, :proxy), Tuple{Nothing, Nothing, Int64, Nothing}}})
@ Base .\error.jl:296
[3] (::HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}})(req::HTTP.Messages.Request; retry::Bool, retries::Int64, retry_delays::ExponentialBackOff, retry_check::Function, retry_non_idempotent::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, NTuple{4, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose, :proxy), Tuple{Nothing, Nothing, Int64, Nothing}}})
@ HTTP.RetryRequest C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\RetryRequest.jl:75
[4] manageretries
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\RetryRequest.jl:30 [inlined]
[5] (::HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}})(req::HTTP.Messages.Request; cookies::Bool, cookiejar::HTTP.Cookies.CookieJar, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, NTuple{4, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose, :proxy), Tuple{Nothing, Nothing, Int64, Nothing}}})
@ HTTP.CookieRequest C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\CookieRequest.jl:42
[6] managecookies
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\CookieRequest.jl:19 [inlined]
[7] (::HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}})(req::HTTP.Messages.Request; iofunction::Nothing, decompress::Nothing, basicauth::Bool, detect_content_type::Bool, canonicalize_headers::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol}, NamedTuple{(:verbose, :proxy), Tuple{Int64, Nothing}}})
@ HTTP.HeadersRequest C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\HeadersRequest.jl:71
[8] defaultheaders
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\HeadersRequest.jl:14 [inlined]
[9] (::HTTP.RedirectRequest.var"#redirects#3"{HTTP.RedirectRequest.var"#redirects#1#4"{HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}})(req::HTTP.Messages.Request; redirect::Bool, redirect_limit::Int64, redirect_method::Nothing, forwardheaders::Bool, response_stream::Nothing, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol}, NamedTuple{(:verbose, :proxy), Tuple{Int64, Nothing}}})
@ HTTP.RedirectRequest C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\RedirectRequest.jl:25
[10] redirects
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\RedirectRequest.jl:14 [inlined]
[11] (::HTTP.MessageRequest.var"#makerequest#3"{HTTP.MessageRequest.var"#makerequest#1#4"{HTTP.RedirectRequest.var"#redirects#3"{HTTP.RedirectRequest.var"#redirects#1#4"{HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}})(method::String, url::URIs.URI, headers::Dict{Any, Any}, body::Vector{UInt8}; copyheaders::Bool, response_stream::Nothing, http_version::HTTP.Strings.HTTPVersion, verbose::Int64, kw::Base.Pairs{Symbol, Nothing, Tuple{Symbol}, NamedTuple{(:proxy,), Tuple{Nothing}}})
@ HTTP.MessageRequest C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\MessageRequest.jl:35
[12] makerequest
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\clientlayers\MessageRequest.jl:24 [inlined]
[13] request(stack::HTTP.MessageRequest.var"#makerequest#3"{HTTP.MessageRequest.var"#makerequest#1#4"{HTTP.RedirectRequest.var"#redirects#3"{HTTP.RedirectRequest.var"#redirects#1#4"{HTTP.HeadersRequest.var"#defaultheaders#2"{HTTP.HeadersRequest.var"#defaultheaders#1#3"{HTTP.CookieRequest.var"#managecookies#4"{HTTP.CookieRequest.var"#managecookies#1#5"{HTTP.RetryRequest.var"#manageretries#3"{HTTP.RetryRequest.var"#manageretries#1#4"{HTTP.ConnectionRequest.var"#connections#4"{HTTP.ConnectionRequest.var"#connections#1#5"{HTTP.TimeoutRequest.var"#timeouts#3"{HTTP.TimeoutRequest.var"#timeouts#1#4"{HTTP.ExceptionRequest.var"#exceptions#2"{HTTP.ExceptionRequest.var"#exceptions#1#3"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}, method::String, url::String, h::Dict{Any, Any}, b::Vector{UInt8}, q::Dict{String, String}; headers::Dict{Any, Any}, body::Vector{UInt8}, query::Dict{String, String}, kw::Base.Pairs{Symbol, Nothing, Tuple{Symbol}, NamedTuple{(:proxy,), Tuple{Nothing}}})
@ HTTP C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\HTTP.jl:457
[14] #request#20
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\HTTP.jl:315 [inlined]
[15] request (repeats 2 times)
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\HTTP.jl:313 [inlined]
[16] #get#38
@ C:\Users\USUARIO.julia\packages\HTTP\SN7VW\src\HTTP.jl:518 [inlined]
[17] get_quoteSummary(symbol::String; item::Nothing, throw_error::Bool)
@ YFinance C:\Users\USUARIO.julia\packages\YFinance\II1mO\src\QuoteSummary.jl:97
[18] get_quoteSummary(symbol::String)
@ YFinance C:\Users\USUARIO.julia\packages\YFinance\II1mO\src\QuoteSummary.jl:69
[19] top-level scope
@ In[20]:1

1
get_quoteSummary("AAPL")

Search_Symbol.jl proposal

Hey,
I see you've provided a Search_Symbol.jl file for fetching/reading the symbols (tickers). I know it's empty, but I think it's possible to fill this file, and provide a function to catch the Symbols of several markets. But first, I want to know what your desired workflow is for it. Do you want to fetch the data from an API, or load an existing .csv file that contains the symbol names?

I guess you want to keep dependencies at the lowest level possible -> Reading from a CSV file isn't a good option. But, I would be happy if you explicitly share your desired workflow.

How to get commodity prices using YFinance.jl?

I see you've mentioned "commodity" in the description of the repository. I checked the documentation and searched for the "Commod" term to find related documentation in this regard. Unfortunately, I didn't find any related instructions. So, I'm writing to ask for an MRE for fetching commodity prices such as Brent oil or wheat.

Possible Change in API

julia> appl = get_prices("APPL")
ERROR: KeyError: key :timestamp not found
Stacktrace:
 [1] getindex(h::Dict{Symbol, Int64}, key::Symbol)
   @ Base .\dict.jl:484
 [2] get(obj::JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}, key::Symbol)
   @ JSON3 C:\Users\elias\.julia\packages\JSON3\L8Yfy\src\JSON3.jl:87
 [3] getproperty(obj::JSON3.Object{Vector{UInt8}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}, prop::Symbol)
   @ JSON3 C:\Users\elias\.julia\packages\JSON3\L8Yfy\src\JSON3.jl:127
 [4] get_prices(symbol::String; range::String, interval::String, startdt::String, enddt::String, prepost::Bool, autoadjust::Bool, timeout::Int64, throw_error::Bool, exchange_local_time::Bool)
   @ YFinance C:\Users\elias\.julia\packages\YFinance\II1mO\src\Prices.jl:180
 [5] get_prices(symbol::String)
   @ YFinance C:\Users\elias\.julia\packages\YFinance\II1mO\src\Prices.jl:112
 [6] top-level scope
   @ REPL[2]:1

getting daily stock prices

When I ask for the maximum range of stock prices, I get the quearterly quotes only. Is it possible to get all of the daily stock prices (adjusted)?

Thank you

Increase Code Coverage

Increase the test coverage. All main functions are tested (if the correct user input is provided).

Expose more of the mutual fund related data points.

Adding direct access to mutual fund-related information:

  • Holdings-related information (Sector weights, top holdings, ...)
  • Performance
  • Morningstar Category & Style box
  • Manager Information (Tenure, Bio, etc).
  • Fees/Expenses
  • Brokerages

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.