Type/to search
Built-in Functions
Structures
Trade
Ticker
Record
Order
Condition
OrderBook
Depth
Account
Asset
Position
Market
Funding
OtherStruct
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
Chart-options
KLineChart-options
SetData-data
EventLoop-return
DBExec-return
Thread.join-return
Built-in Variables

This JSON structure is used to configure button controls in the status bar. The button control JSON structure can be embedded into the status bar table JSON structure. This is the latest version of the button JSON structure.
Status bar button control construction example (after the button is clicked, a popup contains multiple input controls, constructed through the group field):

json
{ "type": "button", "cmd": "open", "name": "Open Position", "group": [{ "type": "selected", "name": "tradeType", "label": "Order Type", "description": "Market order, Limit order", "default": 0, "group": "Trading Settings", "settings": { "options": ["Market Order", "Limit Order"], "required": true, } }, { "type": "selected", "name": "direction", "label": "Trade Direction", "description": "Buy, Sell", "default": "buy", "group": "Trading Settings", "settings": { "render": "segment", "required": true, "options": [{"name": "Buy", "value": "buy"}, {"name": "Sell", "value": "sell"}], } }, { "type": "number", "name": "price", "label": "Price", "description": "Order price", "group": "Trading Settings", "filter": "tradeType==1", "settings": { "required": true, } }, { "type": "number", "name": "amount", "label": "Order Amount", "description": "Order quantity", "group": "Trading Settings", "settings": { "required": true, } }], }

The controls in the popup triggered by clicking the status bar button control are set through the input or group field.

Attributes

NameTypeDescription

type

string

For button controls, this field is fixed as: button.

name

string

The text displayed on the button control, i.e., the button name.

cmd

string

The interactive command content sent to the strategy when the button control triggers a click action.

input

JSON

When constructing status bar buttons for interaction, input data is also supported. The interaction commands are ultimately captured by the GetCommand() function. Add an input item to the JSON data structure of the status bar button control to configure the input controls displayed in the popup when the button is triggered.

Compared to the old version of the input structure, the new version adds some new fields and changes:

json
{ "type": "selected", "name": "test", "label": "topic", "description": "desc", "default": 1, "filter": "a>1", "group": "group1", "settings": { ... }, // Component configuration }

Description and explanation of each field in the above JSON structure:

  • type
    Control type (required field), supports setting to: "number" numeric input box, "string" string input box, "selected" dropdown box, "boolean" switch control.

  • name
    If the current JSON structure is the field value of the input field, when the label field is not set, name is the control title in the popup that appears after clicking the status bar button.
    If the current JSON structure is an element in the field value (array structure) of the group field, name is not used as the control title, the name field is used to represent the field name of the control input content. For example, the following code snippet of the group field explains:

    json
    var testBtn3 = { type: "button", name: "testBtn3", cmd: "cmdTestBtn3", group: [ {name: "comboBox1", label: "labelComboBox1", description: "Dropdown box 1", type: "selected", defValue: 1, options: ["A", "B"]}, {name: "comboBox2", label: "labelComboBox2", description: "Dropdown box 2", type: "selected", defValue: "A|B"}, {name: "comboBox3", label: "labelComboBox3", description: "Dropdown box 3", type: "selected", defValue: [0, 2], multiple: true, options: ["A", "B", "C"]}, { name: "comboBox4", label: "labelComboBox4", description: "Dropdown box 4", type: "selected", defValue: ["A", "C"], multiple: true, options: [{text: "Option A", value: "A"}, {text: "Option B", value: "B"}, {text: "Option C", value: "C"}, {text: "Option D", value: "D"}] } ] }

    According to this code snippet, if the status bar button triggers interaction, a popup will appear with 4 controls, all of which are dropdown controls. After setting the options for each control and clicking OK to send the interaction message, the GetCommand function in the strategy will receive cmdTestBtn3:{"comboBox1":1,"comboBox2":0,"comboBox3":[0,2],"comboBox4":["A","C"]}.
    The values of name in the JSON structure are all used as field names for the returned interaction information, for example: comboBox1, comboBox2, etc.

  • label
    Used to set the control title.

  • description
    Description information of the control. If the current JSON structure is an element in the field value (array structure) of the group field, when the label field is not set, description is the control title in the popup that appears after clicking the status bar button.

  • default
    The default value of the control.

  • filter
    Selector, used to hide controls. Not setting this field means no filtering (display control); when this field is set, when the expression is true, no filtering (display control), when the expression is false, filtering (do not display control).

  • group
    Used to control control grouping, collapsible.

  • settings
    Component configuration, controls have multiple UI options to choose from, this option can be used for specific settings. For example:

    json
    settings:{ multiple:true, customizable:true, options:[{name:'xxx|yyy',value:0}] }

    Settings related configurations:
    settings.required: Whether required.
    settings.disabled: Whether disabled.
    settings.min: Valid when type=number, indicates minimum value or minimum string length.
    settings.max: Valid when type=number, indicates maximum value or maximum string length.
    settings.step: Valid when type=number, render=slider, indicates step size.
    settings.multiple: Valid when type=selected, indicates support for multiple selection.
    settings.customizable: Valid when type=selected, indicates support for customization; users can directly edit and add new options in the dropdown control, if a newly edited option is selected, the name of the option is used instead of the value it represents when triggering interaction.
    settings.options: Valid when type=selected, indicates the option data format of the selector: ["Option 1", "Option 2"], [{'name':'xxx','value':0}, {'name':'xxx','value':1}].
    settings.render: Render component type.
    When type=number, settings.render is not set (default numeric input box), optional: slider (slider bar), date (time selector returns timestamp).
    When type=string, settings.render is not set (default single-line input box), optional: textarea (multi-line input), date (time selector returns yyyy-MM-dd hh:mm:ss), color (color selector returns #FF00FF).
    When type=selected, settings.render is not set (default dropdown box), optional: segment (segment selector).
    When type=boolean, currently only default checkbox.

group

array

The input field configures a control in the dialog box that pops up after clicking the status bar button. The difference between group and input is that group configures a group of controls. The elements in group have the same data structure as the input field values. Please refer to the above input field description.

See Also

Remarks

Supports bilingual settings:

json
{ type:'selected', name:'test', label:'选项|options', description:'描述|description', default:0, // Here default value is set to 0, representing the value in {name:'xxx|yyy',value:0} option filter:'a>1&&a<10', group:'分组|group', settings:{ multiple:true, customizable:true, options:[{name:'xxx|yyy',value:0}] } }