Message: TradeSubscription

File: WebAPI/trade_routing_2.proto

Description

Subscription to trade routing data and notifications about trading information updates. The client can be subscribed to several publications. If some account is subscribed by several publications, then client will receive a separate snapshot per subscription but one real time update with a list of subscriptions.

Limits:

1.  The number of simultaneous subscriptions is limited, 200 by default.

2.  Total number of either explicitly or implicitly subscribed accounts is limited, 5000 by default. Any subscription that leads to exceeding this limit is failed.

Response: TradeSubscriptionStatus, TradeSnapshotCompletion, order_2.OrderStatus, PositionStatus, CollateralStatus, AccountSummaryStatus, ExchangePositionStatus, ExchangeBalanceStatus.

Used in

ClientMsg

Fields

id

Type: uint32

Description: ID of a subscription that should be unique enough to match responses and updates with corresponding requests.

subscription_scopes

Type: uint32

Description: This field is associated with SubscriptionScope enum type. Request is rejected if subscription_scopes contains duplicates.

publication_type

Type: uint32

Description: This field is associated with PublicationType enum type.

account_ids

Type: uint32

Description: Account IDs when publicationType = PUBLICATION_TYPE_ACCOUNTS.

Source: trading_account_2.Account.account_id.

sales_series_number

Type: string

Description: Sales series number when publicationType = PUBLICATION_TYPE_SALES_SERIES.

Source: trading_account_2.SalesSeries.number.

brokerage_id

Type: uint32

Description: Brokerage ID when publicationType = PUBLICATION_TYPE_BROKERAGE or PUBLICATION_TYPE_SALES_SERIES.

Source: trading_account_2.Brokerage.id.

subscribe

Type: bool

Description: True to subscribe, false to unsubscribe (only ID value is used to unsubscribe).

last_order_update_utc_time (deprecated)

Type: sint64

Description: Note: Use last_order_update_utc_timestamp field instead.

last_order_update_utc_timestamp

Type: google.protobuf.Timestamp

Description: Optionally limit request to receive information about orders that were updated/added after specified server related time (inclusive). It is used to reduce the amount of information necessary to send after re-connection. The client should be ready for duplicates that have to be detected by corresponding IDs. If specified it’s used instead of last_order_update_utc_time field.

skip_orders_snapshot

Type: bool

Description: True means sending only real time data and skip sending an initial orders snapshot, send initial snapshot otherwise.

Note: Do not set this attribute after restoring session since some events might be missed to be delivered, use last_order_update_utc_time instead.

Note: When set to True, WebAPI server does not send order snapshots for accounts authorized during the subscription.

confirmed_positions_only

Type: bool

Description: True means sending only FCM confirmed positions and their updates (if subscribed) without matching with current day fills, send matched net positions otherwise.

matching_algorithm

Type: uint32

Description: This field is associated with MatchingAlgorithm enum type. MATCHING_ALGORITHM_FIFO is used if omitted. Applicable only for contracts with metadata_2.ContractMetadata.position_tracking = POSITION_TRACKING_TYPE_NET_POSITION. For other contract types it is always MATCHING_ALGORITHM_FIFO.

match_intraday_first

Type: bool

Description: If true or omitted then intraday trades are matched first and then intraday leftover is matched against previous close positions. If false then previous day open positions and intraday fills are matched in a single pass. Applicable only for contracts with metadata_2.ContractMetadata.position_tracking = POSITION_TRACKING_TYPE_NET_POSITION. For other contract types it is always false.

historical_matching_algorithm

Type: uint32

Description: This field is associated with MatchingAlgorithm enum type. Historical positions Matching algorithm. The same as matching_algorithm if omitted. It is ignored if match_intraday_first is false. Applicable only for contracts with metadata_2.ContractMetadata.position_tracking = POSITION_TRACKING_TYPE_NET_POSITION.

include_cross_orders

Type: bool

Description: If this field is set to true, statuses on orders with ORDER_TYPE_CROSS type will be included into responses. See CrossOrderParameters message.

Note: Order statuses with cross order type are excluded from snapshot only if
include_cross_orders set to false (or empty) and ORDER_TYPE_CROSS type is not included
into order_snapshot_filter.order_types.

include_algo_strategy_child_orders

Type: bool

Description: If this field is set to true, child orders of algo strategies will be included into responses. Algo strategy order is order that has Order.algo_strategy field set. Some of these subordinate orders will reference initial order (see strategy_2.SyntheticStrategyProperties.root_order_id), such orders are algo strategy “child” orders.

Note: Unlike synthetic strategy case, algo strategy child orders are not included in subscription’s snapshot or updates by default. Unlike synthetic strategy case, fill transactions of child orders are duplicated in algo strategy parent order, but shall be counted only once in calculations of position, collaterals, etc. Algo strategy child order doesn’t correspond to any “leg” or “node” in “synthetic strategy” sense, so for algo strategy child order strategy_2.SyntheticStrategyProperties.node_number is not set.

order_snapshot_filter

Type: OrderSnapshotFilter

Description: Only order statuses that match the filter are included in a snapshot. By default, no filtration is done by the filter. Affects result for scope SUBSCRIPTION_SCOPE_ORDERS.

Note: The snapshot might still include additional data in responses (e.g., when multiple trade subscriptions with different snapshot filters are requested).

account_summary_parameters

Type: AccountSummaryParameters

Description: Parameters for account summary trade subscription. It is required field for subscriptions with SUBSCRIPTION_SCOPE_ACCOUNT_SUMMARY scope.

Enum SubscriptionScope

Description: Scope of the subscription.

Values

      SUBSCRIPTION_SCOPE_ORDERS = 1

     Subscribe to order updates.

      SUBSCRIPTION_SCOPE_POSITIONS = 2

     Subscribe to open positions and matched trades updates.

     Note: PositionStatus messages are reported only for accounts with trading_account_2.Account.cleared_by_statements=True flag. Accounts without this flag will not receive PositionStatus messages, but the subscription will succeed.

      SUBSCRIPTION_SCOPE_COLLATERAL = 3

     Deprecated. Use SUBSCRIPTION_SCOPE_ACCOUNT_SUMMARY instead.

      SUBSCRIPTION_SCOPE_ACCOUNT_SUMMARY = 4

     Subscribe to account summary updates (current margin, purchasing power, total filled quantity, etc.).

     Note: AccountSummaryStatus messages are reported only for accounts with trading_account_2.Account.cleared_by_statements=True flag. Accounts without this flag will not receive AccountSummaryStatus messages, but the subscription will succeed.

      SUBSCRIPTION_SCOPE_EXCHANGE_POSITIONS = 5

     Subscribe to positions updates from exchange.

     Note: ExchangePositionStatus messages are reported only for accounts with trading_account_2.Account.supports_exchange_positions_subscription=True flag. Accounts without this flag will not receive ExchangePositionStatus messages, but the subscription will succeed.

      SUBSCRIPTION_SCOPE_EXCHANGE_BALANCES = 6

     Subscribe to balances updates from exchange on a per-currency basis.

     Note: ExchangeBalanceStatus messages are reported only for accounts with trading_account_2.Account.supports_exchange_balances_subscription=True flag. Accounts without this flag will not receive ExchangeBalanceStatus messages, but the subscription will succeed.

Enum PublicationType

Description: Type of the publication to subscribe.

Values

      PUBLICATION_TYPE_ACCOUNTS = 1

     Subscribe to a single account or list of accounts.

      PUBLICATION_TYPE_SALES_SERIES = 2

     Subscribe to all accounts of a specific sales series.

      PUBLICATION_TYPE_BROKERAGE = 3

     Subscribe to all accounts of a specific brokerage.

      PUBLICATION_TYPE_ALL_AUTHORIZED = 4

     Subscribe to all accounts this user is authorized for (default).

Enum MatchingAlgorithm

Description: Positions matching algorithm (for position subscription).

Values

      MATCHING_ALGORITHM_FIFO = 1

     First In, First Out. The first order filled is the first order offset when an order on the opposite side of the market is executed.

      MATCHING_ALGORITHM_HBHS = 2

     High Buy, High Sell. The highest buy is matched with the highest sell.

      MATCHING_ALGORITHM_LIFO = 3

     Last In, First Out. The last order filled is the first order offset when an order on the opposite side of the market is executed.