💹 All content on this page applies to the Trading Terminal only.
Trading Host is an API for interaction between Broker API and the Chart Trading Subsystem. Its main purpose is to exchange information between our charts and your trading adapter. In terms of JS
, it is an object
with a set of functions. Here is the list of Hosts's methods.
order
to be placed or modifiedhandler
is a function to process buy/sell/modify. It should return Promisefocus
- Focus constant.
Shows standard order dialog to create or modify an order and executes handler if Buy/Sell/Modify is pressed.
orderId
ID of an order to be cancelledhandler
is a function to process cancellation. It should return Promise
Shows a confirmation dialog and executes handler if YES/OK is pressed.
symbol
of orders to be cancelledside
- side of orders to be cancelledqty
- amount of orders to be cancelledhandler
is a function to process cancellation. It should return Promise
Shows a confirmation dialog and executes handler if YES/OK is pressed.
showClosePositionDialog(positionId, handler) : Promise
positionId
identifier of a position to be closedhandler
is a function to process position close. It should return Promise
Shows a confirmation dialog and executes handler if YES/OK is pressed.
showReversePositionDialog(position, handler) : Promise
position
to be reversedhandler
is a function to process position reverse. It should return a Promise
Shows a confirmation dialog and executes handler if YES/OK is pressed.
position
to be modifiedbrackets
(optional) new bracketsfocus
- Focus constant.handler
is a function to process modification of brackets. It should return Promise
Shows a default edit brackets dialog and executes handler if MODIFY is pressed.
Opens the bottom panel and switches the tab to Trading.
Shows the properties dialog, switches current tab to Trading.
Displays a notification. Type can be 1
- success or 0
- error.
Triggers show active orders.
Returns a Formatter with the specified number of decimal places.
Returns a default Formatter formatter for the specified instrument. This formatter is created based on SymbolInfo.
factory
is an object property. Its functions are described below.
Creates a Delegate object.
Creates a WatchedValue object.
Creates a price Formatter. The arguments of this function are described in another article.
Returns quotes of a symbol.
floatingTradingPanelVisibility: WatchedValue
Returns whether floatingTradingPanel is visible or not.
showPricesWithZeroVolume: WatchedValue
Returns whether levels with empty volume (between min and max volume levels) are collapsed or not.
silentOrdersPlacement: WatchedValue
Returns if orders can be sent to the broker without showing the order ticket.
Returned object properties:
- value - use it to get the current value. It returns Promise.
- setValue - use it to set new value
- changed : Subscription
It is to synchronize quantity in the Floating Trading Panel and in the dialogs.
Bottom Trading Panel has a button with a list of dropdown items. This method can be used to replace existing items.
actions
is an array of ActionMetainfo, each of them representing one dropdown item.
Provides default buy/sell, show properties actions to be returned as a default by chartContextMenuActions.
Provides default dropdown list of actions. You can use default actions in setButtonDropdownActions.
You can add/remove default action from the result using options
:
showFloatingToolbar
: boolean;tradingProperties
: boolean;selectAnotherBroker
: boolean;disconnect
: boolean;
The usage of these methods is required to notify the chart that it needs to update information.
orderUpdate(order)
Call this method when an order is added or changed.
orderPartialUpdate(order)
Call this method when an order is not changed, but the fields that you added to the order object to display in the Account Manager are changed. It should be used only if you want to display custom fields in the Account Manager.
positionUpdate (position)
Call this method when a position is added or changed.
positionPartialUpdate (position)
Call this method when a position is not changed, but fields that you added to the position object to display in the Account Manager are changed. It should be used only if you want to display custom fields in the Account Manager.
executionUpdate(execution)
Call this method when an execution is added.
Call this method when all data has been changed. For example, user account has been changed.
Call this method when a broker connection has received a PL update. This method should be used when supportPLUpdate
flag is set in configFlags
.
Call this method when a broker connection has received an equity update. This method is required by the standard order dialog.
tradeUpdate (trade)
Call this method when a trade is added or changed.
tradePartialUpdate (trade)
Call this method when a trade is not changed, but fields that you added to the trade object to display in the Account Manager are changed.
Call this method when a broker connection has received a trade PL update.