Skip to content

Commit

Permalink
Add calendar functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dm13450 committed Jan 29, 2021
1 parent abb8175 commit 5420308
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/AlphaVantage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export
balance_sheet,
cash_flow,
listing_status,
earnings
earnings,
earnings_calendar,
ipo_calendar

end # module
14 changes: 14 additions & 0 deletions src/fundamentals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,17 @@ for (timeframe, f, value, dateKey) in FUNDAMENTAL_VALUES
export $fname
end
end

function earnings_calendar(horizon::Int64; client=GLOBAL[], parser = "default")
uri = _form_uri_head(client, "EARNINGS_CALENDAR") * "&horizon=$(horizon)month" * _form_uri_tail(client)
data = retry(_get_request, delays=Base.ExponentialBackOff(n=3, first_delay=4, max_delay=1000))(uri)
p = _parser(parser, "csv")
return p(data)
end

function ipo_calendar(; client = GLOBAL[], parser = "default")
uri = _form_uri_head(client, "IPO_CALENDAR") * _form_uri_tail(client)
data = retry(_get_request, delays=Base.ExponentialBackOff(n=3, first_delay=4, max_delay=1000))(uri)
p = _parser(parser, "csv")
return p(data)
end
5 changes: 5 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ function _form_uri_tail(client::AVClient, outputsize, datatype)
return a
end

function _form_uri_tail(client::AVClient)
"&apikey=" * key(client)
end


"""
Internal function that helps forms the request uri
"""
Expand Down
13 changes: 13 additions & 0 deletions test/fundamentals_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,27 @@ MAX_TESTS = parse(Int64, get(ENV, "MAX_TESTS", "1"))
@testset "Default" begin
data = listing_status()
@test length(data) == 2
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end

@testset "Delisted and Date" begin
data = listing_status(state = "delisted", date = "2020-12-17")
@test length(data) == 2
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end
end

@testset "Earnings Calendar" begin
data = earnings_calendar(3)
@test length(data) == 2
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end

@testset "IPO Calendar" begin
data = ipo_calendar()
@test length(data) == 2
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end
end

end # module

0 comments on commit 5420308

Please sign in to comment.