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.
The throttling works as follows:
OnixS::Eurex::Trading::Handler::send
call in the caller's thread;The Sliding Window algorithm is used to keep track of the number of requests sent to Eurex. The algorithm works as follows:
time to wait = time interval - (current time - timestamp of the first request in the window)
;Eurex provides information related to the throttling in the following messages:
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.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.