Class: Polygonio::Rest::Crypto
Defined Under Namespace
Classes: CryptoExchange, DailyOpenCloseResponse, FullSnapshotResponse, HistoricTradesResponse, LastTradeResponse, SnapshotBookResponse, SnapshotGainersLosersResponse, SnapshotResponse, SnapshotTicker
Instance Attribute Summary
#client
Instance Method Summary
collapse
#initialize
Instance Method Details
#daily_open_close(from, to, date) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/polygonio/rest/api/crypto.rb', line 65
def daily_open_close(from, to, date)
from = Types::String[from]
to = Types::String[to]
date = Types::JSON::Date[date]
res = client.request.get("/v1/open-close/crypto/#{from}/#{to}/#{date}")
DailyOpenCloseResponse[res.body]
end
|
#full_snapshot ⇒ Object
140
141
142
143
|
# File 'lib/polygonio/rest/api/crypto.rb', line 140
def full_snapshot
res = client.request.get("/v2/snapshot/locale/global/markets/crypto/tickers")
FullSnapshotResponse[res.body]
end
|
#historic_trades(from, to, date, opts = {}) ⇒ Object
90
91
92
93
94
95
96
97
98
|
# File 'lib/polygonio/rest/api/crypto.rb', line 90
def historic_trades(from, to, date, opts = {})
from = Types::String[from]
to = Types::String[to]
date = Types::JSON::Date[date]
opts = PagingParameters[opts]
res = client.request.get("/v1/historic/crypto/#{from}/#{to}/#{date}", opts.to_h)
HistoricTradesResponse[res.body]
end
|
#last_trade(from, to) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/polygonio/rest/api/crypto.rb', line 35
def last_trade(from, to)
from = Types::String[from]
to = Types::String[to]
res = client.request.get("/v1/last/crypto/#{from}/#{to}")
LastTradeResponse[res.body]
end
|
#list ⇒ Object
14
15
16
17
|
# File 'lib/polygonio/rest/api/crypto.rb', line 14
def list
res = client.request.get("/v1/meta/crypto-exchanges")
Types::Array.of(CryptoExchange)[res.body]
end
|
#snapshot(ticker) ⇒ Object
150
151
152
153
154
|
# File 'lib/polygonio/rest/api/crypto.rb', line 150
def snapshot(ticker)
ticker = Types::String[ticker]
res = client.request.get("/v2/snapshot/locale/global/markets/crypto/tickers/#{ticker}")
SnapshotResponse[res.body]
end
|
#snapshot_book(ticker) ⇒ Object
183
184
185
186
187
|
# File 'lib/polygonio/rest/api/crypto.rb', line 183
def snapshot_book(ticker)
ticker = Types::String[ticker]
res = client.request.get("/v2/snapshot/locale/global/markets/crypto/tickers/#{ticker}/book")
SnapshotBookResponse[res.body]
end
|
#snapshot_gainers_losers(direction) ⇒ Object
191
192
193
194
195
|
# File 'lib/polygonio/rest/api/crypto.rb', line 191
def snapshot_gainers_losers(direction)
direction = Types::Coercible::String.enum("gainers", "losers")[direction]
res = client.request.get("/v2/snapshot/locale/global/markets/crypto/#{direction}")
SnapshotGainersLosersResponse[res.body]
end
|