Class: IGMarkets::Streaming::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/ig_markets/streaming/subscription.rb

Overview

This class manages a single Lightstreamer subscription used to handle streaming data. Subscriptions should always be managed using the methods provided by DealingPlatform::StreamingMethods. Data can be consumed by registering an asynchronous data callback using #on_data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lightstreamer_subscriptionLightstreamer::Subscription (readonly)

The underlying Lightstreamer subscription instance being managed by this class.

Returns:

  • (Lightstreamer::Subscription)

10
11
12
# File 'lib/ig_markets/streaming/subscription.rb', line 10

def lightstreamer_subscription
  @lightstreamer_subscription
end

Instance Method Details

#on_data(&callback) ⇒ Object

Adds the passed block to the list of callbacks that will be run when this subscription receives new data. The block will be called on a worker thread and so the code that is run by the block must be thread-safe. The arguments passed to the block are |data, merged_data|, and the data will be an instance of AccountUpdate, MarketUpdate, DealConfirmation, PositionUpdate, WorkingOrderUpdate, ConsolidatedChartDataUpdate or ChartTickUpdate, depending on what was subscribed to. The merged_data argument will be nil for deal confirmations, position updates, working order updates, and chart tick updates.

Parameters:

  • callback (Proc)

    The callback that is to be run.


41
42
43
# File 'lib/ig_markets/streaming/subscription.rb', line 41

def on_data(&callback)
  @on_data_callbacks << callback
end

#unsilenceObject

If this subscription was started with the silent: true option then this method can be called to unsilence the subscription and start receiving its data.


29
30
31
# File 'lib/ig_markets/streaming/subscription.rb', line 29

def unsilence
  lightstreamer_subscription.unsilence
end