Skip to content
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

Add time_series_intraday_extended #30

Merged
merged 6 commits into from
Dec 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/stock_time_series.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
function time_series_intraday_extended(symbol::String, interval::String="60min", slice::String="year1month1")
@argcheck in(interval, ["1min", "5min", "15min", "30min", "60min"])
sliceMatch = match(r"year(?<year>\d+)month(?<month>\d+)", slice)
@argcheck !isnothing(sliceMatch)
@argcheck parse(Int, sliceMatch["year"]) > 0
@argcheck parse(Int, sliceMatch["year"]) < 3
@argcheck parse(Int, sliceMatch["month"]) > 0
@argcheck parse(Int, sliceMatch["month"]) < 13
uri = "$(alphavantage_api)query?function=TIME_SERIES_INTRADAY_EXTENDED&symbol=$symbol&interval=$interval&slice=$slice&apikey=" * ENV["ALPHA_VANTAGE_API_KEY"]
data = _get_request(uri)
return _parse_response(data, "csv")
end
export time_series_intraday_extended

function time_series_intraday(symbol::String, interval::String="1min"; outputsize::String="compact", datatype::String="json")
@argcheck in(interval, ["1min", "5min", "15min", "30min", "60min"])
@argcheck in(outputsize, ["compact", "full"])
Expand Down
10 changes: 10 additions & 0 deletions test/stock_time_series_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ stock_time_series_functions_test = vcat(:time_series_intraday, stock_time_series
end
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end

f = :time_series_intraday_extended
@eval begin
testname = string($f)
@testset "$testname" begin
data = $f("MSFT")
@test typeof(data) === Tuple{Array{Any, 2}, Array{AbstractString, 2}}
@test length(data) === 2
end
end
end