输入/搜索内容
内置函数
结构体
Trade
Ticker
Record
Order
OrderBook
Depth
Account
Position
Market
OtherStruct
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
状态栏组件
Chart-options
KLineChart-options
SetData-data
EventLoop-return
DBExec-return
Thread.join-return
内置变量

该JSON结构用于配置状态栏中的按钮控件,按钮控件JSON结构可以嵌入到状态栏表格JSON结构中。此结构为旧版本结构,平台目前仍然兼容,建议使用最新版本的按钮JSON结构。
状态栏按钮控件构造示例(按钮触发点击后,弹框中包含单个输入控件,通过input字段构造):

json
{ "type": "button", "cmd": "open", "name": "开仓", "input": { "name": "开仓数量", "type": "number", "defValue": 1 } }

状态栏按钮控件点击触发后的弹框中的控件通过input或group字段设置。

属性

名称类型描述

type

string

对于按钮控件,固定设置为:button。

class

string

按钮类型设置。

name

string

按钮控件上显示的文本,即按钮名称。

cmd

string

按钮控件触发点击操作时,发送给策略的交互命令内容。

description

string

按钮控件的描述信息。当鼠标悬停在状态栏中该按钮上时显示此描述信息。

disabled

bool

设置按钮为禁用(true)或启用(false)。

input

object

点击按钮后弹框中的输入控件,交互命令由GetCommand()读取;字段见备注中的「input字段」。

group

array

点击按钮后弹框中的一组控件,每个元素的结构与input相同,见备注中的「input字段」。

参考

备注

input字段

例如:

json
{ "name": "开仓数量", "type": "number", "defValue": 1, "description": "test" }
字段说明
name弹框中控件的标题
description弹框中控件的描述信息
type控件类型:number数值输入、string字符串输入、selected下拉框、boolean开关
defValue控件的默认值;下拉框用它设置选项,见表后说明
options下拉框选项,元素可以是字符串或{text: "描述", value: "值"};此时用defValue设置默认选项,可以多选
multiple为true时下拉框支持多选

下拉框(selected)的defValue可以直接设置选项,例如"input": {"name": "开仓数量", "type": "selected", "defValue": "A|B|C"}设置选项A、B、C。

状态栏中按钮JSON结构的class属性取值示例:

javascript
function main() { var table = { type: "table", title: "状态栏按钮样式", cols: ["默认", "原始", "成功", "信息", "警告", "危险"], rows: [ [ {"type":"button", "class": "btn btn-xs btn-default", "name": "默认"}, {"type":"button", "class": "btn btn-xs btn-primary", "name": "原始"}, {"type":"button", "class": "btn btn-xs btn-success", "name": "成功"}, {"type":"button", "class": "btn btn-xs btn-info", "name": "信息"}, {"type":"button", "class": "btn btn-xs btn-warning", "name": "告警"}, {"type":"button", "class": "btn btn-xs btn-danger", "name": "危险"} ] ] } LogStatus("`" + JSON.stringify(table) + "`") }

group字段与input字段使用示例:

javascript
function main() { // 状态栏按钮控件(通过设置input字段实现)testBtn1按钮触发的页面中的下拉框控件使用options字段设置选项,使用defValue字段设置默认选项。与本章其他示例中直接使用defValue设置选项的方式不同。 var testBtn1 = { type: "button", name: "testBtn1", cmd: "cmdTestBtn1", input: {name: "testBtn1ComboBox", type: "selected", options: ["A", "B"], defValue: 1} } /* 状态栏按钮控件(通过设置input字段实现)testBtn2按钮触发的页面中的下拉框控件使用options字段设置选项,options字段中的选项不仅支持字符串, 还支持使用```{text: "描述", value: "值"}```结构。使用defValue字段设置默认选项,默认选项可以是多选(通过数组结构实现多选)。多选需要将额外的字段multiple设置为真值(true)。 */ var testBtn2 = { type: "button", name: "testBtn2", cmd: "cmdTestBtn2", input: { name: "testBtn2MultiComboBox", type: "selected", description: "实现下拉框多选", options: [{text: "选项A", value: "A"}, {text: "选项B", value: "B"}, {text: "选项C", value: "C"}], defValue: ["A", "C"], multiple: true } } // 状态栏分组按钮控件(通过设置group字段实现)testBtn3按钮触发的页面中的下拉框控件使用options字段设置选项,也支持直接使用defValue设置选项。 var testBtn3 = { type: "button", name: "testBtn3", cmd: "cmdTestBtn3", group: [ {name: "comboBox1", label: "labelComboBox1", description: "下拉框1", type: "selected", defValue: 1, options: ["A", "B"]}, {name: "comboBox2", label: "labelComboBox2", description: "下拉框2", type: "selected", defValue: "A|B"}, {name: "comboBox3", label: "labelComboBox3", description: "下拉框3", type: "selected", defValue: [0, 2], multiple: true, options: ["A", "B", "C"]}, { name: "comboBox4", label: "labelComboBox4", description: "下拉框4", type: "selected", defValue: ["A", "C"], multiple: true, options: [{text: "选项A", value: "A"}, {text: "选项B", value: "B"}, {text: "选项C", value: "C"}, {text: "选项D", value: "D"}] } ] } while (true) { LogStatus("`" + JSON.stringify(testBtn1) + "`\n", "`" + JSON.stringify(testBtn2) + "`\n", "`" + JSON.stringify(testBtn3) + "`\n") var cmd = GetCommand() if (cmd) { Log(cmd) } Sleep(5000) } }