Skip to content
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
2 changes: 1 addition & 1 deletion src/PolygonIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ include("streaming_socket.jl")


######### Global export of user API ################
export tickers, PolyOpts
export PolyOpts, tickers, ticker_types

end
12 changes: 11 additions & 1 deletion src/reference_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ function tickers(opts::PolyOpts,
return request_json.results |> opts.sink
end


end

############ Ticker Types ####################
"""
"""
function ticker_types(opts::PolyOpts)
params = Dict("apiKey" => opts.api_key)
request_json = HTTP.get(ticker_types_base_url, query=params).body |> JSON3.read

if opts.sink ≠ nothing
@warn "This endpoint does not support a tabular interface. Returning JSON instead of $(opts.sink)."
end

return request_json.results
end

############ Tickers Details ####################

Expand Down
4 changes: 3 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
tickers_base_url = "https://api.polygon.io/v3/reference/tickers"
tickers_base_url = "https://api.polygon.io/v3/reference/tickers"

ticker_types_base_url = "https://api.polygon.io/v2/reference/types"
15 changes: 12 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Test: length
using ConfigEnv
using PolygonIO
using TypedTables
Expand All @@ -7,9 +8,17 @@ using Test
dotenv()

const API_KEY = ENV["API_KEY"]
const tabular_opts = PolyOpts(API_KEY, Table)
const regular_ops = PolyOpts(API_KEY, nothing)


@testset "PolygonIO.jl" begin
# Write your tests here.
@test tickers(PolyOpts(API_KEY, Table), "bitcoin") |> size == (10, )
@test tickers(PolyOpts(API_KEY, nothing), "bitcoin") |> size == (10, )
# tickets test
@test tickers(tabular_opts, "bitcoin") |> size == (10, )
@test tickers(regular_ops, "bitcoin") |> size == (10, )

# ticker_types test
@test ticker_types(tabular_opts) |> length == 2
@test ticker_types(regular_ops) |> length == 2
@test_logs (:warn, "This endpoint does not support a tabular interface. Returning JSON instead of $(tabular_opts.sink).") ticker_types(tabular_opts)
end