public interface Callback
These callbacks are always called from a separate thread, and thus can be called at anytime. The trading client is not re-entrant and calling back into the client from any of these callbacks will result in unpredictable behavior.
None of these callbacks expect exceptions to be thrown from them. Letting an exception escape from any of these callbacks will result in unpredictable behavior.
Most callbacks contain an event-id. These ids are strictly monotonically increasing integers, but they may be discontinuous. When a trading client is created, the last event-id received from a previous client instance can be provided. This allows the trading-server to replay any events which may have occurred since the previous instance was logged in. Event-ids only sequence events within a single account, and automatically reset at the end of the day. Thus it is not possible to replay events across days.
Modifier and Type | Method and Description |
---|---|
void |
onBust(long eventId,
long orderId,
Side reversedSide,
long bustedPrice,
int quantityBusted,
int quantityLeft,
java.util.Date transactTime,
java.lang.String symbol,
FillOptions options)
Called when a previous fill on an US-Equities order is busted
(reversed).
|
void |
onCancelAck(long eventId,
long orderId)
Called upon acknowledgement by the market of a successful
cancel.
|
void |
onCancelReject(long eventId,
long orderId,
java.lang.String reason)
Called upon rejection of a cancel attempt by either the
trading-server or the market.
|
void |
onConnect()
Called when the client successfully connects to the
trading-server.
|
void |
onCorrect(long eventId,
long orderId,
Side side,
long newFillPrice,
int newFilledQuantity,
int quantityLeft,
java.util.Date transactTime,
java.lang.String symbol,
FillOptions options)
Called when a fill correction occurs on an US-Equities order.
|
void |
onDisconnect(java.lang.String reason)
Called if an existing connection to the trading-server is broken
(whether intentionally or unexpectedly), or if a connection
attempt to the trading-server fails.
|
void |
onFill(long eventId,
long orderId,
Side side,
int liquidity,
long fillPrice,
int quantityFilled,
int quantityLeft,
java.util.Date transactTime,
java.lang.String symbol,
FillOptions options)
Called when a fill occurs on an US-Equities order.
|
void |
onOrderAck(long eventId,
long orderId,
long limeOrderId,
AckOptions options)
Called upon acknowledgment by the market of a successful new
order (not a cancel-replace).
|
void |
onOrderEcho(long eventId,
long orderId,
Side side,
long price,
int quantity,
java.lang.String route,
java.lang.String symbol)
Called when a new US-Equities order is placed via some
alternative mechanism into the trading-server (for example, via
Portal).
|
void |
onOrderReject(long eventId,
long orderId,
java.lang.String reason)
Called upon rejection of a new order (not cancel-replace) by
either the trading-server or the market.
|
void |
onPartialCancelAck(long eventId,
long orderId,
int quantityLeft)
Called upon acknowledgement by the market of a successful
partial cancel.
|
void |
onReplaceAck(long eventId,
long origOrderId,
long orderId,
long limeOrderId,
AckOptions options)
Called upon acknowledgement by the market of a successful
cancel-replace.
|
void |
onReplaceEcho(long eventId,
long origOrderId,
long orderId,
long price,
int quantity)
Called when a cancel-replace is attempted via some alternative
mechanism (for example, via Portal).
|
void |
onReplaceReject(long eventId,
long origOrderId,
long orderId,
java.lang.String reason)
Called upon rejection of a cancel-replace by either the
trading-server or the market.
|
void |
onUSOptionsBust(long eventId,
long orderId,
Side reversedSide,
long bustedPrice,
int quantityBusted,
int quantityLeft,
java.util.Date transactTime,
USOptionsSymbol symbol,
FillOptions options)
Called when a previous fill on an US-Options order is busted
(reversed).
|
void |
onUSOptionsCorrect(long eventId,
long orderId,
Side side,
long newFillPrice,
int newFilledQuantity,
int quantityLeft,
java.util.Date transactTime,
USOptionsSymbol symbol,
FillOptions options)
Called when a fill correction occurs on an US-Options order.
|
void |
onUSOptionsFill(long eventId,
long orderId,
Side side,
int liquidity,
long fillPrice,
int quantityFilled,
int quantityLeft,
java.util.Date transactTime,
USOptionsSymbol symbol,
FillOptions options)
Called when a fill occurs on an US-Options order.
|
void |
onUSOptionsOrderEcho(long eventId,
long orderId,
Side side,
long price,
int quantity,
PositionEffect positionEffect,
java.lang.String route,
USOptionsSymbol symbol)
Called when a new US-Options order is placed via some
alternative mechanism into the trading-server (for example, via
Portal).
|
void onConnect()
void onDisconnect(java.lang.String reason)
reason
- textual disconnect reasonClient.disconnect()
void onOrderAck(long eventId, long orderId, long limeOrderId, AckOptions options)
eventId
- event identifierorderId
- client order identifierlimeOrderId
- Lime-Brokerage order identifieroptions
- optional additional informationClient.place(long, int, long, limebrokerage.trading.api.Side, java.lang.String, java.lang.String)
,
Client.placeUSOptions(long, int, long, limebrokerage.trading.api.Side, limebrokerage.trading.api.PositionEffect, limebrokerage.trading.api.USOptionsSymbol, java.lang.String)
void onReplaceAck(long eventId, long origOrderId, long orderId, long limeOrderId, AckOptions options)
eventId
- event identifierorigOrderId
- client identifier of replaced orderorderId
- client identifier of replacement orderlimeOrderId
- Lime-Brokerage replacement order identifieroptions
- optional additional informationClient.replace(long, long, int, long)
,
Client.replaceUSOptions(long, long, int, long)
void onCancelAck(long eventId, long orderId)
eventId
- event identifierorderId
- client order identifierClient.cancel(long)
,
Client.cancelAll()
void onPartialCancelAck(long eventId, long orderId, int quantityLeft)
eventId
- event identifierorderId
- client order identifierquantityLeft
- remaining shares openClient.partialCancel(long, int)
,
Client.cancelAll()
void onOrderReject(long eventId, long orderId, java.lang.String reason)
The reason strings are provided for human consumption and should not be handled programmatically. They can change at any time without warning. Do not hard-code program behavior based on reason string contents.
eventId
- event identifierorderId
- client order identifierreason
- reason for rejection.Client.place(long, int, long, limebrokerage.trading.api.Side, java.lang.String, java.lang.String)
,
Client.placeUSOptions(long, int, long, limebrokerage.trading.api.Side, limebrokerage.trading.api.PositionEffect, limebrokerage.trading.api.USOptionsSymbol, java.lang.String)
void onReplaceReject(long eventId, long origOrderId, long orderId, java.lang.String reason)
The reason strings are provided for human consumption and should not be handled programmatically. They can change at any time without warning. Do not hard-code program behavior based on reason string contents.
eventId
- event identifierorigOrderId
- client identifier of attempted replaced orderorderId
- client identifier of attempted replacement orderreason
- reason for rejectionClient.replace(long, long, int, long)
,
Client.replaceUSOptions(long, long, int, long)
void onCancelReject(long eventId, long orderId, java.lang.String reason)
Note that not all markets provide cancel-rejects in response to unsuccessful cancels. In that case, no response will be received for the cancel attempt.
The reason strings are provided for human consumption and should not be handled programmatically. They can change at any time without warning. Do not hard-code program behavior based on reason string contents.
eventId
- event identifierorderId
- client order identifierreason
- reason for rejectionClient.cancel(long)
,
Client.partialCancel(long, int)
,
Client.cancelAll()
void onFill(long eventId, long orderId, Side side, int liquidity, long fillPrice, int quantityFilled, int quantityLeft, java.util.Date transactTime, java.lang.String symbol, FillOptions options)
quantityLeft
. Once zero, the order is dead.eventId
- event identifierorderId
- client order identifierside
- order's specified sideliquidity
- Lime-Brokerage normalized liquidity codefillPrice
- execution price (scaled by Client.PRICE_SCALE
)quantityFilled
- execution quantityquantityLeft
- number of shares left open in ordertransactTime
- market timestamp when the fill occurredsymbol
- order's specified symboloptions
- optional additional informationvoid onBust(long eventId, long orderId, Side reversedSide, long bustedPrice, int quantityBusted, int quantityLeft, java.util.Date transactTime, java.lang.String symbol, FillOptions options)
A bust can occur for both live and dead orders. However, if the
order was dead, it will remain dead after the bust. A bust cannot
"resurrect" a dead order. Even if the order is dead,
quantityLeft
may still show a non-zero quantity, but
this is for informational purposes only.
reversedSide
, bustedPrice
,
quantityBusted
, and symbol
are provided
for informational purposes, but will always match the values of
the busted fill. The execution-id of the busted fill is provided
in options
.
eventId
- event identifierorderId
- client order identifierreversedSide
- order's reversed side (buy becomes sell, sell becomes buy, etc)bustedPrice
- busted fill's execution price (scaled by Client.PRICE_SCALE
)quantityBusted
- busted fill's execution quantityquantityLeft
- number of shares left open in ordertransactTime
- market or Lime-Brokerage timestamp when the bust occurredsymbol
- order's specified symboloptions
- optional additional informationvoid onCorrect(long eventId, long orderId, Side side, long newFillPrice, int newFilledQuantity, int quantityLeft, java.util.Date transactTime, java.lang.String symbol, FillOptions options)
onBust
callback first to reverse out the erroneous
fill. This callback will then give the corrected fill parameters.
The same caveats with busts regarding dead orders applies here. A correction will not make a dead order become live again.
side
and symbol
are provided for
information purposes, but will always match the specified values
in the order. The execution-id of the corrected fill is provided
in options
. This will be the execution-id of the
original fill if this is an actual correction, or a new
execution-id if this is an administrative fill.
eventId
- event identifierorderId
- client order identifierside
- order's specified sidenewFillPrice
- new execution price (scaled by Client.PRICE_SCALE
)newFilledQuantity
- new execution quantityquantityLeft
- number of shares left open in ordertransactTime
- market or Lime-Brokerage timestamp when the correct occurredsymbol
- order's specified symboloptions
- optional additional informationvoid onUSOptionsFill(long eventId, long orderId, Side side, int liquidity, long fillPrice, int quantityFilled, int quantityLeft, java.util.Date transactTime, USOptionsSymbol symbol, FillOptions options)
quantityLeft
. Once zero, the order is dead.eventId
- event identifierorderId
- client order identifierside
- order's specified sideliquidity
- Lime-Brokerage normalized liquidity codefillPrice
- execution price (scaled by Client.PRICE_SCALE
)quantityFilled
- execution quantityquantityLeft
- number of shares left open in ordertransactTime
- market timestamp when the fill occurredsymbol
- order's specified symboloptions
- optional additional informationvoid onUSOptionsBust(long eventId, long orderId, Side reversedSide, long bustedPrice, int quantityBusted, int quantityLeft, java.util.Date transactTime, USOptionsSymbol symbol, FillOptions options)
A bust can occur for both live and dead orders. However, if the
order was dead, it will remain dead after the bust. A bust cannot
"resurrect" a dead order. Even if the order is dead,
quantityLeft
may still show a non-zero quantity, but
this is for informational purposes only.
reversedSide
, bustedPrice
,
quantityBusted
, and symbol
are provided
for informational purposes, but will always match the values of
the busted fill. The execution-id of the busted fill is provided
in options
.
eventId
- event identifierorderId
- client order identifierreversedSide
- order's reversed side (buy becomes sell, sell becomes buy, etc)bustedPrice
- busted fill's execution price (scaled by Client.PRICE_SCALE
)quantityBusted
- busted fill's execution quantityquantityLeft
- number of shares left open in ordertransactTime
- market or Lime-Brokerage timestamp when the bust occurredsymbol
- order's specified symboloptions
- optional additional informationvoid onUSOptionsCorrect(long eventId, long orderId, Side side, long newFillPrice, int newFilledQuantity, int quantityLeft, java.util.Date transactTime, USOptionsSymbol symbol, FillOptions options)
onUSOptionsBust
callback first to reverse out the
erroneous fill. This callback will then give the corrected fill
parameters.
The same caveats with busts regarding dead orders applies here. A correction will not make a dead order become live again.
side
and symbol
are provided for
information purposes, but will always match the specified values
in the order. The execution-id of the corrected fill is provided
in options
. This will be the execution-id of the
original fill if this is an actual correction, or a new
execution-id if this is an administrative fill.
eventId
- event identifierorderId
- client order identifierside
- order's specified sidenewFillPrice
- new execution price (scaled by Client.PRICE_SCALE
)newFilledQuantity
- new execution quantityquantityLeft
- number of shares left open in ordertransactTime
- market or Lime-Brokerage timestamp when the correct occurredsymbol
- order's specified symboloptions
- optional additional informationvoid onOrderEcho(long eventId, long orderId, Side side, long price, int quantity, java.lang.String route, java.lang.String symbol)
This callback provides a programatic way to inform about the placement of new orders via some alternative mechanism that this application may not be aware of. This behavior must be configured and is not enabled by default.
If an order is reported via this mechanism, it will be followed
by an onOrderAck
(or possibly
onOrderReject
) callback sometime after for the same
order. This callback is triggered when the trading-server
receives the order, where the onOrderAck
callback is
triggered when the market acknowledges the order.
The identifier of this order is generated according to the rules of the mechanism which placed it. In general it is not possible to predict the identifier of the order, but it won't conflict with identifiers of any other live orders.
eventId
- event identifierorderId
- client order identifierside
- order's specified sideprice
- order's specified pricequantity
- order's specified quantityroute
- order's specified routesymbol
- order's specified symbolvoid onUSOptionsOrderEcho(long eventId, long orderId, Side side, long price, int quantity, PositionEffect positionEffect, java.lang.String route, USOptionsSymbol symbol)
This callback provides a programatic way to inform about the placement of new orders via some alternative mechanism that this application may not be aware of. This behavior must be configured and is not enabled by default.
If an order is reported via this mechanism, it will be followed
by an onOrderAck
(or possibly
onOrderReject
) callback sometime after for the same
order. This callback is triggered when the trading-server
receives the order, where the onOrderAck
callback is
triggered when the market acknowledges the order.
The identifier of this order is generated according to the rules of the mechanism which placed it. In general it is not possible to predict the identifier of the order, but it won't conflict with identifiers of any other live orders.
eventId
- event identifierorderId
- client order identifierside
- order's specified sideprice
- order's specified pricequantity
- order's specified quantitypositionEffect
- order's specified position-effectroute
- order's specified routesymbol
- order's specified symbolvoid onReplaceEcho(long eventId, long origOrderId, long orderId, long price, int quantity)
This callback provides a programatic way to inform about cancel-replace attempts via some alternative mechanism that this application may not be aware of. This behavior must be configured and is not enabled by default.
If a cancel-replace is reported via this mechanism, it will be
followed by an onReplaceAck
(or possibly
onReplaceReject
) callback sometime after for the
same order. This callback is triggered when the trading-server
receives the cancel-replace, where the onReplaceAck
callback is triggered when the market acknowledges the
cancel-replace.
The identifier of this replacement order is generated according to the rules of the mechanism which placed it. In general it is not possible to predict the identifier of the order, but it won't conflict with identifiers of any other live orders.
eventId
- event identifierorigOrderId
- client identifier of replaced orderorderId
- client identifier of replacement orderprice
- order's specified pricequantity
- order's specified quantity
Securities are offered by Lime Trading Corp., member FINRA & SIPC,NFA. All investing incurs risk, including but not limited to loss of principal. Further information may be found on our Disclosures Page.
Please read the following documents Characteristics and Risks of Standardized Options before trading options.
Options involve risk and are not suitable for all investors as the special risks inherent to options trading may expose investors to potentially rapid and substantial losses. Options trading privileges are subject to Lime Trading Corp. review and approval. Hedging and protective strategies generally involve additional costs and do not assure a profit or guarantee against loss. With long options, investors may lose 100% of funds invested. Covered calls provide income, downside protection only to the extent of the premium received, and limit upside potential to the strike price plus premium received. Multi-leg option orders are not a standard option trade. There is no national best bid or offer for multi-leg orders. Multi-leg trades are executed on the exchanges at the discretion of specialists or market makers, who cannot be held to a net price on a multi-leg order. Therefore, you may not receive the national best bid or offer on each individual leg of an order. Multi-leg orders are executed as a single trade on the same exchange. Legs cannot be executed separately on different exchanges to get the national best bid or offer for each leg. Each individual leg of a multi-leg order can be subject to early exercise risk, possibly taking away the protection that the multi-leg position may provide. Partial or full assignment on a leg may originate a margin call or losses greater than you anticipated when you entered into the position. When a multi-leg order is canceled or filled, additional reporting may be required by the specialist or market maker. Reporting fills and cancels may cause delays and create risks, especially in fast moving markets. Other risks might be associated with multi-leg options trading.