IBrokerTerminal
Methods
accountManagerInfo
This function should return the information that will be used to build an Account manager.
Signature
accountManagerInfo() => AccountManagerInfo
Returns
cancelOrder
This method is called to cancel a single order with the given id
.
Signature
cancelOrder(orderId: string) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
orderId | string | id for the order to cancel |
Returns
Promise<void>
cancelOrders
This method is called to cancel multiple orders for a symbol
and side
.
ordersIds
parameter should contain the list of order ids to be cancelled.
Signature
cancelOrders(symbol: string, side: Side, ordersIds: string[]) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
side | Side | order side |
ordersIds | string[] | ids already collected by symbol and side |
Returns
Promise<void>
chartContextMenuActions
Chart can have a sub-menu Trading
in the context menu. This method should return an array of ActionMetaInfo elements, each of them representing one context menu item.
Signature
chartContextMenuActions(context: TradeContext, options?: DefaultContextMenuActionsParams) => Promise<ActionMetaInfo[]>
Parameters
Name | Type | Description |
---|---|---|
context | TradeContext | context object passed by a browser |
options? | DefaultContextMenuActionsParams | - |
Returns
Promise<ActionMetaInfo[]>
closePosition
OptionalThis method is called if supportClosePosition
configuration flag is on. It allows to close the position by id.
Signature
closePosition(positionId: string, amount?: number) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
positionId | string | position id |
amount? | number | - |
Returns
Promise<void>
closeTrade
OptionalThis method is called if supportCloseTrade
configuration flag is on. It allows to close the trade by id.
Signature
closeTrade(tradeId: string, amount?: number) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
tradeId | string | trade id |
amount? | number | - |
Returns
Promise<void>
connectionStatus
Connection status for the Broker API.
You don't need to return values other than 1
(Connected
) 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.
Signature
connectionStatus() => ConnectionStatus
Returns
editPositionBrackets
OptionalThis method is called if supportPositionBrackets
configuration flag is on. It shows a dialog that enables take profit
and stop loss
editing.
Signature
editPositionBrackets(positionId: string, brackets: Brackets, customFields?: CustomInputFieldsValues) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
positionId | string | is an ID of an existing position to be modified |
brackets | Brackets | new Brackets to be set for the position |
customFields? | CustomInputFieldsValues | - |
Returns
Promise<void>
editTradeBrackets
OptionalThis method is called if supportTradeBrackets
configuration flag is on. It displays a dialog that enables take profit and stop loss editing.
Signature
editTradeBrackets(tradeId: string, brackets: Brackets) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
tradeId | string | ID of existing trade to be modified |
brackets | Brackets | new Brackets to be set for the trade |
Returns
Promise<void>
executions
Called by Trading Terminal to request executions for the specified symbol
Signature
executions(symbol: string) => Promise<Execution[]>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
Promise<Execution[]>
formatter
OptionalProvide a custom price formatter for the specified symbol.
Signature
formatter(symbol: string, alignToMinMove: boolean) => Promise<INumberFormatter>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
alignToMinMove | boolean | align formatted number to the minimum movement amount of the symbol |
Returns
Promise<INumberFormatter>
getOrderDialogOptions
OptionalImplement this method if you use the standard Order dialog and want to customize it.
Use the symbol
parameter to return customization options for a particular symbol.
Signature
getOrderDialogOptions(symbol: string) => Promise<OrderDialogOptions>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
Promise<OrderDialogOptions>
getPositionDialogOptions
OptionalImplement this method if you want to customize the position dialog.
Signature
getPositionDialogOptions() => PositionDialogOptions
Returns
isTradable
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.
If you want to show a custom message with the reason why the symbol cannot be traded then you can return an object IsTradableResult
.
Signature
isTradable(symbol: string) => Promise<boolean | IsTradableResult>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
Promise<boolean | IsTradableResult>
leverageInfo
OptionalThis method is called to receive leverageInfo from the broker.
Signature
leverageInfo(leverageInfoParams: LeverageInfoParams) => Promise<LeverageInfo>
Parameters
Name | Type | Description |
---|---|---|
leverageInfoParams | LeverageInfoParams | information about the specific symbol to provide leverage info for |
Returns
Promise<LeverageInfo>
modifyOrder
Method is called when a user wants to modify an existing order.
Signature
modifyOrder(order: Order, confirmId?: string) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
order | Order | order information |
confirmId? | string | - |
Returns
Promise<void>
orders
Called by Trading Terminal to request orders
Signature
orders() => Promise<Order[]>
Returns
Promise<Order[]>
ordersHistory
OptionalThis method is called by the Trading Terminal to request orders history.
It is expected that returned orders will have a final status (rejected
, filled
, cancelled
).
This method is optional. If you don't support orders history, please set supportOrdersHistory
flag to false
.
Signature
ordersHistory() => Promise<Order[]>
Returns
Promise<Order[]>
placeOrder
Method is called when a user wants to place an order. Order is pre-filled with partial or complete information. This function returns an object with the order id.
Signature
placeOrder(order: PreOrder, confirmId?: string) => Promise<PlaceOrderResult>
Parameters
Name | Type | Description |
---|---|---|
order | PreOrder | order information |
confirmId? | string | - |
Returns
PlaceOrderResult, which should include an orderId
Promise<PlaceOrderResult>
positions
OptionalCalled by Trading Terminal to request positions
Signature
positions() => Promise<Position[]>
Returns
Promise<Position[]>
previewLeverage
OptionalThis method is called to receive LeveragePreviewResult object which holds messages about the leverage value set by the user.
Signature
previewLeverage(leverageSetParams: LeverageSetParams) => Promise<LeveragePreviewResult>
Parameters
Name | Type | Description |
---|---|---|
leverageSetParams | LeverageSetParams | leverageSetParams is an object similar to leverageInfoParams, but contains an additional leverage: number field, which holds the leverage value set by the user. |
Returns
Promise<LeveragePreviewResult>
previewOrder
OptionalReturns estimated commission, fees, margin and other information for the order without it actually being placed.
The method is called if supportPlaceOrderPreview
configuration flag is on.
Signature
previewOrder(order: PreOrder) => Promise<OrderPreviewResult>
Parameters
Name | Type | Description |
---|---|---|
order | PreOrder | order information |
Returns
Promise<OrderPreviewResult>
quantityFormatter
OptionalProvide a custom quantity formatter for the specified symbol.
Signature
quantityFormatter(symbol: string) => Promise<INumberFormatter>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
Promise<INumberFormatter>
reversePosition
OptionalThis method is called if supportNativeReversePosition
configuration flag is on. It allows to reverse the position by id.
Signature
reversePosition(positionId: string) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
positionId | string | position |
Returns
Promise<void>
setLeverage
OptionalThis method is called to send user's leverage value to the broker. The value should be verified and corrected on the broker's side if required, and sent back in the response.
Signature
setLeverage(leverageSetParams: LeverageSetParams) => Promise<LeverageSetResult>
Parameters
Name | Type | Description |
---|---|---|
leverageSetParams | LeverageSetParams | leverageSetParams is an object similar to leverageInfoParams, but contains an additional leverage: number field, which holds the leverage value set by the user. |
Returns
Promise<LeverageSetResult>
spreadFormatter
OptionalProvide a custom spread formatter for the specified symbol.
Signature
spreadFormatter(symbol: string) => Promise<INumberFormatter>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
Promise<INumberFormatter>
subscribeDOM
OptionalLibrary is requesting that realtime DOM (Depth of Market) updates should be supplied for this symbol
Signature
subscribeDOM(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void
subscribeEquity
OptionalThe method should be implemented if you use the standard Order dialog and support stop loss. Equity is used to calculate Risk in Percent.
Once this method is called the broker should provide equity (Balance + P/L) updates via IBrokerConnectionAdapterHost.equityUpdate method.
Signature
subscribeEquity() => void
Returns
void
subscribeMarginAvailable
OptionalThe method should be implemented if you use the standard Order dialog and want to show the margin meter.
Once this method is called the broker should provide margin available updates via IBrokerConnectionAdapterHost.marginAvailableUpdate method.
Signature
subscribeMarginAvailable(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void
subscribePL
OptionalDeprecated
Brokers should always send PL and equity updates
Signature
subscribePL(positionId: string) => void
Parameters
Name | Type |
---|---|
positionId | string |
Returns
void
subscribePipValue
OptionalThe method should be implemented if you use a standard Order dialog.
pipValues
is displayed in the Order info and it is used to calculate the Trade Value and risks.
If this method is not implemented then pipValue
from the symbolInfo
is used in the order panel/dialog.
Once this method is called the broker should provide pipValue
updates via IBrokerConnectionAdapterHost.pipValueUpdate method.
Signature
subscribePipValue(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void
subscribeRealtime
Library is requesting that realtime updates should be supplied for this symbol.
Signature
subscribeRealtime(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void
symbolInfo
Called by the internal Order dialog, DOM panel, and floating trading panel to get symbol information.
Signature
symbolInfo(symbol: string) => Promise<InstrumentInfo>
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
Promise<InstrumentInfo>
trades
OptionalCalled by Trading Terminal to request trades
Signature
trades() => Promise<Trade[]>
Returns
Promise<Trade[]>
unsubscribeDOM
OptionalLibrary is notifying that realtime DOM (Depth of Market) updates are no longer required for this symbol.
Signature
unsubscribeDOM(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void
unsubscribeEquity
OptionalThe method should be implemented if you use the standard Order dialog and support stop loss.
Once this method is called the broker should stop providing equity updates.
Signature
unsubscribeEquity() => void
Returns
void
unsubscribeMarginAvailable
OptionalThe method should be implemented if you use the standard Order dialog want to show the margin meter.
Once this method is called the broker should stop providing margin available updates.
Signature
unsubscribeMarginAvailable(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void
unsubscribePL
OptionalDeprecated
Signature
unsubscribePL(positionId: string) => void
Parameters
Name | Type |
---|---|
positionId | string |
Returns
void
unsubscribePipValue
OptionalThe method should be implemented if you use a standard Order dialog and implement subscribePipValue
.
Once this method is called the broker should stop providing pipValue
updates.
Signature
unsubscribePipValue(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void
unsubscribeRealtime
Library is notifying that realtime updates are no longer required for this symbol.
Signature
unsubscribeRealtime(symbol: string) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | symbol identifier |
Returns
void