@lumencharts/trading-platform 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +55 -0
  3. package/README.md +53 -2
  4. package/dist/asset-entry.d.ts +3 -0
  5. package/dist/asset.d.ts +3 -0
  6. package/dist/asset.js +21689 -0
  7. package/dist/chart/bracket-links.d.ts +8 -0
  8. package/dist/chart/context-actions.d.ts +7 -0
  9. package/dist/chart/edit-presentation.d.ts +32 -0
  10. package/dist/chart/edit-preview.d.ts +26 -0
  11. package/dist/chart/exit-profit.d.ts +32 -0
  12. package/dist/chart/frame-batch.d.ts +15 -0
  13. package/dist/chart/overlay-coordinator.d.ts +18 -0
  14. package/dist/chart/overlay-events.d.ts +3 -0
  15. package/dist/chart/overlay-gesture.d.ts +40 -0
  16. package/dist/chart/overlay-index.d.ts +30 -0
  17. package/dist/chart/overlay-projection.d.ts +51 -0
  18. package/dist/chart/overlay-types.d.ts +42 -0
  19. package/dist/chart/parent-links.d.ts +33 -0
  20. package/dist/chart/position-profit.d.ts +15 -0
  21. package/dist/chart/review-lock.d.ts +14 -0
  22. package/dist/chart/ticket-projection.d.ts +36 -0
  23. package/dist/compat/default-formatters.d.ts +6 -0
  24. package/dist/compat/delegate.d.ts +11 -0
  25. package/dist/compat/factory.d.ts +5 -0
  26. package/dist/compat/formatters.d.ts +26 -0
  27. package/dist/compat/host-dialogs.d.ts +5 -0
  28. package/dist/compat/host-preferences.d.ts +8 -0
  29. package/dist/compat/host.d.ts +39 -0
  30. package/dist/compat/watched-value.d.ts +25 -0
  31. package/dist/conformance/index.d.ts +78 -0
  32. package/dist/conformance/index.js +6859 -0
  33. package/dist/conformance/replay.d.ts +35 -0
  34. package/dist/contracts/broker.d.ts +1122 -0
  35. package/dist/contracts/broker.js +168 -0
  36. package/dist/contracts/index.d.ts +3 -0
  37. package/dist/contracts/index.js +168 -0
  38. package/dist/contracts/market-data.d.ts +289 -0
  39. package/dist/contracts/market-data.js +11 -0
  40. package/dist/contracts/ports.d.ts +469 -0
  41. package/dist/contracts/ports.js +5 -0
  42. package/dist/core/account-datasets.d.ts +29 -0
  43. package/dist/core/account-lifecycle.d.ts +70 -0
  44. package/dist/core/account-types.d.ts +6 -0
  45. package/dist/core/bounded-map.d.ts +12 -0
  46. package/dist/core/bracket-input.d.ts +32 -0
  47. package/dist/core/bracket-modification.d.ts +6 -0
  48. package/dist/core/bracket-parent.d.ts +11 -0
  49. package/dist/core/broker-debug.d.ts +10 -0
  50. package/dist/core/capabilities.d.ts +34 -0
  51. package/dist/core/capability-metadata.d.ts +60 -0
  52. package/dist/core/capability-policy.d.ts +32 -0
  53. package/dist/core/chart-exit-level.d.ts +11 -0
  54. package/dist/core/chart-order-edit.d.ts +50 -0
  55. package/dist/core/clock.d.ts +2 -0
  56. package/dist/core/close-commands.d.ts +24 -0
  57. package/dist/core/close-flow.d.ts +14 -0
  58. package/dist/core/command-context.d.ts +16 -0
  59. package/dist/core/command-coordinator.d.ts +71 -0
  60. package/dist/core/command-follow.d.ts +32 -0
  61. package/dist/core/command-keys.d.ts +11 -0
  62. package/dist/core/context-orders.d.ts +19 -0
  63. package/dist/core/deferred.d.ts +5 -0
  64. package/dist/core/dialog-coordinator.d.ts +73 -0
  65. package/dist/core/display-preferences.d.ts +10 -0
  66. package/dist/core/disposal.d.ts +8 -0
  67. package/dist/core/entity-store.d.ts +56 -0
  68. package/dist/core/entity-validation.d.ts +9 -0
  69. package/dist/core/errors.d.ts +24 -0
  70. package/dist/core/execution-demand.d.ts +11 -0
  71. package/dist/core/execution-sound.d.ts +10 -0
  72. package/dist/core/exit-level-draft.d.ts +9 -0
  73. package/dist/core/exit-level-summary.d.ts +3 -0
  74. package/dist/core/exit-level-template.d.ts +16 -0
  75. package/dist/core/features.d.ts +39 -0
  76. package/dist/core/financial-rules.d.ts +70 -0
  77. package/dist/core/history-limit.d.ts +11 -0
  78. package/dist/core/identity.d.ts +14 -0
  79. package/dist/core/immutable.d.ts +8 -0
  80. package/dist/core/keyed-ref-count.d.ts +18 -0
  81. package/dist/core/leverage-commands.d.ts +42 -0
  82. package/dist/core/modification-context.d.ts +22 -0
  83. package/dist/core/modification-routing.d.ts +43 -0
  84. package/dist/core/notification-log.d.ts +33 -0
  85. package/dist/core/number-precision.d.ts +4 -0
  86. package/dist/core/order-commands.d.ts +50 -0
  87. package/dist/core/order-duration.d.ts +14 -0
  88. package/dist/core/order-labels.d.ts +7 -0
  89. package/dist/core/order-matching.d.ts +16 -0
  90. package/dist/core/order-modification.d.ts +20 -0
  91. package/dist/core/order-notifications.d.ts +30 -0
  92. package/dist/core/order-protection.d.ts +4 -0
  93. package/dist/core/parent-protection.d.ts +10 -0
  94. package/dist/core/position-commands.d.ts +45 -0
  95. package/dist/core/position-custom-fields.d.ts +5 -0
  96. package/dist/core/position-estimates.d.ts +22 -0
  97. package/dist/core/position-protection-permissions.d.ts +4 -0
  98. package/dist/core/preferences-key.d.ts +2 -0
  99. package/dist/core/preview-leases.d.ts +12 -0
  100. package/dist/core/protection-legs.d.ts +23 -0
  101. package/dist/core/protection-notifications.d.ts +9 -0
  102. package/dist/core/protection-rules.d.ts +21 -0
  103. package/dist/core/quantity-input.d.ts +53 -0
  104. package/dist/core/read-coordinator.d.ts +15 -0
  105. package/dist/core/readers.d.ts +6 -0
  106. package/dist/core/relative-price.d.ts +4 -0
  107. package/dist/core/review-policy.d.ts +17 -0
  108. package/dist/core/session-types.d.ts +1 -0
  109. package/dist/core/session.d.ts +114 -0
  110. package/dist/core/snapshot-dataset.d.ts +47 -0
  111. package/dist/core/symbol-catalog.d.ts +37 -0
  112. package/dist/core/tradability.d.ts +26 -0
  113. package/dist/core/trading-commands.d.ts +104 -0
  114. package/dist/core/trading-rules.d.ts +14 -0
  115. package/dist/core/trading-settings.d.ts +39 -0
  116. package/dist/core/trading-state.d.ts +52 -0
  117. package/dist/core/value-store.d.ts +11 -0
  118. package/dist/index.d.ts +15 -0
  119. package/dist/index.js +6593 -0
  120. package/dist/market-data/depth-book.d.ts +18 -0
  121. package/dist/market-data/index.d.ts +3 -0
  122. package/dist/market-data/index.js +735 -0
  123. package/dist/market-data/session-demand.d.ts +15 -0
  124. package/dist/market-data/subscriptions.d.ts +13 -0
  125. package/dist/mock/broker.d.ts +75 -0
  126. package/dist/mock/clock.d.ts +12 -0
  127. package/dist/mock/feeds.d.ts +18 -0
  128. package/dist/mock/index.d.ts +5 -0
  129. package/dist/mock/index.js +1956 -0
  130. package/dist/mock/protection-cancellation.d.ts +7 -0
  131. package/dist/mock/scenarios.d.ts +5 -0
  132. package/dist/paper/broker.d.ts +41 -0
  133. package/dist/paper/index.d.ts +6 -0
  134. package/dist/paper/index.js +469 -0
  135. package/dist/paper/market.d.ts +57 -0
  136. package/dist/paper/rules.d.ts +40 -0
  137. package/dist/ui/account-manager/account-pages.d.ts +18 -0
  138. package/dist/ui/account-manager/column-presentation.d.ts +5 -0
  139. package/dist/ui/account-manager/context-menu.d.ts +13 -0
  140. package/dist/ui/account-manager/csv-downloads.d.ts +5 -0
  141. package/dist/ui/account-manager/custom-page.d.ts +16 -0
  142. package/dist/ui/account-manager/custom-table.d.ts +18 -0
  143. package/dist/ui/account-manager/format-account-value.d.ts +12 -0
  144. package/dist/ui/account-manager/position-reader.d.ts +19 -0
  145. package/dist/ui/account-manager/row-action-tracker.d.ts +12 -0
  146. package/dist/ui/account-manager/row-actions.d.ts +37 -0
  147. package/dist/ui/account-manager/status-counts.d.ts +6 -0
  148. package/dist/ui/account-manager/table-controls.d.ts +13 -0
  149. package/dist/ui/account-manager/table-export.d.ts +30 -0
  150. package/dist/ui/account-manager/table-model.d.ts +11 -0
  151. package/dist/ui/account-manager/table-toolbar.d.ts +25 -0
  152. package/dist/ui/account-manager/table.d.ts +24 -0
  153. package/dist/ui/account-manager/view.d.ts +19 -0
  154. package/dist/ui/account-manager/workspace.d.ts +15 -0
  155. package/dist/ui/chart-actions.d.ts +11 -0
  156. package/dist/ui/chart-controls/eligibility.d.ts +6 -0
  157. package/dist/ui/chart-controls/quote-buttons.d.ts +15 -0
  158. package/dist/ui/chart-controls/quote-controls.d.ts +12 -0
  159. package/dist/ui/chart-controls/quote-widths.d.ts +8 -0
  160. package/dist/ui/dialogs/close-amount-form.d.ts +8 -0
  161. package/dist/ui/dialogs/close-preview-dialog.d.ts +5 -0
  162. package/dist/ui/dialogs/confirm-dialog.d.ts +7 -0
  163. package/dist/ui/dialogs/dialog-body.d.ts +11 -0
  164. package/dist/ui/dialogs/leverage-form.d.ts +10 -0
  165. package/dist/ui/dialogs/message-dialog.d.ts +6 -0
  166. package/dist/ui/dialogs/position-protection.d.ts +14 -0
  167. package/dist/ui/dialogs/properties-dialog.d.ts +9 -0
  168. package/dist/ui/dialogs/sanitize-html.d.ts +2 -0
  169. package/dist/ui/dialogs/types.d.ts +5 -0
  170. package/dist/ui/dialogs/view.d.ts +5 -0
  171. package/dist/ui/dock-sizes.d.ts +20 -0
  172. package/dist/ui/dom/controller.d.ts +34 -0
  173. package/dist/ui/dom/ladder.d.ts +23 -0
  174. package/dist/ui/dom/view.d.ts +8 -0
  175. package/dist/ui/dom/workspace.d.ts +17 -0
  176. package/dist/ui/effective-mode.d.ts +11 -0
  177. package/dist/ui/financial-lease.d.ts +3 -0
  178. package/dist/ui/icons.d.ts +4 -0
  179. package/dist/ui/index.d.ts +9 -0
  180. package/dist/ui/index.js +15918 -0
  181. package/dist/ui/layout.d.ts +5 -0
  182. package/dist/ui/mount.d.ts +11 -0
  183. package/dist/ui/notifications/log.d.ts +6 -0
  184. package/dist/ui/notifications/toasts.d.ts +5 -0
  185. package/dist/ui/number-input.d.ts +2 -0
  186. package/dist/ui/order-ticket/chart-draft-controls.d.ts +8 -0
  187. package/dist/ui/order-ticket/chart-projection.d.ts +9 -0
  188. package/dist/ui/order-ticket/controller.d.ts +41 -0
  189. package/dist/ui/order-ticket/custom-field.d.ts +9 -0
  190. package/dist/ui/order-ticket/duration-input.d.ts +9 -0
  191. package/dist/ui/order-ticket/exit-input.d.ts +34 -0
  192. package/dist/ui/order-ticket/financial-controls.d.ts +10 -0
  193. package/dist/ui/order-ticket/layout-context.d.ts +7 -0
  194. package/dist/ui/order-ticket/market.d.ts +12 -0
  195. package/dist/ui/order-ticket/menu.d.ts +6 -0
  196. package/dist/ui/order-ticket/mode-rules.d.ts +4 -0
  197. package/dist/ui/order-ticket/modification-fields.d.ts +23 -0
  198. package/dist/ui/order-ticket/move-handle.d.ts +4 -0
  199. package/dist/ui/order-ticket/order-sent.d.ts +4 -0
  200. package/dist/ui/order-ticket/placement.d.ts +27 -0
  201. package/dist/ui/order-ticket/preview-message.d.ts +4 -0
  202. package/dist/ui/order-ticket/price-input.d.ts +14 -0
  203. package/dist/ui/order-ticket/quantity-input.d.ts +26 -0
  204. package/dist/ui/order-ticket/review-panel.d.ts +10 -0
  205. package/dist/ui/order-ticket/rules.d.ts +16 -0
  206. package/dist/ui/order-ticket/stop-input.d.ts +17 -0
  207. package/dist/ui/order-ticket/submit-bar.d.ts +13 -0
  208. package/dist/ui/order-ticket/symbol-search-controller.d.ts +50 -0
  209. package/dist/ui/order-ticket/symbol-search.d.ts +12 -0
  210. package/dist/ui/order-ticket/untradable-notice.d.ts +8 -0
  211. package/dist/ui/order-ticket/view.d.ts +16 -0
  212. package/dist/ui/panel-visibility.d.ts +6 -0
  213. package/dist/ui/pointer-drag.d.ts +20 -0
  214. package/dist/ui/popup-mount.d.ts +4 -0
  215. package/dist/ui/primitives.d.ts +29 -0
  216. package/dist/ui/protection/editor.d.ts +18 -0
  217. package/dist/ui/protection/fields.d.ts +30 -0
  218. package/dist/ui/protection/level.d.ts +14 -0
  219. package/dist/ui/protection/protected-size.d.ts +5 -0
  220. package/dist/ui/protection/ticket-workspace.d.ts +7 -0
  221. package/dist/ui/resize-handle.css +34 -0
  222. package/dist/ui/resize-handle.d.ts +20 -0
  223. package/dist/ui/resize-handle.js +185 -0
  224. package/dist/ui/select.d.ts +26 -0
  225. package/dist/ui/surface-theme.d.ts +3 -0
  226. package/dist/ui/switch.d.ts +7 -0
  227. package/dist/ui/symbol-logo.d.ts +7 -0
  228. package/dist/ui/tabs.d.ts +19 -0
  229. package/dist/ui/ticket-dock.d.ts +18 -0
  230. package/dist/ui/ticket-shell.d.ts +15 -0
  231. package/dist/ui/trading.css +1808 -0
  232. package/dist/ui/trap-tab.d.ts +11 -0
  233. package/dist/vendor/solid-ui/index.d.ts +3 -0
  234. package/dist/vendor/solid-ui/paged-list-window.d.ts +27 -0
  235. package/dist/vendor/solid-ui/virtual-list.d.ts +21 -0
  236. package/package.json +104 -3
@@ -0,0 +1,1122 @@
1
+ /**
2
+ * Broker contracts for the Lumen Charts trading platform: the interface a
3
+ * broker integration implements (`IBrokerTerminal`), the host services it
4
+ * receives (`IBrokerConnectionAdapterHost`) and the order, position,
5
+ * execution and account records they exchange.
6
+ *
7
+ * The shapes follow the widely used broker API surface so existing broker
8
+ * integrations can be connected without changes.
9
+ */
10
+ export declare const enum DisconnectReason {
11
+ SessionRestoreFailed = 0,
12
+ ConnectionLost = 1,
13
+ TokenExpired = 2,
14
+ Inactivity = 3,
15
+ UserLogOut = 4
16
+ }
17
+ export declare const enum DisconnectType {
18
+ LogOut = 0,
19
+ FailedRestoring = 1,
20
+ Offline = 2,
21
+ APIError = 3,
22
+ TwoFactorRequired = 4,
23
+ CancelAuthorization = 5,
24
+ TimeOutForAuthorization = 6,
25
+ OauthError = 7,
26
+ BrokenConnection = 8,
27
+ Reconnect = 9,
28
+ FailedSignIn = 10
29
+ }
30
+ export declare const enum StandardFormatterName {
31
+ Date = "date",
32
+ DateOrDateTime = "dateOrDateTime",
33
+ Default = "default",
34
+ Fixed = "fixed",
35
+ FixedInCurrency = "fixedInCurrency",
36
+ VariablePrecision = "variablePrecision",
37
+ FormatQuantity = "formatQuantity",
38
+ FormatPrice = "formatPrice",
39
+ FormatPriceForexSup = "formatPriceForexSup",
40
+ FormatExitLevels = "formatExitLevels",
41
+ FormatPriceInCurrency = "formatPriceInCurrency",
42
+ IntegerSeparated = "integerSeparated",
43
+ LocalDate = "localDate",
44
+ LocalDateOrDateTime = "localDateOrDateTime",
45
+ Percentage = "percentage",
46
+ ColoredPercentage = "coloredPercentage",
47
+ Pips = "pips",
48
+ Profit = "profit",
49
+ ProfitInInstrumentCurrency = "profitInInstrumentCurrency",
50
+ ProfitInInstrumentCurrencyFloored = "profitInInstrumentCurrencyFloored",
51
+ ProfitInPercent = "profitInPercent",
52
+ Side = "side",
53
+ PositionSide = "positionSide",
54
+ Status = "status",
55
+ Symbol = "symbol",
56
+ Text = "text",
57
+ Type = "type",
58
+ MarginPercent = "marginPercent",
59
+ Empty = "empty"
60
+ }
61
+ export declare enum BottomWidgetBarMode {
62
+ Minimized = "minimized",
63
+ Normal = "normal",
64
+ Maximized = "maximized"
65
+ }
66
+ export declare enum CashTransactionType {
67
+ Deposit = "deposit",
68
+ Withdrawal = "withdrawal"
69
+ }
70
+ export declare enum CommonAccountManagerColumnId {
71
+ Symbol = "symbol"
72
+ }
73
+ /** Connection state reported by the broker. */
74
+ export declare enum ConnectionStatus {
75
+ Connected = 1,
76
+ Connecting = 2,
77
+ Disconnected = 3,
78
+ Error = 4
79
+ }
80
+ export declare enum ConnectionType {
81
+ Demo = 1,
82
+ Real = 0
83
+ }
84
+ export declare enum NotificationType {
85
+ Error = 0,
86
+ Success = 1
87
+ }
88
+ export declare enum OrderOrPositionMessageType {
89
+ Information = "information",
90
+ Warning = "warning",
91
+ Error = "error"
92
+ }
93
+ /** Lifecycle states of an order. */
94
+ export declare enum OrderStatus {
95
+ Canceled = 1,
96
+ Filled = 2,
97
+ Inactive = 3,
98
+ Placing = 4,
99
+ Rejected = 5,
100
+ Working = 6
101
+ }
102
+ export declare enum OrderStatusFilter {
103
+ All = 0,
104
+ Canceled = 1,
105
+ Filled = 2,
106
+ Inactive = 3,
107
+ Rejected = 5,
108
+ Working = 6
109
+ }
110
+ export declare enum OrderTicketFocusControl {
111
+ LimitPrice = 1,
112
+ StopPrice = 2,
113
+ TakeProfit = 3,
114
+ StopLoss = 4,
115
+ Quantity = 5
116
+ }
117
+ /** Supported order types. */
118
+ export declare enum OrderType {
119
+ Limit = 1,
120
+ Market = 2,
121
+ Stop = 3,
122
+ StopLimit = 4
123
+ }
124
+ export declare enum ParentType {
125
+ Order = 1,
126
+ Position = 2,
127
+ IndividualPosition = 3
128
+ }
129
+ export declare enum PriceType {
130
+ Limit = 1,
131
+ Stop = 2
132
+ }
133
+ /** Buy or sell. */
134
+ export declare enum Side {
135
+ Buy = 1,
136
+ Sell = -1
137
+ }
138
+ export declare enum StopType {
139
+ StopLoss = 0,
140
+ TrailingStop = 1,
141
+ GuaranteedStop = 2
142
+ }
143
+ export interface AccountManagerColumnBase<TFormatterName extends StandardFormatterName | FormatterName, TPossibleFields extends string = string> {
144
+ label: string;
145
+ alignment?: CellAlignment;
146
+ id: string;
147
+ formatter?: TFormatterName;
148
+ dataFields: TFormatterName extends StandardFormatterName ? StandardFormattersDependenciesMapping<TPossibleFields>[TFormatterName] : FieldRef<TPossibleFields>[];
149
+ sortProp?: FieldRef;
150
+ notSortable?: boolean;
151
+ help?: string;
152
+ highlightDiff?: boolean;
153
+ notHideable?: boolean;
154
+ hideByDefault?: boolean;
155
+ tooltipProperty?: string;
156
+ isCapitalize?: boolean;
157
+ showZeroValues?: boolean;
158
+ }
159
+ /** Layout of the account manager: summary fields, order and position tables, and extra pages. */
160
+ export interface AccountManagerInfo {
161
+ accountTitle: string;
162
+ summary: AccountManagerSummaryField[];
163
+ customFormatters?: CustomTableElementFormatter[];
164
+ orderColumns: OrderTableColumn[];
165
+ orderColumnsSorting?: SortingParameters;
166
+ historyColumns?: OrderTableColumn[];
167
+ historyColumnsSorting?: SortingParameters;
168
+ positionColumns?: AccountManagerColumn[];
169
+ individualPositionColumns?: AccountManagerColumn[];
170
+ pages: AccountManagerPage[];
171
+ possibleOrderStatuses?: OrderStatus[];
172
+ contextMenuActions?(contextMenuEvent: MouseEvent | TouchEvent, activePageActions: ActionMetaInfo[]): Promise<ActionMetaInfo[]>;
173
+ }
174
+ export interface AccountManagerPage {
175
+ id: string;
176
+ title: string;
177
+ tables: AccountManagerTable[];
178
+ displayCounterInTab?: boolean;
179
+ }
180
+ export interface AccountManagerSummaryField {
181
+ text: string;
182
+ wValue: IWatchedValueReadonly<any>;
183
+ formatter?: StandardFormatterName;
184
+ isDefault?: boolean;
185
+ informerMessage?: string;
186
+ }
187
+ export interface AccountManagerTable {
188
+ id: string;
189
+ title?: string;
190
+ columns: AccountManagerColumn[];
191
+ initialSorting?: SortingParameters;
192
+ changeDelegate: ISubscription<(data: {}) => void>;
193
+ deleteDelegate?: ISubscription<(id: string) => void>;
194
+ flags?: AccountManagerTableFlags;
195
+ getData(paginationLastId?: string | number): Promise<{}[]>;
196
+ }
197
+ export interface AccountManagerTableFlags {
198
+ supportPagination?: boolean;
199
+ }
200
+ export interface AccountMetainfo {
201
+ id: AccountId;
202
+ name: string;
203
+ type?: "live" | "demo";
204
+ currency?: string;
205
+ currencySign?: string;
206
+ }
207
+ export interface ActionDescription {
208
+ text?: "-" | string;
209
+ separator?: boolean;
210
+ shortcut?: string;
211
+ tooltip?: string;
212
+ checked?: boolean;
213
+ checkedStateSource?: () => boolean;
214
+ checkable?: boolean;
215
+ enabled?: boolean;
216
+ externalLink?: boolean;
217
+ icon?: string;
218
+ }
219
+ export interface ActionDescriptionWithCallback extends ActionDescription {
220
+ action: (a?: ActionDescription) => void;
221
+ }
222
+ export interface BaseInputFieldValidatorResult {
223
+ valid: boolean;
224
+ }
225
+ export interface BracketOrder extends PlacedOrder {
226
+ parentId: string;
227
+ parentType: ParentType;
228
+ exitLevelId?: string;
229
+ }
230
+ /** Take-profit and stop-loss prices attached to an order or position. */
231
+ export interface Brackets {
232
+ stopLoss?: number;
233
+ guaranteedStop?: number;
234
+ takeProfit?: number;
235
+ trailingStopPips?: number;
236
+ exitLevels?: ExitLevel[];
237
+ }
238
+ /** Feature switches a broker declares, such as brackets, order types and editing support. Unset flags take their default. */
239
+ export interface BrokerConfigFlags {
240
+ showQuantityInsteadOfAmount?: boolean;
241
+ supportOrderBrackets?: boolean;
242
+ supportStopLoss?: boolean;
243
+ supportTrailingStop?: boolean;
244
+ supportGuaranteedStop?: boolean;
245
+ supportPositions?: boolean;
246
+ supportPositionBrackets?: boolean;
247
+ supportIndividualPositionBrackets?: boolean;
248
+ supportPositionNetting?: boolean;
249
+ supportClosePosition?: boolean;
250
+ supportCloseIndividualPosition?: boolean;
251
+ supportModifyOrderPrice?: boolean;
252
+ supportEditAmount?: boolean;
253
+ supportModifyBrackets?: boolean;
254
+ supportLevel2Data?: boolean;
255
+ supportMultiposition?: boolean;
256
+ supportPLUpdate?: boolean;
257
+ supportReversePosition?: boolean;
258
+ supportNativeReversePosition?: boolean;
259
+ supportMarketOrders?: boolean;
260
+ supportLimitOrders?: boolean;
261
+ supportStopOrders?: boolean;
262
+ supportStopLimitOrders?: boolean;
263
+ supportDemoLiveSwitcher?: boolean;
264
+ supportMarketBrackets?: boolean;
265
+ supportSymbolSearch?: boolean;
266
+ supportModifyDuration?: boolean;
267
+ supportModifyTrailingStop?: boolean;
268
+ supportMargin?: boolean;
269
+ supportPlaceOrderPreview?: boolean;
270
+ supportModifyOrderPreview?: boolean;
271
+ supportLeverage?: boolean;
272
+ supportLeverageButton?: boolean;
273
+ supportOrdersHistory?: boolean;
274
+ supportAddBracketsToExistingOrder?: boolean;
275
+ supportBalances?: boolean;
276
+ closePositionCancelsOrders?: boolean;
277
+ supportOnlyPairPositionBrackets?: boolean;
278
+ supportOnlyPairOrderBrackets?: boolean;
279
+ supportCryptoExchangeOrderTicket?: boolean;
280
+ supportSymbolSpecificCryptoOrderTicket?: boolean;
281
+ positionPLInInstrumentCurrency?: boolean;
282
+ showRiskInInstrumentCurrency?: boolean;
283
+ supportPartialClosePosition?: boolean;
284
+ supportPartialCloseIndividualPosition?: boolean;
285
+ supportCancellingBothBracketsOnly?: boolean;
286
+ supportCryptoBrackets?: boolean;
287
+ showNotificationsLog?: boolean;
288
+ supportStopOrdersInBothDirections?: boolean;
289
+ supportStopLimitOrdersInBothDirections?: boolean;
290
+ supportStrictCheckingLimitOrderPrice?: boolean;
291
+ supportExecutions?: boolean;
292
+ supportModifyOrderType?: boolean;
293
+ requiresFIFOCloseIndividualPositions?: boolean;
294
+ supportMultipleExitLevels?: boolean;
295
+ supportUnpairedExitLevels?: boolean;
296
+ supportCustomOrderInfo?: boolean;
297
+ supportPreviewClosePosition?: boolean;
298
+ }
299
+ export interface BrokerCustomUI {
300
+ showOrderDialog?: (order: OrderTemplate | Order, focus?: OrderTicketFocusControl) => Promise<boolean>;
301
+ showPositionDialog?: (position: Position | IndividualPosition, brackets: Brackets, focus?: OrderTicketFocusControl) => Promise<boolean>;
302
+ showCancelOrderDialog?: (order: Order) => Promise<boolean>;
303
+ showClosePositionDialog?: (position: Position | IndividualPosition) => Promise<boolean>;
304
+ showReversePositionDialog?: (position: Position) => Promise<boolean>;
305
+ }
306
+ export interface ChangeAccountSolution {
307
+ changeAccount: AccountId;
308
+ }
309
+ export interface ChangeSymbolSolution {
310
+ changeSymbol: string;
311
+ }
312
+ export interface CheckboxFieldMetaInfo extends CustomFieldMetaInfoBase {
313
+ inputType: "Checkbox";
314
+ value: boolean;
315
+ supportModify?: boolean;
316
+ help?: string;
317
+ }
318
+ export interface ClosePositionPreviewResult {
319
+ id?: string;
320
+ rows: ClosePositionPreviewRow[];
321
+ disclaimer?: string | MarkupText;
322
+ }
323
+ export interface ClosePositionPreviewRowData {
324
+ title: string;
325
+ value?: string;
326
+ currency?: string;
327
+ }
328
+ export interface ClosePositionPreviewSeparator {
329
+ type: "separator";
330
+ }
331
+ export interface ContractExpirationDate {
332
+ dateOrDateTime: number;
333
+ hasTime: boolean;
334
+ }
335
+ export interface CryptoBalance {
336
+ symbol: string;
337
+ total: number;
338
+ available: number;
339
+ reserved?: number;
340
+ value?: number;
341
+ valueCurrency?: string;
342
+ longName?: string;
343
+ btcValue?: number;
344
+ }
345
+ export interface CustomComboBoxItem {
346
+ text: string;
347
+ value: string;
348
+ }
349
+ export interface CustomComboBoxMetaInfo extends CustomInputFieldMetaInfo {
350
+ inputType: "ComboBox";
351
+ items: CustomComboBoxItem[];
352
+ }
353
+ export interface CustomFieldMetaInfoBase {
354
+ inputType: string;
355
+ id: string;
356
+ title: string;
357
+ value?: any;
358
+ saveToSettings?: boolean;
359
+ }
360
+ export interface CustomInputFieldMetaInfo extends CustomFieldMetaInfoBase {
361
+ preventModify?: boolean;
362
+ placeHolder?: string;
363
+ validator?: InputFieldValidator;
364
+ customInfo?: any;
365
+ }
366
+ export interface CustomInputFieldsValues {
367
+ [fieldId: string]: TextWithCheckboxValue | boolean | string | any;
368
+ }
369
+ export interface CustomTableElementFormatter<T extends TableFormatterInputValues = TableFormatterInputValues> {
370
+ name: FormatterName;
371
+ formatElement?: CustomTableFormatElementFunction<T>;
372
+ formatText: TableFormatTextFunction<T>;
373
+ isPriceFormatterNeeded?: boolean;
374
+ }
375
+ export interface DOMData {
376
+ snapshot: boolean;
377
+ asks: DOMLevel[];
378
+ bids: DOMLevel[];
379
+ }
380
+ export interface DOMLevel {
381
+ price: number;
382
+ volume: number;
383
+ }
384
+ export interface DefaultContextMenuActionsParams {
385
+ }
386
+ export interface DefaultDropdownActionsParams {
387
+ tradingProperties?: boolean;
388
+ restoreConfirmations?: boolean;
389
+ }
390
+ export interface DisconnectionInfo {
391
+ message?: string;
392
+ heading?: string;
393
+ additionalInfo?: string;
394
+ disconnectType?: DisconnectType;
395
+ reason?: DisconnectReason;
396
+ }
397
+ export interface ErrorFormatterParseResult extends FormatterParseResult {
398
+ error?: string;
399
+ res: false;
400
+ }
401
+ /** A single fill reported by the broker. */
402
+ export interface Execution extends WithExtraData {
403
+ id: string;
404
+ symbol: string;
405
+ price: number;
406
+ qty: number;
407
+ side: Side;
408
+ time: number;
409
+ commission?: number;
410
+ fee?: number;
411
+ netAmount?: number;
412
+ currencyRate?: number;
413
+ }
414
+ export interface ExitLevel {
415
+ id: string;
416
+ qty: number;
417
+ takeProfit?: number;
418
+ stopLoss?: number;
419
+ guaranteedStop?: number;
420
+ trailingStopPips?: number;
421
+ isExisting?: boolean;
422
+ }
423
+ export interface ExitLevelTemplate extends ExitLevel {
424
+ tpPips?: number;
425
+ slPips?: number;
426
+ tpRiskInPercent?: number;
427
+ slRiskInPercent?: number;
428
+ tpParentPricePercent?: number;
429
+ slParentPricePercent?: number;
430
+ tpRiskInCurrency?: number;
431
+ slRiskInCurrency?: number;
432
+ }
433
+ export interface ExtraData {
434
+ [key: string]: any;
435
+ }
436
+ export interface FormatterFormatOptions {
437
+ ignoreLocaleNumberFormat?: boolean;
438
+ }
439
+ export interface FormatterParseOptions {
440
+ ignoreLocaleNumberFormat?: boolean;
441
+ }
442
+ export interface FormatterParseResult {
443
+ res: boolean;
444
+ }
445
+ export interface HyperlinkInfo {
446
+ text: string;
447
+ url: string;
448
+ }
449
+ export interface IBoxedValue<T> extends IBoxedValueReadOnly<T> {
450
+ setValue(value: T): void;
451
+ }
452
+ export interface IBoxedValueReadOnly<T> {
453
+ value(): T;
454
+ }
455
+ export interface IBrokerAccountInfo {
456
+ accountsMetainfo(): Promise<AccountMetainfo[]>;
457
+ currentAccount(): AccountId;
458
+ setCurrentAccount?(id: AccountId): void;
459
+ }
460
+ /** Read-only broker surface: account, orders, positions, executions and symbol details. */
461
+ export interface IBrokerCommon {
462
+ chartContextMenuActions(context: TradeContext, options?: DefaultContextMenuActionsParams): Promise<ActionMetaInfo[]>;
463
+ isTradable(symbol: string): Promise<boolean | IsTradableResult>;
464
+ connectionStatus(): ConnectionStatus;
465
+ orders(): Promise<Order[]>;
466
+ ordersHistory?(): Promise<Order[]>;
467
+ positions?(): Promise<Position[]>;
468
+ individualPositions?(): Promise<IndividualPosition[]>;
469
+ executions(symbol: string): Promise<Execution[]>;
470
+ symbolInfo(symbol: string): Promise<InstrumentInfo>;
471
+ accountManagerInfo(): AccountManagerInfo;
472
+ formatter?(symbol: string, alignToMinMove: boolean): Promise<INumberFormatter>;
473
+ spreadFormatter?(symbol: string): Promise<INumberFormatter>;
474
+ quantityFormatter?(symbol: string): Promise<INumberFormatter>;
475
+ getOrderDialogOptions?(symbol: string): Promise<OrderDialogOptions | undefined>;
476
+ getPositionDialogOptions?(symbol: string): Promise<PositionDialogOptions | undefined>;
477
+ getSymbolSpecificTradingOptions?(symbol: string): Promise<SymbolSpecificTradingOptions | undefined>;
478
+ }
479
+ /** Creates the watched values, delegates and formatters a broker integration needs. */
480
+ export interface IBrokerConnectionAdapterFactory {
481
+ createDelegate<T extends Function>(): IDelegate<T>;
482
+ createWatchedValue<T>(value?: T): IWatchedValue<T>;
483
+ createPriceFormatter(priceScale?: number, minMove?: number, fractional?: boolean, minMove2?: number, variableMinTick?: string): IPriceFormatter;
484
+ }
485
+ /** Services the platform gives a broker integration: push updates for orders, positions and executions, connection status, notifications and formatters. */
486
+ export interface IBrokerConnectionAdapterHost {
487
+ factory: IBrokerConnectionAdapterFactory;
488
+ connectionStatusUpdate(status: ConnectionStatus, info?: DisconnectionInfo): void;
489
+ defaultFormatter(symbol: string, alignToMinMove: boolean): Promise<INumberFormatter>;
490
+ numericFormatter(decimalPlaces: number): Promise<INumberFormatter>;
491
+ quantityFormatter(decimalPlaces?: number): Promise<INumberFormatter>;
492
+ defaultContextMenuActions(context: TradeContext, params?: DefaultContextMenuActionsParams): Promise<ActionMetaInfo[]>;
493
+ defaultDropdownMenuActions(options?: Partial<DefaultDropdownActionsParams>): ActionMetaInfo[];
494
+ sellBuyButtonsVisibility(): IWatchedValue<boolean> | null;
495
+ domPanelVisibility(): IWatchedValue<boolean> | null;
496
+ orderPanelVisibility(): IWatchedValue<boolean> | null;
497
+ tradedSourcesVisibility(): IWatchedValue<boolean> | null;
498
+ silentOrdersPlacement(): IWatchedValue<boolean>;
499
+ patchConfig(config: Partial<BrokerConfigFlags>): void;
500
+ setDurations(durations: OrderDurationMetaInfo[]): void;
501
+ orderUpdate(order: Order): void;
502
+ ordersFullUpdate(): void;
503
+ orderPartialUpdate(id: string, orderChanges: Partial<Order>): void;
504
+ positionUpdate(position: Position, isHistoryUpdate?: boolean): void;
505
+ positionsFullUpdate(): void;
506
+ positionPartialUpdate(id: string, positionChanges: Partial<Position>): void;
507
+ individualPositionUpdate(individualPosition: IndividualPosition, isHistoryUpdate?: boolean): void;
508
+ individualPositionsFullUpdate(): void;
509
+ individualPositionPartialUpdate(id: string, changes: Partial<IndividualPosition>): void;
510
+ executionUpdate(execution: Execution): void;
511
+ currentAccountUpdate(): void;
512
+ realtimeUpdate(symbol: string, data: TradingQuotes): void;
513
+ plUpdate(positionId: string, pl: number): void;
514
+ pipValueUpdate(symbol: string, pipValues: PipValues): void;
515
+ individualPositionPLUpdate(individualPositionId: string, pl: number): void;
516
+ equityUpdate(equity: number): void;
517
+ marginAvailableUpdate(marginAvailable: number): void;
518
+ cryptoBalanceUpdate(symbol: string, balance: CryptoBalance): void;
519
+ domUpdate(symbol: string, equity: DOMData): void;
520
+ setQty(symbol: string, quantity: number): void;
521
+ getQty(symbol: string): Promise<number>;
522
+ subscribeSuggestedQtyChange(symbol: string, listener: SuggestedQtyChangedListener): void;
523
+ unsubscribeSuggestedQtyChange(symbol: string, listener: SuggestedQtyChangedListener): void;
524
+ showOrderDialog?<T extends PreOrder>(order: T, focus?: OrderTicketFocusControl): Promise<boolean>;
525
+ showNotification(title: string, text: string, notificationType?: NotificationType): void;
526
+ showCancelOrderDialog(orderId: string, handler: () => Promise<void>): Promise<void>;
527
+ showCancelMultipleOrdersDialog(symbol: string, side: Side, qty: number, handler: () => Promise<void>): Promise<void>;
528
+ showCancelBracketsDialog(orderId: string, handler: () => Promise<void>): Promise<void>;
529
+ showCancelMultipleBracketsDialog(orderId: string, handler: () => Promise<void>): Promise<void>;
530
+ showReversePositionDialog(position: string, handler: () => Promise<boolean>): Promise<boolean>;
531
+ showPositionBracketsDialog(position: Position | IndividualPosition, brackets: Brackets, focus: OrderTicketFocusControl): Promise<boolean>;
532
+ activateBottomWidget(): Promise<void>;
533
+ getAccountManagerVisibilityMode(): IWatchedValueReadonly<BottomWidgetBarMode>;
534
+ setAccountManagerVisibilityMode(mode: BottomWidgetBarMode): void;
535
+ showTradingProperties(): void;
536
+ getSymbolMinTick(symbol: string): Promise<number>;
537
+ showMessageDialog(title: string, text: string, textHasHTML?: boolean): void;
538
+ showConfirmDialog(title: string, content: string | string[], mainButtonText?: string, cancelButtonText?: string, showDisableConfirmationsCheckbox?: boolean): Promise<boolean>;
539
+ showSimpleConfirmDialog(title: string, content: string | string[], mainButtonText?: string, cancelButtonText?: string, showDisableConfirmationsCheckbox?: boolean): Promise<boolean>;
540
+ getOrderTicketSetting<K extends keyof OrderTicketSettings>(settingName: K): Promise<OrderTicketSettings[K]>;
541
+ setOrderTicketSetting<K extends keyof OrderTicketSettings>(settingName: K, value: OrderTicketSettings[K]): Promise<void>;
542
+ }
543
+ /** The interface a broker integration implements. The platform calls it to read account state and to place, modify and cancel orders. */
544
+ export interface IBrokerTerminal extends IBrokerCommon, IBrokerAccountInfo {
545
+ placeOrder(order: PreOrder, confirmId?: string): Promise<PlaceOrderResult>;
546
+ previewOrder?(order: PreOrder): Promise<OrderPreviewResult>;
547
+ modifyOrder(order: Order, confirmId?: string): Promise<void>;
548
+ cancelOrder(orderId: string): Promise<void>;
549
+ cancelOrders?(symbol: string, side: Side | undefined, ordersIds: string[]): Promise<void>;
550
+ reversePosition?(positionId: string): Promise<void>;
551
+ closePosition?(positionId: string, amount?: number, confirmId?: string): Promise<void>;
552
+ closeIndividualPosition?(individualPositionId: string, amount?: number, confirmId?: string): Promise<void>;
553
+ editPositionBrackets?(positionId: string, brackets: Brackets, customFields?: CustomInputFieldsValues): Promise<void>;
554
+ editIndividualPositionBrackets?(individualPositionId: string, brackets: Brackets): Promise<void>;
555
+ leverageInfo?(leverageInfoParams: LeverageInfoParams): Promise<LeverageInfo>;
556
+ setLeverage?(leverageSetParams: LeverageSetParams): Promise<LeverageSetResult>;
557
+ previewLeverage?(leverageSetParams: LeverageSetParams): Promise<LeveragePreviewResult>;
558
+ subscribeEquity?(): void;
559
+ subscribeMarginAvailable?(symbol: string): void;
560
+ subscribePipValue?(symbol: string): void;
561
+ unsubscribePipValue?(symbol: string): void;
562
+ unsubscribeMarginAvailable?(symbol: string): void;
563
+ unsubscribeEquity?(): void;
564
+ }
565
+ /** A list of subscribers that is notified when an event fires. */
566
+ export interface IDelegate<TFunc extends Function> extends ISubscription<TFunc> {
567
+ fire: TFunc;
568
+ }
569
+ export interface IFormatter<T> {
570
+ format(value?: T, options?: FormatterFormatOptions): string;
571
+ parse?(value: string, options?: FormatterParseOptions): ErrorFormatterParseResult | SuccessFormatterParseResult<T>;
572
+ }
573
+ export interface INumberFormatter extends IFormatter<number> {
574
+ format(value?: number, options?: NumberFormatterFormatOptions): string;
575
+ formatChange?(currentPrice: number, prevPrice: number, options?: NumberFormatterFormatOptions): string;
576
+ }
577
+ export interface IObservable<T> {
578
+ subscribe(callback: ObservableCallback<T>): void;
579
+ unsubscribe(callback: ObservableCallback<T>): void;
580
+ }
581
+ export interface IObservableValue<T> extends IBoxedValue<T>, IObservable<T> {
582
+ }
583
+ export interface IObservableValueReadOnly<T> extends IBoxedValueReadOnly<T>, IObservable<T> {
584
+ }
585
+ export interface IPriceFormatter extends ISymbolValueFormatter {
586
+ format(price: number, options?: PriceFormatterFormatOptions): string;
587
+ formatChange?(price: number, prevPrice: number, options?: PriceFormatterFormatOptions): string;
588
+ }
589
+ export interface ISubscription<TFunc extends Function> {
590
+ subscribe(obj: object | null, member: TFunc, singleshot?: boolean): void;
591
+ unsubscribe(obj: object | null, member: TFunc): void;
592
+ unsubscribeAll(obj: object | null): void;
593
+ }
594
+ export interface ISymbolValueFormatter extends INumberFormatter {
595
+ format(price: number, options?: SymbolValueFormatterFormatOptions): string;
596
+ formatChange?(currentPrice: number, prevPrice: number, options?: SymbolValueFormatterFormatOptions): string;
597
+ }
598
+ /** A value the platform can read and subscribe to; brokers use it to publish changing state. */
599
+ export interface IWatchedValue<T> extends IWatchedValueReadonly<T>, IObservableValue<T> {
600
+ setValue(value: T, forceUpdate?: boolean): void;
601
+ subscribe(callback: WatchedValueCallback<T>, options?: WatchedValueSubscribeOptions): void;
602
+ unsubscribe(callback?: WatchedValueCallback<T> | null): void;
603
+ }
604
+ export interface IWatchedValueReadonly<T> extends IObservableValueReadOnly<T> {
605
+ subscribe(callback: (value: T) => void, options?: WatchedValueSubscribeOptions): void;
606
+ unsubscribe(callback?: ((value: T) => void) | null): void;
607
+ when(callback: WatchedValueCallback<T>): void;
608
+ }
609
+ /** One individual position, for brokers that report positions per entry rather than netted. */
610
+ export interface IndividualPosition extends IndividualPositionBase, WithExtraData {
611
+ }
612
+ export interface IndividualPositionBase {
613
+ id: string;
614
+ date: number;
615
+ symbol: string;
616
+ qty: number;
617
+ side: Side;
618
+ price: number;
619
+ message?: OrderOrPositionMessage;
620
+ canBeClosed?: boolean;
621
+ stopLoss?: number;
622
+ takeProfit?: number;
623
+ guaranteedStop?: number;
624
+ trailingStopPips?: number;
625
+ trailingStopPrice?: number;
626
+ stopType?: StopType;
627
+ avgPrice?: number;
628
+ updateTime?: number;
629
+ lastPrice?: number;
630
+ bidPrice?: number;
631
+ askPrice?: number;
632
+ unrealizedPl?: number;
633
+ unrealizedPlPercent?: number;
634
+ unrealizedPlQty?: number;
635
+ marketValue?: number;
636
+ pl?: number;
637
+ visiblePL?: number;
638
+ currency?: string;
639
+ exitLevels?: ExitLevel[];
640
+ }
641
+ /** Trading parameters for a symbol: quantity limits, tick size, pip value and allowed order types. */
642
+ export interface InstrumentInfo {
643
+ qty: QuantityMetainfo;
644
+ pipValue: number;
645
+ pipSize: number;
646
+ minTick: number;
647
+ lotSize?: number;
648
+ type?: SymbolType;
649
+ units?: string;
650
+ brokerSymbol?: string;
651
+ description: string;
652
+ leverage?: string;
653
+ marginRate?: number;
654
+ limitPriceStep?: number;
655
+ stopPriceStep?: number;
656
+ allowedDurations?: string[];
657
+ variableMinTick?: string;
658
+ currency?: string;
659
+ baseCurrency?: string;
660
+ quoteCurrency?: string;
661
+ bigPointValue?: number;
662
+ priceMagnifier?: number;
663
+ allowedOrderTypes?: OrderType[];
664
+ }
665
+ export interface IsTradableResult {
666
+ tradable: boolean;
667
+ reason?: string;
668
+ reasonHeading?: string;
669
+ solutions?: TradableSolutions;
670
+ shortReason?: string;
671
+ confirmButtonText?: string;
672
+ }
673
+ export interface LevelsFormatterProperties<T extends string = string> {
674
+ base: [
675
+ priceProperty: FieldRef<T>
676
+ ];
677
+ withLevels: [
678
+ priceProperty: FieldRef<T>,
679
+ exitLevels: FieldRef<T>,
680
+ qty: FieldRef<T>
681
+ ];
682
+ }
683
+ export interface LeverageInfo {
684
+ title: string;
685
+ leverage: number;
686
+ min: number;
687
+ max: number;
688
+ step: number;
689
+ }
690
+ export interface LeverageInfoParams {
691
+ symbol: string;
692
+ orderType: OrderType;
693
+ side: Side;
694
+ customFields?: CustomInputFieldsValues;
695
+ }
696
+ export interface LeveragePreviewResult {
697
+ infos?: string[];
698
+ warnings?: string[];
699
+ errors?: string[];
700
+ }
701
+ export interface LeverageSetParams extends LeverageInfoParams {
702
+ leverage: number;
703
+ }
704
+ export interface LeverageSetResult {
705
+ leverage: number;
706
+ }
707
+ export interface MenuSeparator extends ActionDescription {
708
+ separator: boolean;
709
+ }
710
+ export interface NegativeBaseInputFieldValidatorResult extends BaseInputFieldValidatorResult {
711
+ valid: false;
712
+ errorMessage: string;
713
+ }
714
+ export interface NumberFormatterFormatOptions extends FormatterFormatOptions {
715
+ noExponentialForm?: boolean;
716
+ }
717
+ export interface OpenUrlSolution {
718
+ openUrl: {
719
+ url: string;
720
+ text: string;
721
+ };
722
+ }
723
+ export interface OrderDialogOptions extends TradingDialogOptions {
724
+ showTotal?: boolean;
725
+ }
726
+ export interface OrderDuration {
727
+ type: string;
728
+ datetime?: number;
729
+ }
730
+ export interface OrderDurationMetaInfo {
731
+ hasDatePicker?: boolean;
732
+ hasTimePicker?: boolean;
733
+ default?: boolean;
734
+ name: string;
735
+ value: string;
736
+ supportedOrderTypes?: OrderType[];
737
+ }
738
+ export interface OrderOrPositionMessage {
739
+ type: OrderOrPositionMessageType;
740
+ text: string;
741
+ }
742
+ export interface OrderPreviewResult {
743
+ sections: OrderPreviewSection[];
744
+ confirmId?: string;
745
+ warnings?: OrderPreviewMessage[];
746
+ errors?: OrderPreviewMessage[];
747
+ }
748
+ export interface OrderPreviewSection {
749
+ rows: OrderPreviewSectionRow[];
750
+ header?: string;
751
+ }
752
+ export interface OrderPreviewSectionRow {
753
+ title: string;
754
+ value: string;
755
+ }
756
+ export interface OrderRule {
757
+ id: string;
758
+ severity: "warning" | "error";
759
+ }
760
+ export interface OrderTemplate extends OrderTemplateBase {
761
+ exitLevels?: ExitLevelTemplate[];
762
+ }
763
+ export interface OrderTemplateBase {
764
+ symbol: string;
765
+ type?: OrderType;
766
+ side?: Side;
767
+ qty?: number;
768
+ stopType?: StopType;
769
+ currentQuotes?: AskBid;
770
+ stopPrice?: number;
771
+ limitPrice?: number;
772
+ takeProfit?: number;
773
+ stopLoss?: number;
774
+ guaranteedStop?: number;
775
+ trailingStopPips?: number;
776
+ duration?: OrderDuration;
777
+ customFields?: CustomInputFieldsValues;
778
+ }
779
+ export interface OrderTicketSettings {
780
+ showRelativePriceControl: boolean;
781
+ showOrderPreview: boolean;
782
+ }
783
+ export interface PipValues {
784
+ buyPipValue: number;
785
+ sellPipValue: number;
786
+ }
787
+ export interface PlaceOrderResult {
788
+ orderId?: string;
789
+ }
790
+ /** An order the broker has accepted, with its id and status. */
791
+ export interface PlacedOrder extends WithExtraData {
792
+ id: string;
793
+ symbol: string;
794
+ type: OrderType;
795
+ side: Side;
796
+ qty: number;
797
+ status: OrderStatus;
798
+ stopLoss?: number;
799
+ guaranteedStop?: number;
800
+ trailingStopPips?: number;
801
+ trailingStopPrice?: number;
802
+ stopType?: StopType;
803
+ takeProfit?: number;
804
+ exitLevels?: ExitLevel[];
805
+ duration?: OrderDuration;
806
+ customFields?: CustomInputFieldsValues;
807
+ filledQty?: number;
808
+ avgPrice?: number;
809
+ updateTime?: number;
810
+ limitPrice?: number;
811
+ stopPrice?: number;
812
+ message?: OrderOrPositionMessage;
813
+ }
814
+ /** A net position as reported by the broker. */
815
+ export interface Position extends PositionBase, WithExtraData {
816
+ }
817
+ export interface PositionBase {
818
+ id: string;
819
+ symbol: string;
820
+ qty: number;
821
+ shortQty?: number;
822
+ longQty?: number;
823
+ side: Side;
824
+ avgPrice: number;
825
+ updateTime?: number;
826
+ lastPrice?: number;
827
+ bidPrice?: number;
828
+ askPrice?: number;
829
+ unrealizedPl?: number;
830
+ unrealizedPlPercent?: number;
831
+ unrealizedPlQty?: number;
832
+ marketValue?: number;
833
+ stopLoss?: number;
834
+ takeProfit?: number;
835
+ guaranteedStop?: number;
836
+ trailingStopPips?: number;
837
+ trailingStopPrice?: number;
838
+ stopType?: StopType;
839
+ currency?: string;
840
+ contractExpirationDate?: ContractExpirationDate;
841
+ message?: OrderOrPositionMessage;
842
+ exitLevels?: ExitLevel[];
843
+ }
844
+ export interface PositionDialogOptions extends TradingDialogOptions {
845
+ }
846
+ export interface PositiveBaseInputFieldValidatorResult extends BaseInputFieldValidatorResult {
847
+ valid: true;
848
+ }
849
+ /** An order as submitted from the order ticket, before the broker has accepted it. */
850
+ export interface PreOrder extends OrderTemplateBase {
851
+ symbol: string;
852
+ type: OrderType;
853
+ side: Side;
854
+ qty: number;
855
+ isClose?: boolean;
856
+ exitLevels?: ExitLevel[];
857
+ }
858
+ export interface PriceFormatterFormatOptions extends SymbolValueFormatterFormatOptions {
859
+ tailSize?: number;
860
+ signNegative?: boolean;
861
+ useRtlFormat?: boolean;
862
+ cutFractionalByPrecision?: boolean;
863
+ removeAllEndingZeros?: boolean;
864
+ }
865
+ export interface QuantityMetainfo {
866
+ min: number;
867
+ max: number;
868
+ step: number;
869
+ uiStep?: number;
870
+ default?: number;
871
+ }
872
+ /** Broker configuration passed to the trading platform: feature flags, order durations and custom fields. */
873
+ export interface SingleBrokerMetaInfo {
874
+ configFlags: BrokerConfigFlags;
875
+ tradedGroupConfig?: TradedGroupConfig;
876
+ customNotificationFields?: string[];
877
+ durations?: OrderDurationMetaInfo[];
878
+ orderRules?: OrderRule[];
879
+ customUI?: BrokerCustomUI;
880
+ }
881
+ export interface SortingParameters {
882
+ property: FieldRef;
883
+ asc?: boolean;
884
+ }
885
+ export interface StandardFormattersDependenciesMapping<T extends string = string> {
886
+ [StandardFormatterName.Default]: FieldRef<T>[];
887
+ [StandardFormatterName.Symbol]: SymbolFormatterProperties<T>[keyof SymbolFormatterProperties];
888
+ [StandardFormatterName.Side]: [
889
+ sideProperty: FieldRef<T>
890
+ ];
891
+ [StandardFormatterName.PositionSide]: [
892
+ sideProperty: FieldRef<T>
893
+ ];
894
+ [StandardFormatterName.Text]: FieldRef<T>[];
895
+ [StandardFormatterName.Type]: [
896
+ orderTypeProperty: FieldRef<T>,
897
+ parentIdProperty: FieldRef<T>,
898
+ stopTypeProperty: FieldRef<T>
899
+ ];
900
+ [StandardFormatterName.FormatPrice]: [
901
+ priceProperty: FieldRef<T>
902
+ ];
903
+ [StandardFormatterName.FormatPriceForexSup]: [
904
+ priceProperty: FieldRef<T>
905
+ ];
906
+ [StandardFormatterName.FormatExitLevels]: LevelsFormatterProperties<T>[keyof LevelsFormatterProperties];
907
+ [StandardFormatterName.FormatPriceInCurrency]: [
908
+ priceProperty: FieldRef<T>,
909
+ currencyProperty: FieldRef<T>
910
+ ];
911
+ [StandardFormatterName.Status]: [
912
+ statusProperty: FieldRef<T>
913
+ ];
914
+ [StandardFormatterName.Date]: [
915
+ dateProperty: FieldRef<T>
916
+ ];
917
+ [StandardFormatterName.LocalDate]: [
918
+ dateProperty: FieldRef<T>
919
+ ];
920
+ [StandardFormatterName.DateOrDateTime]: [
921
+ dateProperty: FieldRef<T>
922
+ ];
923
+ [StandardFormatterName.LocalDateOrDateTime]: [
924
+ dateProperty: FieldRef<T>
925
+ ];
926
+ [StandardFormatterName.Fixed]: [
927
+ valueProperty: FieldRef<T>
928
+ ];
929
+ [StandardFormatterName.FixedInCurrency]: [
930
+ valueProperty: FieldRef<T>,
931
+ currencyProperty: FieldRef<T>
932
+ ];
933
+ [StandardFormatterName.VariablePrecision]: [
934
+ valueProperty: FieldRef<T>
935
+ ];
936
+ [StandardFormatterName.Pips]: [
937
+ pipsProperty: FieldRef<T>
938
+ ];
939
+ [StandardFormatterName.IntegerSeparated]: [
940
+ valueProperty: FieldRef<T>
941
+ ];
942
+ [StandardFormatterName.FormatQuantity]: [
943
+ qtyProperty: FieldRef<T>
944
+ ];
945
+ [StandardFormatterName.Profit]: [
946
+ profitProperty: FieldRef<T>
947
+ ];
948
+ [StandardFormatterName.ProfitInInstrumentCurrency]: [
949
+ profitProperty: FieldRef<T>,
950
+ currencyProperty: FieldRef<T>
951
+ ];
952
+ [StandardFormatterName.ProfitInInstrumentCurrencyFloored]: [
953
+ profitProperty: FieldRef<T>,
954
+ currencyProperty: FieldRef<T>
955
+ ];
956
+ [StandardFormatterName.ProfitInPercent]: [
957
+ plPercent: FieldRef<T>
958
+ ];
959
+ [StandardFormatterName.Percentage]: [
960
+ valueProperty: FieldRef<T>
961
+ ];
962
+ [StandardFormatterName.ColoredPercentage]: [
963
+ valueProperty: FieldRef<T>
964
+ ];
965
+ [StandardFormatterName.MarginPercent]: [
966
+ valueProperty: FieldRef<T>
967
+ ];
968
+ [StandardFormatterName.Empty]: [
969
+ ];
970
+ }
971
+ export interface SuccessFormatterParseResult<T> extends FormatterParseResult {
972
+ res: true;
973
+ value: T;
974
+ suggest?: string;
975
+ }
976
+ export interface SymbolFormatterProperties<T extends string = string> {
977
+ base: [
978
+ symbolDisplayNameProperty: FieldRef<T>,
979
+ symbolProperty: FieldRef<T>
980
+ ];
981
+ withMessage: [
982
+ symbolDisplayNameProperty: FieldRef<T>,
983
+ symbolProperty: FieldRef<T>,
984
+ messageProperty: FieldRef<T>
985
+ ];
986
+ }
987
+ export interface SymbolSpecificTradingOptions {
988
+ allowedDurations?: string[];
989
+ allowedOrderTypes?: OrderType[];
990
+ supportOrderBrackets?: boolean;
991
+ supportBracketsInPips?: boolean;
992
+ supportAddBracketsToExistingOrder?: boolean;
993
+ supportModifyBrackets?: boolean;
994
+ supportPositionBrackets?: boolean;
995
+ supportIndividualPositionBrackets?: boolean;
996
+ supportReversePosition?: boolean;
997
+ warningMessage?: string;
998
+ supportModifyPositionBrackets?: boolean;
999
+ supportModifyOrderBrackets?: boolean;
1000
+ supportRiskControlsAndInfo?: boolean;
1001
+ supportStopLoss?: boolean;
1002
+ supportTrailingStop?: boolean;
1003
+ supportGuaranteedStop?: boolean;
1004
+ supportCryptoExchange?: boolean;
1005
+ }
1006
+ export interface SymbolValueFormatterFormatOptions extends NumberFormatterFormatOptions {
1007
+ signPositive?: boolean;
1008
+ }
1009
+ export interface TableFormatterInputs<T extends TableFormatterInputValues = TableFormatterInputValues> {
1010
+ values: T extends [
1011
+ ...args: infer A
1012
+ ] ? [
1013
+ ...A
1014
+ ] : never;
1015
+ prevValues?: Partial<T extends [
1016
+ ...args: infer A
1017
+ ] ? [
1018
+ ...A
1019
+ ] : never>;
1020
+ }
1021
+ export interface TextFieldMetaInfo extends CustomInputFieldMetaInfo {
1022
+ inputType: "TextField";
1023
+ value: string;
1024
+ validator?: TextInputFieldValidator;
1025
+ maskWithAsterisk?: boolean;
1026
+ }
1027
+ export interface TextWithCheckboxFieldCustomInfo {
1028
+ checkboxTitle: string;
1029
+ asterix?: boolean;
1030
+ }
1031
+ export interface TextWithCheckboxFieldMetaInfo extends CustomInputFieldMetaInfo {
1032
+ inputType: "TextWithCheckBox";
1033
+ value: TextWithCheckboxValue;
1034
+ customInfo: TextWithCheckboxFieldCustomInfo;
1035
+ validator?: TextInputFieldValidator;
1036
+ }
1037
+ export interface TextWithCheckboxValue {
1038
+ text: string;
1039
+ checked: boolean;
1040
+ }
1041
+ export interface TradableSolutionsTypes {
1042
+ changeAccountSolution: ChangeAccountSolution;
1043
+ changeSymbolSolution: ChangeSymbolSolution;
1044
+ openUrlSolution: OpenUrlSolution;
1045
+ }
1046
+ /** The symbol and its current quote, as seen by the order ticket. */
1047
+ export interface TradeContext {
1048
+ symbol: string;
1049
+ displaySymbol: string;
1050
+ value: number | null;
1051
+ formattedValue: string;
1052
+ last: number;
1053
+ }
1054
+ export interface TradedGroupConfig {
1055
+ supportAdaptiveLayout: boolean;
1056
+ }
1057
+ export interface TradingDialogOptions {
1058
+ customFields?: TradingDialogCustomField[];
1059
+ maxExitLevelsCount?: number;
1060
+ }
1061
+ export interface TradingQuotes {
1062
+ trade?: number;
1063
+ size?: number;
1064
+ bid?: number;
1065
+ bid_size?: number;
1066
+ ask?: number;
1067
+ ask_size?: number;
1068
+ spread?: number;
1069
+ isDelayed?: boolean;
1070
+ isHalted?: boolean;
1071
+ isHardToBorrow?: boolean;
1072
+ isNotShortable?: boolean;
1073
+ lastSize?: number;
1074
+ }
1075
+ export interface WatchedValueSubscribeOptions {
1076
+ once?: boolean;
1077
+ callWithLast?: boolean;
1078
+ }
1079
+ export interface WithExtraData {
1080
+ extra?: ExtraData;
1081
+ }
1082
+ export type AccountId = Nominal<string, "AccountID">;
1083
+ export type AccountManagerColumn<TPossibleFields extends string = string> = {
1084
+ [TFormatterName in StandardFormatterName | FormatterName]: AccountManagerColumnBase<TFormatterName, TPossibleFields>;
1085
+ }[StandardFormatterName | FormatterName];
1086
+ export type ActionMetaInfo = ActionDescriptionWithCallback | MenuSeparator;
1087
+ export type AskBid = Required<Pick<TradingQuotes, "ask" | "bid">>;
1088
+ export type CellAlignment = "left" | "right";
1089
+ export type ClosePositionPreviewRow = ClosePositionPreviewRowData | ClosePositionPreviewSeparator;
1090
+ export type CustomFieldPossibleTypes = "TextWithCheckBox" | "ComboBox" | "Checkbox" | "TextField";
1091
+ export type CustomTableFormatElementFunction<T extends TableFormatterInputValues = TableFormatterInputValues> = (inputs: TableFormatterInputs<T>) => undefined | string | HTMLElement;
1092
+ export type FieldRef<T extends string = string> = T | [
1093
+ T,
1094
+ ...string[]
1095
+ ];
1096
+ export type FormatterName = Nominal<string, "FormatterName">;
1097
+ export type IndividualPositionTableColumn = AccountManagerColumn<keyof IndividualPosition>;
1098
+ export type InputFieldValidator = (value: any) => InputFieldValidatorResult;
1099
+ export type InputFieldValidatorResult = PositiveBaseInputFieldValidatorResult | NegativeBaseInputFieldValidatorResult;
1100
+ export type LeverageParams = LeverageInfoParams | LeverageSetParams;
1101
+ export type MarkupText = (string | HyperlinkInfo)[];
1102
+ export type Nominal<T, Name extends string> = T & {
1103
+ [Symbol.species]: Name;
1104
+ };
1105
+ export type ObservableCallback<T> = (value: T) => void;
1106
+ /** An order as reported by the broker. */
1107
+ export type Order = PlacedOrder | BracketOrder;
1108
+ export type OrderPreviewMessage = string | MarkupText;
1109
+ export type OrderTableColumn = AccountManagerColumn<keyof (PlacedOrder & BracketOrder)> & {
1110
+ supportedStatusFilters?: OrderStatusFilter[];
1111
+ };
1112
+ export type PositionTableColumn = AccountManagerColumn<keyof Position>;
1113
+ export type SuggestedQtyChangedListener = (newQty: number) => void;
1114
+ export type SymbolType = "stock" | "index" | "forex" | "futures" | "bitcoin" | "crypto" | "undefined" | "expression" | "spread" | "cfd" | "economic" | "equity" | "dr" | "bond" | "right" | "warrant" | "fund" | "structured" | "commodity" | "fundamental" | "spot" | "swap" | "option" | "ndf";
1115
+ export type TableFormatTextFunction<T extends TableFormatterInputValues = TableFormatterInputValues> = (inputs: TableFormatterInputs<T>) => string;
1116
+ export type TableFormatterInputValue = any;
1117
+ export type TableFormatterInputValues = TableFormatterInputValue[];
1118
+ export type TextInputFieldValidator = (value: string) => InputFieldValidatorResult;
1119
+ export type TradableSolutions = TradableSolutionsTypes[keyof TradableSolutionsTypes];
1120
+ export type TradingDialogCustomField = CheckboxFieldMetaInfo | TextWithCheckboxFieldMetaInfo | CustomComboBoxMetaInfo | TextFieldMetaInfo;
1121
+ export type WatchedValueCallback<T> = (value: T) => void;
1122
+ export {};