Skip to content

Commit

Permalink
Merge pull request #17 from tbreloff/master
Browse files Browse the repository at this point in the history
added fundamentals
  • Loading branch information
dm13450 authored Aug 7, 2020
2 parents 3b23877 + bab19ce commit 7677661
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/AlphaVantage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ include("digital_currency.jl")
include("foreign_exchange_currency.jl")
include("stock_technical_indicators.jl")
include("sector_performance.jl")
include("fundamentals.jl")

end # module
44 changes: 44 additions & 0 deletions src/fundamentals.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# Company Overview (https://www.alphavantage.co/documentation/#company-overview)
# ex: https://www.alphavantage.co/query?function=OVERVIEW&symbol=IBM&apikey=demo

function company_overview(symbol::String; outputsize::String="compact", datatype::String="json")
@argcheck in(datatype, ["json", "csv"])
uri = _form_uri_head("OVERVIEW") * "&symbol=$symbol" * _form_uri_tail(outputsize, datatype)
data = _get_request(uri)
return _parse_response(data, datatype)
end
export company_overview

# Income Statement (https://www.alphavantage.co/documentation/#income-statement)
# ex: https://www.alphavantage.co/query?function=INCOME_STATEMENT&symbol=IBM&apikey=demo

function income_statement(symbol::String; outputsize::String="compact", datatype::String="json")
@argcheck in(datatype, ["json", "csv"])
uri = _form_uri_head("INCOME_STATEMENT") * "&symbol=$symbol" * _form_uri_tail(outputsize, datatype)
data = _get_request(uri)
return _parse_response(data, datatype)
end
export income_statement

# Balance Sheet (https://www.alphavantage.co/documentation/#balance-sheet)
# ex: https://www.alphavantage.co/query?function=BALANCE_SHEET&symbol=IBM&apikey=demo

function balance_sheet(symbol::String; outputsize::String="compact", datatype::String="json")
@argcheck in(datatype, ["json", "csv"])
uri = _form_uri_head("BALANCE_SHEET") * "&symbol=$symbol" * _form_uri_tail(outputsize, datatype)
data = _get_request(uri)
return _parse_response(data, datatype)
end
export balance_sheet

# Cash Flow (https://www.alphavantage.co/documentation/#cash-flow)
# ex: https://www.alphavantage.co/query?function=CASH_FLOW&symbol=IBM&apikey=demo

function cash_flow(symbol::String; outputsize::String="compact", datatype::String="json")
@argcheck in(datatype, ["json", "csv"])
uri = _form_uri_head("CASH_FLOW") * "&symbol=$symbol" * _form_uri_tail(outputsize, datatype)
data = _get_request(uri)
return _parse_response(data, datatype)
end
export cash_flow
31 changes: 31 additions & 0 deletions test/fundamentals_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@testset "Fundamentals" begin
symbol = "IBM"

@testset "Overview" begin
data = company_overview(symbol)
@test typeof(data) === Dict{String, Any}
@test length(data) === 59
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end

@testset "Income Statement" begin
data = income_statement(symbol)
@test typeof(data) === Dict{String, Any}
@test length(data) === 3
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end

@testset "Balance Sheet" begin
data = balance_sheet(symbol)
@test typeof(data) === Dict{String, Any}
@test length(data) === 3
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end

@testset "Cash Flow" begin
data = cash_flow(symbol)
@test typeof(data) === Dict{String, Any}
@test length(data) === 3
sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include("foreign_exchange_curency_test.jl")
include("sector_performance_test.jl")
include("technical_indicators_test.jl")
include("digital_currency_test.jl")
include("fundamentals_test.jl")

end

Expand Down

0 comments on commit 7677661

Please sign in to comment.