QIFI
Quantaxis Differential Information Flow for Finance Intergration
QIFI 协议 作为qatrader/ qapms的标准协议, 支持股票/期货市场
  • 名称 QIFI 为 Quantaxis Differential Information Flow for Finance Intergration
  • 核心字段
    • 'accounts'
    • 'events'
    • 'trades'
    • 'orders'
    • 'positions'
    • 'broker_name'
交易的协议参见交易协议

关联项目

为什么要有这个协议:

主要目的是把 策略 / 背后的账户实现解耦
策略无需关心背后的账户情况, 仅需相应的申请资源即可(如 申请模拟账户/ 申请回测账户/ 申请实盘账户/) 策略在申请完毕后, 可以直接去读取相应字段, 如 策略想获取持仓的时候 即可直接get('positions') 即为持仓字段

协议实例概览

1
{
2
"account_cookie" : "100010", // 账户号(兼容QUANTAXIS QAAccount)
3
"password" : "100010",
4
"ping_gap" : 5,
5
"portfolio" : "default",
6
"broker_name" : "QUANTAXIS", // 接入商名称
7
"capital_password" : null, // 资金密码 (实盘用)
8
"bank_password" : null, // 银行密码(实盘用)
9
"bankid" : "SIM", // 银行id
10
"investor_name" : "", // 开户人名称
11
"money" : 0.0, // 当前可用现金
12
"pub_host" : "localhost",
13
"settlement" : {},
14
"taskid" : null,
15
16
"qifi_id": String,
17
"trade_host" : "127.0.0.1",
18
"updatetime" : "2019-09-06 21:19:48.346640",
19
"wsuri" : "ws://www.yutiansut.com:7988",
20
"bankname" : "模拟银行",
21
"trading_day" : "20190909",
22
"status" : 200
23
"accounts" : {
24
"user_id" : "100010", // 用户号 兼容diff协议, ==> 实盘则为具体账户号
25
"currency" : "CNY", // 货币属性 兼容diff协议
26
"pre_balance" : 0.0, // 上一个交易日的结算权益
27
"deposit" : 1000000.0, // 今日转入资金
28
"withdraw" : 0.0, // 今日转出资金
29
"WithdrawQuota" : 3.95252516672997e-322, // 当前可取字段(QIFI 独有)
30
"close_profit" : 0.0, // 平仓盈亏
31
"commission" : 6.84, // 手续费
32
"premium" : 0.0, // 附加费
33
"static_balance" : 1000000.0, // 静态权益(一般= pre_balance)
34
"position_profit" : -80.0, // 持仓盈亏
35
"float_profit" : -80.0, // 浮动盈亏
36
"balance" : 999913.16, // 当前权益
37
"margin" : 5472.0, // 保证金
38
"frozen_margin" : 5472.0, // 冻结保证金
39
"frozen_commission" : 0.0, // 冻结手续费
40
"frozen_premium" : 0.0, // 冻结附加费用
41
"available" : 988969.16, // 可用资金
42
"risk_ratio" : 0.00547247522974895 // 风险度
43
},
44
"banks" : { // 银行内容(支持多银行 id识别)
45
"SIM" : {
46
"id" : "SIM",
47
"name" : "模拟银行",
48
"bank_account" : "",
49
"fetch_amount" : 0.0,
50
"qry_count" : 0
51
}
52
},
53
"event" : { // 事件 time+ 内容
54
"2019-09-06 21:01:36" : "登录成功",
55
"2019-09-06 21:12:53" : "下单成功",
56
"2019-09-06 21:14:25" : "下单成功",
57
"2019-09-06 21:14:37" : "下单成功",
58
"2019-09-06 21:14:57" : "成交通知,合约:SHFE.rb2001,手数:1",
59
"2019-09-06 21:16:50" : "成交通知,合约:SHFE.rb2001,手数:1"
60
},
61
"orders" : { // 多段order 订单
62
"QAOTG_5oAYRUI3" : {
63
"seqno" : 8,
64
"user_id" : "100010",
65
"order_id" : "QAOTG_5oAYRUI3",
66
"exchange_id" : "SHFE",
67
"instrument_id" : "rb2001",
68
"direction" : "SELL",
69
"offset" : "OPEN",
70
"volume_orign" : 1,
71
"price_type" : "LIMIT",
72
"limit_price" : 3426.0,
73
"time_condition" : "GFD",
74
"volume_condition" : "ANY",
75
"insert_date_time" : NumberLong(1567775573528050636),
76
"exchange_order_id" : "QAOTG_5oAYRUI3",
77
"status" : "FINISHED",
78
"volume_left" : 0,
79
"last_msg" : ""
80
},
81
"QAOTG_xyVXjgcZ" : {
82
"seqno" : 3,
83
"user_id" : "100010",
84
"order_id" : "QAOTG_xyVXjgcZ",
85
"exchange_id" : "SHFE",
86
"instrument_id" : "rb2001",
87
"direction" : "SELL",
88
"offset" : "OPEN",
89
"volume_orign" : 1,
90
"price_type" : "LIMIT",
91
"limit_price" : 3480.0,
92
"time_condition" : "GFD",
93
"volume_condition" : "ANY",
94
"insert_date_time" : NumberLong(1567775665377198042),
95
"exchange_order_id" : "QAOTG_xyVXjgcZ",
96
"status" : "ALIVE",
97
"volume_left" : 1,
98
"last_msg" : ""
99
},
100
"QAOTG_BIn7hPtG" : {
101
"seqno" : 5,
102
"user_id" : "100010",
103
"order_id" : "QAOTG_BIn7hPtG",
104
"exchange_id" : "SHFE",
105
"instrument_id" : "rb2001",
106
"direction" : "SELL",
107
"offset" : "OPEN",
108
"volume_orign" : 1,
109
"price_type" : "LIMIT",
110
"limit_price" : 3480.0,
111
"time_condition" : "GFD",
112
"volume_condition" : "ANY",
113
"insert_date_time" : NumberLong(1567775677891881150),
114
"exchange_order_id" : "QAOTG_BIn7hPtG",
115
"status" : "ALIVE",
116
"volume_left" : 1,
117
"last_msg" : ""
118
},
119
"QAOTG_P4kEw2FJ" : {
120
"seqno" : 13,
121
"user_id" : "100010",
122
"order_id" : "QAOTG_P4kEw2FJ",
123
"exchange_id" : "SHFE",
124
"instrument_id" : "rb2001",
125
"direction" : "BUY",
126
"offset" : "OPEN",
127
"volume_orign" : 1,
128
"price_type" : "LIMIT",
129
"limit_price" : 3480.0,
130
"time_condition" : "GFD",
131
"volume_condition" : "ANY",
132
"insert_date_time" : NumberLong(1567775810195686542),
133
"exchange_order_id" : "QAOTG_P4kEw2FJ",
134
"status" : "FINISHED",
135
"volume_left" : 0,
136
"last_msg" : ""
137
}
138
},
139
"positions" : {
140
"SHFE_rb2001" : {
141
"user_id" : "100010",
142
"exchange_id" : "SHFE",
143
"instrument_id" : "rb2001",
144
"volume_long_today" : 1,
145
"volume_long_his" : 0,
146
"volume_long" : 1,
147
"volume_long_frozen_today" : 0,
148
"volume_long_frozen_his" : 0,
149
"volume_long_frozen" : 0,
150
"volume_short_today" : 1,
151
"volume_short_his" : 0,
152
"volume_short" : 1,
153
"volume_short_frozen_today" : 0,
154
"volume_short_frozen_his" : 0,
155
"volume_short_frozen" : 0,
156
"volume_long_yd" : 0,
157
"volume_short_yd" : 0,
158
"pos_long_his" : 0,
159
"pos_long_today" : 1,
160
"pos_short_his" : 0,
161
"pos_short_today" : 1,
162
"open_price_long" : 3434.0,
163
"open_price_short" : 3426.0,
164
"open_cost_long" : 34340.0,
165
"open_cost_short" : 34260.0,
166
"position_price_long" : 3434.0,
167
"position_price_short" : 3426.0,
168
"position_cost_long" : 34340.0,
169
"position_cost_short" : 34260.0,
170
"last_price" : 3432.0,
171
"float_profit_long" : -20.0,
172
"float_profit_short" : -60.0,
173
"float_profit" : -80.0,
174
"position_profit_long" : -20.0,
175
"position_profit_short" : -60.0,
176
"position_profit" : -80.0,
177
"margin_long" : 2736.0,
178
"margin_short" : 2736.0,
179
"margin" : 5472.0
180
}
181
},
182
"trades" : {
183
"6" : {
184
"seqno" : 7,
185
"user_id" : "100010",
186
"trade_id" : "6",
187
"exchange_id" : "SHFE",
188
"instrument_id" : "rb2001",
189
"order_id" : "QAOTG_5oAYRUI3",
190
"exchange_trade_id" : "6",
191
"direction" : "SELL",
192
"offset" : "OPEN",
193
"volume" : 1,
194
"price" : 3426.0,
195
"trade_date_time" : NumberLong(1567775697237747424),
196
"commission" : 3.42
197
},
198
"11" : {
199
"seqno" : 12,
200
"user_id" : "100010",
201
"trade_id" : "11",
202
"exchange_id" : "SHFE",
203
"instrument_id" : "rb2001",
204
"order_id" : "QAOTG_P4kEw2FJ",
205
"exchange_trade_id" : "11",
206
"direction" : "BUY",
207
"offset" : "OPEN",
208
"volume" : 1,
209
"price" : 3434.0,
210
"trade_date_time" : NumberLong(1567775810195972480),
211
"commission" : 3.42
212
}
213
},
214
"transfers" : {},
215
}
Copied!
Last modified 7mo ago