Skip to main content

Interface: IBrokerConnectionAdapterHost

Broker.IBrokerConnectionAdapterHost

The Trading Host is an API for interaction between the Broker API and the library code related to trading. Its main purpose is to receive information from your backend server where trading logic is implemented and provide updates to the library. Refer to the Core trading concepts article for more information.

Properties​

factory​

Broker Connection Adapter Factory object

Methods​

activateBottomWidget​

Deprecated

activateBottomWidget(): Promise<void>

Deprecated

This method will be removed from the library in the next major version. Please use setAccountManagerVisibilityMode instead. Activate bottom widget


connectionStatusUpdate​

connectionStatusUpdate(status, info?): void

Triggers a connection status update throughout the broker by reinvoking IBrokerCommon.connectionStatus.

Parameters​

NameTypeDescription
statusConnectionStatusnew connection status to propagate internally to the host
info?DisconnectionInfoadditional information to provide when entering a disconnected status

cryptoBalanceUpdate​

cryptoBalanceUpdate(symbol, balance): void

Call this method when a broker connection has received a balance update. This method is required by the crypto Order Ticket. It should be implemented when the BrokerConfigFlags.supportBalances flag is set to true in SingleBrokerMetaInfo.configFlags.

Parameters​

NameTypeDescription
symbolstringsymbol ID
balanceCryptoBalanceupdated crypto balance

currentAccountUpdate​

currentAccountUpdate(): void

Call this method when user account has been changed synchronously. The terminal will re-request all displayed information.


defaultContextMenuActions​

defaultContextMenuActions(context, params?): Promise<ActionMetaInfo[]>

Provides default buy/sell, show properties actions to be returned as a default by IBrokerCommon.chartContextMenuActions.

Parameters​

NameTypeDescription
contextTradeContexttrade context
params?DefaultContextMenuActionsParamsoptional parameters

Returns​

Promise<ActionMetaInfo[]>


defaultDropdownMenuActions​

defaultDropdownMenuActions(options?): ActionMetaInfo[]

Provides default dropdown list of actions. You can use default actions in IBrokerConnectionAdapterHost.setButtonDropdownActions

Parameters​

NameTypeDescription
options?Partial<DefaultDropdownActionsParams>options for the dropdown menu actions

Returns​

ActionMetaInfo[]


defaultFormatter​

defaultFormatter(symbol, alignToMinMove): Promise<INumberFormatter>

Generates and returns the default value formatter for the symbol

Parameters​

NameTypeDescription
symbolstringsymbol identifier
alignToMinMovebooleanwhether the formatted number should be aligned to minimum movement for the symbol

Returns​

Promise<INumberFormatter>


domPanelVisibility​

domPanelVisibility(): IWatchedValue<boolean>

Returns whether DOM Panel is visible or not.

Returns​

IWatchedValue<boolean>


domUpdate​

domUpdate(symbol, equity): void

Update the Depth of Market data for a specified symbol.

Parameters​

NameTypeDescription
symbolstringsymbol identifier
equityDOMDataDepth of Market data

equityUpdate​

equityUpdate(equity): void

Call this method when a broker connection has received an equity update. This method is required by the standard Order Ticket to calculate risks.

Parameters​

NameTypeDescription
equitynumberupdated equity

executionUpdate​

executionUpdate(execution): void

Call this method when an execution is added.

Parameters​

NameTypeDescription
executionExecutionexecution which was added

getAccountManagerVisibilityMode​

getAccountManagerVisibilityMode(): IWatchedValueReadonly<BottomWidgetBarMode>

Method to retrieve the current visibility mode of the Account Manager.

Returns​

IWatchedValueReadonly<BottomWidgetBarMode>


getOrderTicketSetting​

getOrderTicketSetting<K>(settingName): Promise<OrderTicketSettings[K]>

Retrieves the current value for a specified Order Ticket setting in the ellipsis menu.

Type parameters​

NameTypeDescription
Kextends keyof OrderTicketSettingsA key of the OrderTicketSettings type.

Parameters​

NameTypeDescription
settingNameKThe name of the Order Ticket setting.

Returns​

Promise<OrderTicketSettings[K]> — A promise that resolves with the value of the specified setting.


getQty​

getQty(symbol): Promise<number>

Returns the quantity for a given symbol.

Parameters​

NameTypeDescription
symbolstringsymbol

Returns​

Promise<number>

  • quantity for the given symbol

getSymbolMinTick​

getSymbolMinTick(symbol): Promise<number>

Returns symbol minTick.

Parameters​

NameTypeDescription
symbolstringsymbol identifier

Returns​

Promise<number>


individualPositionPLUpdate​

individualPositionPLUpdate(individualPositionId, pl): void

Call this method when a broker connection has received an individual position profit and loss update.

Parameters​

NameTypeDescription
individualPositionIdstringID of the individual position
plnumberupdated profit / loss for the individual position

individualPositionPartialUpdate​

individualPositionPartialUpdate(id, changes): void

Call this method when an individual position has not changed, but fields that you added to the individual position object to display in the Account Manager have changed.

Parameters​

NameTypeDescription
idstringID of the updated individual position
changesPartial<IndividualPosition>changes to the individual position object

individualPositionUpdate​

individualPositionUpdate(individualPosition, isHistoryUpdate?): void

Call this method when an individual position is added or changed.

Parameters​

NameTypeDescription
individualPositionIndividualPositionupdated individual position
isHistoryUpdate?booleanwhether the change is a history update

individualPositionsFullUpdate​

individualPositionsFullUpdate(): void

Call this method to clear the current cache for individual positions and notify the chart that it needs to request individual positions again. Use this method only in cases such as ID mismatches. For more details, see Order and position IDs mismatch.


marginAvailableUpdate​

marginAvailableUpdate(marginAvailable): void

Call this method when a broker connection has received a margin available update. This method is required by the standard Order Ticket to display the margin meter. This method should be used when BrokerConfigFlags.supportMargin is set to true in SingleBrokerMetaInfo.configFlags. The Trading Platform subscribes to margin available updates using IBrokerTerminal.subscribeMarginAvailable.

Parameters​

NameTypeDescription
marginAvailablenumberupdated available margin

numericFormatter​

numericFormatter(decimalPlaces?): Promise<INumberFormatter>

Generates and returns a number formatter with the desired decimal places

Parameters​

NameTypeDescription
decimalPlaces?numberdecimal places

Returns​

Promise<INumberFormatter>


orderPanelVisibility​

orderPanelVisibility(): IWatchedValue<boolean>

Returns whether the order panel is visible or not.

Returns​

IWatchedValue<boolean>


orderPartialUpdate​

orderPartialUpdate(id, orderChanges): void

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 have changed. It should be used only if you want to display custom fields in the Account Manager.

Parameters​

NameTypeDescription
idstringorder id
orderChangesPartial<Order>changes made to the order object

orderUpdate​

orderUpdate(order): void

Call this method to notify the chart that it needs to update information after an order is added or changed.

Parameters​

NameTypeDescription
orderOrderorder which was added or changed

ordersFullUpdate​

ordersFullUpdate(): void

Call this method to clear the current cache for orders and notify the chart that it needs to request orders again. Use this method only in cases such as ID mismatches. For more details, see Order and position IDs mismatch.


patchConfig​

patchConfig(config): void

Patch changes into the current broker configuration

Parameters​

NameTypeDescription
configPartial<BrokerConfigFlags>partial configuration changes to apply

pipValueUpdate​

pipValueUpdate(symbol, pipValues): void

Call this method when a broker connection has a pipValue update. The library subscribes to pipValue updates using IBrokerTerminal.subscribePipValue.

Parameters​

NameTypeDescription
symbolstringsymbol with updated pip values
pipValuesPipValuesupdated pip values

plUpdate​

plUpdate(positionId, pl): void

Call this method when a broker connection has received a profit and loss update. Use this method when the BrokerConfigFlags.supportPLUpdate flag is set to true in SingleBrokerMetaInfo.configFlags.

Parameters​

NameTypeDescription
positionIdstringID of the position
plnumberupdated profit / loss value

positionPartialUpdate​

positionPartialUpdate(id, positionChanges): void

Call this method when a position is not changed, but the fields that you added to the position object to display in the Account Manager have changed. It should be used only if you want to display custom fields in the Account Manager.

Parameters​

NameTypeDescription
idstringid of the position
positionChangesPartial<Position>changes to the position object

positionUpdate​

positionUpdate(position, isHistoryUpdate?): void

Call this method when a position is added or changed.

Parameters​

NameTypeDescription
positionPositionposition which was added or changed
isHistoryUpdate?booleanwhether the change is a history update

positionsFullUpdate​

positionsFullUpdate(): void

Call this method to clear the current cache for positions and notify the chart that it needs to request positions again. Use this method only in cases such as ID mismatches. For more details, see Order and position IDs mismatch.


quantityFormatter​

quantityFormatter(decimalPlaces?): Promise<INumberFormatter>

Generates and returns a quantity formatter with the desired decimal places

Parameters​

NameTypeDescription
decimalPlaces?numberdecimal places

Returns​

Promise<INumberFormatter>


realtimeUpdate​

realtimeUpdate(symbol, data): void

Trading quote realtime update

Parameters​

NameTypeDescription
symbolstringsymbol identifier
dataTradingQuotesrealtime updated data for the symbol quotes

sellBuyButtonsVisibility​

sellBuyButtonsVisibility(): IWatchedValue<boolean>

Returns whether the buy/sell buttons are visible or not.

Returns​

IWatchedValue<boolean>


setAccountManagerVisibilityMode​

setAccountManagerVisibilityMode(mode): void

Method to set a new visibility mode for the Account Manager.

Parameters​

NameType
modeBottomWidgetBarMode

setDurations​

setDurations(durations): void

Set expiration durations

Parameters​

NameTypeDescription
durationsOrderDurationMetaInfo[]Expiration options for orders

setOrderTicketSetting​

setOrderTicketSetting<K>(settingName, value): Promise<void>

Updates the value of a specified Order Ticket setting in the ellipsis menu.

Type parameters​

NameTypeDescription
Kextends keyof OrderTicketSettingsA key of OrderTicketSettings type.

Parameters​

NameTypeDescription
settingNameKThe name of the Order Ticket setting to be updated.
valueOrderTicketSettings[K]The new value to be assigned to the setting.

Returns​

Promise<void> — A promise that resolves when the setting is successfully updated.


setQty​

setQty(symbol, quantity): void

Sets the quantity for a given symbol. Use this method only when you need to override the user-specified quantity with a new value.

To specify the default quantity, use the InstrumentInfo.qty field instead.

Parameters​

NameTypeDescription
symbolstringsymbol
quantitynumberquantity to update

showCancelBracketsDialog​

showCancelBracketsDialog(orderId, handler): Promise<void>

Shows the cancel brackets dialog

Parameters​

NameTypeDescription
orderIdstringid of order
handler() => Promise<void>cancel brackets confirmation handler (called when brackets should be cancelled)

showCancelMultipleBracketsDialog​

showCancelMultipleBracketsDialog(orderId, handler): Promise<void>

Shows the cancel brackets dialog for multiple brackets

Parameters​

NameTypeDescription
orderIdstringid of order
handler() => Promise<void>cancel brackets confirmation handler (called when brackets should be cancelled)

showCancelMultipleOrdersDialog​

showCancelMultipleOrdersDialog(symbol, side, qty, handler): Promise<void>

Shows the cancel Order Ticket for multiple orders

Parameters​

NameTypeDescription
symbolstringsymbol for which to cancel orders
sideSideside of the order
qtynumberquantity of the order
handler() => Promise<void>cancel orders confirmation handler (called when orders should be cancelled)

showCancelOrderDialog​

showCancelOrderDialog(orderId, handler): Promise<void>

Shows the cancel Order Ticket for specified order

Parameters​

NameTypeDescription
orderIdstringid of order to potentially cancel
handler() => Promise<void>cancel order confirmation handler (called when order should be cancelled)

showConfirmDialog​

showConfirmDialog(title, content, mainButtonText?, cancelButtonText?, showDisableConfirmationsCheckbox?): Promise<boolean>

Displays a confirmation dialog to a user and returns a Promise to the result.

Parameters​

NameTypeDescription
titlestringtitle of the confirmation dialog
contentstring | string[]content for the dialog
mainButtonText?stringtext for the main button (true result)
cancelButtonText?stringtext for the cancel button (false result)
showDisableConfirmationsCheckbox?booleanshow disable confirmations checkbox within the dialog

Returns​

Promise<boolean>


showMessageDialog​

showMessageDialog(title, text, textHasHTML?): void

Displays a message dialog to a user.

Parameters​

NameTypeDescription
titlestringtitle of the message dialog
textstringmessage
textHasHTML?booleanwhether message text contains HTML

showNotification​

showNotification(title, text, notificationType?): void

Shows notification message

Parameters​

NameTypeDescription
titlestringnotification title
textstringnotification content
notificationType?NotificationTypetype of notification (default: NotificationType.Error)

showOrderDialog​

Optional

showOrderDialog<T>(order, focus?): Promise<boolean>

Shows the Order Ticket

Type parameters​

NameType
Textends PreOrder

Parameters​

NameTypeDescription
orderTorder to show in the dialog
focus?OrderTicketFocusControlinput control to focus on when dialog is opened

Returns​

Promise<boolean>


showPositionBracketsDialog​

showPositionBracketsDialog(position, brackets, focus): Promise<boolean>

Shows the position brackets dialog

Parameters​

NameTypeDescription
positionPosition | IndividualPositionposition or individual position
bracketsBracketsbrackets for the position or individual position
focusOrderTicketFocusControlinput control to focus on when dialog is opened

Returns​

Promise<boolean>


showReversePositionDialog​

showReversePositionDialog(position, handler): Promise<boolean>

Shows reverse position dialog

Parameters​

NameTypeDescription
positionstringposition to be reversed
handler() => Promise<boolean>reverse position confirmation handler (called when the position should be reversed)

Returns​

Promise<boolean>


showSimpleConfirmDialog​

showSimpleConfirmDialog(title, content, mainButtonText?, cancelButtonText?, showDisableConfirmationsCheckbox?): Promise<boolean>

Displays a simple confirmation dialog to a user and returns a Promise to the result.

Parameters​

NameTypeDescription
titlestringtitle of the confirmation dialog
contentstring | string[]content for the dialog
mainButtonText?stringtext for the main button (true result)
cancelButtonText?stringtext for the cancel button (false result)
showDisableConfirmationsCheckbox?booleanshow disable confirmations checkbox within the dialog

Returns​

Promise<boolean>


showTradingProperties​

showTradingProperties(): void

Shows trading properties


silentOrdersPlacement​

silentOrdersPlacement(): IWatchedValue<boolean>

Returns if orders can be sent to the broker without showing the order ticket.

Returns​

IWatchedValue<boolean>


subscribeSuggestedQtyChange​

subscribeSuggestedQtyChange(symbol, listener): void

Adds a callback to be executed whenever there's a change of quantity for a given symbol.

Make sure to unsubscribe from these changes using the corresponding unsubscribeSuggestedQtyChange method.

Parameters​

NameTypeDescription
symbolstringsymbol to which the callback will be linked to
listenerSuggestedQtyChangedListenercallback

unsubscribeSuggestedQtyChange​

unsubscribeSuggestedQtyChange(symbol, listener): void

Remove a previously added callback from the list.

Parameters​

NameTypeDescription
symbolstringsymbol to remove the callback from
listenerSuggestedQtyChangedListenercallback to be removed