Common Broker API issues
This article describes common issues that you might face when implementing the Broker API.
Timeout issue
You may encounter one of the following timeout issues:
- Failed to close position: Position closing timeout.
 - Failed to modify order: timeout waiting for new order.
 - Failed to reverse position: Position reversing timeout.
 
These issues happen because the library either received incorrect information or failed to receive timely updates for an order or a position from your Broker API implementation. To avoid these issues, ensure that:
- Your Broker API implementation calls 
orderUpdate/positionUpdatewithin 10 seconds after the library sends a request to place/modify/cancel order or close/reverse position. This update is confirmation to the library that your backend server received the request. - Your backend server and Broker API implementation provide the correct information to the library.
 
Consider the following example: a user closes a position of 10 AAPL shares.
In this case, the library calls the closePosition method to notify your backend server about the user's intent.
As a parameter, it provides your server with positionId.
After that, the library expects your backend server to close the position and provide an update on its new state within 10 seconds.
Your Broker API implementation should call the positionUpdate method on the Trading Host to provide updates.
As a parameter, it should send the correct Position object to the library, which means that:
- the 
idproperty should matchpositionId - the 
qtyproperty should be0 - other required properties are specified
 
When the library gets a position update, for example with a non-zero quantity or a different ID, it assumes the data is for a different position and waits for the correct data. If the library waits more than 10 seconds, it returns Failed to close position: Position closing timeout.