Skip to main content

Trading events

on_order_accept

def on_order_accept(self,
order_id: int, lime_order_: int,
attributes: lime_trading_api.AckAttr,
event_id: int) -> None:
print(f"AckAttr structure for order {order_id}:")
print(str(attributes))

Function is called when the order identified by order_id was accepted by the venue. lime_order_id is generated by Lime trading platform and used to identify the order to the venue. Original client order_id is not exposed to the venue. Additional information that may be provided by markets in the order accept message is presented via AckAttr structure:

fielddescription
Decimal adjusted_priceThe price at which an order or replace was accepted by the market if it is different from the entered price. Some markets (e.g. NASDAQ) may re-price orders on entry. If the accepted price is the same as the entered price of the order or the cancel replace, as is usually the case, adjusted_price is set to zero.
Decimal display_priceThe price at which the order is displayed by the exchange. It is returned if it is different from the adjusted_price and if the customer account is configured to receive displayed prices.
bool display_price_adjustedSome exchanges do not supply the display price itself but inform whether display price is different from the price at which the order was accepted. In such event display_price_adjusted flag will be set, if the account is configured for display price notifications. The flag is always set when non-zero adjusted_price is provided.
string market_cl_ord_idThe value of is set to a ClOrdId used by the Lime trading platform to identify the order to the market if it is different from the lime_order_id. This attribute will only be supplied if the customer account is explicitly configured for it.
string market_order_idThe order id used by the exchange to identify the order. This attribute will only be supplied if the customer account is explicitly configured for it.
lime_trading_api.PositionEffect position_effectThe value of the position_effect as sent to the market. The values are 0=Nil, 1=Open, 1=Close. Only applies to Option orders, otherwise set to zero. The trading server may re-mark this value.
lime_trading_api.Side sideSide enumeration, which is 0=Buy, 1=Sell, 2=SellShort, 3=SellShortExempt, 4=BuyToCover. In some cases the server may re-mark the value

on_order_fill

def on_order_fill(self,
order_id: int,
fill_info: lime_trading_api.FillInfo,
event_id: int) -> None:

The equity order identified by order_id was filled or partially filled. Fill information is contained in FillInfo structure:

fielddescription
string symbolSecurity symbol
lime_trading_api.Side sideSide enumeration, which is 0=Buy, 1=Sell, 2=SellShort, 3=SellShortExempt, 4=BuyToCover
int last_sharesQuantity of shares filled on this execution
Decimal last_priceThe price of this execution.
int left_qtyQuantity left open on the market for the original order. The value is zero if the order is filled completely.
int liquidity
int transact_timeMarket timestamp provided with the fill and is the number of milliseconds since Unix epoch
lime_trading_api.ExecType exec_typeExecType enumeration, 0=Fill, 1=Bust, 2=Correction
string exec_ida globally unique identifier of this execution assigned by Lime. For busts and corrections, the returned exec_id is that of the original execution that is being busted or corrected
string contra_brokerProvided optionally, if passed back by an exchange.
string last_marketProvided optionally, if passed back by an exchange.
string client_data_1The data specified by client when sending the order is echoed back here
string client_data_2The data specified by client when sending the order is echoed back here
string client_data_3The data specified by client when sending the order is echoed back here
string market_liquiduityProvided optionally, if passed back by an exchange.
int transact_time_nanosUnix time stamp with nanoseconds precision

on_options_order_fill

def on_options_order_fill(self,
order_id: int,
fill_info: lime_trading_api.USOptionsFillInfo,
event_id: int) -> None

This is the options equivalent for on_order_fill specifying the fill information on USOptionsFillInfo structure. It is identical to FillInfo structure with only exception of the symbol field, which is not a string but a more complex USOptionSymbol structure.

on_order_cancel

def on_order_cancel(self,
order_id: int,
event_id: int) -> None:

The order identified by order_id was cancelled by the venue.

on_order_reject

def on_order_reject(self,
order_id: int, reason: str,
event_id: int) -> None:

An order identified by order_id was rejected by venue or by Lime trading platform. The reason for the reject is in the reason field. Note that in some rare cases event_id in this callback may be set to zero. This happens if the order is rejected in the API layer itself. Callbacks with zero event_id will not be replayed upon reconnection.

on_order_cancel_reject

def on_order_cancel_reject(self,
order_id: int, reason: str,
event_id: int) -> None:

A cancellation of an order identified by order_id was rejected by venue or by Lime trading platform. The reason for the reject is in the reason field. The most common rejection reason is that the order being cancelled is not open at the moment because it has already been filled or cancelled by this time. Note that in some cases event_id in this callback may be set to zero. This happens if the cancel request is rejected in the API itself Callbacks with zero event_id will not be replayed upon reconnection.

on_order_cancel_replace_reject

def on_order_cancel_replace_reject(self,
order_id: int, replace_order_id: int, reason: str,
event_id: int) -> None:

A cancel replace request identified by replace_order_id for an order identified by order_id was rejected by the venue or by Lime trading platform. The reason for the reject is in the reason field. Note that in some cases event_id in this callback may be set to zero. This happens if the replace request is rejected in the API itself. Callbacks with zero event_id will not be replayed upon reconnection.

on_order_replace

def on_order_replace(self,
order_id: int, replace_order_id: int, lime_replace_order_id: int,
attributes: lime_trading_api.AckAttr,
event_id: int) -> None:

Acknowledges that a previously submitted order identified by order_id is now sucessfully replaced by a new order identified by replace_order_id. Lime trading platform generated lime_replace_order_id for this order and used it to identify the order to the venue. The structure used here is the same as in on_order_accept event

on_manual_order

def on_manual_order(self,
order_id: int,
manual_order_info: lime_trading_api.ManualOrderInfo,
event_id: int) -> None:

Sometimes the orders on Lime accounts are placed out of band, for example, using LimePortal. To facilitate the tracking of positions and exposure in the customer application, the API provides optional callbacks echoing the information about such manual orders.

fielddescription
string symbolSecurity symbol.
string routeA route this order was sent to.
int quantityQuantity of shares.
Decimal priceOrder price in case this is a limit order.
lime_trading_api.Side sideSide enumeration, which is 0=Buy, 1=Sell, 2=SellShort, 3=SellShortExempt, 4=BuyToCover.

on_manual_options_order

def on_manual_options_order(self,
order_id: int,
manual_order_info: lime_trading_api.ManualUSOptionsOrderInfo,
event_id: int) -> None:

The same callback as on_manual_order designed for Options

fielddescription
lime_trading_api.USOptionSymbol symbolOption symbol, refer to on_options_order_fill for details.
string routeA route this order was sent to.
int quantityQuantity of shares.
Decimal priceOrder price in case this is a limit order.
lime_trading_api.Side sideSide enumeration, which is 0=Buy, 1=Sell, 2=SellShort, 3=SellShortExempt, 4=BuyToCover.
lime_trading_api.PositionEffect position_effectThe value of the position_effect as sent to the market. The values are 0=Nil, 1=Open, 1=Close.

on_manual_order_replace

def on_manual_order_replace(self,
order_id: int, replace_order_id: int,
quantity: int, price: Decimal,
event_id : int) -> None:

Notification about an out-of-band order replace. An order known as order_id is being replaced by a new order known as replace_order_id, where quantity and price are the new values.