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


######### Global export of user API ################
export PolyOpts, tickers, ticker_types, ticker_details, ticker_details_vX
export PolyOpts, tickers, ticker_types, ticker_details, ticker_details_vX,
ticker_news


end
25 changes: 25 additions & 0 deletions src/reference_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,32 @@ function ticker_details_vX(opts::PolyOpts, ticker::String, date::String)
end

############ Ticker News #######################
"""
"""
function ticker_news(opts::PolyOpts,
ticker::String;
published_utc_gte="2021-04-26",
limit=10,
order="descending",
sort="published_utc",
kwargs...)

params = Dict(
"apiKey" => opts.api_key,
"ticker" => ticker,
"published_utc.gte" => published_utc_gte,
"limit" => limit,
"order" => order,
"sort" => sort
)
# Extract kwargs and add to params
merge!(params, Dict(kwargs))

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

return request_json.results

end

############ Markets ####################

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

ticker_types_base_url = "https://api.polygon.io/v2/reference/types"

ticker_new_base_url = "https://api.polygon.io/v2/reference/news"
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ const regular_opts = PolyOpts(API_KEY, nothing)
# 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

# ticker_news test
@test ticker_news(tabular_opts, "AAPL") |> length == 10
@test ticker_news(regular_opts, "AAPL") |> length == 10
end