输入/搜索内容
内置函数
结构体
Trade
Ticker
Record
Order
OrderBook
Depth
Account
Position
Market
OtherStruct
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
状态栏组件
grid
tabs
kpi
stat
progress
gauge
sparkline
chart
heatmap
calendar
histogram
pie
timeline
markdown
alert
badge
Chart-options
KLineChart-options
SetData-data
EventLoop-return
DBExec-return
Thread.join-return
内置变量

进度条:显示一个比例,或「当前值 / 总数」。

示例

显示冻结资金的占比,以及今日下单次数相对上限的进度。

javascript
function main() { while (!exchange.IO("status")) Sleep(1000) exchange.SetContractType("rb888") 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(): while not exchange.IO("status"): Sleep(1000) exchange.SetContractType("rb888") 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() { while !exchange.IO("status").is_ok_and(|v| v.as_i64() == Some(1)) { Sleep(1000); } if exchange.SetContractType("rb888").is_err() { return; } 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

必填,固定为 progress。

value

number

必填。当前值。

max

number

总数,给出时显示 value / max;不给时 value 是 0–1 的比例,显示为百分比。

color

string

进度条颜色,默认 primary。取值见状态栏组件。

title

string

标题,显示在组件左上角。

id

string

稳定标识。组件的个数或顺序会变化时设置,状态栏刷新时组件不重建。

span

number

在所在grid中占几列。默认 1。

参考