-
Notifications
You must be signed in to change notification settings - Fork 3
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
Requesting prices outside available date range for ticker leads to unhelpful error #19
Comments
Found the issue. I need to make another if statement in the part where I throw the error after catching the error from the HTTP request. Normally if the call returns a 400 error I just pass on the error given from Yahoo directly - turns out that in this specific case the Yahoo error is stored in a different value in the returned JSON object. |
@nilshg would this work for you? This is basically the error message that is returned by Yahoo. I could parse out the UNIX dates and convert them but not sure that is needed. julia> get_prices("aapl",startdt=Date(1800), enddt = Date(1900))
┌ Warning: Data doesn't exist for startDate = -5364662400, endDate = -2208988800 for aapl. An empy OrderedCollections.OrderedDict was returned!
└ @ Main c:\Users\elias\OneDrive\Julia\Packages\YFinance\src\Prices.jl:192
OrderedDict{Any, Any}()
julia> get_prices("aapl",startdt=Date(1800), enddt = Date(1900),throw_error=true)
ERROR: Data doesn't exist for startDate = -5364662400, endDate = -2208988800 for aapl
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] get_prices(symbol::String; range::String, interval::String, startdt::Date, enddt::Date, prepost::Bool, autoadjust::Bool, timeout::Int64, throw_error::Bool, exchange_local_time::Bool, divsplits::Bool)
@ Main c:\Users\elias\OneDrive\Julia\Packages\YFinance\src\Prices.jl:190
[3] top-level scope
@ REPL[2]:1 |
Looks good to me - parsing those UNIX dates seems like a fairly low effort way to make users' lives easier but not the end of the world if it stays like this (get ready for GitHub issues asking why the package is looking for prices on date -5 billion though :)). |
Fair enough just have to parse the dates out of the string etc |
Just hope parsing out the dates doesnt result in weird errors for edge cases. julia> get_prices("aapl",startdt=Date(1800), enddt = Date(1900))
┌ Warning: Data doesn't exist for startDate = 1800-01-01T00:00:00, endDate = 1900-01-01T00:00:00 for aapl. An empy OrderedCollections.OrderedDict was returned!
└ @ Main c:\Users\elias\OneDrive\Julia\Packages\YFinance\src\Prices.jl:191
OrderedDict{Any, Any}()
julia> get_prices("aapl",startdt=Date(1800), enddt = Date(1900),throw_error=true)
ERROR: Data doesn't exist for startDate = 1800-01-01T00:00:00, endDate = 1900-01-01T00:00:00 for aapl
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] get_prices(symbol::String; range::String, interval::String, startdt::Date, enddt::Date, prepost::Bool, autoadjust::Bool, timeout::Int64, throw_error::Bool, exchange_local_time::Bool, divsplits::Bool)
@ Main c:\Users\elias\OneDrive\Julia\Packages\YFinance\src\Prices.jl:189
[3] top-level scope
@ REPL[12]:1 Edit: copied the unparsed version by mistake |
Here's an extreme example:
I hit on this while getting prices for a whole list of tickers, where one of them happened to not have any prices available for the 6-month window I was looking at - took me a while to work out that
key :finance not found
means there aren't any prices for the requested dates.This should probably be a more descriptive error.
The text was updated successfully, but these errors were encountered: