💹 All content on this page is related to Trading Terminal only.
Broker API is a key component that enables live trading. Its main purpose is to connect our charts with your trading logic. In terms of JS
, it is an object
which is expected to expose the specific interface. Here is a list of API's methods that Terminal is expected to have.
The constructor of the Broker API usually takes Trading Host.
This method is called by the Trading Terminal to request positions.
This method is called by the Trading Terminal to request orders.
This method is called by the Trading Terminal to request executions.
This method is called by the Trading Terminal to request trades (individual positions).
e
is a context object passed by a browser
Chart can have a sub-menu Trading
in the context menu. It returns the list of items in a sub-menu. The format is the same as in buttonDropdownItems
.
You don't need to return values other than 1
typically since the broker is already connected when you create the widget. You can use it if you want to display a spinner in the bottom panel while the data is being loaded.
Possible return values are:
ConnectionStatus.Connected = 1
ConnectionStatus.Connecting = 2
ConnectionStatus.Disconnected = 3
ConnectionStatus.Error = 4
This function is required for the Floating Trading Panel. The ability to trade via the panel depends on the result of this function: true
or false
. You don't need to implement this method if all symbols can be traded.
This function should return the information that will be used to build an account manager. See Account Manager for more information.
showOrderDialog(order)
This function is requested by the chart when a user creates or modifies an order.
You have the ability to use your own dialog and manage it as you see fit.
placeOrder(order, silently)
Method is requested when a user wants to place an order. Order is pre-filled with partial or complete information.
If silently
is true
no order dialog should be shown.
modifyOrder(order, silently, focus)
order
is an order object to modifysilently
- if it istrue
no order dialog should be shownfocus
- OrderTicketFocusControl constants. It can be already initialized by the chart.
Method is requested when a user wants to modify an existing order.
This method is requested to cancel a single order with a given id
.
If silently
is true
no dialogs should be shown.
symbol
- symbol stringside
: Side constant orundefined
ordersIds
- ids already collected bysymbol
andside
If silently
is true
no dialogs should be shown.
This method is requested to cancel multiple orders for a symbol
and side
.
positionId
is an ID of an existing position to be modifiedfocus
- Focus constant.
This method is requested if supportPositionBrackets
configuration flag is on. It shows a dialog that enables take profit and stop loss editing.
This method is requested if supportClosePosition
configuration flag is on. It allows to close the position by id.
If silently
is true
no dialogs should be shown.
This method is requested if supportReversePosition
configuration flag is on. It allows to reverse the position by id.
If silently
is true
no dialogs should be shown.
tradeId
is ID of existing trade to be modifiedfocus
- Focus constant.
This method is requested if supportTradeBrackets
configuration flag is on. It displays a dialog that enables take profit and stop loss editing.
This method is requested if supportCloseTrade
configuration flag is on. It allows to close the trade by id.
If silently
is true
no dialogs should be shown.
symbol
- symbol string
This method is requested by the internal Order Dialog, DOM panel and floating trading panel to get symbol information.
The result is an object with the following data:
qty
- object with fieldsmin
,max
andstep
that specifies Quantity, field step and boundaries.pipSize
- size of 1 pip (e.g., 0.0001 for EURUSD)pipValue
- values of 1 pip in account currency (e.g., 1 for EURUSD for an account in USD)minTick
- minimal price change (e.g., 0.00001 for EURUSD). Used for price fields.description
- a description to be displayed in the dialogtype
- instrument type, onlyforex
matters - it enables negative pips. You can check that in the order dialogdomVolumePrecision
- number of decimal places of DOM asks/bids volume (optional, 0 by default)
This method is requested by the internal Order Dialog to get the account information. It should return only one field for now:
- currencySign: string - which is a sign of account currency
Once this method is called the broker should stop providing profit/loss.
The method should be implemented if you use a standard order dialog and support stop loss.
Once this method is called the broker should provide equity updates via equityUpdate method.
The method should be implemented if you use a standard order dialog and support stop loss.
Once this method is called the broker should stop providing equity updates.
- How to connect your trading controller to the chart
- Trading Host