This JSON structure is used to configure the button control in the status bar. The button control JSON structure can be embedded in the status bar table JSON structure. The latest version of the button JSON structure. Example of constructing a status bar button control (after the button is triggered and clicked, the pop-up box contains multiple input controls, which are constructed through the group field):
{
"type": "button",
"cmd": "open",
"name": "Open a position and place an order",
"group": [{
"type": "selected",
"name": "tradeType",
"label": "order type",
"description": "market order, limit order",
"default": 0,
"group": "trading setup",
"settings": {
"options": ["market order", "limit order"],
"required": true,
}
}, {
"type": "selected",
"name": "direction",
"label": "trading direction",
"description": "buy, sell",
"default": "buy",
"group": "trading setup",
"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 setup",
"filter": "tradeType==1",
"settings": {
"required": true,
}
}, {
"type": "number",
"name": "amount",
"label": "order quantity",
"description": "order quantity",
"group": "trading setup",
"settings": {
"required": true,
}
}],
}
The controls in the pop-up box triggered by clicking the status bar button control are set through input
or group
.
For button controls, the fixed setting is: button
.
type
string
The text on the button control, that is, the button name.
name
string
The interactive command content sent to the strategy when the button control triggers a click operation.
cmd
string
When constructing a status bar button for interaction, data input is also supported. The interaction command is ultimately captured by the GetCommand()
function. Add the input
item to the JSON data structure of the button control in the status bar to configure the input control in the pop-up box displayed when the button is triggered.
Compared with the old version of the input structure, the new version has some new fields and changes:
{
"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 the following settings: "number"
numeric input box, "string"
string input box, "selected"
drop-down 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 pop-up box that pops up after the status bar button is clicked. 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 indicate the field name of the control input content. For example, an excerpt of the group field is used as an illustration:
var testBtn3 = {
type: "button",
name: "testBtn3",
cmd: "cmdTestBtn3",
group: [
{name: "comboBox1", label: "labelComboBox1", description: "Drop-down box 1", type: "selected", defValue: 1, options: ["A", "B"]},
{name: "comboBox2", label: "labelComboBox2", description: "Drop-down box 2", type: "selected", defValue: "A|B"},
{name: "comboBox3", label: "labelComboBox3", description: "Drop-down box 3", type: "selected", defValue: [0, 2], multiple: true, options: ["A", "B", "C"]},
{
name: "comboBox4",
label: "labelComboBox4",
description: "Drop-down 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 snippet, if the status bar button triggers an interaction, a pop-up box will pop up with 4 controls, all of which are drop-down box 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 value of name in the JSON structure is used as the field name of the returned interactive information, for example: comboBox1, comboBox2, etc.
label Used to set the title of the control.
description Description of the control. If the current JSON structure is an element in the field value (array structure) of the group field, and the label field is not set, description is the control title in the pop-up box that pops up after the status bar button is clicked.
default The default value of the control.
filter Selector, used to hide controls. Not setting this field means no filtering (displaying controls); when this field is set, no filtering (displaying controls) occurs when the expression is true. When the expression is false, filtering occurs (no displaying controls)
group Used to control the grouping of controls, which can be folded.
settings Component configuration, the control has a variety of UI options, use this option to make specific settings. For example:
settings:{
multiple:true,
customizable:true,
options:[{name:'xxx|yyy',value:0}]
}
settings: settings.required: Whether it is required. settings.disabled: Whether to disable. settings.min: Valid when type=number, indicating the minimum value or minimum length of a string. settings.max: Valid when type=number, indicating the maximum value or the maximum length of a string. settings.step: Valid when type=number and render=slider, indicating the step length. settings.multiple: Valid when type=selected, indicating that multiple selections are supported. settings.customizable: It is valid when type=selected, indicating that customization is supported; users can directly edit and add new options in the drop-down box control. If the newly edited option is selected, the name of the option is used instead of the value represented by the option when the interaction is triggered. settings.options: Valid when type=selected, indicating the selector option data format: [“option 1”, “option 2”], [{‘name’:‘xxx’,‘value’:0}, {‘name’:‘xxx’,‘value’:1}]. settings.render: Rendering component type. When type=number, settings.render is not set (default number 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 drop-down box), optional: segment (segment selector). When type=boolean, there is currently only a default checkbox.
input
JSON
The input
field configures a control in the pop-up box that pops up after the status bar button is triggered by clicking. The difference between group
and input
is that it configures a group of controls. The elements in group
have the same data structure as the input
field value. Please refer to the above description of the input
field.
group array
Support bilingual settings:
{
type:'selected',
name:'test',
label:'选项|options',
description:'描述|description',
default:0, // Here, the default value is set to 0, which means the value in the option {name:'xxx|yyy',value:0}
filter:'a>1&&a<10',
group:'分组|group',
settings:{
multiple:true,
customizable:true,
options:[{name:'xxx|yyy',value:0}]
}
}
{@fun/Log/LogStatus LogStatus}
LogStatus-btnTypeOne Chart-options