Class: Polygonio::Rest::Stocks
Defined Under Namespace
Classes: AggregatesResponse, DailyOpenCloseResponse, FullSnapshotResponse, GroupedDailyResponse, HistoricParams, HistoricQuotesResponse, HistoricTradesResponse, LastQuoteResponse, LastTradeResponse, PreviousCloseResponse, SnapshotGainersLosersResponse, SnapshotResponse, SnapshotTicker, StockExchange
Instance Attribute Summary
#client
Instance Method Summary
collapse
-
#aggregates(ticker, multiplier, timespan, from, to, unadjusted = false) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#condition_mappings(tick_type) ⇒ Object
-
#daily_open_close(symbol, date) ⇒ Object
-
#full_snapshot ⇒ Object
-
#grouped_daily(locale, market, date, unadjusted = false) ⇒ Object
-
#historic_quotes(ticker, date, params = {}) ⇒ Object
-
#historic_trades(ticker, date, params = {}) ⇒ Object
-
#last_quote(symbol) ⇒ Object
-
#last_trade(symbol) ⇒ Object
-
#list_exchanges ⇒ Object
-
#previous_close(ticker, unadjusted = false) ⇒ Object
-
#snapshot(ticker) ⇒ Object
-
#snapshot_gainers_losers(direction) ⇒ Object
#initialize
Instance Method Details
#aggregates(ticker, multiplier, timespan, from, to, unadjusted = false) ⇒ Object
rubocop:disable Metrics/ParameterLists
285
286
287
288
289
290
291
292
293
294
295
|
# File 'lib/polygonio/rest/api/stocks.rb', line 285
def aggregates(ticker, multiplier, timespan, from, to, unadjusted = false) ticker = Types::String[ticker]
multiplier = Types::Integer[multiplier]
timespan = Types::Coercible::String.enum("minute", "hour", "day", "week", "month", "quarter", "year")[timespan]
from = Types::JSON::Date[from]
to = Types::JSON::Date[to]
unadjusted = Types::Bool[unadjusted]
res = client.request.get("/v2/aggs/ticker/#{ticker}/range/#{multiplier}/#{timespan}/#{from}/#{to}", { unadjusted: unadjusted })
AggregatesResponse[res.body]
end
|
#condition_mappings(tick_type) ⇒ Object
153
154
155
156
157
158
|
# File 'lib/polygonio/rest/api/stocks.rb', line 153
def condition_mappings(tick_type)
tick_type = Types::String.enum("trades", "quotes")[tick_type]
res = client.request.get("/v1/meta/conditions/#{tick_type}")
Types::Hash[res.body]
end
|
#daily_open_close(symbol, date) ⇒ Object
145
146
147
148
149
150
151
|
# File 'lib/polygonio/rest/api/stocks.rb', line 145
def daily_open_close(symbol, date)
symbol = Types::String[symbol]
date = Types::JSON::Date[date]
res = client.request.get("/v1/open-close/#{symbol}/#{date}")
DailyOpenCloseResponse[res.body]
end
|
#full_snapshot ⇒ Object
210
211
212
213
|
# File 'lib/polygonio/rest/api/stocks.rb', line 210
def full_snapshot
res = client.request.get("/v2/snapshot/locale/us/markets/stocks/tickers")
FullSnapshotResponse[res.body]
end
|
#grouped_daily(locale, market, date, unadjusted = false) ⇒ Object
316
317
318
319
320
321
322
323
324
|
# File 'lib/polygonio/rest/api/stocks.rb', line 316
def grouped_daily(locale, market, date, unadjusted = false)
locale = Types::String[locale]
market = Types::Coercible::String.enum("stocks", "crypto", "bonds", "mf", "mmf", "indices", "fx")[market]
date = Types::JSON::Date[date]
unadjusted = Types::Bool[unadjusted]
res = client.request.get("/v2/aggs/grouped/locale/#{locale}/market/#{market.upcase}/#{date}", { unadjusted: unadjusted })
GroupedDailyResponse[res.body]
end
|
#historic_quotes(ticker, date, params = {}) ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'lib/polygonio/rest/api/stocks.rb', line 81
def historic_quotes(ticker, date, params = {})
ticker = Types::String[ticker]
date = Types::JSON::Date[date]
params = HistoricParams[params]
res = client.request.get("/v2/ticks/stocks/nbbo/#{ticker}/#{date}", params.to_h)
HistoricQuotesResponse[res.body]
end
|
#historic_trades(ticker, date, params = {}) ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/polygonio/rest/api/stocks.rb', line 48
def historic_trades(ticker, date, params = {})
ticker = Types::String[ticker]
date = Types::JSON::Date[date]
params = HistoricParams[params]
res = client.request.get("/v2/ticks/stocks/trades/#{ticker}/#{date}", params.to_h)
HistoricTradesResponse[res.body]
end
|
#last_quote(symbol) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/polygonio/rest/api/stocks.rb', line 126
def last_quote(symbol)
symbol = Types::String[symbol]
res = client.request.get("/v1/last_quote/stocks/#{symbol}")
LastQuoteResponse[res.body]
end
|
#last_trade(symbol) ⇒ Object
105
106
107
108
109
110
|
# File 'lib/polygonio/rest/api/stocks.rb', line 105
def last_trade(symbol)
symbol = Types::String[symbol]
res = client.request.get("/v1/last/stocks/#{symbol}")
LastTradeResponse[res.body]
end
|
#list_exchanges ⇒ Object
15
16
17
18
|
# File 'lib/polygonio/rest/api/stocks.rb', line 15
def list_exchanges
res = client.request.get("/v1/meta/exchanges")
Types::Array.of(StockExchange)[res.body]
end
|
#previous_close(ticker, unadjusted = false) ⇒ Object
258
259
260
261
262
263
264
|
# File 'lib/polygonio/rest/api/stocks.rb', line 258
def previous_close(ticker, unadjusted = false)
ticker = Types::String[ticker]
unadjusted = Types::Bool[unadjusted]
res = client.request.get("/v2/aggs/ticker/#{ticker}/prev", { unadjusted: unadjusted })
PreviousCloseResponse[res.body]
end
|
#snapshot(ticker) ⇒ Object
220
221
222
223
224
225
|
# File 'lib/polygonio/rest/api/stocks.rb', line 220
def snapshot(ticker)
ticker = Types::String[ticker]
res = client.request.get("/v2/snapshot/locale/us/markets/stocks/tickers/#{ticker}")
SnapshotResponse[res.body]
end
|
#snapshot_gainers_losers(direction) ⇒ Object
232
233
234
235
236
237
|
# File 'lib/polygonio/rest/api/stocks.rb', line 232
def snapshot_gainers_losers(direction)
direction = Types::String.enum("gainers", "losers")[direction]
res = client.request.get("/v2/snapshot/locale/us/markets/stocks/#{direction}")
SnapshotGainersLosersResponse[res.body]
end
|