输入/搜索内容
内置函数
结构体
Ticker
Depth
OrderBook
Trade
Record
Market
Order
Condition
Account
Asset
Position
Funding
其它结构
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
状态栏组件
Chart-options
Chart-return
KLineChart-options
KLineChart-return
SetData-data
EventLoop-return
exchange.Go-return
DBExec-return
Dial-return
Thread.join-return
内置变量与常量
通用约定
交易所

状态栏按钮JSON结构的旧写法(输入控件不带settings),平台仍然兼容;新代码使用LogStatus-btnTypeTwo,字段说明见LogStatus的「状态栏按钮」。

按钮可以单独输出到状态栏,也可以嵌入状态栏表格。点击按钮后弹框里的控件用input(一个控件)或group(一组控件)配置,提交的内容由GetCommand收到。例如点击后弹出一个数值输入框:

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

属性

名称类型描述

type

string

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

class

string

按钮样式,取Bootstrap按钮类名,例如"btn btn-xs btn-danger";取值范例见备注。

name

string

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

cmd

string

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

description

string

按钮控件的描述信息,在状态栏中鼠标放在该按钮上时显示的描述信息。

disabled

bool

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

input

object

点击按钮后弹框中的输入控件,字段见备注中的「input字段」表。

group

array

点击按钮后弹框中的一组控件,每个元素的结构与input相同。

参考

备注

input字段(group的每个元素相同):

字段说明
name弹框中控件的标题。
description弹框中控件的描述信息。
type控件类型:number数值输入框、string字符串输入框、selected下拉框、boolean开关。
defValue控件的默认值。下拉框可以直接用它写选项(选项之间用竖线分隔);设置了options时它是默认选项,多选时为数组。
options下拉框的选项,元素为字符串或{text: "描述", value: "值"}。
multiple为true时下拉框可以多选。

状态栏中按钮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) } }