@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
package/README.md
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
- **Plain objects, idiomatic TypeScript.** Every CTP struct is a generated `interface` with camelCase fields (`tick.lastPrice`, `tick.instrumentId`); every CTP enum is a real TS `enum`. No hand-written marshalling.
|
|
25
25
|
- **Fast.** The CTP callback thread only memcpy's bytes into a lock-free ring; JS decodes straight from it into plain objects at **~8M ticks/sec** (166× headroom over a 50k/sec open-auction burst).
|
|
26
26
|
- **Hybrid API.** `EventEmitter` for streaming pushes (`rtn-depth-market-data`, `rtn-order`…) + `Promise` for request/response (login, queries, orders), correlated by request id with multi-row accumulation.
|
|
27
|
-
- **Pre-trade risk in C++.** Kill-switch, max order volume, max notional, price-deviation (fat-finger) guard, account-wide and per-instrument open-position
|
|
27
|
+
- **Pre-trade risk in C++.** Kill-switch, max order volume, max notional, price-deviation (fat-finger) guard, account-wide and per-instrument open-position margin caps, per-instrument max position (lots, per side), and a token-bucket rate limiter are enforced on the order path in native code — a JS GC pause can't defeat them.
|
|
28
28
|
- **Stable by construction.** No hand-marshalling, threadsafe-functions released properly, `Init()` deferred so `front-connected` is never missed, compiler-truth (`offsetof`) binary layout, gb18030 decoded in JS (no Windows code-page bug).
|
|
29
29
|
|
|
30
30
|
> Targets the regime CTP actually supports (snapshot-driven, ms-tolerant strategies: CTA, arbitrage, market making). True microsecond HFT is not achievable through CTP in any language.
|
|
31
31
|
|
|
32
32
|
## Requirements
|
|
33
33
|
|
|
34
|
-
Node ≥ 18. Prebuilt binaries are shipped for Windows
|
|
34
|
+
Node ≥ 18. Prebuilt binaries are shipped for **Windows and Linux (x64)** — most users need no compiler there. **macOS (and any other platform) builds from source on install**, which needs a C++ toolchain (macOS: Xcode Command Line Tools; Windows: VS Build Tools; Linux: clang/gcc). The CTP shared libraries are bundled next to the loaded addon and resolved automatically.
|
|
35
35
|
|
|
36
36
|
## Install
|
|
37
37
|
|
|
@@ -53,6 +53,7 @@ const { Trader, MarketData } = require("@hitrading/ctp-node"); // CommonJS
|
|
|
53
53
|
- **Full API reference** — every TypeScript/JavaScript interface and method, with each parameter's type and meaning, plus usage examples: [English](docs/API.md) · [简体中文](docs/API.zh-CN.md)
|
|
54
54
|
- Architecture & native internals — the lock-free data plane, the C++ risk engine, backpressure, and the create-once process-lifecycle notes: [English](docs/native-hooks.md) · [简体中文](docs/native-hooks.zh-CN.md)
|
|
55
55
|
- **Troubleshooting & FAQ** — connection/front rotation, login & authentication, query rate limits, order rejections, limit-down, lifecycle, build issues, CTP error codes: [English](docs/troubleshooting.md) · [简体中文](docs/troubleshooting.zh-CN.md)
|
|
56
|
+
- **Testing & coverage** — unit tests (JS ≥ 95 %, C++ `risk`/`arm` standalone ≥ 98 %) plus the credential-gated live SimNow integration suite: [integration & testing](docs/integration.md)
|
|
56
57
|
- **Releasing** — fully automatic `semantic-release` (Conventional Commits → version + CHANGELOG + GitHub Release + npm publish): [RELEASING.md](RELEASING.md) · [CHANGELOG.md](CHANGELOG.md)
|
|
57
58
|
|
|
58
59
|
## Quick start — market data
|
|
@@ -71,6 +72,11 @@ md.on("rtn-depth-market-data", (tick) => {
|
|
|
71
72
|
// tick is a plain object with camelCase fields
|
|
72
73
|
console.log(tick.instrumentId, tick.lastPrice, tick.bidPrice1, tick.askPrice1);
|
|
73
74
|
});
|
|
75
|
+
|
|
76
|
+
// Latest market data is cached in C++ (a last-value cache, updated on every tick
|
|
77
|
+
// before it reaches JS), so you get a synchronous snapshot with no bookkeeping in JS:
|
|
78
|
+
// md.snapshot("rb2510"); // latest full depth tick (DepthMarketData) or null
|
|
79
|
+
// md.last("rb2510"); // latest price, 0 if none seen yet
|
|
74
80
|
```
|
|
75
81
|
|
|
76
82
|
## Quick start — trading
|
|
@@ -81,8 +87,8 @@ import { Trader } from "@hitrading/ctp-node";
|
|
|
81
87
|
const td = new Trader("./flow/td/", "tcp://182.254.243.31:30002");
|
|
82
88
|
|
|
83
89
|
// Pre-trade risk, enforced in C++ on every order:
|
|
84
|
-
td.riskSet({ maxOrderVolume: 10, maxOrdersPerSec: 20, maxPriceDeviation: 0.02,
|
|
85
|
-
td.trackMarketData(md); //
|
|
90
|
+
td.riskSet({ maxOrderVolume: 10, maxOrdersPerSec: 20, maxPriceDeviation: 0.02, maxMargin: 2_000_000 }); // maxMargin = real-margin cap on open positions
|
|
91
|
+
td.trackMarketData(md); // use live MD prices (read in C++) for the price-deviation guard
|
|
86
92
|
td.setMaxPositions({ rb2610: 100, au2610: 10, ru2610: { long: 100, short: 20 } }); // per-instrument lot caps
|
|
87
93
|
td.setMaxPositionCosts({ ag2608: 2_000_000, au2608: 5_000_000 }); // per-instrument cost caps
|
|
88
94
|
|
|
@@ -152,6 +158,7 @@ Direction.Sell; // "1"
|
|
|
152
158
|
- Requests are camelCase methods taking a `Partial<...>` of the CTP field object and returning a `Promise`. `reqQry*` resolve with an array of rows; most requests resolve with the single response row.
|
|
153
159
|
- Exchange-bound inserts/actions (`reqOrderInsert`, `reqOrderAction`, …) resolve on **submission** — CTP returns no success response for an accepted order, only `rtn-order` / `rtn-trade` (correlate by `orderRef`). They reject only if the send is refused (risk gate, rate limit, or a CTP API error code).
|
|
154
160
|
- Streaming events use kebab-case names (`rtn-depth-market-data`, `rtn-order`, …); handlers get `(data, options)` where `options` carries `{ requestId?, isLast?, rspInfo? }`.
|
|
161
|
+
- The latest tick per instrument is kept in a C++ last-value cache (updated on every tick before it reaches JS; an entry is cleared on unsubscribe, all on close), so `md.snapshot(instrumentId)` returns the latest full `DepthMarketData` (or `null`) and `md.last(instrumentId)` the latest price (0 if none) — synchronously, with no per-tick bookkeeping in JS. The same cache backs the price-deviation guard, so that check reads live prices in C++.
|
|
155
162
|
- `client.droppedRecords` reports records dropped under backpressure. Market
|
|
156
163
|
data drops the **oldest** unread record (so you always see the freshest quote);
|
|
157
164
|
the trader drops the **newest** instead, so a queued order/trade return is never
|
|
@@ -199,7 +206,7 @@ CTP callback thread (C++) Node event loop (JS)
|
|
|
199
206
|
```
|
|
200
207
|
|
|
201
208
|
Everything below the public API is generated from the CTP headers
|
|
202
|
-
(`
|
|
209
|
+
(`ctpsdk/ThostFtdc*.h`) by `scripts/codegen/` — 519 struct interfaces, 326
|
|
203
210
|
enums, field layout tables (via `offsetof`), and the full trader SPI + request
|
|
204
211
|
dispatch. Run `npm run gen` after updating the headers.
|
|
205
212
|
|
package/README.zh-CN.md
CHANGED
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
- **纯对象、地道的 TypeScript。** 每个 CTP 结构体都是生成的 `interface`,字段为 camelCase(`tick.lastPrice`、`tick.instrumentId`);每个 CTP 枚举都是真正的 TS `enum`。无手写编解码。
|
|
25
25
|
- **快。** CTP 回调线程只把字节 memcpy 进无锁环;JS 直接从环里解码成纯对象,**约 800 万 tick/秒**(相对 5 万/秒的开盘集合竞价突发有 166 倍余量)。
|
|
26
26
|
- **混合 API。** 流式推送用 `EventEmitter`(`rtn-depth-market-data`、`rtn-order` 等)+ 请求/响应用 `Promise`(登录、查询、报单),按 request id 关联并支持多行累积。
|
|
27
|
-
- **盘前风控在 C++ 中。**
|
|
27
|
+
- **盘前风控在 C++ 中。** 一键熔断、单笔最大手数、最大名义价值、价格偏离(防胖手指)、账户级与按合约的开仓持仓保证金上限、按合约的最大持仓(手数、分边)、以及令牌桶限频器,都在原生代码里、报单路径上执行——JS 的 GC 停顿打不垮它们。
|
|
28
28
|
- **构造即稳定。** 无手写编解码、threadsafe-function 正确释放、`Init()` 延后以保证 `front-connected` 不丢失、编译器真值(`offsetof`)的二进制布局、GB18030 在 JS 解码(无 Windows 代码页 bug)。
|
|
29
29
|
|
|
30
30
|
> 面向 CTP 实际支持的范畴(快照驱动、容忍毫秒级的策略:CTA、套利、做市)。真正的微秒级 HFT 在任何语言下都无法通过 CTP 实现。
|
|
31
31
|
|
|
32
32
|
## 环境要求
|
|
33
33
|
|
|
34
|
-
Node ≥ 18
|
|
34
|
+
Node ≥ 18。**Windows 与 Linux(x64)提供预编译二进制**,这两个平台多数用户无需编译器。**macOS(及其他平台)在安装时从源码构建**,需要 C++ 工具链(macOS:Xcode Command Line Tools;Windows:VS Build Tools;Linux:clang/gcc)。CTP 共享库随插件一起打包在旁并自动解析。
|
|
35
35
|
|
|
36
36
|
## 安装
|
|
37
37
|
|
|
@@ -53,6 +53,7 @@ const { Trader, MarketData } = require("@hitrading/ctp-node"); // CommonJS
|
|
|
53
53
|
- **完整 API 参考** —— 每一个 TypeScript/JavaScript 接口和方法,含每个参数的类型与含义,以及用法示例:[English](docs/API.md) · [简体中文](docs/API.zh-CN.md)
|
|
54
54
|
- 架构与原生内部 —— 无锁数据平面、C++ 风控引擎、背压,以及一次创建的进程生命周期说明:[English](docs/native-hooks.md) · [简体中文](docs/native-hooks.zh-CN.md)
|
|
55
55
|
- **故障排查与 FAQ** —— 连接/前置轮换、登录与认证、查询限频、报单被拒、跌停、生命周期、构建问题、CTP 错误码:[English](docs/troubleshooting.md) · [简体中文](docs/troubleshooting.zh-CN.md)
|
|
56
|
+
- **测试与覆盖率** —— 单元测试(JS ≥ 95 %、C++ `risk`/`arm` 独立 ≥ 98 %)+ 凭据门控的实盘 SimNow 集成套件:[集成与测试](docs/integration.md)
|
|
56
57
|
- **发布** —— 全自动 `semantic-release`(Conventional Commits → 版本号 + CHANGELOG + GitHub Release + npm 发布):[RELEASING.md](RELEASING.md) · [CHANGELOG.md](CHANGELOG.md)
|
|
57
58
|
|
|
58
59
|
## 快速开始 —— 行情
|
|
@@ -71,6 +72,11 @@ md.on("rtn-depth-market-data", (tick) => {
|
|
|
71
72
|
// tick 是带 camelCase 字段的纯对象
|
|
72
73
|
console.log(tick.instrumentId, tick.lastPrice, tick.bidPrice1, tick.askPrice1);
|
|
73
74
|
});
|
|
75
|
+
|
|
76
|
+
// 最新行情缓存在 C++ 中(一个 last-value 缓存,每个 tick 到达 JS 前都会更新),
|
|
77
|
+
// 因此无需在 JS 里记账即可同步取到快照:
|
|
78
|
+
// md.snapshot("rb2510"); // 最新完整深度行情(DepthMarketData)或 null
|
|
79
|
+
// md.last("rb2510"); // 最新价,尚无则为 0
|
|
74
80
|
```
|
|
75
81
|
|
|
76
82
|
## 快速开始 —— 交易
|
|
@@ -81,8 +87,8 @@ import { Trader } from "@hitrading/ctp-node";
|
|
|
81
87
|
const td = new Trader("./flow/td/", "tcp://182.254.243.31:30002");
|
|
82
88
|
|
|
83
89
|
// 盘前风控,在 C++ 中对每笔报单执行:
|
|
84
|
-
td.riskSet({ maxOrderVolume: 10, maxOrdersPerSec: 20, maxPriceDeviation: 0.02,
|
|
85
|
-
td.trackMarketData(md); //
|
|
90
|
+
td.riskSet({ maxOrderVolume: 10, maxOrdersPerSec: 20, maxPriceDeviation: 0.02, maxMargin: 2_000_000 }); // maxMargin = 开仓持仓的真实保证金上限
|
|
91
|
+
td.trackMarketData(md); // 用实时行情价(在 C++ 中读取)做价格偏离校验
|
|
86
92
|
td.setMaxPositions({ rb2610: 100, au2610: 10, ru2610: { long: 100, short: 20 } }); // 按合约手数上限
|
|
87
93
|
td.setMaxPositionCosts({ ag2608: 2_000_000, au2608: 5_000_000 }); // 按合约成本上限
|
|
88
94
|
|
|
@@ -148,6 +154,7 @@ Direction.Sell; // "1"
|
|
|
148
154
|
- 请求是 camelCase 方法,接受 CTP 字段对象的 `Partial<...>` 并返回 `Promise`。`reqQry*` 以行数组 resolve;多数请求以单条响应行 resolve。
|
|
149
155
|
- 发往交易所的 insert/action(`reqOrderInsert`、`reqOrderAction` 等)**提交成功即** resolve —— CTP 对已接受的报单不返回成功响应,只有 `rtn-order` / `rtn-trade`(用 `orderRef` 关联)。只有发送被拒(风控网关、限频、或 CTP API 错误码)才 reject。
|
|
150
156
|
- 流式事件用 kebab-case 名称(`rtn-depth-market-data`、`rtn-order` 等);处理函数收到 `(data, options)`,`options` 带 `{ requestId?, isLast?, rspInfo? }`。
|
|
157
|
+
- 每个合约的最新 tick 保存在 C++ 的 last-value 缓存里(每个 tick 到达 JS 前都会更新;退订时清除该条目、关闭时全部清除),因此 `md.snapshot(instrumentId)` 返回最新的完整 `DepthMarketData`(或 `null`)、`md.last(instrumentId)` 返回最新价(尚无则为 0)——同步返回,无需在 JS 里逐 tick 记账。价格偏离校验也由同一缓存支撑,因此该校验在 C++ 中读取实时价。
|
|
151
158
|
- `client.droppedRecords` 报告背压下丢弃的记录数。行情丢弃**最旧**的未读记录(使你总能看到最新报价);交易端则丢弃**最新**的,使排队中的报单/成交回报永不被静默丢弃。两者都应监控。
|
|
152
159
|
- `client.close()` 释放底层 CTP API。在关闭时调用**一次**——CTP 客户端是一次创建/复用的;靠重建来重连会在厂商 DLL 里死锁(见[生命周期](#生命周期-一次创建并复用))。
|
|
153
160
|
|
|
@@ -178,7 +185,7 @@ CTP 回调线程 (C++) Node 事件循环 (JS)
|
|
|
178
185
|
交易端丢最新/可靠)
|
|
179
186
|
```
|
|
180
187
|
|
|
181
|
-
公开 API 之下的一切都由 CTP 头文件(`
|
|
188
|
+
公开 API 之下的一切都由 CTP 头文件(`ctpsdk/ThostFtdc*.h`)经 `scripts/codegen/` 生成—— 519 个结构体接口、326 个枚举、字段布局表(经 `offsetof`),以及完整的 trader SPI + 请求分发。更新头文件后运行 `npm run gen`。
|
|
182
189
|
|
|
183
190
|
## 从源码构建
|
|
184
191
|
|
package/binding.gyp
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"include_dirs": [
|
|
19
19
|
"<!(node -p \"require('node-addon-api').include_dir\")",
|
|
20
|
-
"
|
|
20
|
+
"ctpsdk"
|
|
21
21
|
],
|
|
22
22
|
"defines": [
|
|
23
23
|
"NAPI_VERSION=8",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"cflags_cc!": [ "-fno-exceptions" ],
|
|
28
28
|
"conditions": [
|
|
29
29
|
["OS=='win'", {
|
|
30
|
-
"library_dirs": [ "<(module_root_dir)/
|
|
30
|
+
"library_dirs": [ "<(module_root_dir)/ctpsdk/windows" ],
|
|
31
31
|
"libraries": [
|
|
32
32
|
"thostmduserapi_se.lib",
|
|
33
33
|
"thosttraderapi_se.lib"
|
|
@@ -41,42 +41,42 @@
|
|
|
41
41
|
{
|
|
42
42
|
"destination": "<(PRODUCT_DIR)",
|
|
43
43
|
"files": [
|
|
44
|
-
"<(module_root_dir)/
|
|
45
|
-
"<(module_root_dir)/
|
|
44
|
+
"<(module_root_dir)/ctpsdk/windows/thostmduserapi_se.dll",
|
|
45
|
+
"<(module_root_dir)/ctpsdk/windows/thosttraderapi_se.dll"
|
|
46
46
|
]
|
|
47
47
|
}
|
|
48
48
|
]
|
|
49
49
|
}],
|
|
50
50
|
["OS=='linux'", {
|
|
51
51
|
"libraries": [
|
|
52
|
-
"<(module_root_dir)/
|
|
53
|
-
"<(module_root_dir)/
|
|
52
|
+
"<(module_root_dir)/ctpsdk/linux/thostmduserapi_se.so",
|
|
53
|
+
"<(module_root_dir)/ctpsdk/linux/thosttraderapi_se.so",
|
|
54
54
|
"-Wl,-rpath,'$$ORIGIN'",
|
|
55
|
-
"-Wl,-rpath,<(module_root_dir)/
|
|
55
|
+
"-Wl,-rpath,<(module_root_dir)/ctpsdk/linux"
|
|
56
56
|
],
|
|
57
57
|
"cflags_cc": [ "-std=c++17", "-fexceptions" ],
|
|
58
58
|
"copies": [
|
|
59
59
|
{
|
|
60
60
|
"destination": "<(PRODUCT_DIR)",
|
|
61
61
|
"files": [
|
|
62
|
-
"<(module_root_dir)/
|
|
63
|
-
"<(module_root_dir)/
|
|
62
|
+
"<(module_root_dir)/ctpsdk/linux/thostmduserapi_se.so",
|
|
63
|
+
"<(module_root_dir)/ctpsdk/linux/thosttraderapi_se.so"
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
]
|
|
67
67
|
}],
|
|
68
68
|
["OS=='mac'", {
|
|
69
69
|
"include_dirs": [
|
|
70
|
-
"<(module_root_dir)/
|
|
71
|
-
"<(module_root_dir)/
|
|
70
|
+
"<(module_root_dir)/ctpsdk/macos/thostmduserapi_se.framework/Versions/A/Headers",
|
|
71
|
+
"<(module_root_dir)/ctpsdk/macos/thosttraderapi_se.framework/Versions/A/Headers"
|
|
72
72
|
],
|
|
73
73
|
"libraries": [
|
|
74
|
-
"-F<(module_root_dir)/
|
|
74
|
+
"-F<(module_root_dir)/ctpsdk/macos",
|
|
75
75
|
"-framework thostmduserapi_se",
|
|
76
76
|
"-framework thosttraderapi_se",
|
|
77
77
|
"-liconv",
|
|
78
78
|
"-Wl,-rpath,@loader_path",
|
|
79
|
-
"-Wl,-rpath,<(module_root_dir)/
|
|
79
|
+
"-Wl,-rpath,<(module_root_dir)/ctpsdk/macos"
|
|
80
80
|
],
|
|
81
81
|
"xcode_settings": {
|
|
82
82
|
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
package/{tradeapi/macos/thostmduserapi_se.framework/Versions/A/Headers → ctpsdk}/ThostFtdcMdApi.h
RENAMED
|
@@ -82,9 +82,10 @@ class MD_API_EXPORT CThostFtdcMdApi
|
|
|
82
82
|
public:
|
|
83
83
|
///����MdApi
|
|
84
84
|
///@param pszFlowPath ����������Ϣ�ļ���Ŀ¼��Ĭ��Ϊ��ǰĿ¼
|
|
85
|
+
///@param bIsProductionMode true:ʹ�������汾��API false:ʹ�ò����汾API
|
|
85
86
|
///@return ��������UserApi
|
|
86
87
|
///modify for udp marketdata
|
|
87
|
-
static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false);
|
|
88
|
+
static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false, bool bIsProductionMode=true);
|
|
88
89
|
|
|
89
90
|
///��ȡAPI�İ汾��Ϣ
|
|
90
91
|
///@retrun ��ȡ���İ汾��
|
|
@@ -48,6 +48,9 @@ public:
|
|
|
48
48
|
///�ͻ�����֤��Ӧ
|
|
49
49
|
virtual void OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
50
50
|
|
|
51
|
+
///�÷����ڴ���˽����֮ǰ������
|
|
52
|
+
///@param nSeqNo ������������˽���������
|
|
53
|
+
virtual void OnRtnPrivateSeqNo(int nSeqNo) {};
|
|
51
54
|
|
|
52
55
|
///��¼������Ӧ
|
|
53
56
|
virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
@@ -145,6 +148,9 @@ public:
|
|
|
145
148
|
///�����ѯ��Լ����������Ӧ
|
|
146
149
|
virtual void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
147
150
|
|
|
151
|
+
///�����ѯ�û��Ự��Ӧ
|
|
152
|
+
virtual void OnRspQryUserSession(CThostFtdcUserSessionField *pUserSession, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
153
|
+
|
|
148
154
|
///�����ѯ��������Ӧ
|
|
149
155
|
virtual void OnRspQryExchange(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
150
156
|
|
|
@@ -498,6 +504,72 @@ public:
|
|
|
498
504
|
|
|
499
505
|
///Ͷ���߲�ƷRULE��֤���ѯ��Ӧ
|
|
500
506
|
virtual void OnRspQryInvestorProdRULEMargin(CThostFtdcInvestorProdRULEMarginField *pInvestorProdRULEMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
507
|
+
|
|
508
|
+
///Ͷ����������ϱ�֤�ز�ѯ��Ӧ
|
|
509
|
+
virtual void OnRspQryInvestorPortfSetting(CThostFtdcInvestorPortfSettingField *pInvestorPortfSetting, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
510
|
+
|
|
511
|
+
///Ͷ�����걨�ѽ�����ȡ��¼��ѯ��Ӧ
|
|
512
|
+
virtual void OnRspQryInvestorInfoCommRec(CThostFtdcInvestorInfoCommRecField *pInvestorInfoCommRec, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
513
|
+
|
|
514
|
+
///�������Ϣ��ѯ��Ӧ
|
|
515
|
+
virtual void OnRspQryCombLeg(CThostFtdcCombLegField *pCombLeg, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
516
|
+
|
|
517
|
+
///�Գ�����������Ӧ
|
|
518
|
+
virtual void OnRspOffsetSetting(CThostFtdcInputOffsetSettingField *pInputOffsetSetting, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
519
|
+
|
|
520
|
+
///�Գ����ó���������Ӧ
|
|
521
|
+
virtual void OnRspCancelOffsetSetting(CThostFtdcInputOffsetSettingField *pInputOffsetSetting, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
522
|
+
|
|
523
|
+
///�Գ�����֪ͨ
|
|
524
|
+
virtual void OnRtnOffsetSetting(CThostFtdcOffsetSettingField *pOffsetSetting) {};
|
|
525
|
+
|
|
526
|
+
///�Գ����ô���ر�
|
|
527
|
+
virtual void OnErrRtnOffsetSetting(CThostFtdcInputOffsetSettingField *pInputOffsetSetting, CThostFtdcRspInfoField *pRspInfo) {};
|
|
528
|
+
|
|
529
|
+
///�Գ����ó�������ر�
|
|
530
|
+
virtual void OnErrRtnCancelOffsetSetting(CThostFtdcCancelOffsetSettingField *pCancelOffsetSetting, CThostFtdcRspInfoField *pRspInfo) {};
|
|
531
|
+
|
|
532
|
+
///Ͷ���߶Գ����ò�ѯ��Ӧ
|
|
533
|
+
virtual void OnRspQryOffsetSetting(CThostFtdcOffsetSettingField *pOffsetSetting, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
534
|
+
|
|
535
|
+
///���������֤����Ӧ
|
|
536
|
+
virtual void OnRspGenSMSCode(CThostFtdcRspGenSMSCodeField *pRspGenSMSCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
537
|
+
|
|
538
|
+
///����ȷ�ϻظ�
|
|
539
|
+
virtual void OnRspSpdApply(CThostFtdcInputSpdApplyField *pInputSpdApply, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
540
|
+
|
|
541
|
+
///����ȷ�ϳ����ظ�
|
|
542
|
+
virtual void OnRspSpdApplyAction(CThostFtdcInputSpdApplyActionField *pInputSpdApplyAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
543
|
+
|
|
544
|
+
///����ȷ�ϲ�ѯ�ظ�
|
|
545
|
+
virtual void OnRspQrySpdApply(CThostFtdcSpdApplyField *pSpdApply, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
546
|
+
|
|
547
|
+
///����ȷ��֪ͨ
|
|
548
|
+
virtual void OnRtnSpdApply(CThostFtdcSpdApplyField *pSpdApply) {};
|
|
549
|
+
|
|
550
|
+
///��������¼�����ر�
|
|
551
|
+
virtual void OnErrRtnSpdApply(CThostFtdcInputSpdApplyField *pInputSpdApply, CThostFtdcRspInfoField *pRspInfo) {};
|
|
552
|
+
|
|
553
|
+
///����ȷ�ϳ���֪ͨ
|
|
554
|
+
virtual void OnErrRtnSpdApplyAction(CThostFtdcSpdApplyActionField *pSpdApplyAction, CThostFtdcRspInfoField *pRspInfo) {};
|
|
555
|
+
|
|
556
|
+
///�ױ�ȷ�ϻظ�
|
|
557
|
+
virtual void OnRspHedgeCfm(CThostFtdcInputHedgeCfmField *pInputHedgeCfm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
558
|
+
|
|
559
|
+
///�ױ�ȷ�ϳ����ظ�
|
|
560
|
+
virtual void OnRspHedgeCfmAction(CThostFtdcInputHedgeCfmActionField *pInputHedgeCfmAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
561
|
+
|
|
562
|
+
///�ױ�ȷ�ϲ�ѯ�ظ�
|
|
563
|
+
virtual void OnRspQryHedgeCfm(CThostFtdcHedgeCfmField *pHedgeCfm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
|
564
|
+
|
|
565
|
+
///�ױ�ȷ��֪ͨ
|
|
566
|
+
virtual void OnRtnHedgeCfm(CThostFtdcHedgeCfmField *pHedgeCfm) {};
|
|
567
|
+
|
|
568
|
+
///�ױ����¼�����ر�
|
|
569
|
+
virtual void OnErrRtnHedgeCfm(CThostFtdcInputHedgeCfmField *pInputHedgeCfm, CThostFtdcRspInfoField *pRspInfo) {};
|
|
570
|
+
|
|
571
|
+
///�ױ�ȷ�ϳ���֪ͨ
|
|
572
|
+
virtual void OnErrRtnHedgeCfmAction(CThostFtdcHedgeCfmActionField *pHedgeCfmAction, CThostFtdcRspInfoField *pRspInfo) {};
|
|
501
573
|
};
|
|
502
574
|
|
|
503
575
|
class TRADER_API_EXPORT CThostFtdcTraderApi
|
|
@@ -505,8 +577,9 @@ class TRADER_API_EXPORT CThostFtdcTraderApi
|
|
|
505
577
|
public:
|
|
506
578
|
///����TraderApi
|
|
507
579
|
///@param pszFlowPath ����������Ϣ�ļ���Ŀ¼��Ĭ��Ϊ��ǰĿ¼
|
|
580
|
+
///@param bIsProductionMode true:ʹ�������汾��API false:ʹ�ò����汾��API
|
|
508
581
|
///@return ��������UserApi
|
|
509
|
-
static CThostFtdcTraderApi *CreateFtdcTraderApi(const char *pszFlowPath = "");
|
|
582
|
+
static CThostFtdcTraderApi *CreateFtdcTraderApi(const char *pszFlowPath = "", bool bIsProductionMode = true);
|
|
510
583
|
|
|
511
584
|
///��ȡAPI�İ汾��Ϣ
|
|
512
585
|
///@retrun ��ȡ���İ汾��
|
|
@@ -529,21 +602,27 @@ public:
|
|
|
529
602
|
///@remark ֻ�е�¼�ɹ���,���ܵõ���ȷ�Ľ�����
|
|
530
603
|
virtual const char *GetTradingDay() = 0;
|
|
531
604
|
|
|
605
|
+
///��ȡ�����ӵ�ǰ�õ���Ϣ
|
|
606
|
+
/// @param pFrontInfo������������������ڴ洢��ȡ����ǰ����Ϣ������Ϊ��
|
|
607
|
+
/// @remark ���ӳɹ��ɻ�ȡ��ȷ��ǰ�õ�ַ��Ϣ
|
|
608
|
+
/// @remark ��¼�ɹ��ɻ�ȡ��ȷ��ǰ��������Ϣ
|
|
609
|
+
virtual void GetFrontInfo(CThostFtdcFrontInfoField* pFrontInfo) =0;
|
|
610
|
+
|
|
532
611
|
///ע��ǰ�û������ַ
|
|
533
|
-
///@param pszFrontAddress
|
|
612
|
+
///@param pszFrontAddress��ǰ�û������ַ��
|
|
534
613
|
///@remark �����ַ�ĸ�ʽΪ����protocol://ipaddress:port�����磺��tcp://127.0.0.1:17001����
|
|
535
614
|
///@remark ��tcp����������Э�飬��127.0.0.1��������������ַ����17001�������������˿ںš�
|
|
536
615
|
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
|
537
616
|
|
|
538
617
|
///ע�����ַ����������ַ
|
|
539
|
-
///@param pszNsAddress
|
|
618
|
+
///@param pszNsAddress�����ַ����������ַ��
|
|
540
619
|
///@remark �����ַ�ĸ�ʽΪ����protocol://ipaddress:port�����磺��tcp://127.0.0.1:12001����
|
|
541
620
|
///@remark ��tcp����������Э�飬��127.0.0.1��������������ַ����12001�������������˿ںš�
|
|
542
621
|
///@remark RegisterNameServer������RegisterFront
|
|
543
622
|
virtual void RegisterNameServer(char *pszNsAddress) = 0;
|
|
544
623
|
|
|
545
624
|
///ע�����ַ������û���Ϣ
|
|
546
|
-
///@param pFensUserInfo
|
|
625
|
+
///@param pFensUserInfo���û���Ϣ��
|
|
547
626
|
virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0;
|
|
548
627
|
|
|
549
628
|
///ע��ص��ӿ�
|
|
@@ -555,8 +634,10 @@ public:
|
|
|
555
634
|
/// THOST_TERT_RESTART:�ӱ������տ�ʼ�ش�
|
|
556
635
|
/// THOST_TERT_RESUME:���ϴ��յ�������
|
|
557
636
|
/// THOST_TERT_QUICK:ֻ���͵�¼��˽����������
|
|
637
|
+
/// THOST_TERT_RESUME_FROM_SEQ_NO:��ָ����ſ�ʼ�ش�����Ŵ�1��ʼ
|
|
638
|
+
///@param nSeqNo ˽������ţ�ֻ��THOST_TERT_RESUME_FROM_SEQ_NOģʽ����Ч
|
|
558
639
|
///@remark �÷���Ҫ��Init����ǰ���á������������յ�˽���������ݡ�
|
|
559
|
-
virtual void SubscribePrivateTopic(THOST_TE_RESUME_TYPE nResumeType) = 0;
|
|
640
|
+
virtual void SubscribePrivateTopic(THOST_TE_RESUME_TYPE nResumeType, int nSeqNo=1) = 0;
|
|
560
641
|
|
|
561
642
|
///����������
|
|
562
643
|
///@param nResumeType �������ش���ʽ
|
|
@@ -577,9 +658,13 @@ public:
|
|
|
577
658
|
///�ϱ��û��ն���Ϣ�������м̷���������Ա��¼ģʽ
|
|
578
659
|
///����Ա��¼���Զ�ε��øýӿ��ϱ��ͻ���Ϣ
|
|
579
660
|
virtual int SubmitUserSystemInfo(CThostFtdcUserSystemInfoField *pUserSystemInfo) = 0;
|
|
661
|
+
///ע���û��ն���Ϣ�������м̷�����������ģʽ.������С�����Ӧ���ϱ���Ϣ.
|
|
662
|
+
virtual int RegisterWechatUserSystemInfo(CThostFtdcWechatUserSystemInfoField *pUserSystemInfo) = 0;
|
|
663
|
+
///�ϱ��û��ն���Ϣ�������м̷���������Ա��¼ģʽ.������С�����Ӧ���ϱ���Ϣ.
|
|
664
|
+
virtual int SubmitWechatUserSystemInfo(CThostFtdcWechatUserSystemInfoField *pUserSystemInfo) = 0;
|
|
580
665
|
|
|
581
666
|
///�û���¼����
|
|
582
|
-
|
|
667
|
+
virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0;
|
|
583
668
|
|
|
584
669
|
///�dz�����
|
|
585
670
|
virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
|
@@ -683,6 +768,9 @@ public:
|
|
|
683
768
|
///�����ѯ��Լ��������
|
|
684
769
|
virtual int ReqQryInstrumentCommissionRate(CThostFtdcQryInstrumentCommissionRateField *pQryInstrumentCommissionRate, int nRequestID) = 0;
|
|
685
770
|
|
|
771
|
+
///�����ѯ�û��Ự
|
|
772
|
+
virtual int ReqQryUserSession(CThostFtdcQryUserSessionField *pQryUserSession, int nRequestID) = 0;
|
|
773
|
+
|
|
686
774
|
///�����ѯ������
|
|
687
775
|
virtual int ReqQryExchange(CThostFtdcQryExchangeField *pQryExchange, int nRequestID) = 0;
|
|
688
776
|
|
|
@@ -907,6 +995,45 @@ public:
|
|
|
907
995
|
|
|
908
996
|
///Ͷ���߲�ƷRULE��֤���ѯ
|
|
909
997
|
virtual int ReqQryInvestorProdRULEMargin(CThostFtdcQryInvestorProdRULEMarginField *pQryInvestorProdRULEMargin, int nRequestID) = 0;
|
|
998
|
+
|
|
999
|
+
///Ͷ����������ϱ�֤�ز�ѯ
|
|
1000
|
+
virtual int ReqQryInvestorPortfSetting(CThostFtdcQryInvestorPortfSettingField *pQryInvestorPortfSetting, int nRequestID) = 0;
|
|
1001
|
+
|
|
1002
|
+
///Ͷ�����걨�ѽ�����ȡ��¼��ѯ
|
|
1003
|
+
virtual int ReqQryInvestorInfoCommRec(CThostFtdcQryInvestorInfoCommRecField *pQryInvestorInfoCommRec, int nRequestID) = 0;
|
|
1004
|
+
|
|
1005
|
+
///�������Ϣ��ѯ
|
|
1006
|
+
virtual int ReqQryCombLeg(CThostFtdcQryCombLegField *pQryCombLeg, int nRequestID) = 0;
|
|
1007
|
+
|
|
1008
|
+
///�Գ���������
|
|
1009
|
+
virtual int ReqOffsetSetting(CThostFtdcInputOffsetSettingField *pInputOffsetSetting, int nRequestID) = 0;
|
|
1010
|
+
|
|
1011
|
+
///�Գ����ó�������
|
|
1012
|
+
virtual int ReqCancelOffsetSetting(CThostFtdcInputOffsetSettingField *pInputOffsetSetting, int nRequestID) = 0;
|
|
1013
|
+
|
|
1014
|
+
///Ͷ���߶Գ����ò�ѯ
|
|
1015
|
+
virtual int ReqQryOffsetSetting(CThostFtdcQryOffsetSettingField *pQryOffsetSetting, int nRequestID) = 0;
|
|
1016
|
+
|
|
1017
|
+
///���������֤������
|
|
1018
|
+
virtual int ReqGenSMSCode(CThostFtdcReqGenSMSCodeField *pReqGenSMSCode, int nRequestID) = 0;
|
|
1019
|
+
|
|
1020
|
+
///����ȷ������
|
|
1021
|
+
virtual int ReqSpdApply(CThostFtdcInputSpdApplyField *pInputSpdApply, int nRequestID) = 0;
|
|
1022
|
+
|
|
1023
|
+
///����ȷ�ϳ�������
|
|
1024
|
+
virtual int ReqSpdApplyAction(CThostFtdcInputSpdApplyActionField *pInputSpdApplyAction, int nRequestID) = 0;
|
|
1025
|
+
|
|
1026
|
+
///����ȷ�ϲ�ѯ����
|
|
1027
|
+
virtual int ReqQrySpdApply(CThostFtdcQrySpdApplyField *pQrySpdApply, int nRequestID) = 0;
|
|
1028
|
+
|
|
1029
|
+
///�ױ�ȷ������
|
|
1030
|
+
virtual int ReqHedgeCfm(CThostFtdcInputHedgeCfmField *pInputHedgeCfm, int nRequestID) = 0;
|
|
1031
|
+
|
|
1032
|
+
///�ױ�ȷ�ϳ�������
|
|
1033
|
+
virtual int ReqHedgeCfmAction(CThostFtdcInputHedgeCfmActionField *pInputHedgeCfmAction, int nRequestID) = 0;
|
|
1034
|
+
|
|
1035
|
+
///�ױ�ȷ�ϲ�ѯ����
|
|
1036
|
+
virtual int ReqQryHedgeCfm(CThostFtdcQryHedgeCfmField *pQryHedgeCfm, int nRequestID) = 0;
|
|
910
1037
|
protected:
|
|
911
1038
|
~CThostFtdcTraderApi(){};
|
|
912
1039
|
};
|