Skip to content

Cancel On Disconnect Notification

wojciech-adaptive edited this page Jun 29, 2023 · 3 revisions

Usecases

Artio supports a callback for supporting Cancel on Disconnect use-cases if you're building a FIX acceptor on top of Artio. Cancel on Disconnect provides FIX counter-parties with the option to have their orders automatically cancelled by the exchange during logout or when an abnormal disconnection occurs. Artio isn't opinionated about what types of orders are cancelled or the business rules - it just provides a callback when it detects a Session might need to cancel orders. Then your business logic can perform whatever internal cancellation logic is required.

The Callback API

When Artio detects a cancel on disconnect scenario has occurred it will invoke a callback in order to notify your application about the event and enable you to cancel the orders in your internal systems, such as a matching engine. The callbacks is of type CancelOnDisconnectTimeoutHandler and contains a single method that is called when the event occurs. It will notify your application about which session this event happened on. It can be configured using the EngineConfiguration.cancelOnDisconnectTimeoutHandler() configuration method. The default handler is null will implies that cancel on disconnect events will be ignored.

Configuration

By default, COD is disabled and each session needs to provide its desired COD settings in the Logon message. Sessions can configure under what scenarios cancel on disconnect occurs and what the timeout of the cancellation is. You can change the defaults for accepted sessions using EngineConfiguration.cancelOnDisconnectOption() and EngineConfiguration.cancelOnDisconnectTimeoutWindowInMs().

Cancel on disconnect type

By default, in order to enable COD functionality, users must include the tag CancelOnDisconnectType (35002) on every Logon session message, indicating the criteria used to initiate it. If this tag is not present in the Logon message, then the default value is assumed and COD will not be enabled, unless engine configuration is adjusted. The type of this field is a char of length 1. This specifies the criteria used to initiate COD by Artio. Valid values:

0 - Don’t cancel on disconnect or logout. If tag CancelOnDisconnectType (35002) is not present in the logon message or if it’s assigned 35002=0, COD functionality will not be enabled, and your callback will not be invoked.

1 - Cancel on disconnect only. When users want their working orders to be automatically cancelled only upon an abrupt disconnection, tag CancelOnDisconnectType (35002) must be assigned with value 35002=1. If a hard disconnect is detected by Artio then your callback handler will be invoked and when users gracefully terminate the session by sending a logout message, your callback will not be invoked.

2 - Cancel on logout only. When users want their working orders to be cancelled only upon a logout, tag CancelOnDisconnectType (35002) must be assigned with value 35002=2. In this case, when an involuntary session disconnection occurs, your callback will not be invoked.

3 - Cancel on disconnect and logout. When users want their orders to be cancelled upon either a hard disconnection or an intentional logout, tag CancelOnDisconnectType (35002) must be assigned with value 35002=3. In this case, if by any means the session is terminated, the system will automatically try to invoke your callback.

COD Timeout Window

The COD functionality was designed to provide a timeout window that allows the user to reconnect before the orders are cancelled. The value, in milliseconds, must be set in the Logon message using tag CODTimeoutWindow (35003). The countdown is started as soon as the loss of connectivity is detected. If this tag is not provided, it’s assumed 35003=0. The data type of this tag is an int. The maximum allowed value is 60000ms. If a value over 60000 is provided then the limit is echo'd back to the client in the corresponding acceptor logon message.

Your FIX Dictionary

In order to use the Cancel on Disconnect callback with a per session configuration, your FIX Dictionary needs to support the CancelOnDisconnectType (35002) tag and the COD Timeout Window tag.

The cancel on disconnect fields will be echoed back in the corresponding acceptor logon message.

If you set implicit global COD settings using EngineConfiguration, your dictionary doesn't have to include those fields.