Class: MassiveClient::Rest::Crypto

Inherits:
PolygonRestHandler show all
Defined in:
lib/massiveclient/rest/api/crypto.rb

Defined Under Namespace

Classes: CryptoExchange, DailyOpenCloseResponse, FullSnapshotResponse, HistoricTradesResponse, LastTradeResponse, SnapshotBookResponse, SnapshotGainersLosersResponse, SnapshotResponse, SnapshotTicker

Instance Attribute Summary

Attributes inherited from PolygonRestHandler

#client

Instance Method Summary collapse

Methods inherited from PolygonRestHandler

#initialize

Constructor Details

This class inherits a constructor from MassiveClient::Rest::PolygonRestHandler

Instance Method Details

#daily_open_close(from, to, date) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/massiveclient/rest/api/crypto.rb', line 66

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_snapshotObject



141
142
143
144
# File 'lib/massiveclient/rest/api/crypto.rb', line 141

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



91
92
93
94
95
96
97
98
99
# File 'lib/massiveclient/rest/api/crypto.rb', line 91

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



36
37
38
39
40
41
42
# File 'lib/massiveclient/rest/api/crypto.rb', line 36

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

#listObject



15
16
17
18
# File 'lib/massiveclient/rest/api/crypto.rb', line 15

def list
  res = client.request.get("/v1/meta/crypto-exchanges")
  Types::Array.of(CryptoExchange)[res.body]
end

#snapshot(ticker) ⇒ Object



151
152
153
154
155
# File 'lib/massiveclient/rest/api/crypto.rb', line 151

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



184
185
186
187
188
# File 'lib/massiveclient/rest/api/crypto.rb', line 184

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



192
193
194
195
196
# File 'lib/massiveclient/rest/api/crypto.rb', line 192

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