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 PolyOpts, tickers, ticker_types, ticker_details
export PolyOpts, tickers, ticker_types, ticker_details, ticker_details_vX

end
18 changes: 18 additions & 0 deletions src/reference_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,25 @@ function ticker_details(opts::PolyOpts, stocksTicker::String)
end

############ Ticker Details vX ####################
"""
"""
function ticker_details_vX(opts::PolyOpts, ticker::String, date::String)
# TODO: Dispatch on proper Date type?
ticker_details_vX_base_url = "https://api.polygon.io/vX/reference/tickers/$ticker"

params = Dict(
"apiKey" => opts.api_key,
"date" => date
)

request_json = HTTP.get(ticker_details_vX_base_url, query=params).body |> JSON3.read

if opts.sink === nothing
return request_json.results
else
return [request_json.results] |> opts.sink
end
end

############ Ticker News #######################

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

ticker_types_base_url = "https://api.polygon.io/v2/reference/types"
ticker_types_base_url = "https://api.polygon.io/v2/reference/types"
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Test: length
using ConfigEnv
using PolygonIO
using TypedTables
Expand All @@ -21,6 +20,11 @@ const regular_opts = PolyOpts(API_KEY, nothing)
@test ticker_types(tabular_opts) |> length == 2
@test ticker_types(regular_opts) |> length == 2

# ticker_details test
@test ticker_details(tabular_opts, "AAPL") |> size == (1, )
@test ticker_details(regular_opts, "AAPL") |> length == 28

# ticker_details_vX next version test
@test ticker_details_vX(tabular_opts, "AAPL", "2019-07-31") |> size == (1, )
@test ticker_details_vX(regular_opts, "AAPL", "2019-07-31") |> length == 19
end