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
• factory: IBrokerConnectionAdapterFactory
Broker Connection Adapter Factory object
Methods
activateBottomWidget
▸ activateBottomWidget(): Promise<void>
Activate bottom widget
Returns
Promise<void>
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
| Name | Type | Description |
|---|---|---|
symbol | string | symbol ID |
balance | CryptoBalance | updated crypto balance |
Returns
void
currentAccountUpdate
▸ currentAccountUpdate(): void
Call this method when user account has been changed synchronously. The terminal will re-request all displayed information.
Returns
void
defaultContextMenuActions
▸ defaultContextMenuActions(context, params?): Promise<ActionMetaInfo[]>
Provides default buy/sell, show properties actions to be returned as a default by IBrokerCommon.chartContextMenuActions.
Parameters
| Name | Type | Description |
|---|---|---|
context | TradeContext | trade context |
params? | DefaultContextMenuActionsParams | optional parameters |
Returns
Promise<ActionMetaInfo[]>
defaultDropdownMenuActions
▸ defaultDropdownMenuActions(options?): ActionMetaInfo[]
Provides default dropdown list of actions. You can use default actions in IBrokerConnectionAdapterHost.setButtonDropdownActions
Parameters
| Name | Type | Description |
|---|---|---|
options? | Partial<DefaultDropdownActionsParams> | options for the dropdown menu actions |
Returns
defaultFormatter
▸ defaultFormatter(symbol, alignToMinMove): Promise<INumberFormatter>
Generates and returns the default value formatter for the symbol
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol identifier |
alignToMinMove | boolean | whether 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 for the specified symbol
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol identifier |
equity | DOMData | Depth of market data |
Returns
void
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
| Name | Type | Description |
|---|---|---|
equity | number | updated equity |
Returns
void
executionUpdate
▸ executionUpdate(execution): void
Call this method when an execution is added.
Parameters
| Name | Type | Description |
|---|---|---|
execution | Execution | execution which was added |
Returns
void
getQty
▸ getQty(symbol): Promise<number>
Returns the quantity for a given symbol.
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol |
Returns
Promise<number>
- quantity for the given symbol
getSymbolMinTick
▸ getSymbolMinTick(symbol): Promise<number>
Returns symbol minTick.
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol identifier |
Returns
Promise<number>
individualPositionPLUpdate
▸ individualPositionPLUpdate(individualPositionId, pl): void
Call this method when a broker connection has received an individual position PL update.
Parameters
| Name | Type | Description |
|---|---|---|
individualPositionId | string | ID of the individual position |
pl | number | updated profit / loss for the individual position |
Returns
void
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
| Name | Type | Description |
|---|---|---|
id | string | ID of the updated individual position |
changes | Partial<IndividualPosition> | changes to the individual position object |
Returns
void
individualPositionUpdate
▸ individualPositionUpdate(individualPosition, isHistoryUpdate?): void
Call this method when an individual position is added or changed.
Parameters
| Name | Type | Description |
|---|---|---|
individualPosition | IndividualPosition | updated individual position |
isHistoryUpdate? | boolean | whether the change is a history update |
Returns
void
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 IBrokerWithoutRealtime.subscribeMarginAvailable.
Parameters
| Name | Type | Description |
|---|---|---|
marginAvailable | number | updated available margin |
Returns
void
numericFormatter
▸ numericFormatter(decimalPlaces?): Promise<INumberFormatter>
Generates and returns a number formatter with the desired decimal places
Parameters
| Name | Type | Description |
|---|---|---|
decimalPlaces? | number | decimal 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
| Name | Type | Description |
|---|---|---|
id | string | order id |
orderChanges | Partial<Order> | changes made to the order object |
Returns
void
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
| Name | Type | Description |
|---|---|---|
order | Order | order which was added or changed |
Returns
void
patchConfig
▸ patchConfig(config): void
Patch changes into the current broker configuration
Parameters
| Name | Type | Description |
|---|---|---|
config | Partial<BrokerConfigFlags> | partial configuration changes to apply |
Returns
void
pipValueUpdate
▸ pipValueUpdate(symbol, pipValues): void
Call this method when a broker connection has a pipValue update.
The library subscribes to pipValue updates using IBrokerWithoutRealtime.subscribePipValue.
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol with updated pip values |
pipValues | PipValues | updated pip values |
Returns
void
plUpdate
▸ plUpdate(positionId, pl): void
Call this method when a broker connection has received a PL update.
Use this method when the BrokerConfigFlags.supportPLUpdate flag is set to true in SingleBrokerMetaInfo.configFlags.
Parameters
| Name | Type | Description |
|---|---|---|
positionId | string | ID of the position |
pl | number | updated profit / loss value |
Returns
void
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
| Name | Type | Description |
|---|---|---|
id | string | id of the position |
positionChanges | Partial<Position> | changes to the position object |
Returns
void
positionUpdate
▸ positionUpdate(position, isHistoryUpdate?): void
Call this method when a position is added or changed.
Parameters
| Name | Type | Description |
|---|---|---|
position | Position | position which was added or changed |
isHistoryUpdate? | boolean | whether the change is a history update |
Returns
void
quantityFormatter
▸ quantityFormatter(decimalPlaces?): Promise<INumberFormatter>
Generates and returns a quantity formatter with the desired decimal places
Parameters
| Name | Type | Description |
|---|---|---|
decimalPlaces? | number | decimal places |
Returns
Promise<INumberFormatter>
realtimeUpdate
▸ realtimeUpdate(symbol, data): void
Trading quote realtime update
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol identifier |
data | TradingQuotes | realtime updated data for the symbol quotes |
Returns
void
sellBuyButtonsVisibility
▸ sellBuyButtonsVisibility(): IWatchedValue<boolean>
Returns whether the buy/sell buttons are visible or not.
Returns
IWatchedValue<boolean>
setDurations
▸ setDurations(durations): void
Set expiration durations
Parameters
| Name | Type | Description |
|---|---|---|
durations | OrderDurationMetaInfo[] | Expiration options for orders |
Returns
void
setQty
▸ setQty(symbol, quantity): void
Sets the quantity for a given symbol.
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol |
quantity | number | quantity to update |
Returns
void
showCancelBracketsDialog
▸ showCancelBracketsDialog(orderId, handler): Promise<void>
Shows the cancel brackets dialog
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | id of order |
handler | () => Promise<void> | cancel brackets confirmation handler (called when brackets should be cancelled) |
Returns
Promise<void>
showCancelMultipleBracketsDialog
▸ showCancelMultipleBracketsDialog(orderId, handler): Promise<void>
Shows the cancel brackets dialog for multiple brackets
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | id of order |
handler | () => Promise<void> | cancel brackets confirmation handler (called when brackets should be cancelled) |
Returns
Promise<void>
showCancelMultipleOrdersDialog
▸ showCancelMultipleOrdersDialog(symbol, side, qty, handler): Promise<void>
Shows the cancel Order Ticket for multiple orders
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol for which to cancel orders |
side | Side | side of the order |
qty | number | quantity of the order |
handler | () => Promise<void> | cancel orders confirmation handler (called when orders should be cancelled) |
Returns
Promise<void>
showCancelOrderDialog
▸ showCancelOrderDialog(orderId, handler): Promise<void>
Shows the cancel Order Ticket for specified order
Parameters
| Name | Type | Description |
|---|---|---|
orderId | string | id of order to potentially cancel |
handler | () => Promise<void> | cancel order confirmation handler (called when order should be cancelled) |
Returns
Promise<void>
showConfirmDialog
▸ showConfirmDialog(title, content, mainButtonText?, cancelButtonText?, showDisableConfirmationsCheckbox?): Promise<boolean>
Displays a confirmation dialog to a user and returns a Promise to the result.
Parameters
| Name | Type | Description |
|---|---|---|
title | string | title of the confirmation dialog |
content | string | string[] | content for the dialog |
mainButtonText? | string | text for the main button (true result) |
cancelButtonText? | string | text for the cancel button (false result) |
showDisableConfirmationsCheckbox? | boolean | show disable confirmations checkbox within the dialog |
Returns
Promise<boolean>
showMessageDialog
▸ showMessageDialog(title, text, textHasHTML?): void
Displays a message dialog to a user.
Parameters
| Name | Type | Description |
|---|---|---|
title | string | title of the message dialog |
text | string | message |
textHasHTML? | boolean | whether message text contains HTML |
Returns
void
showNotification
▸ showNotification(title, text, notificationType?): void
Shows notification message
Parameters
| Name | Type | Description |
|---|---|---|
title | string | notification title |
text | string | notification content |
notificationType? | NotificationType | type of notification (default: NotificationType.Error) |
Returns
void
showOrderDialog
▸ showOrderDialog<T>(order, focus?): Promise<boolean>
Shows the Order Ticket
Type parameters
| Name | Type |
|---|---|
T | extends PreOrder |
Parameters
| Name | Type | Description |
|---|---|---|
order | T | order to show in the dialog |
focus? | OrderTicketFocusControl | input control to focus on when dialog is opened |
Returns
Promise<boolean>
showPositionBracketsDialog
▸ showPositionBracketsDialog(position, brackets, focus): Promise<boolean>
Shows the position brackets dialog
Parameters
| Name | Type | Description |
|---|---|---|
position | Position | IndividualPosition | position or individual position |
brackets | Brackets | brackets for the position or individual position |
focus | OrderTicketFocusControl | input control to focus on when dialog is opened |
Returns
Promise<boolean>
showReversePositionDialog
▸ showReversePositionDialog(position, handler): Promise<boolean>
Shows reverse position dialog
Parameters
| Name | Type | Description |
|---|---|---|
position | string | position 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
| Name | Type | Description |
|---|---|---|
title | string | title of the confirmation dialog |
content | string | string[] | content for the dialog |
mainButtonText? | string | text for the main button (true result) |
cancelButtonText? | string | text for the cancel button (false result) |
showDisableConfirmationsCheckbox? | boolean | show disable confirmations checkbox within the dialog |
Returns
Promise<boolean>
showTradingProperties
▸ showTradingProperties(): void
Shows trading properties
Returns
void
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.
It's the user's responsibility to manage the unsubscription of any added listener
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol to which the callback will be linked to |
listener | SuggestedQtyChangedListener | callback |
Returns
void
unsubscribeSuggestedQtyChange
▸ unsubscribeSuggestedQtyChange(symbol, listener): void
Remove a previously added callback from the list.
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | symbol to remove the callback from |
listener | SuggestedQtyChangedListener | callback to be removed |
Returns
void