Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 1.33 KB

README.md

File metadata and controls

51 lines (35 loc) · 1.33 KB

PolygonAPI.jl

Julia wrapper around polygon.io REST API to query market data.

To start using it, get your API key from polygon.io and generate your credentials

using PolygonAPI
key = "********"
c = credentials(key)

Use your credentials to request data, like aggregated bars, retrieved in specific Julia structs such as Bar

from = "2023-03-13"
to = "2023-04-14"

aapl = bars(c, "AAPL", 2, PolygonAPI.week, from, to)

The Bar object contains useful fields such as close, open, high, low (OHCL)

julia> fieldnames(Bar)
(:ticker, :close, :high, :low, :number, :open, :timestamp, :volume, :weighted_volume, :otc)

The variable is a vector containing Bar objects. Aggregating every 2 weeks from the initial date to the final date can create 3 Bars.

julia> aapl
3-element Vector{Bar}:
 Bar("AAPL", 160.25, 162.14, 147.7, 6.329477e6, 147.805, DateTime("2023-03-12T05:00:00"), 7.57309847e8, 155.6811, false)
 Bar("AAPL", 164.66, 166.84, 155.98, 4.458346e6, 159.94, DateTime("2023-03-26T04:00:00"), 4.67804539e8, 162.4348, false)
 Bar("AAPL", 165.02, 168.16, 159.78, 5.119241e6, 161.42, DateTime("2023-04-09T04:00:00"), 5.12276199e8, 164.3269, false)
first_bar = aapl[1]

<first_bar> is a Bar object and its field can be accessed as follows:

julia> first_bar.low
147.7