内置函数
结构体
Ticker
Depth
OrderBook
Trade
Record
Market
Order
Condition
Account
Asset
Position
Funding
其它结构
内置变量与常量
通用约定
交易所
progress
进度条:显示一个比例,或「当前值 / 总数」。
示例
显示冻结资金的占比,以及今日下单次数相对上限的进度。
javascript
function main() {
var account = exchange.GetAccount()
if (!account) return
var total = account.Balance + account.FrozenBalance
var frozen = total > 0 ? account.FrozenBalance / total : 0
var orders = 3 // 策略自己统计的下单次数
LogStatus([
{type: "progress", title: "冻结资金占比", value: frozen},
{type: "progress", title: "今日下单次数", value: orders, max: 20, color: "warning"}
])
}
python
def main():
account = exchange.GetAccount()
if not account:
return
total = account["Balance"] + account["FrozenBalance"]
frozen = account["FrozenBalance"] / total if total > 0 else 0
orders = 3 # 策略自己统计的下单次数
LogStatus([
{"type": "progress", "title": "冻结资金占比", "value": frozen},
{"type": "progress", "title": "今日下单次数", "value": orders, "max": 20,
"color": "warning"}
])
rust
fn main() {
let Ok(a) = exchange.GetAccount() else { return };
let total = a.Balance + a.FrozenBalance;
let frozen = if total > 0.0 { a.FrozenBalance / total } else { 0.0 };
let orders = 3; // 策略自己统计的下单次数
LogStatus!(format!(
r#"[{{"type": "progress", "title": "冻结资金占比", "value": {}}},
{{"type": "progress", "title": "今日下单次数", "value": {}, "max": 20,
"color": "warning"}}]"#,
frozen, orders
));
}属性
| 名称 | 类型 | 描述 |
type | string | 必填,固定为 |
value | number | 必填。当前值。 |
max | number | 总数,给出时显示 |
color | string | 进度条颜色,默认 |
title | string | 标题,显示在组件左上角。 |
id | string | 稳定标识。组件的个数或顺序会变化时设置,状态栏刷新时组件不重建。 |
span | number | 在所在 |
参考