# Order events

Order objects are designed to be self-updating, providing seamless integration with the trading platform. These objects establish an internal connection with the platform, allowing them to automatically update their fields whenever a relevant event occurs. This ensures that the information within the order objects remains up-to-date at all times. Additionally, this self-updating mechanism triggers events within the engine, notifying the relevant components of any changes in the order status or associated data.

# Event: status-change

Fired when the order status changes.

  • Example
myOrder.on("status-change", (e) => {
   const { status, previousStatus, } = e.descriptor;
   // ...

# Event: reject

Fired when the order is rejected.

  • Example
myOrder.on("reject", (e) => {
   const rejectionReason = myOrder.rejection;
   // ...

# Event: accept

Fired when the order is validated and accepted.

# Event: pending

Fired when the order enters in pending state, a limit/stop order stays in this state until it gets executed, cancelled, or expires.

# Event: cancel

Fired when the order is cancelled.

# Event: execute

Fired when the order is executed.

  • Example
myOrder.on("execute", (e) => {
   const executedTrades = myOrder.executedTrades;
   const executionPrice = myOrder.executionPrice;
   // ...

# Event: expire

Fired when the order expires.

# Event: trade

Fired when a trade is executed.

# Event: pending-price-change

Fired when the price of a pending limit/stop order has changed.

# Event: pending-volume-change

Fired when the volume of a pending limit/stop order has changed.

# Event: expiration-date-change

Fired when the expiration date of a pending limit/stop order has changed.