-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.ts
331 lines (325 loc) · 14.8 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
/*
* types.ts
*
* Copyright (c) 2022-2024 Xiongfei Shi
*
* Author: Xiongfei Shi <xiongfei.shi(a)icloud.com>
* License: Apache-2.0
*
* https://github.com/shixiongfei/napi-ctp
*/
import { MessageFields, RspInfoField } from "@napi-ctp/types";
/** 行情消息事件 */
export enum MarketDataEvent {
/** 退出 */
Quit = "quit",
/** 当客户端与交易后台建立起通信连接时(还未登录前) */
FrontConnected = "front-connected",
/** 当客户端与交易后台通信连接断开时。当发生这个情况后,API会自动重新连接,客户端可不做处理 */
FrontDisconnected = "front-disconnected",
/** 心跳超时警告。当长时间未收到报文时 */
HeartBeatWarning = "heart-beat-warning",
/** 登录请求响应 */
RspUserLogin = "rsp-user-login",
/** 登出请求响应 */
RspUserLogout = "rsp-user-logout",
/** 请求查询组播合约响应 */
RspQryMulticastInstrument = "rsp-qry-multicast-instrument",
/** 错误应答 */
RspError = "rsp-error",
/** 订阅行情应答 */
RspSubMarketData = "rsp-sub-market-data",
/** 取消订阅行情应答 */
RspUnSubMarketData = "rsp-unsub-market-data",
/** 订阅询价应答 */
RspSubForQuote = "rsp-sub-for-quote",
/** 取消订阅询价应答 */
RspUnSubForQuote = "rsp-unsub-for-quote",
/** 深度行情通知 */
RtnDepthMarketData = "rtn-depth-market-data",
/** 询价通知 */
RtnForQuote = "rtn-for-quote",
}
/** 交易消息事件 */
export enum TraderEvent {
/** 退出 */
Quit = "quit",
/** 当客户端与交易后台建立起通信连接时(还未登录前) */
FrontConnected = "front-connected",
/** 当客户端与交易后台通信连接断开时。当发生这个情况后,API会自动重新连接,客户端可不做处理 */
FrontDisconnected = "front-disconnected",
/** 心跳超时警告。当长时间未收到报文时 */
HeartBeatWarning = "heart-beat-warning",
/** 客户端认证响应 */
RspAuthenticate = "rsp-authenticate",
/** 登录请求响应 */
RspUserLogin = "rsp-user-login",
/** 登出请求响应 */
RspUserLogout = "rsp-user-logout",
/** 用户口令更新请求响应 */
RspUserPasswordUpdate = "rsp-user-password-update",
/** 资金账户口令更新请求响应 */
RspTradingAccountPasswordUpdate = "rsp-trading-account-password-update",
/** 查询用户当前支持的认证模式的回复 */
RspUserAuthMethod = "rsp-user-auth-method",
/** 获取图形验证码请求的回复 */
RspGenUserCaptcha = "rsp-gen-user-captcha",
/** 获取短信验证码请求的回复 */
RspGenUserText = "rsp-gen-user-text",
/** 报单录入请求响应 */
RspOrderInsert = "rsp-order-insert",
/** 预埋单录入请求响应 */
RspParkedOrderInsert = "rsp-parked-order-insert",
/** 预埋撤单录入请求响应 */
RspParkedOrderAction = "rsp-parked-order-action",
/** 报单操作请求响应 */
RspOrderAction = "rsp-order-action",
/** 查询最大报单数量响应 */
RspQryMaxOrderVolume = "rsp-qry-max-order-volume",
/** 投资者结算结果确认响应 */
RspSettlementInfoConfirm = "rsp-settlement-info-confirm",
/** 删除预埋单响应 */
RspRemoveParkedOrder = "rsp-remove-parked-order",
/** 删除预埋撤单响应 */
RspRemoveParkedOrderAction = "rsp-remove-parked-order-action",
/** 执行宣告录入请求响应 */
RspExecOrderInsert = "rsp-exec-order-insert",
/** 执行宣告操作请求响应 */
RspExecOrderAction = "rsp-exec-order-action",
/** 询价录入请求响应 */
RspForQuoteInsert = "rsp-for-quote-insert",
/** 报价录入请求响应 */
RspQuoteInsert = "rsp-quote-insert",
/** 报价操作请求响应 */
RspQuoteAction = "rsp-quote-action",
/** 批量报单操作请求响应 */
RspBatchOrderAction = "rsp-batch-order-action",
/** 期权自对冲录入请求响应 */
RspOptionSelfCloseInsert = "rsp-option-self-close-insert",
/** 期权自对冲操作请求响应 */
RspOptionSelfCloseAction = "rsp-option-self-close-action",
/** 申请组合录入请求响应 */
RspCombActionInsert = "rsp-comb-action-insert",
/** 请求查询报单响应 */
RspQryOrder = "rsp-qry-order",
/** 请求查询成交响应 */
RspQryTrade = "rsp-qry-trade",
/** 请求查询投资者持仓响应 */
RspQryInvestorPosition = "rsp-qry-investor-position",
/** 请求查询资金账户响应 */
RspQryTradingAccount = "rsp-qry-trading-account",
/** 请求查询投资者响应 */
RspQryInvestor = "rsp-qry-investor",
/** 请求查询交易编码响应 */
RspQryTradingCode = "rsp-qry-trading-code",
/** 请求查询合约保证金率响应 */
RspQryInstrumentMarginRate = "rsp-qry-instrument-margin-rate",
/** 请求查询合约手续费率响应 */
RspQryInstrumentCommissionRate = "rsp-qry-instrument-commission-rate",
/** 请求查询交易所响应 */
RspQryExchange = "rsp-qry-exchange",
/** 请求查询产品响应 */
RspQryProduct = "rsp-qry-product",
/** 请求查询合约响应 */
RspQryInstrument = "rsp-qry-instrument",
/** 请求查询行情响应 */
RspQryDepthMarketData = "rsp-qry-depth-market-data",
/** 请求查询交易员报盘机响应 */
RspQryTraderOffer = "rsp-qry-trader-offer",
/** 请求查询投资者结算结果响应 */
RspQrySettlementInfo = "rsp-qry-settlement-info",
/** 请求查询转帐银行响应 */
RspQryTransferBank = "rsp-qry-transfer-bank",
/** 请求查询投资者持仓明细响应 */
RspQryInvestorPositionDetail = "rsp-qry-investor-position-detail",
/** 请求查询客户通知响应 */
RspQryNotice = "rsp-qry-notice",
/** 请求查询结算信息确认响应 */
RspQrySettlementInfoConfirm = "rsp-qry-settlement-info-confirm",
/** 请求查询投资者持仓明细响应 */
RspQryInvestorPositionCombineDetail = "rsp-qry-investor-position-combine-detail",
/** 查询保证金监管系统经纪公司资金账户密钥响应 */
RspQryCFMMCTradingAccountKey = "rsp-qry-cfmmc-trading-account-key",
/** 请求查询仓单折抵信息响应 */
RspQryEWarrantOffset = "rsp-qry-e-warrant-offset",
/** 请求查询投资者品种/跨品种保证金响应 */
RspQryInvestorProductGroupMargin = "rsp-qry-investor-product-group-margin",
/** 请求查询交易所保证金率响应 */
RspQryExchangeMarginRate = "rsp-qry-exchange-margin-rate",
/** 请求查询交易所调整保证金率响应 */
RspQryExchangeMarginRateAdjust = "rsp-qry-exchange-margin-rate-adjust",
/** 请求查询汇率响应 */
RspQryExchangeRate = "rsp-qry-exchange-rate",
/** 请求查询二级代理操作员银期权限响应 */
RspQrySecAgentACIDMap = "rsp-qry-sec-agent-acid-map",
/** 请求查询产品报价汇率 */
RspQryProductExchRate = "rsp-qry-product-exch-rate",
/** 请求查询产品组 */
RspQryProductGroup = "rsp-qry-product-group",
/** 请求查询做市商合约手续费率响应 */
RspQryMMInstrumentCommissionRate = "rsp-qry-mm-instrument-commission-rate",
/** 请求查询做市商期权合约手续费响应 */
RspQryMMOptionInstrCommRate = "rsp-qry-mm-option-instr-comm-rate",
/** 请求查询报单手续费响应 */
RspQryInstrumentOrderCommRate = "rsp-qry-instrument-order-comm-rate",
/** 请求查询资金账户响应 */
RspQrySecAgentTradingAccount = "rsp-qry-sec-agent-trading-account",
/** 请求查询二级代理商资金校验模式响应 */
RspQrySecAgentCheckMode = "rsp-qry-sec-agent-check-mode",
/** 请求查询二级代理商信息响应 */
RspQrySecAgentTradeInfo = "rsp-qry-sec-agent-trade-info",
/** 请求查询期权交易成本响应 */
RspQryOptionInstrTradeCost = "rsp-qry-option-instr-trade-cost",
/** 请求查询期权合约手续费响应 */
RspQryOptionInstrCommRate = "rsp-qry-option-instr-comm-rate",
/** 请求查询执行宣告响应 */
RspQryExecOrder = "rsp-qry-exec-order",
/** 请求查询询价响应 */
RspQryForQuote = "rsp-qry-for-quote",
/** 请求查询报价响应 */
RspQryQuote = "rsp-qry-quote",
/** 请求查询期权自对冲响应 */
RspQryOptionSelfClose = "rsp-qry-option-self-close",
/** 请求查询投资单元响应 */
RspQryInvestUnit = "rsp-qry-invest-unit",
/** 请求查询组合合约安全系数响应 */
RspQryCombInstrumentGuard = "rsp-qry-comb-instrument-guard",
/** 请求查询申请组合响应 */
RspQryCombAction = "rsp-qry-comb-action",
/** 请求查询转帐流水响应 */
RspQryTransferSerial = "rsp-qry-transfer-serial",
/** 请求查询银期签约关系响应 */
RspQryAccountRegister = "rsp-qry-account-register",
/** 错误应答 */
RspError = "rsp-error",
/** 报单通知 */
RtnOrder = "rtn-order",
/** 成交通知 */
RtnTrade = "rtn-trade",
/** 报单录入错误回报 */
ErrRtnOrderInsert = "err-rtn-order-insert",
/** 报单操作错误回报 */
ErrRtnOrderAction = "err-rtn-order-action",
/** 合约交易状态通知 */
RtnInstrumentStatus = "rtn-instrument-status",
/** 交易所公告通知 */
RtnBulletin = "rtn-bulletin",
/** 交易通知 */
RtnTradingNotice = "rtn-trading-notice",
/** 提示条件单校验错误 */
RtnErrorConditionalOrder = "rtn-error-conditional-order",
/** 执行宣告通知 */
RtnExecOrder = "rtn-exec-order",
/** 执行宣告录入错误回报 */
ErrRtnExecOrderInsert = "err-rtn-exec-order-insert",
/** 执行宣告操作错误回报 */
ErrRtnExecOrderAction = "err-rtn-exec-order-action",
/** 询价录入错误回报 */
ErrRtnForQuoteInsert = "err-rtn-for-quote-insert",
/** 报价通知 */
RtnQuote = "rtn-quote",
/** 报价录入错误回报 */
ErrRtnQuoteInsert = "err-rtn-quote-insert",
/** 报价操作错误回报 */
ErrRtnQuoteAction = "err-rtn-quote-action",
/** 询价通知 */
RtnForQuote = "rtn-for-quote",
/** 保证金监控中心用户令牌 */
RtnCFMMCTradingAccountToken = "rtn-cfmmc-trading-account-token",
/** 批量报单操作错误回报 */
ErrRtnBatchOrderAction = "err-rtn-batch-order-action",
/** 期权自对冲通知 */
RtnOptionSelfClose = "rtn-option-self-close",
/** 期权自对冲录入错误回报 */
ErrRtnOptionSelfCloseInsert = "err-rtn-option-self-close-insert",
/** 期权自对冲操作错误回报 */
ErrRtnOptionSelfCloseAction = "err-rtn-option-self-close-action",
/** 申请组合通知 */
RtnCombAction = "rtn-comb-action",
/** 申请组合录入错误回报 */
ErrRtnCombActionInsert = "err-rtn-comb-action-insert",
/** 请求查询签约银行响应 */
RspQryContractBank = "rsp-qry-contract-bank",
/** 请求查询预埋单响应 */
RspQryParkedOrder = "rsp-qry-parked-order",
/** 请求查询预埋撤单响应 */
RspQryParkedOrderAction = "rsp-qry-parked-order-action",
/** 请求查询交易通知响应 */
RspQryTradingNotice = "rsp-qry-trading-notice",
/** 请求查询经纪公司交易参数响应 */
RspQryBrokerTradingParams = "rsp-qry-broker-trading-params",
/** 请求查询经纪公司交易算法响应 */
RspQryBrokerTradingAlgos = "rsp-qry-broker-trading-algos",
/** 银行发起银行资金转期货通知 */
RtnFromBankToFutureByBank = "rtn-from-bank-to-future-by-bank",
/** 银行发起期货资金转银行通知 */
RtnFromFutureToBankByBank = "rtn-from-future-to-bank-by-bank",
/** 银行发起冲正银行转期货通知 */
RtnRepealFromBankToFutureByBank = "rtn-repeal-from-bank-to-future-by-bank",
/** 银行发起冲正期货转银行通知 */
RtnRepealFromFutureToBankByBank = "rtn-repeal-from-future-to-bank-by-bank",
/** 期货发起银行资金转期货通知 */
RtnFromBankToFutureByFuture = "rtn-from-bank-to-future-by-future",
/** 期货发起期货资金转银行通知 */
RtnFromFutureToBankByFuture = "rtn-from-future-to-bank-by-future",
/** 系统运行时期货端手工发起冲正银行转期货请求,银行处理完毕后报盘发回的通知 */
RtnRepealFromBankToFutureByFutureManual = "rtn-repeal-from-bank-to-future-by-future-manual",
/** 系统运行时期货端手工发起冲正期货转银行请求,银行处理完毕后报盘发回的通知 */
RtnRepealFromFutureToBankByFutureManual = "rtn-repeal-from-future-to-bank-by-future-manual",
/** 期货发起查询银行余额通知 */
RtnQueryBankBalanceByFuture = "rtn-query-bank-balance-by-future",
/** 期货发起银行资金转期货错误回报 */
ErrRtnBankToFutureByFuture = "err-rtn-bank-to-future-by-future",
/** 期货发起期货资金转银行错误回报 */
ErrRtnFutureToBankByFuture = "err-rtn-future-to-bank-by-future",
/** 系统运行时期货端手工发起冲正银行转期货错误回报 */
ErrRtnRepealBankToFutureByFutureManual = "err-rtn-repeal-bank-to-future-by-future-manual",
/** 系统运行时期货端手工发起冲正期货转银行错误回报 */
ErrRtnRepealFutureToBankByFutureManual = "err-rtn-repeal-future-to-bank-by-future-manual",
/** 期货发起查询银行余额错误回报 */
ErrRtnQueryBankBalanceByFuture = "err-rtn-query-bank-balance-by-future",
/** 期货发起冲正银行转期货请求,银行处理完毕后报盘发回的通知 */
RtnRepealFromBankToFutureByFuture = "rtn-repeal-from-bank-to-future-by-future",
/** 期货发起冲正期货转银行请求,银行处理完毕后报盘发回的通知 */
RtnRepealFromFutureToBankByFuture = "rtn-repeal-from-future-to-bank-by-future",
/** 期货发起银行资金转期货应答 */
RspFromBankToFutureByFuture = "rsp-from-bank-to-future-by-future",
/** 期货发起期货资金转银行应答 */
RspFromFutureToBankByFuture = "rsp-from-future-to-bank-by-future",
/** 期货发起查询银行余额应答 */
RspQueryBankAccountMoneyByFuture = "rsp-query-bank-account-money-by-future",
/** 银行发起银期开户通知 */
RtnOpenAccountByBank = "rtn-open-account-by-bank",
/** 银行发起银期销户通知 */
RtnCancelAccountByBank = "rtn-cancel-account-by-bank",
/** 银行发起变更银行账号通知 */
RtnChangeAccountByBank = "rtn-change-account-by-bank",
/** 请求查询分类合约响应 */
RspQryClassifiedInstrument = "rsp-qry-classified-instrument",
/** 请求组合优惠比例响应 */
RspQryCombPromotionParam = "rsp-qry-comb-promotion-param",
/** 投资者风险结算持仓查询响应 */
RspQryRiskSettleInvstPosition = "rsp-qry-risk-settle-invst-position",
/** 风险结算产品查询响应 */
RspQryRiskSettleProductStatus = "rsp-qry-risk-settle-product-status",
}
/** 回调消息类型 */
export type CallbackMessage = undefined | number | MessageFields;
/** 回调消息信息 */
export type CallbackOptions = {
/** 请求时产生的唯一编号 */
requestId?: number;
/** 是否为该请求的最后一条消息 */
isLast?: boolean;
/** CTP 返回的错误信息 */
rspInfo?: RspInfoField;
/** 从 CTP 产生回调时的时间戳(毫秒) */
timestamp: number;
/** 从 CTP 产生回调到进入 NodeJS 主循环队列的耗时(毫秒) */
elapsed: number;
};
/** 消息事件回调接口 */
export type CallbackFunction<T extends CallbackMessage> = (
message: T,
options: CallbackOptions
) => void;