Handling EPIQ Subscriptions
Creating EPIQ subscriptions
TT .NET SDK supports delivering Position-in-Queue (PIQ) for each of you orders. To create a PIQ subscription and start receiving updates:
- Enable EPIQ when initializing the API.
tt_net_sdk.TTAPIOptions.SDKMode sdkMode = tt_net_sdk.TTAPIOptions.SDKMode.Client;
tt_net_sdk.TTAPIOptions apiConfig = new tt_net_sdk.TTAPIOptions(
sdkMode,
environment,
appSecretKey,
5000);
//Set to true if EPIQ is to be calculated
apiConfig.EnableEstimatedPositionInQueue = true;
- Create an EstimatedPositionInQueueSubscription object for a specific instrument.
- Create an event handler method to be called when EPIQ updates are available.
- Register the event handler with the EstimatedPositionInQueueSubscription instance.
- Call the Start() method of the EstimatedPositionInQueueSubscription instance.
Subscribing for EPIQ
Typically, you start an EPIQ subscription immediately after initializing the API. The following snippet demonstrates how to instantiate an EstimatedPositionInQueueSubscription instance:
private EstimatedPositionInQueueSubscription m_epiqSubscription = null;
//subscribe for Estimated Position in Queue
m_epiqSubscription = new EstimatedPositionInQueueSubscription(tt_net_sdk.Dispatcher.Current);
m_epiqSubscription.EstimatedPositionInQueueUpdated += M_epiqSubscription_EstimatedPositionInQueueUpdated;
m_epiqSubscription.Start();
Note: When you have a shared order book or if you have existing orders in the market, you will receive the EPIQ snapshot before receiving the live stream.
Creating the subscription event handler
After the subscription starts, TT .NET SDK retrieves the EPIQ data for all of your orders and invokes the event handler method you registered with the subscription. Subsequent events are then fired as EPIQ changes.
The following code snippet shows the structure of a sample EPIQ subscription event handler method:
private void M_epiqSubscription_EstimatedPositionInQueueUpdated(object sender, EstimatedPositionInQueueEventArgs e)
{
Console.WriteLine("\n==== Estimated Position In Queue : for Order Id => {0} is {1} ======", e.OrderId, e.PositionInQueue);
}