@vibek/cli 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -16
- package/config.example.toml +44 -52
- package/index.js +761 -770
- package/package.json +1 -1
- package/vibek-package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Vibek 是一个个人自用的 CTP 量化交易项目,提供后台行情与交
|
|
|
10
10
|
不建议直接用于他人的生产或实盘交易环境。
|
|
11
11
|
|
|
12
12
|
Vibek 可能连接真实期货账户,但不构成投资建议,也不对交易损失负责。使用者应自行评估并承担风险;
|
|
13
|
-
|
|
13
|
+
首次使用应先在 CTP 测试环境、Paper 模式和离线回测中完成充分验证;Live 策略必须显式加载并启动。
|
|
14
14
|
|
|
15
15
|
## 运行环境
|
|
16
16
|
|
|
@@ -50,38 +50,34 @@ vibek --default-config > ~/.config/vibek/config.toml
|
|
|
50
50
|
${EDITOR:-vi} ~/.config/vibek/config.toml
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
账号名由 `broker_id-user` 自动生成。配置只支持一个账号:
|
|
54
54
|
|
|
55
55
|
```toml
|
|
56
|
-
|
|
57
|
-
active_account = "9999-account"
|
|
58
|
-
|
|
59
|
-
[accounts."9999-account".identity]
|
|
56
|
+
[account]
|
|
60
57
|
broker_id = "9999"
|
|
61
58
|
user = "account"
|
|
62
59
|
|
|
63
|
-
[
|
|
60
|
+
[account.ctp]
|
|
64
61
|
market_front = "tcp://行情前置地址:端口"
|
|
65
62
|
trader_front = "tcp://交易前置地址:端口"
|
|
66
63
|
app_id = "你的-app-id"
|
|
67
64
|
production_mode = true
|
|
68
65
|
|
|
69
|
-
[
|
|
70
|
-
live_enabled = false
|
|
66
|
+
[account.trading]
|
|
71
67
|
max_order_volume = 1
|
|
72
68
|
max_position = 2
|
|
73
69
|
max_active_orders = 2
|
|
74
70
|
allow_short = true
|
|
75
71
|
```
|
|
76
72
|
|
|
77
|
-
`production_mode` 选择 CTP API
|
|
78
|
-
`
|
|
73
|
+
`production_mode` 选择 CTP API 的生产/评测模式;它不决定策略使用 Paper 还是 Live。
|
|
74
|
+
换号时修改 `[account]`,然后执行 `vibek daemon restart`。
|
|
79
75
|
|
|
80
76
|
### 2. 校验配置
|
|
81
77
|
|
|
82
78
|
```bash
|
|
83
79
|
vibek config
|
|
84
|
-
vibek
|
|
80
|
+
vibek status
|
|
85
81
|
```
|
|
86
82
|
|
|
87
83
|
配置有未知字段、类型错误、账号引用错误或风控值越界时,`vibek config` 会直接指出问题。
|
|
@@ -135,9 +131,7 @@ Web 工作台本身不会自动启动交易 daemon。需要行情、账户或策
|
|
|
135
131
|
| 命令 | 用途 |
|
|
136
132
|
| --- | --- |
|
|
137
133
|
| `vibek status` | 汇总账号、daemon、行情、交易连接和策略状态 |
|
|
138
|
-
| `vibek account
|
|
139
|
-
| `vibek account use <名称>` | 切换当前账号 |
|
|
140
|
-
| `vibek account show` | 查询当前柜台资金 |
|
|
134
|
+
| `vibek account` | 查询当前柜台资金 |
|
|
141
135
|
| `vibek positions` | 查询实时持仓 |
|
|
142
136
|
| `vibek orders` | 查询当前交易日委托 |
|
|
143
137
|
| `vibek trades` | 查询当前交易日成交 |
|
|
@@ -176,7 +170,7 @@ vibek strategy unload <策略实例ID>
|
|
|
176
170
|
vibek backtest ./my-strategy.ts --help
|
|
177
171
|
```
|
|
178
172
|
|
|
179
|
-
Live 模式必须显式使用 `--mode live
|
|
173
|
+
Live 模式必须显式使用 `--mode live`、显式启动,并通过委托限制和持仓核对。
|
|
180
174
|
不要用尚未在 Paper 和回测中验证的策略直接连接实盘。
|
|
181
175
|
|
|
182
176
|
## 配置和数据位置
|
package/config.example.toml
CHANGED
|
@@ -1,58 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
[account]
|
|
2
|
+
broker_id = ""
|
|
3
|
+
user = ""
|
|
4
|
+
|
|
5
|
+
[account.ctp]
|
|
6
|
+
market_front = ""
|
|
7
|
+
trader_front = ""
|
|
8
|
+
front_candidates = []
|
|
9
|
+
app_id = ""
|
|
10
|
+
production_mode = true
|
|
11
|
+
|
|
12
|
+
[account.logging]
|
|
13
|
+
level = "info"
|
|
14
|
+
|
|
15
|
+
[account.market]
|
|
16
|
+
db_path = ""
|
|
17
|
+
record_instruments = []
|
|
18
|
+
max_future_tick_ms = 5000
|
|
19
|
+
|
|
20
|
+
[account.trading]
|
|
21
|
+
max_order_volume = 10
|
|
22
|
+
max_position = 20
|
|
23
|
+
max_active_orders = 5
|
|
24
|
+
allow_short = true
|
|
25
|
+
|
|
26
|
+
[account.schedule]
|
|
27
|
+
enabled = true
|
|
28
|
+
day_start = "08:45"
|
|
29
|
+
day_stop = "15:15"
|
|
30
|
+
night_start = "20:45"
|
|
31
|
+
night_stop = "02:35"
|
|
32
|
+
max_start_attempts = 4
|
|
33
|
+
retry_base_ms = 30000
|
|
34
|
+
tick_ms = 30000
|
|
35
|
+
|
|
36
|
+
[account.notifications]
|
|
37
|
+
bark_key = ""
|
|
38
|
+
bark_signal_keys = []
|
|
39
|
+
telegram_bot_token = ""
|
|
40
|
+
telegram_chat_id = ""
|
|
7
41
|
|
|
8
42
|
[storage]
|
|
9
|
-
|
|
43
|
+
data_root = "~/.vibek"
|
|
10
44
|
|
|
11
45
|
[server]
|
|
12
|
-
|
|
13
|
-
|
|
46
|
+
daemon_port = 3111
|
|
47
|
+
webui_port = 3211
|
|
14
48
|
|
|
15
49
|
[network]
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# [accounts."9999-account".identity]
|
|
19
|
-
# broker_id = "9999"
|
|
20
|
-
# user = "account"
|
|
21
|
-
|
|
22
|
-
# [accounts."9999-account".ctp]
|
|
23
|
-
# market_front = "tcp://host:port"
|
|
24
|
-
# trader_front = "tcp://host:port"
|
|
25
|
-
# front_candidates = ["主线@1.2.3.4", "备用@1.2.3.5"]
|
|
26
|
-
# app_id = "client-id"
|
|
27
|
-
# production_mode = true
|
|
28
|
-
|
|
29
|
-
# [accounts."9999-account".logging]
|
|
30
|
-
# level = "info" # trace | debug | info | warn | error
|
|
31
|
-
|
|
32
|
-
# [accounts."9999-account".market]
|
|
33
|
-
# db_path = ""
|
|
34
|
-
# record_instruments = ["NI2609.SHFE", "IF2609.CFFEX"]
|
|
35
|
-
# max_future_tick_ms = 5000
|
|
36
|
-
|
|
37
|
-
# [accounts."9999-account".trading]
|
|
38
|
-
# live_enabled = false
|
|
39
|
-
# max_order_volume = 10
|
|
40
|
-
# max_position = 20
|
|
41
|
-
# max_active_orders = 5
|
|
42
|
-
# allow_short = true
|
|
43
|
-
|
|
44
|
-
# [accounts."9999-account".schedule]
|
|
45
|
-
# enabled = true
|
|
46
|
-
# day_start = "08:45"
|
|
47
|
-
# day_stop = "15:15"
|
|
48
|
-
# night_start = "20:45"
|
|
49
|
-
# night_stop = "02:35"
|
|
50
|
-
# max_start_attempts = 4
|
|
51
|
-
# retry_base_ms = 30000
|
|
52
|
-
# tick_ms = 30000
|
|
53
|
-
|
|
54
|
-
# [accounts."9999-account".notifications]
|
|
55
|
-
# bark_key = ""
|
|
56
|
-
# bark_signal_keys = []
|
|
57
|
-
# telegram_bot_token = ""
|
|
58
|
-
# telegram_chat_id = ""
|
|
50
|
+
telegram_proxy = ""
|