Module: Polygon::Api::Endpoints
- Included in:
- Client
- Defined in:
- lib/polygon/api/endpoints.rb
Instance Method Summary collapse
- #aggregates(symbol:, multiplier:, timespan:, from:, to:, options: {}) ⇒ Object
- #all_trades(symbol:, date:, options: {}, &block) ⇒ Object
- #trades(symbol:, date:, options: {}) ⇒ Object
Instance Method Details
#aggregates(symbol:, multiplier:, timespan:, from:, to:, options: {}) ⇒ Object
21 22 23 |
# File 'lib/polygon/api/endpoints.rb', line 21 def aggregates(symbol:, multiplier:, timespan:, from:, to:, options: {}) get("/v2/aggs/ticker/#{symbol}/range/#{multiplier}/#{timespan}/#{from}/#{to}", { apiKey: api_key }.merge()) end |
#all_trades(symbol:, date:, options: {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/polygon/api/endpoints.rb', line 10 def all_trades(symbol:, date:, options: {}, &block) last_trade = nil loop do = last_trade ? .merge(timestamp: last_trade&.dig(:t)) : trades = trades(symbol: symbol, date: date, options: )[:results] trades.each { |trade| block.call(trade) } last_trade = trades.last break if trades.size < ([:limit] || 50_000) end end |
#trades(symbol:, date:, options: {}) ⇒ Object
6 7 8 |
# File 'lib/polygon/api/endpoints.rb', line 6 def trades(symbol:, date:, options: {}) get("/v2/ticks/stocks/trades/#{symbol}/#{date}", { apiKey: api_key }.merge()) end |