# Position events

Position 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 position 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: trade

Fired when a trade impacting the position is executed.

  • Example
myPosition.on("trade", (e) => {
   const { trade, } = e.descriptor;
   
   // ...
});

# Event: volume-open

Fired when the position volume is increased.

# Event: volume-close

Fired when part of the position volume is closed.

# Event: close

Fired when the entire position volume is closed.

# Event: protection-change

Fired when the position stop loss and/or take profit is changed.

# Event: take-profit-change

Fired when the position take profit is changed.

# Event: stop-loss-change

Fired when the position stop loss is changed.