Account Manager - SpartaCommodities/Trading_view_wiki GitHub Wiki
:chart: All content on this page is relevant to Trading Terminal only.
Account Manager is an interactive table that displays trading information. It includes 3 pages: orders/positions and account information.
To create an account manager you will need to describe columns of each page and provide data.
Remark 1. Broker API should implement accountManagerInfo
Account Manager Meta Information
The following information should be returned by accountManagerInfo.
Account Manager header
Account Manager's header includes the name of the broker and a summary.
accountTitle: String
SummaryField
summary: array ofYou can display your own custom fields that will always be shown above the pages.
Orders Page
Column
orderColumns: array ofColumns description that you want to be displayed on the Orders page. You can display any field of an order or add your own fields to an order object and display them.
SortingParameters
orderColumnsSorting:Optional sorting of the table.
OrderStatus
possibleOrderStatuses: array ofOptional list of statuses to be used in the orders filter. Default list is used if it hasn't been set.
Column
historyColumns: array ofHistory page will be displayed if it exists. All orders from previous sessions will be shown in the History.
SortingParameters
historyColumnsSorting:Optional sorting of the table.
Positions Page
Column
positionColumns: array ofYou can display any field of a position or add your own fields to a position object and display them.
Additional Pages (e.g. Account Summary)
Page
pages: array ofYou can add new tabs in the Account Manager by using pages
. Each tab is a set of tables.
Page
Page
is a description of an additional Account Manager tab. It is an object with the following fields:
-
id
: StringUnique identifier of a page
-
title
: StringPage title. It is the tab name.
-
tables
: Array of Table.It is possible to display one or more tables in this tab.
Table
You can add one or more tables to a Page. Account Summary table metainfo is an object with the following fields:
-
id
: StringUnique identifier of a table.
-
title
: StringOptional title of a table.
-
columns
: array of Column -
getData
: PromiseThis function is used to request table data. It should return Promise (or Deferred) and resolve it with an array of data rows.
Each row is an object. Keys of this object are column names with the corresponding values.
There is a predefined field
isTotalRow
which can be used to mark a row that should be at the bottom of the table. -
changeDelegate
: DelegateThis delegate is used to watch the data changes and update the table. Pass new account manager data row by row to the
fire
method of the delegate. -
initialSorting
: SortingParametersOptional sorting of the table.
NOTE: make sure that you have a unique string id
field in each row to identify it.
SortingParameters
Object with the following properties:
- `columnId` - `property` of the column that will be used for sorting.
- `asc` - (optional, default `true`) - If it is `false`, then initial sorting will be in descending order.
Column description
The most valuable part of Account Manager description is a description of its columns.
label
Column title. It will be displayed in the table's header row.
alignment
Horizontal alignment of the cell value. The default value is left
.
alignment | description |
---|---|
left | It aligns the cell value to the left |
right | It aligns the cell value to the right |
formatter
Name of the formatter to be used for data formatting. If formatter
is not set the value is displayed as is.
Formatter can be a default or a custom one.
Here is the list of default formatters:
name | description |
---|---|
date |
Displays the date or time. |
dateOrDateTime |
Displays the date or date and time. This formatter accepts an object {value: number, hasTime: boolean} . If hasTime is set to true then the date and time are displayed. Otherwise only the date is displayed. |
fixed |
Displays a number with 2 decimal places. |
formatPrice |
Displays symbol's price. |
formatQuantity |
Displays an integer or floating point quantity, separates thousands groups with a space. |
formatPriceForexSup |
The same as formatPrice , but it makes the last character of the price superscripted. It works only if instrument type is set to forex . |
localDate |
Displays the local date or time. |
localDateOrDateTime |
The same as dateOrDateTime , but it displays time in the local timezone. |
pips |
Displays a number with 1 decimal place. |
profit |
Displays profit in account currency. It also adds the + sign, separates thousands and changes the cell text color to red or green. |
profitInInstrumentCurrency |
Displays profit in instrument currency. It also adds the + sign, separates thousands and changes the cell text color to red or green. |
side |
It is used to display the side: Sell or Buy. |
positionSide |
It is used to display the position side: Short or Long. |
status |
It is used to format the status . |
symbol |
It is used for a symbol field. It displays brokerSymbol , but when you click on a symbol the chart changes according to the symbol field. property key is ignored. |
text |
Displays a text value. |
textNoWrap |
Displays a text value without word wrapping. |
type |
It is used to display the type of order: Limit/Stop/StopLimit/Market. |
variablePrecision |
Displays a number with variable precision. |
There are some special formatters that are used to add buttons to the table:
orderSettings
adds Modify/Cancel buttons to the orders tab.
posSettings
adds Edit/Close buttons to the Positions/Net Positions tab.
tradeSettings
adds Edit/Close buttons to the Individual Positions tab.
property
property
is a data object key that is used to get the data to display in a table.
sortProp
Optional sortProp
is a data object key that is used for data sorting.
notSortable
Optional notSortable
can be set to prevent column sorting.
help
help
is a tooltip string for the column.
highlightDiff
highlightDiff
can be set with formatPrice
and formatPriceForexSup
formatters only to highlight the changes of the field.
notHideable
Optional notHideable
parameter can be set to prevent the column from hiding.
hideByDefault
Optional hideByDefault
parameter can be set to hide the column by default.
tooltipProperty
tooltipProperty
is a key of the row object that is used to get the tooltip to display when hovering over a cell. The tooltip property refers to an object whose keys are property names and values are the corresponding tooltips.
supportedStatusFilters
An optional numeric array of order statuses that is applied to order columns only. If it is available then the column will be displayed in the specified tabs of the status filter only.
Here is the list of possible order statuses:
- 0 - All
- 1 - Canceled
- 2 - Filled
- 3 - Inactive
- 5 - Rejected,
- 6 - Working
isCapitalize
If it is true
, the first character of every word in the sentence in the column will be capitalized. The default value is true
.
showZeroValues
If it is false
, the zero values will be hidden. The default value is true
.
SummaryField
SummaryField
is an object with the following fields:
-
text
: StringDisplays a text value.
-
wValue
: WatchedValueA WatchedValue object that can be used to read the state of field.
-
formatter
: StringName of the formatter, for details please see formatter.
-
isDefault
: BooleanOptional
isDefault
parameter can be set to display the field by default.
Context Menu
contextMenuActions(contextMenuEvent, activePageActions)
contextMenuEvent
: MouseEvent or TouchEvent object passed by a browser
activePageActions
: array of ActionMetaInfo
items for the current page
Optional function to create a custom context menu.
It should return Promise
that is resolved with an array of ActionMetaInfo
.