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
- all properties correspond to the declared types
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.
Empty fields in bracket controls
You may encounter an issue when the input fields for bracket controls are empty. Besides, users cannot enter values when accessing the Edit position brackets dialog.
This issue occurs because the library has not received all the necessary values for these fields. To solve this issue, ensure that your integration meets the following requirements.
- The
resolveSymbolmethod returns all required fields within theLibrarySymbolInfoobject. - The
symbolInfomethod returns all required fields within theInstrumentInfoobject. - You provide the library with the following updates:
- Quote values via the
getQuotes/subscribeQuotesmethod of the Datafeed API. - Pip values via the
pipValueUpdatemethod of the Trading Host ifsubscribePipValueis implemented. Ignore this update ifsubscribePipValueis not implemented. - Equity values via the
equityUpdatemethod of the Trading Host.tipIt is advisable to send the equity updates once the broker has been created. If you want to provide updates while constructing the broker, encapsulate the updates within the
setTimeoutmethod.setTimeout(() => {
this._host.equityUpdate(12345678);
}, 5);
- Quote values via the