输入/搜索内容
内置函数
结构体
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结构。
状态栏按钮控件构造示例(按钮触发点击后,弹出框中包含多个输入控件,通过group字段构造):

json
{ "type": "button", "cmd": "open", "name": "开仓下单", "group": [{ "type": "selected", "name": "tradeType", "label": "下单类型", "description": "市价单、限价单", "default": 0, "group": "交易设置", "settings": { "options": ["市价单", "限价单"], "required": true, } }, { "type": "selected", "name": "direction", "label": "交易方向", "description": "买入、卖出", "default": "buy", "group": "交易设置", "settings": { "render": "segment", "required": true, "options": [{"name": "买入", "value": "buy"}, {"name": "卖出", "value": "sell"}], } }, { "type": "number", "name": "price", "label": "价格", "description": "订单的价格", "group": "交易设置", "filter": "tradeType==1", "settings": { "required": true, } }, { "type": "number", "name": "amount", "label": "下单量", "description": "订单的下单量", "group": "交易设置", "settings": { "required": true, } }], }

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

属性

名称类型描述

type

string

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

name

string

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

cmd

string

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

input

object

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

group

array

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

参考

备注

input字段

相对于旧版本的input结构(LogStatus-btnTypeOne),新版本的结构如下:

json
{ "type": "selected", "name": "test", "label": "topic", "description": "desc", "default": 1, "filter": "a>1", "group": "group1", "settings": { ... }, // 组件配置 }
字段说明
type控件类型(必填):number数值输入框、string字符串输入框、selected下拉框、boolean开关
name用于input时,没有设置label就作为弹框中控件的标题;用于group的元素时,是该控件的输入值在交互命令中的字段名
label控件的标题
description控件的描述信息;用于group的元素且没有设置label时,作为控件的标题
default控件的默认值
filter显示条件表达式:不设置时总是显示;表达式为真时显示,为假时隐藏
group控件分组,可折叠
settings组件配置,见下文

group示例(节选):

javascript
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"}] } ] }

点击按钮后弹框中有4个下拉框控件,设置好选项并确定后,GetCommand()收到cmdTestBtn3:{"comboBox1":1,"comboBox2":0,"comboBox3":[0,2],"comboBox4":["A","C"]},各控件的name(comboBox1等)就是命令中的字段名。

settings组件配置

settings用于选择和设置控件的界面形式,例如:

json
settings:{ multiple:true, customizable:true, options:[{name:'xxx|yyy',value:0}] }
字段说明
required是否必选
disabled是否禁用
min / max最小 / 最大值(number),或字符串的最小 / 最大长度
steptype为number且render为slider时有效,表示步长
multipletype为selected时有效,支持多选
customizabletype为selected时有效,支持在下拉框中编辑添加新选项;选中新选项时,交互命令中使用选项的名称而不是值
optionstype为selected时有效,选项数据:["选项1", "选项2"]或[{name: "xxx", value: 0}, {name: "xxx", value: 1}]
render渲染的组件类型,见下表
typerender可选值(不设置时为默认组件)
--
number默认数字输入框;slider滑动条,date时间选择器(返回时间戳)
string默认单行输入框;textarea多行输入,date时间选择器(返回yyyy-MM-dd hh:mm:ss),color颜色选择器(返回#FF00FF)
selected默认下拉框;segment分段选择器
boolean只有默认的复选框

支持双语设置:

json
{ type:'selected', name:'test', label:'选项|options', description:'描述|description', default:0, // 此处default默认值设置为0,表示{name:'xxx|yyy',value:0}选项中的value值 filter:'a>1&&a<10', group:'分组|group', settings:{ multiple:true, customizable:true, options:[{name:'xxx|yyy',value:0}] } }