Class: Alphapoint::GetQuotes
- Inherits:
-
Object
- Object
- Alphapoint::GetQuotes
- Defined in:
- lib/alphapoint/get_quotes.rb
Instance Method Summary collapse
- #execute(payload, &block) ⇒ Object
-
#initialize(ws) ⇒ GetQuotes
constructor
A new instance of GetQuotes.
Constructor Details
#initialize(ws) ⇒ GetQuotes
Returns a new instance of GetQuotes.
5 6 7 8 9 10 11 |
# File 'lib/alphapoint/get_quotes.rb', line 5 def initialize(ws) @ws = ws @data = [] @instruments_number = -1 @count = 0 end |
Instance Method Details
#execute(payload, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/alphapoint/get_quotes.rb', line 13 def execute(payload, &block) @ws.get_instruments(payload) do |res| res.each do |inst| payloadSub = payload.merge({ InstrumentId: inst['InstrumentId'] }) @ws.subscribe_level1(payloadSub) do |ticker| @data << ticker.merge(inst) @count += 1 block.call(@data) if res.size == @count end end end end |