ProtoOaOrderErrorEvent with errorCode: "POSITION_LOCKED" returns no positionID

Created at 10 Feb 2025, 14:02
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
raul_gherman's avatar

raul_gherman

Joined 01.03.2024

ProtoOaOrderErrorEvent with errorCode: "POSITION_LOCKED" returns no positionID
10 Feb 2025, 14:02


maybe it would be useful if returned ProtoOAOrderErrorEvent with errorCode: "POSITION_NOT_FOUND" would include positionId:

ProtoOAOrderErrorEvent {
    payloadType: None,
    ctidTraderAccountId: 4xxxxxxx,
    errorCode: "POSITION_LOCKED",
    orderId: Some(
        0,
    ),
    positionId: Some(
        0,
    ),
    description: None,
}

 

most likely the backend has this info, as it included in errorCode: “POSITION_NOT_FOUND” – maybe it would be more useful if it were returned using the positionId field:

ProtoOAOrderErrorEvent {
    payloadType: None,
    ctidTraderAccountId: 4xxxxxxx,
    errorCode: "POSITION_NOT_FOUND",
    orderId: Some(
        0,
    ),
    positionId: Some(
        0,
    ),
    description: Some(
        "Position not found with id 12345678",
    ),
}

@raul_gherman
Replies

sarah54casiano
11 Feb 2025, 09:31 ( Updated at: 05 Mar 2025, 08:24 )

I completely understand your point. Including the `positionId` in the `ProtoOAOrderErrorEvent` when the `errorCode` is "POSITION_NOT_FOUND" would indeed make the error handling more informative and precise. It would also help in troubleshooting and identifying the specific Tell Culvers position that caused the error. This could be very useful for debugging and improving overall efficiency.

Here's how it could look with the `positionId` included:

```rust
ProtoOAOrderErrorEvent {
   payloadType: None,
   ctidTraderAccountId: 4xxxxxxx,
   errorCode: "POSITION_NOT_FOUND",
   orderId: Some(0),
   positionId: Some(12345678),
   description: Some("Position not found with id 12345678"),
}
```

Including the `positionId` in the error response allows for more detailed logging and tracing of issues, making it easier to pinpoint and resolve problems. It’s definitely a practical improvement. If you plan on proposing this change, it might be helpful to highlight the benefits of enhanced error reporting and troubleshooting it would provide.


@sarah54casiano

raul_gherman
14 Feb 2025, 18:56

POSITION_NOT_FOUND and POSITION_LOCKED – both could use this

thank you so much for properly pointing that out


@raul_gherman