OnixS Eurex ETI Handler C++ library 9.25.0
API documentation
Loading...
Searching...
No Matches

Introduction

The Handler supports throttling, a mechanism to control the number of requests sent to Eurex. The implementation of throttling is based on the Sliding Window algorithm.

High-level Overview

The throttling works as follows:

  • The Handler keeps track of the number of requests sent to Eurex within a certain time interval;
  • When the number of requests exceeds the limit set by Eurex, the Handler blocks OnixS::Eurex::Trading::Handler::send call in the caller's thread;
  • The Handlers starts waiting until the time interval is finished;
  • When the time interval is finished, the Handler sends a blocked request;
  • The Handler returns the control to the caller's thread.

Sliding Window Algorithm

The Sliding Window algorithm is used to keep track of the number of requests sent to Eurex. The algorithm works as follows:

  • For each request the Handler remembers its timestamp;
  • When the Handler receives a new transaction, it checks the number of requests sent within the time interval;
  • If the number of requests exceeds the limit set by Eurex, the Handler calculates the time to wait and starts waiting;
  • To calculate the time to wait, the Handler uses the following formula: time to wait = time interval - (current time - timestamp of the first request in the window);
  • When the time to wait is finished, the Handler sends a blocked request.

Eurex Messages

Eurex provides information related to the throttling in the following messages:

  • Session Logon Response;
  • Throttle Update Notification.

When the Handler receives any of these messages it updates its internal settings to the new one according to the following fields:

  • ThrottleTimeInterval - is used to set throttle time interval in number of milliseconds applicable for transaction limit;
  • ThrottleNoMsgs - is used to set transaction limit per ThrottleTimeInterval. If set to 0, throttling will be switched off.

Handler Callbacks

Also, the Handler provides additional option to control the throttling - OnixS::Eurex::Trading::HandlerSettings::throttleMessageMargin. This can be useful if a user wants to decrease the number of requests allowed by throttling settings set by Eurex.

The Handler provides the following callbacks related to the throttling:

When the Handler receives either Session Logon Response or Throttle Update Notification it calls OnixS::Eurex::Trading::SessionListener::onThrottleSettingsChanged.

When the Handler detects that the number of requests is higher than allowed by Eurex it calls OnixS::Eurex::Trading::SessionListener::onThrottleDelayStarted and starts waiting. When waiting is finished, the Handler calls OnixS::Eurex::Trading::SessionListener::onThrottleDelayFinished and sends a blocked request.