Trading-Host

:chart: All content on this page is relevant for [[Trading Terminal]] only.

Trading Host is API for interaction between [[Broker API]] and the Chart Trading Subsystem. Its main purpose is to exchange information between our charts with your trading logic. In terms of JS, it is an object with a set of functions. Here is a list of Hosts's methods.

Commands

showOrderDialog(order, handler, focus) : Promise

  1. order to be placed or modified
  2. handler is a function to process buy/sell/modify. It should return Promise
  3. focus - [[Focus constant|Trading-Objects-and-Constants#focusoptions]].

Shows standard order dialog to create or modify an order and executes handler if Buy/Sell/Modify is pressed.

showCancelOrderDialog(orderId, handler) : Promise

  1. orderId ID of an order to be cancelled
  2. handler is a function to process cancellation. It should return Promise

Shows a confirmation dialog and executes handler if YES/OK is pressed.

showCancelMultipleOrdersDialog(symbol, side, qty, handler) : Promise

  1. symbol of orders to be cancelled
  2. side - side of orders to be cancelled
  3. qty - amount of orders to be cancelled
  4. handler is a function to process cancellation. It should return Promise

Shows a confirmation dialog and executes handler if YES/OK is pressed.

showClosePositionDialog([[positionId|Trading-Objects-and-Constants#position]], handler) : Promise

  1. positionId identifier of a position to be closed
  2. handler 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|Trading-Objects-and-Constants#position]], handler) : Promise

  1. position to be reversed
  2. handler is a function to process position reverse. It should return a Promise

Shows a confirmation dialog and executes handler if YES/OK is pressed.

showPositionBracketsDialog([[position|Trading-Objects-and-Constants#position]], [[brackets|Trading-Objects-and-Constants#brackets]], focus, handler) : Promise

  1. position to be modified
  2. brackets (optional) new [brackets|Trading-Objects-and-Constants#Brackets]
  3. focus - [[Focus constant|Trading-Objects-and-Constants#focusoptions]].
  4. 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.

activateBottomWidget : Promise

Opens bottom panel and switches tab to Trading.

showTradingProperties()

Shows the properties dialog, switches current tab to Trading.

showNotification(title, text, type)

Displays a notification. Type can be 1 - success or 0 - error.

triggerShowActiveOrders()

Triggers show active orders.

numericFormatter(decimalPlaces)

Returns a [[Formatter|Trading-Objects-and-Constants#focusoptions]] with the specified number of decimal places.

defaultFormatter(symbol)

Returns a default [[Formatter|Trading-Objects-and-Constants#focusoptions]] formatter for the specified instrument. This formatter is created based on [[SymbolInfo|Symbology#symbolinfo-structure].

factory

factory is an object property. Its members are described below.

factory.createDelegate

Creates a [[Delegate]] object.

factory.createWatchedValue

Creates a [[WatchedValue]] object.

symbolSnapshot(symbol) : Promise

Returns quotes of a symbol.

Getters and Setters

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.

suggestedQty() : Object

Returned object properties:

  1. value - use it to get current value. It returns Promise.
  2. setValue - use it to set new value
  3. changed : [[Subscription]]
    It is to synchronize quantity in Trading Floating Panel and in the dialogs.

setButtonDropdownActions(actions)

Bottom Trading Panel has a button with a list of dropdown items. This method can be used to replace existing items.

  1. actions is an array of [[ActionMetainfo|Trading-Objects-and-Constants#actionmetainfo]], each of them representing one dropdown item.

defaultContextMenuActions()

Provides default buy/sell, show properties actions to be returned as a default by [chartContextMenuItems](Broker API#chartcontextmenuitemse).

defaultDropdownMenuActions(options)

Provides default dropdown list of actions. You can use default actions in setButtonDropdownActions.
You can add/remove default action from the result using options:

  1. showFloatingToolbar: boolean;
  2. tradingProperties: boolean;
  3. selectAnotherBroker: boolean;
  4. disconnect: boolean;

Data Updates

Using of these methods is required to notify the chart that it needs to update information.

orderUpdate([[order|Trading-Objects-and-Constants#order]])

Call this method when an order is added or changed.

orderPartialUpdate([[order|Trading-Objects-and-Constants#order]])

Call this method when an order is not changed, but 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|Trading-Objects-and-Constants#position]])

Call this method when a position is added or changed.

positionPartialUpdate ([[position|Trading-Objects-and-Constants#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|Trading-Objects-and-Constants#execution]])

Call this method when an execution is added.

fullUpdate()

Call this method when an data is invalidated. For example, user account has been changed.

plUpdate(positionId, pl)

Call this method when a broker connection has received a PL update. This method should be used when supportPLUpdate flag is set in configFlags.

equityUpdate(equity)

Call this method when a broker connection has received an equity update. This method is required by the standard order dialog.

tradeUpdate ([[trade|Trading-Objects-and-Constants#trade]])

Call this method when a trade is added or changed.

tradePartialUpdate ([[trade|Trading-Objects-and-Constants#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.

tradePLUpdate(tradeId, pl)

Call this method when a broker connection has received a trade PL update.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市见擦,隨后出現(xiàn)的幾起案子段标,更是在濱河造成了極大的恐慌宣渗,老刑警劉巖焕檬,帶你破解...
    沈念sama閱讀 221,820評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件朱转,死亡現(xiàn)場離奇詭異返吻,居然都是意外死亡逮走,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評論 3 399
  • 文/潘曉璐 我一進店門重慢,熙熙樓的掌柜王于貴愁眉苦臉地迎上來饥臂,“玉大人,你說我怎么就攤上這事似踱∮缥酰” “怎么了志衣?”我有些...
    開封第一講書人閱讀 168,324評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長猛们。 經(jīng)常有香客問我念脯,道長,這世上最難降的妖魔是什么弯淘? 我笑而不...
    開封第一講書人閱讀 59,714評論 1 297
  • 正文 為了忘掉前任绿店,我火速辦了婚禮,結(jié)果婚禮上庐橙,老公的妹妹穿的比我還像新娘假勿。我一直安慰自己,他們只是感情好态鳖,可當我...
    茶點故事閱讀 68,724評論 6 397
  • 文/花漫 我一把揭開白布转培。 她就那樣靜靜地躺著,像睡著了一般浆竭。 火紅的嫁衣襯著肌膚如雪浸须。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,328評論 1 310
  • 那天邦泄,我揣著相機與錄音删窒,去河邊找鬼。 笑死顺囊,一個胖子當著我的面吹牛肌索,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播特碳,決...
    沈念sama閱讀 40,897評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼诚亚,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了午乓?” 一聲冷哼從身側(cè)響起站宗,我...
    開封第一講書人閱讀 39,804評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎硅瞧,沒想到半個月后份乒,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體恕汇,經(jīng)...
    沈念sama閱讀 46,345評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡腕唧,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,431評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了瘾英。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片枣接。...
    茶點故事閱讀 40,561評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖缺谴,靈堂內(nèi)的尸體忽然破棺而出但惶,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 36,238評論 5 350
  • 正文 年R本政府宣布膀曾,位于F島的核電站县爬,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏添谊。R本人自食惡果不足惜财喳,卻給世界環(huán)境...
    茶點故事閱讀 41,928評論 3 334
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望斩狱。 院中可真熱鬧耳高,春花似錦、人聲如沸所踊。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,417評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽秕岛。三九已至碌燕,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間继薛,已是汗流浹背陆蟆。 一陣腳步聲響...
    開封第一講書人閱讀 33,528評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留惋增,地道東北人叠殷。 一個月前我還...
    沈念sama閱讀 48,983評論 3 376
  • 正文 我出身青樓,卻偏偏與公主長得像诈皿,于是被迫代替她去往敵國和親林束。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,573評論 2 359

推薦閱讀更多精彩內(nèi)容