@hitrading/ctp-node 1.1.0 → 2.0.0
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 +12 -5
- package/README.zh-CN.md +12 -5
- package/binding.gyp +13 -13
- package/{tradeapi/macos/thostmduserapi_se.framework/Versions/A/Headers → ctpsdk}/ThostFtdcMdApi.h +2 -1
- package/{tradeapi/macos/thosttraderapi_se.framework/Versions/A/Headers → ctpsdk}/ThostFtdcTraderApi.h +133 -6
- package/{tradeapi/macos/thostmduserapi_se.framework/Versions/A/Headers → ctpsdk}/ThostFtdcUserApiDataType.h +199 -3
- package/{tradeapi/macos/thosttraderapi_se.framework/Versions/A/Headers → ctpsdk}/ThostFtdcUserApiStruct.h +1574 -12
- package/{tradeapi → ctpsdk}/error.xml +56 -11
- package/ctpsdk/linux/thostmduserapi_se.so +0 -0
- package/{tradeapi → ctpsdk}/linux/thosttraderapi_se.so +0 -0
- package/{tradeapi → ctpsdk/macos/thostmduserapi_se.framework/Versions/A/Headers}/ThostFtdcMdApi.h +1 -1
- package/{tradeapi → ctpsdk/macos/thostmduserapi_se.framework/Versions/A/Headers}/ThostFtdcUserApiDataType.h +35 -2
- package/{tradeapi → ctpsdk/macos/thostmduserapi_se.framework/Versions/A/Headers}/ThostFtdcUserApiStruct.h +121 -11
- package/{tradeapi → ctpsdk}/macos/thostmduserapi_se.framework/Versions/A/Resources/Info.plist +46 -46
- package/{tradeapi → ctpsdk}/macos/thostmduserapi_se.framework/Versions/A/_CodeSignature/CodeResources +149 -149
- package/{tradeapi → ctpsdk}/macos/thostmduserapi_se.framework/Versions/A/thostmduserapi_se +0 -0
- package/{tradeapi → ctpsdk/macos/thosttraderapi_se.framework/Versions/A/Headers}/ThostFtdcTraderApi.h +14 -2
- package/{tradeapi → ctpsdk}/macos/thosttraderapi_se.framework/Versions/A/Headers/ThostFtdcUserApiDataType.h +2123 -2090
- package/{tradeapi/macos/thostmduserapi_se.framework → ctpsdk/macos/thosttraderapi_se.framework}/Versions/A/Headers/ThostFtdcUserApiStruct.h +5596 -5486
- package/{tradeapi → ctpsdk}/macos/thosttraderapi_se.framework/Versions/A/Resources/Info.plist +46 -46
- package/{tradeapi → ctpsdk}/macos/thosttraderapi_se.framework/Versions/A/_CodeSignature/CodeResources +149 -149
- package/{tradeapi → ctpsdk}/macos/thosttraderapi_se.framework/Versions/A/thosttraderapi_se +0 -0
- package/ctpsdk/windows/thostmduserapi_se.dll +0 -0
- package/ctpsdk/windows/thostmduserapi_se.lib +0 -0
- package/ctpsdk/windows/thosttraderapi_se.dll +0 -0
- package/ctpsdk/windows/thosttraderapi_se.lib +0 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -0
- package/dist/client.js.map +1 -1
- package/dist/generated/enums.gen.d.ts +76 -6
- package/dist/generated/enums.gen.d.ts.map +1 -1
- package/dist/generated/enums.gen.js +78 -0
- package/dist/generated/enums.gen.js.map +1 -1
- package/dist/generated/structs.gen.d.ts +6271 -4816
- package/dist/generated/structs.gen.d.ts.map +1 -1
- package/dist/generated/structs.gen.js +131 -25
- package/dist/generated/structs.gen.js.map +1 -1
- package/dist/generated/trader.gen.d.ts +39 -1
- package/dist/generated/trader.gen.d.ts.map +1 -1
- package/dist/generated/trader.gen.js +315 -225
- package/dist/generated/trader.gen.js.map +1 -1
- package/dist/index.cjs +594 -296
- package/dist/market-data.d.ts +10 -0
- package/dist/market-data.d.ts.map +1 -1
- package/dist/market-data.js +20 -0
- package/dist/market-data.js.map +1 -1
- package/dist/native-binding.js +1 -1
- package/dist/native-binding.js.map +1 -1
- package/dist/trader.d.ts +38 -30
- package/dist/trader.d.ts.map +1 -1
- package/dist/trader.js +39 -45
- package/dist/trader.js.map +1 -1
- package/package.json +7 -3
- package/prebuilds/linux-x64/@hitrading+ctp-node.node +0 -0
- package/prebuilds/linux-x64/thostmduserapi_se.so +0 -0
- package/prebuilds/linux-x64/thosttraderapi_se.so +0 -0
- package/prebuilds/win32-x64/@hitrading+ctp-node.node +0 -0
- package/prebuilds/win32-x64/thostmduserapi_se.dll +0 -0
- package/prebuilds/win32-x64/thosttraderapi_se.dll +0 -0
- package/src/client.ts +8 -0
- package/src/generated/enums.gen.ts +78 -0
- package/src/generated/layout.gen.cc +794 -40
- package/src/generated/structids.gen.h +54 -1
- package/src/generated/structs.gen.ts +6455 -4841
- package/src/generated/trader.gen.ts +315 -225
- package/src/generated/traderreq.gen.cc +84 -0
- package/src/generated/traderreq.gen.h +89 -75
- package/src/generated/traderspi.gen.cc +102 -0
- package/src/generated/traderspi.gen.h +198 -150
- package/src/market-data.ts +23 -0
- package/src/native/mdapi.cc +49 -2
- package/src/native/mdspi.cc +5 -1
- package/src/native/mdspi.h +4 -0
- package/src/native/risk.cc +50 -21
- package/src/native/risk.h +48 -8
- package/src/native/snapshot.h +61 -0
- package/src/native/traderapi.cc +11 -61
- package/src/native-binding.ts +1 -1
- package/src/trader.ts +55 -58
- package/tradeapi/linux/thostmduserapi_se.so +0 -0
- package/tradeapi/windows/thostmduserapi_se.dll +0 -0
- package/tradeapi/windows/thostmduserapi_se.lib +0 -0
- package/tradeapi/windows/thosttraderapi_se.dll +0 -0
- package/tradeapi/windows/thosttraderapi_se.lib +0 -0
- /package/{tradeapi → ctpsdk}/error.dtd +0 -0
|
@@ -11,156 +11,180 @@ enum {
|
|
|
11
11
|
ET_FrontDisconnected = ET_BASE + 2,
|
|
12
12
|
ET_HeartBeatWarning = ET_BASE + 3,
|
|
13
13
|
ET_RspAuthenticate = ET_BASE + 4,
|
|
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
|
-
|
|
14
|
+
ET_RtnPrivateSeqNo = ET_BASE + 5,
|
|
15
|
+
ET_RspUserLogin = ET_BASE + 6,
|
|
16
|
+
ET_RspUserLogout = ET_BASE + 7,
|
|
17
|
+
ET_RspUserPasswordUpdate = ET_BASE + 8,
|
|
18
|
+
ET_RspTradingAccountPasswordUpdate = ET_BASE + 9,
|
|
19
|
+
ET_RspUserAuthMethod = ET_BASE + 10,
|
|
20
|
+
ET_RspGenUserCaptcha = ET_BASE + 11,
|
|
21
|
+
ET_RspGenUserText = ET_BASE + 12,
|
|
22
|
+
ET_RspOrderInsert = ET_BASE + 13,
|
|
23
|
+
ET_RspParkedOrderInsert = ET_BASE + 14,
|
|
24
|
+
ET_RspParkedOrderAction = ET_BASE + 15,
|
|
25
|
+
ET_RspOrderAction = ET_BASE + 16,
|
|
26
|
+
ET_RspQryMaxOrderVolume = ET_BASE + 17,
|
|
27
|
+
ET_RspSettlementInfoConfirm = ET_BASE + 18,
|
|
28
|
+
ET_RspRemoveParkedOrder = ET_BASE + 19,
|
|
29
|
+
ET_RspRemoveParkedOrderAction = ET_BASE + 20,
|
|
30
|
+
ET_RspExecOrderInsert = ET_BASE + 21,
|
|
31
|
+
ET_RspExecOrderAction = ET_BASE + 22,
|
|
32
|
+
ET_RspForQuoteInsert = ET_BASE + 23,
|
|
33
|
+
ET_RspQuoteInsert = ET_BASE + 24,
|
|
34
|
+
ET_RspQuoteAction = ET_BASE + 25,
|
|
35
|
+
ET_RspBatchOrderAction = ET_BASE + 26,
|
|
36
|
+
ET_RspOptionSelfCloseInsert = ET_BASE + 27,
|
|
37
|
+
ET_RspOptionSelfCloseAction = ET_BASE + 28,
|
|
38
|
+
ET_RspCombActionInsert = ET_BASE + 29,
|
|
39
|
+
ET_RspQryOrder = ET_BASE + 30,
|
|
40
|
+
ET_RspQryTrade = ET_BASE + 31,
|
|
41
|
+
ET_RspQryInvestorPosition = ET_BASE + 32,
|
|
42
|
+
ET_RspQryTradingAccount = ET_BASE + 33,
|
|
43
|
+
ET_RspQryInvestor = ET_BASE + 34,
|
|
44
|
+
ET_RspQryTradingCode = ET_BASE + 35,
|
|
45
|
+
ET_RspQryInstrumentMarginRate = ET_BASE + 36,
|
|
46
|
+
ET_RspQryInstrumentCommissionRate = ET_BASE + 37,
|
|
47
|
+
ET_RspQryUserSession = ET_BASE + 38,
|
|
48
|
+
ET_RspQryExchange = ET_BASE + 39,
|
|
49
|
+
ET_RspQryProduct = ET_BASE + 40,
|
|
50
|
+
ET_RspQryInstrument = ET_BASE + 41,
|
|
51
|
+
ET_RspQryDepthMarketData = ET_BASE + 42,
|
|
52
|
+
ET_RspQryTraderOffer = ET_BASE + 43,
|
|
53
|
+
ET_RspQrySettlementInfo = ET_BASE + 44,
|
|
54
|
+
ET_RspQryTransferBank = ET_BASE + 45,
|
|
55
|
+
ET_RspQryInvestorPositionDetail = ET_BASE + 46,
|
|
56
|
+
ET_RspQryNotice = ET_BASE + 47,
|
|
57
|
+
ET_RspQrySettlementInfoConfirm = ET_BASE + 48,
|
|
58
|
+
ET_RspQryInvestorPositionCombineDetail = ET_BASE + 49,
|
|
59
|
+
ET_RspQryCFMMCTradingAccountKey = ET_BASE + 50,
|
|
60
|
+
ET_RspQryEWarrantOffset = ET_BASE + 51,
|
|
61
|
+
ET_RspQryInvestorProductGroupMargin = ET_BASE + 52,
|
|
62
|
+
ET_RspQryExchangeMarginRate = ET_BASE + 53,
|
|
63
|
+
ET_RspQryExchangeMarginRateAdjust = ET_BASE + 54,
|
|
64
|
+
ET_RspQryExchangeRate = ET_BASE + 55,
|
|
65
|
+
ET_RspQrySecAgentACIDMap = ET_BASE + 56,
|
|
66
|
+
ET_RspQryProductExchRate = ET_BASE + 57,
|
|
67
|
+
ET_RspQryProductGroup = ET_BASE + 58,
|
|
68
|
+
ET_RspQryMMInstrumentCommissionRate = ET_BASE + 59,
|
|
69
|
+
ET_RspQryMMOptionInstrCommRate = ET_BASE + 60,
|
|
70
|
+
ET_RspQryInstrumentOrderCommRate = ET_BASE + 61,
|
|
71
|
+
ET_RspQrySecAgentTradingAccount = ET_BASE + 62,
|
|
72
|
+
ET_RspQrySecAgentCheckMode = ET_BASE + 63,
|
|
73
|
+
ET_RspQrySecAgentTradeInfo = ET_BASE + 64,
|
|
74
|
+
ET_RspQryOptionInstrTradeCost = ET_BASE + 65,
|
|
75
|
+
ET_RspQryOptionInstrCommRate = ET_BASE + 66,
|
|
76
|
+
ET_RspQryExecOrder = ET_BASE + 67,
|
|
77
|
+
ET_RspQryForQuote = ET_BASE + 68,
|
|
78
|
+
ET_RspQryQuote = ET_BASE + 69,
|
|
79
|
+
ET_RspQryOptionSelfClose = ET_BASE + 70,
|
|
80
|
+
ET_RspQryInvestUnit = ET_BASE + 71,
|
|
81
|
+
ET_RspQryCombInstrumentGuard = ET_BASE + 72,
|
|
82
|
+
ET_RspQryCombAction = ET_BASE + 73,
|
|
83
|
+
ET_RspQryTransferSerial = ET_BASE + 74,
|
|
84
|
+
ET_RspQryAccountregister = ET_BASE + 75,
|
|
85
|
+
ET_RspError = ET_BASE + 76,
|
|
86
|
+
ET_RtnOrder = ET_BASE + 77,
|
|
87
|
+
ET_RtnTrade = ET_BASE + 78,
|
|
88
|
+
ET_ErrRtnOrderInsert = ET_BASE + 79,
|
|
89
|
+
ET_ErrRtnOrderAction = ET_BASE + 80,
|
|
90
|
+
ET_RtnInstrumentStatus = ET_BASE + 81,
|
|
91
|
+
ET_RtnBulletin = ET_BASE + 82,
|
|
92
|
+
ET_RtnTradingNotice = ET_BASE + 83,
|
|
93
|
+
ET_RtnErrorConditionalOrder = ET_BASE + 84,
|
|
94
|
+
ET_RtnExecOrder = ET_BASE + 85,
|
|
95
|
+
ET_ErrRtnExecOrderInsert = ET_BASE + 86,
|
|
96
|
+
ET_ErrRtnExecOrderAction = ET_BASE + 87,
|
|
97
|
+
ET_ErrRtnForQuoteInsert = ET_BASE + 88,
|
|
98
|
+
ET_RtnQuote = ET_BASE + 89,
|
|
99
|
+
ET_ErrRtnQuoteInsert = ET_BASE + 90,
|
|
100
|
+
ET_ErrRtnQuoteAction = ET_BASE + 91,
|
|
101
|
+
ET_RtnForQuoteRsp = ET_BASE + 92,
|
|
102
|
+
ET_RtnCFMMCTradingAccountToken = ET_BASE + 93,
|
|
103
|
+
ET_ErrRtnBatchOrderAction = ET_BASE + 94,
|
|
104
|
+
ET_RtnOptionSelfClose = ET_BASE + 95,
|
|
105
|
+
ET_ErrRtnOptionSelfCloseInsert = ET_BASE + 96,
|
|
106
|
+
ET_ErrRtnOptionSelfCloseAction = ET_BASE + 97,
|
|
107
|
+
ET_RtnCombAction = ET_BASE + 98,
|
|
108
|
+
ET_ErrRtnCombActionInsert = ET_BASE + 99,
|
|
109
|
+
ET_RspQryContractBank = ET_BASE + 100,
|
|
110
|
+
ET_RspQryParkedOrder = ET_BASE + 101,
|
|
111
|
+
ET_RspQryParkedOrderAction = ET_BASE + 102,
|
|
112
|
+
ET_RspQryTradingNotice = ET_BASE + 103,
|
|
113
|
+
ET_RspQryBrokerTradingParams = ET_BASE + 104,
|
|
114
|
+
ET_RspQryBrokerTradingAlgos = ET_BASE + 105,
|
|
115
|
+
ET_RspQueryCFMMCTradingAccountToken = ET_BASE + 106,
|
|
116
|
+
ET_RtnFromBankToFutureByBank = ET_BASE + 107,
|
|
117
|
+
ET_RtnFromFutureToBankByBank = ET_BASE + 108,
|
|
118
|
+
ET_RtnRepealFromBankToFutureByBank = ET_BASE + 109,
|
|
119
|
+
ET_RtnRepealFromFutureToBankByBank = ET_BASE + 110,
|
|
120
|
+
ET_RtnFromBankToFutureByFuture = ET_BASE + 111,
|
|
121
|
+
ET_RtnFromFutureToBankByFuture = ET_BASE + 112,
|
|
122
|
+
ET_RtnRepealFromBankToFutureByFutureManual = ET_BASE + 113,
|
|
123
|
+
ET_RtnRepealFromFutureToBankByFutureManual = ET_BASE + 114,
|
|
124
|
+
ET_RtnQueryBankBalanceByFuture = ET_BASE + 115,
|
|
125
|
+
ET_ErrRtnBankToFutureByFuture = ET_BASE + 116,
|
|
126
|
+
ET_ErrRtnFutureToBankByFuture = ET_BASE + 117,
|
|
127
|
+
ET_ErrRtnRepealBankToFutureByFutureManual = ET_BASE + 118,
|
|
128
|
+
ET_ErrRtnRepealFutureToBankByFutureManual = ET_BASE + 119,
|
|
129
|
+
ET_ErrRtnQueryBankBalanceByFuture = ET_BASE + 120,
|
|
130
|
+
ET_RtnRepealFromBankToFutureByFuture = ET_BASE + 121,
|
|
131
|
+
ET_RtnRepealFromFutureToBankByFuture = ET_BASE + 122,
|
|
132
|
+
ET_RspFromBankToFutureByFuture = ET_BASE + 123,
|
|
133
|
+
ET_RspFromFutureToBankByFuture = ET_BASE + 124,
|
|
134
|
+
ET_RspQueryBankAccountMoneyByFuture = ET_BASE + 125,
|
|
135
|
+
ET_RtnOpenAccountByBank = ET_BASE + 126,
|
|
136
|
+
ET_RtnCancelAccountByBank = ET_BASE + 127,
|
|
137
|
+
ET_RtnChangeAccountByBank = ET_BASE + 128,
|
|
138
|
+
ET_RspQryClassifiedInstrument = ET_BASE + 129,
|
|
139
|
+
ET_RspQryCombPromotionParam = ET_BASE + 130,
|
|
140
|
+
ET_RspQryRiskSettleInvstPosition = ET_BASE + 131,
|
|
141
|
+
ET_RspQryRiskSettleProductStatus = ET_BASE + 132,
|
|
142
|
+
ET_RspQrySPBMFutureParameter = ET_BASE + 133,
|
|
143
|
+
ET_RspQrySPBMOptionParameter = ET_BASE + 134,
|
|
144
|
+
ET_RspQrySPBMIntraParameter = ET_BASE + 135,
|
|
145
|
+
ET_RspQrySPBMInterParameter = ET_BASE + 136,
|
|
146
|
+
ET_RspQrySPBMPortfDefinition = ET_BASE + 137,
|
|
147
|
+
ET_RspQrySPBMInvestorPortfDef = ET_BASE + 138,
|
|
148
|
+
ET_RspQryInvestorPortfMarginRatio = ET_BASE + 139,
|
|
149
|
+
ET_RspQryInvestorProdSPBMDetail = ET_BASE + 140,
|
|
150
|
+
ET_RspQryInvestorCommoditySPMMMargin = ET_BASE + 141,
|
|
151
|
+
ET_RspQryInvestorCommodityGroupSPMMMargin = ET_BASE + 142,
|
|
152
|
+
ET_RspQrySPMMInstParam = ET_BASE + 143,
|
|
153
|
+
ET_RspQrySPMMProductParam = ET_BASE + 144,
|
|
154
|
+
ET_RspQrySPBMAddOnInterParameter = ET_BASE + 145,
|
|
155
|
+
ET_RspQryRCAMSCombProductInfo = ET_BASE + 146,
|
|
156
|
+
ET_RspQryRCAMSInstrParameter = ET_BASE + 147,
|
|
157
|
+
ET_RspQryRCAMSIntraParameter = ET_BASE + 148,
|
|
158
|
+
ET_RspQryRCAMSInterParameter = ET_BASE + 149,
|
|
159
|
+
ET_RspQryRCAMSShortOptAdjustParam = ET_BASE + 150,
|
|
160
|
+
ET_RspQryRCAMSInvestorCombPosition = ET_BASE + 151,
|
|
161
|
+
ET_RspQryInvestorProdRCAMSMargin = ET_BASE + 152,
|
|
162
|
+
ET_RspQryRULEInstrParameter = ET_BASE + 153,
|
|
163
|
+
ET_RspQryRULEIntraParameter = ET_BASE + 154,
|
|
164
|
+
ET_RspQryRULEInterParameter = ET_BASE + 155,
|
|
165
|
+
ET_RspQryInvestorProdRULEMargin = ET_BASE + 156,
|
|
166
|
+
ET_RspQryInvestorPortfSetting = ET_BASE + 157,
|
|
167
|
+
ET_RspQryInvestorInfoCommRec = ET_BASE + 158,
|
|
168
|
+
ET_RspQryCombLeg = ET_BASE + 159,
|
|
169
|
+
ET_RspOffsetSetting = ET_BASE + 160,
|
|
170
|
+
ET_RspCancelOffsetSetting = ET_BASE + 161,
|
|
171
|
+
ET_RtnOffsetSetting = ET_BASE + 162,
|
|
172
|
+
ET_ErrRtnOffsetSetting = ET_BASE + 163,
|
|
173
|
+
ET_ErrRtnCancelOffsetSetting = ET_BASE + 164,
|
|
174
|
+
ET_RspQryOffsetSetting = ET_BASE + 165,
|
|
175
|
+
ET_RspGenSMSCode = ET_BASE + 166,
|
|
176
|
+
ET_RspSpdApply = ET_BASE + 167,
|
|
177
|
+
ET_RspSpdApplyAction = ET_BASE + 168,
|
|
178
|
+
ET_RspQrySpdApply = ET_BASE + 169,
|
|
179
|
+
ET_RtnSpdApply = ET_BASE + 170,
|
|
180
|
+
ET_ErrRtnSpdApply = ET_BASE + 171,
|
|
181
|
+
ET_ErrRtnSpdApplyAction = ET_BASE + 172,
|
|
182
|
+
ET_RspHedgeCfm = ET_BASE + 173,
|
|
183
|
+
ET_RspHedgeCfmAction = ET_BASE + 174,
|
|
184
|
+
ET_RspQryHedgeCfm = ET_BASE + 175,
|
|
185
|
+
ET_RtnHedgeCfm = ET_BASE + 176,
|
|
186
|
+
ET_ErrRtnHedgeCfm = ET_BASE + 177,
|
|
187
|
+
ET_ErrRtnHedgeCfmAction = ET_BASE + 178,
|
|
164
188
|
};
|
|
165
189
|
|
|
166
190
|
class TraderSpi : public CThostFtdcTraderSpi {
|
|
@@ -174,6 +198,7 @@ public:
|
|
|
174
198
|
void OnFrontDisconnected(int arg) override;
|
|
175
199
|
void OnHeartBeatWarning(int arg) override;
|
|
176
200
|
void OnRspAuthenticate(CThostFtdcRspAuthenticateField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
201
|
+
void OnRtnPrivateSeqNo(int arg) override;
|
|
177
202
|
void OnRspUserLogin(CThostFtdcRspUserLoginField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
178
203
|
void OnRspUserLogout(CThostFtdcUserLogoutField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
179
204
|
void OnRspUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
@@ -206,6 +231,7 @@ public:
|
|
|
206
231
|
void OnRspQryTradingCode(CThostFtdcTradingCodeField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
207
232
|
void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
208
233
|
void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
234
|
+
void OnRspQryUserSession(CThostFtdcUserSessionField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
209
235
|
void OnRspQryExchange(CThostFtdcExchangeField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
210
236
|
void OnRspQryProduct(CThostFtdcProductField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
211
237
|
void OnRspQryInstrument(CThostFtdcInstrumentField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
@@ -324,6 +350,28 @@ public:
|
|
|
324
350
|
void OnRspQryRULEIntraParameter(CThostFtdcRULEIntraParameterField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
325
351
|
void OnRspQryRULEInterParameter(CThostFtdcRULEInterParameterField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
326
352
|
void OnRspQryInvestorProdRULEMargin(CThostFtdcInvestorProdRULEMarginField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
353
|
+
void OnRspQryInvestorPortfSetting(CThostFtdcInvestorPortfSettingField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
354
|
+
void OnRspQryInvestorInfoCommRec(CThostFtdcInvestorInfoCommRecField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
355
|
+
void OnRspQryCombLeg(CThostFtdcCombLegField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
356
|
+
void OnRspOffsetSetting(CThostFtdcInputOffsetSettingField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
357
|
+
void OnRspCancelOffsetSetting(CThostFtdcInputOffsetSettingField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
358
|
+
void OnRtnOffsetSetting(CThostFtdcOffsetSettingField *p) override;
|
|
359
|
+
void OnErrRtnOffsetSetting(CThostFtdcInputOffsetSettingField *p, CThostFtdcRspInfoField *e) override;
|
|
360
|
+
void OnErrRtnCancelOffsetSetting(CThostFtdcCancelOffsetSettingField *p, CThostFtdcRspInfoField *e) override;
|
|
361
|
+
void OnRspQryOffsetSetting(CThostFtdcOffsetSettingField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
362
|
+
void OnRspGenSMSCode(CThostFtdcRspGenSMSCodeField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
363
|
+
void OnRspSpdApply(CThostFtdcInputSpdApplyField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
364
|
+
void OnRspSpdApplyAction(CThostFtdcInputSpdApplyActionField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
365
|
+
void OnRspQrySpdApply(CThostFtdcSpdApplyField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
366
|
+
void OnRtnSpdApply(CThostFtdcSpdApplyField *p) override;
|
|
367
|
+
void OnErrRtnSpdApply(CThostFtdcInputSpdApplyField *p, CThostFtdcRspInfoField *e) override;
|
|
368
|
+
void OnErrRtnSpdApplyAction(CThostFtdcSpdApplyActionField *p, CThostFtdcRspInfoField *e) override;
|
|
369
|
+
void OnRspHedgeCfm(CThostFtdcInputHedgeCfmField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
370
|
+
void OnRspHedgeCfmAction(CThostFtdcInputHedgeCfmActionField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
371
|
+
void OnRspQryHedgeCfm(CThostFtdcHedgeCfmField *p, CThostFtdcRspInfoField *e, int id, bool last) override;
|
|
372
|
+
void OnRtnHedgeCfm(CThostFtdcHedgeCfmField *p) override;
|
|
373
|
+
void OnErrRtnHedgeCfm(CThostFtdcInputHedgeCfmField *p, CThostFtdcRspInfoField *e) override;
|
|
374
|
+
void OnErrRtnHedgeCfmAction(CThostFtdcHedgeCfmActionField *p, CThostFtdcRspInfoField *e) override;
|
|
327
375
|
|
|
328
376
|
private:
|
|
329
377
|
CThostFtdcTraderApi *api_;
|
package/src/market-data.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
RspUserLogin,
|
|
15
15
|
UserLogout,
|
|
16
16
|
} from "./generated/structs.gen.js";
|
|
17
|
+
import { STRUCT_ID } from "./generated/structs.gen.js";
|
|
17
18
|
|
|
18
19
|
const MD_BASE = 0x1000;
|
|
19
20
|
const MD_EVENTS = new Map<number, string>([
|
|
@@ -89,6 +90,28 @@ export class MarketData extends CtpClient {
|
|
|
89
90
|
return (this.native as { unsubscribeForQuoteRsp(a: string[]): number }).unsubscribeForQuoteRsp(instrumentIds);
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
/** Latest cached depth tick for an instrument — the C++ last-value cache,
|
|
94
|
+
* updated on every tick before it reaches JS. Returns null if none has been
|
|
95
|
+
* seen (or it was unsubscribed). Synchronous: no waiting for an event, no
|
|
96
|
+
* per-tick bookkeeping in your strategy. */
|
|
97
|
+
snapshot(instrumentId: string): DepthMarketData | null {
|
|
98
|
+
const bytes = (this.native as { snapshot(id: string): Uint8Array | null }).snapshot(instrumentId);
|
|
99
|
+
return bytes
|
|
100
|
+
? (this.decodeStruct(STRUCT_ID.DepthMarketData, bytes) as unknown as DepthMarketData)
|
|
101
|
+
: null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Latest price for an instrument from the cache (0 if none seen). Synchronous. */
|
|
105
|
+
last(instrumentId: string): number {
|
|
106
|
+
return (this.native as { last(id: string): number }).last(instrumentId);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @internal Hand the C++ snapshot cache to a Trader (Trader.trackMarketData),
|
|
110
|
+
* so the Trader's deviation check reads live prices in C++ — no JS round-trip. */
|
|
111
|
+
_snapshotExternal(): unknown {
|
|
112
|
+
return (this.native as { _snapshotExternal(): unknown })._snapshotExternal();
|
|
113
|
+
}
|
|
114
|
+
|
|
92
115
|
/** Log in; resolves with the login response (or rejects on CTP error). */
|
|
93
116
|
login(req: MdLoginReq = {}): Promise<RspUserLogin> {
|
|
94
117
|
return this.request<RspUserLogin>(
|
package/src/native/mdapi.cc
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
#include "ThostFtdcMdApi.h"
|
|
25
25
|
#include "channel.h"
|
|
26
26
|
#include "mdspi.h"
|
|
27
|
+
#include "snapshot.h"
|
|
27
28
|
|
|
28
29
|
namespace ctp {
|
|
29
30
|
|
|
@@ -82,6 +83,9 @@ private:
|
|
|
82
83
|
Napi::Value ChannelInfo(const Napi::CallbackInfo &info);
|
|
83
84
|
Napi::Value Close(const Napi::CallbackInfo &info);
|
|
84
85
|
Napi::Value AttachArm(const Napi::CallbackInfo &info);
|
|
86
|
+
Napi::Value Snapshot(const Napi::CallbackInfo &info);
|
|
87
|
+
Napi::Value Last(const Napi::CallbackInfo &info);
|
|
88
|
+
Napi::Value SnapshotExternal(const Napi::CallbackInfo &info);
|
|
85
89
|
Napi::Value InjectTestTick(const Napi::CallbackInfo &info);
|
|
86
90
|
Napi::Value BurstTicks(const Napi::CallbackInfo &info);
|
|
87
91
|
|
|
@@ -89,6 +93,9 @@ private:
|
|
|
89
93
|
MdSpi *spi_ = nullptr;
|
|
90
94
|
EventChannel *ch_ = nullptr;
|
|
91
95
|
std::shared_ptr<ArmRegistry> armReg_;
|
|
96
|
+
// Latest-tick cache (LVC). shared_ptr so a Trader can borrow it (trackMarketData)
|
|
97
|
+
// for its in-C++ deviation reference, like the arm registry.
|
|
98
|
+
std::shared_ptr<SnapshotCache> snap_ = std::make_shared<SnapshotCache>();
|
|
92
99
|
bool started_ = false;
|
|
93
100
|
bool closed_ = false;
|
|
94
101
|
// test-only background producer thread (doorbell cross-thread stress).
|
|
@@ -116,6 +123,9 @@ Napi::Function MarketData::Init(Napi::Env env) {
|
|
|
116
123
|
InstanceMethod("_dropCount", &MarketData::DropCount),
|
|
117
124
|
InstanceMethod("_info", &MarketData::ChannelInfo),
|
|
118
125
|
InstanceMethod("_attachArm", &MarketData::AttachArm),
|
|
126
|
+
InstanceMethod("snapshot", &MarketData::Snapshot),
|
|
127
|
+
InstanceMethod("last", &MarketData::Last),
|
|
128
|
+
InstanceMethod("_snapshotExternal", &MarketData::SnapshotExternal),
|
|
119
129
|
InstanceMethod("_injectTestTick", &MarketData::InjectTestTick),
|
|
120
130
|
InstanceMethod("_burstTicks", &MarketData::BurstTicks),
|
|
121
131
|
InstanceMethod("close", &MarketData::Close),
|
|
@@ -156,6 +166,7 @@ MarketData::MarketData(const Napi::CallbackInfo &info)
|
|
|
156
166
|
ch_ = new EventChannel(8192, static_cast<size_t>(ctpMaxStructSize()),
|
|
157
167
|
DropPolicy::Oldest);
|
|
158
168
|
spi_ = new MdSpi(api_, ch_);
|
|
169
|
+
spi_->setSnapshotCache(snap_.get());
|
|
159
170
|
api_->RegisterSpi(spi_);
|
|
160
171
|
|
|
161
172
|
for (auto &addr : fronts)
|
|
@@ -177,7 +188,10 @@ void MarketData::doClose() {
|
|
|
177
188
|
if (spi_) {
|
|
178
189
|
spi_->clearApi();
|
|
179
190
|
spi_->setArmRegistry(nullptr);
|
|
191
|
+
spi_->setSnapshotCache(nullptr);
|
|
180
192
|
}
|
|
193
|
+
if (snap_)
|
|
194
|
+
snap_->clear(); // free the LVC; a Trader still holding it sees an empty cache
|
|
181
195
|
if (api_) {
|
|
182
196
|
api_->Release(); // stops the CTP callback thread (no more push / onTick)
|
|
183
197
|
api_ = nullptr;
|
|
@@ -231,8 +245,11 @@ Napi::Value MarketData::SubscribeMarketData(const Napi::CallbackInfo &info) {
|
|
|
231
245
|
subscribeImpl(info, &CThostFtdcMdApi::SubscribeMarketData));
|
|
232
246
|
}
|
|
233
247
|
Napi::Value MarketData::UnsubscribeMarketData(const Napi::CallbackInfo &info) {
|
|
234
|
-
|
|
235
|
-
|
|
248
|
+
int rc = subscribeImpl(info, &CThostFtdcMdApi::UnSubscribeMarketData);
|
|
249
|
+
if (snap_)
|
|
250
|
+
for (auto &id : toStringList(info[0]))
|
|
251
|
+
snap_->erase(id); // drop the LVC entry for an unsubscribed instrument
|
|
252
|
+
return Napi::Number::New(info.Env(), rc);
|
|
236
253
|
}
|
|
237
254
|
Napi::Value MarketData::SubscribeForQuoteRsp(const Napi::CallbackInfo &info) {
|
|
238
255
|
return Napi::Number::New(
|
|
@@ -349,6 +366,36 @@ Napi::Value MarketData::AttachArm(const Napi::CallbackInfo &info) {
|
|
|
349
366
|
return info.Env().Undefined();
|
|
350
367
|
}
|
|
351
368
|
|
|
369
|
+
// snapshot(instrumentId) -> the latest full depth tick as raw struct bytes (JS
|
|
370
|
+
// decodes with the shared codec, identical to a streamed tick), or null if none.
|
|
371
|
+
Napi::Value MarketData::Snapshot(const Napi::CallbackInfo &info) {
|
|
372
|
+
Napi::Env env = info.Env();
|
|
373
|
+
if (!info[0].IsString())
|
|
374
|
+
return env.Null();
|
|
375
|
+
CThostFtdcDepthMarketDataField f;
|
|
376
|
+
if (!snap_->get(info[0].As<Napi::String>().Utf8Value(), f))
|
|
377
|
+
return env.Null();
|
|
378
|
+
return Napi::Buffer<uint8_t>::Copy(env, reinterpret_cast<uint8_t *>(&f), sizeof(f));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// last(instrumentId) -> latest price (0 if none). Synchronous, no event wait.
|
|
382
|
+
Napi::Value MarketData::Last(const Napi::CallbackInfo &info) {
|
|
383
|
+
Napi::Env env = info.Env();
|
|
384
|
+
if (!info[0].IsString())
|
|
385
|
+
return Napi::Number::New(env, 0.0);
|
|
386
|
+
return Napi::Number::New(env, snap_->last(info[0].As<Napi::String>().Utf8Value()));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Hand the LVC (as a shared_ptr) to a Trader so its deviation check reads live
|
|
390
|
+
// prices in C++ (Trader._attachSnapshot). Mirrors the arm-registry sharing: a
|
|
391
|
+
// heap shared_ptr copy with a finalizer, so the cache can't dangle.
|
|
392
|
+
Napi::Value MarketData::SnapshotExternal(const Napi::CallbackInfo &info) {
|
|
393
|
+
auto *sp = new std::shared_ptr<SnapshotCache>(snap_);
|
|
394
|
+
return Napi::External<std::shared_ptr<SnapshotCache>>::New(
|
|
395
|
+
info.Env(), sp,
|
|
396
|
+
[](Napi::Env, std::shared_ptr<SnapshotCache> *p) { delete p; });
|
|
397
|
+
}
|
|
398
|
+
|
|
352
399
|
Napi::Value MarketData::InjectTestTick(const Napi::CallbackInfo &info) {
|
|
353
400
|
// Drive the real SPI path (so arm triggers are evaluated too). Optional args
|
|
354
401
|
// override bid/ask, so tests can inject edge prices - e.g. a DBL_MAX "no-bid"
|
package/src/native/mdspi.cc
CHANGED
|
@@ -85,8 +85,12 @@ void MdSpi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *p) {
|
|
|
85
85
|
if (td)
|
|
86
86
|
std::snprintf(p->TradingDay, sizeof(p->TradingDay), "%s", td);
|
|
87
87
|
}
|
|
88
|
-
//
|
|
88
|
+
// Update the latest-tick cache, evaluate armed triggers (lowest tick-to-order
|
|
89
|
+
// latency), then publish to the ring.
|
|
89
90
|
if (p) {
|
|
91
|
+
SnapshotCache *sc = snap_.load(std::memory_order_relaxed);
|
|
92
|
+
if (sc)
|
|
93
|
+
sc->update(*p); // LVC: latest full tick per instrument (incl. trading day)
|
|
90
94
|
ArmRegistry *ar = armReg_.load(std::memory_order_relaxed);
|
|
91
95
|
if (ar)
|
|
92
96
|
ar->onTick(p->InstrumentID, p->BidPrice1, p->AskPrice1);
|
package/src/native/mdspi.h
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include "ThostFtdcMdApi.h"
|
|
12
12
|
#include "arm.h"
|
|
13
13
|
#include "channel.h"
|
|
14
|
+
#include "snapshot.h"
|
|
14
15
|
#include <atomic>
|
|
15
16
|
|
|
16
17
|
namespace ctp {
|
|
@@ -39,6 +40,8 @@ public:
|
|
|
39
40
|
|
|
40
41
|
// Feed depth ticks to a Trader's arm registry (or nullptr to detach).
|
|
41
42
|
void setArmRegistry(ArmRegistry *r) { armReg_.store(r, std::memory_order_relaxed); }
|
|
43
|
+
// Latest-tick cache (LVC) updated on every depth tick (or nullptr to detach).
|
|
44
|
+
void setSnapshotCache(SnapshotCache *c) { snap_.store(c, std::memory_order_relaxed); }
|
|
42
45
|
|
|
43
46
|
// Detach the api pointer before the owning MarketData releases it, so a
|
|
44
47
|
// late/teardown callback (or the test tick hook) can't dereference a freed
|
|
@@ -74,6 +77,7 @@ private:
|
|
|
74
77
|
std::atomic<CThostFtdcMdApi *> api_;
|
|
75
78
|
EventChannel *ch_;
|
|
76
79
|
std::atomic<ArmRegistry *> armReg_{nullptr};
|
|
80
|
+
std::atomic<SnapshotCache *> snap_{nullptr};
|
|
77
81
|
};
|
|
78
82
|
|
|
79
83
|
} // namespace ctp
|