@hitrading/ctp-node 1.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.
Files changed (102) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +208 -0
  3. package/README.zh-CN.md +185 -0
  4. package/binding.gyp +90 -0
  5. package/dist/client.d.ts +115 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +466 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/codec.d.ts +29 -0
  10. package/dist/codec.d.ts.map +1 -0
  11. package/dist/codec.js +131 -0
  12. package/dist/codec.js.map +1 -0
  13. package/dist/generated/enums.gen.d.ts +2257 -0
  14. package/dist/generated/enums.gen.d.ts.map +1 -0
  15. package/dist/generated/enums.gen.js +2576 -0
  16. package/dist/generated/enums.gen.js.map +1 -0
  17. package/dist/generated/structs.gen.d.ts +11041 -0
  18. package/dist/generated/structs.gen.d.ts.map +1 -0
  19. package/dist/generated/structs.gen.js +939 -0
  20. package/dist/generated/structs.gen.js.map +1 -0
  21. package/dist/generated/trader.gen.d.ts +273 -0
  22. package/dist/generated/trader.gen.d.ts.map +1 -0
  23. package/dist/generated/trader.gen.js +653 -0
  24. package/dist/generated/trader.gen.js.map +1 -0
  25. package/dist/index.d.ts +9 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +9 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/market-data.d.ts +66 -0
  30. package/dist/market-data.d.ts.map +1 -0
  31. package/dist/market-data.js +105 -0
  32. package/dist/market-data.js.map +1 -0
  33. package/dist/native-binding.d.ts +2 -0
  34. package/dist/native-binding.d.ts.map +1 -0
  35. package/dist/native-binding.js +22 -0
  36. package/dist/native-binding.js.map +1 -0
  37. package/dist/trader.d.ts +234 -0
  38. package/dist/trader.d.ts.map +1 -0
  39. package/dist/trader.js +388 -0
  40. package/dist/trader.js.map +1 -0
  41. package/package.json +69 -0
  42. package/prebuilds/linux-x64/@hitrading+ctp-node.node +0 -0
  43. package/prebuilds/linux-x64/thostmduserapi_se.so +0 -0
  44. package/prebuilds/linux-x64/thosttraderapi_se.so +0 -0
  45. package/prebuilds/win32-x64/@hitrading+ctp-node.node +0 -0
  46. package/prebuilds/win32-x64/thostmduserapi_se.dll +0 -0
  47. package/prebuilds/win32-x64/thosttraderapi_se.dll +0 -0
  48. package/src/addon.cc +171 -0
  49. package/src/client.ts +539 -0
  50. package/src/codec.ts +160 -0
  51. package/src/generated/enums.gen.ts +2576 -0
  52. package/src/generated/layout.gen.cc +5771 -0
  53. package/src/generated/layout.gen.h +8 -0
  54. package/src/generated/structids.gen.h +470 -0
  55. package/src/generated/structs.gen.ts +12437 -0
  56. package/src/generated/trader.gen.ts +656 -0
  57. package/src/generated/traderreq.gen.cc +706 -0
  58. package/src/generated/traderreq.gen.h +127 -0
  59. package/src/generated/traderspi.gen.cc +636 -0
  60. package/src/generated/traderspi.gen.h +334 -0
  61. package/src/index.ts +14 -0
  62. package/src/market-data.ts +145 -0
  63. package/src/native/arm.cc +77 -0
  64. package/src/native/arm.h +71 -0
  65. package/src/native/channel.cc +175 -0
  66. package/src/native/channel.h +117 -0
  67. package/src/native/gbk.cc +54 -0
  68. package/src/native/gbk.h +17 -0
  69. package/src/native/mdapi.cc +412 -0
  70. package/src/native/mdapi.h +14 -0
  71. package/src/native/mdspi.cc +103 -0
  72. package/src/native/mdspi.h +81 -0
  73. package/src/native/risk.cc +461 -0
  74. package/src/native/risk.h +183 -0
  75. package/src/native/traderapi.cc +533 -0
  76. package/src/native/traderapi.h +14 -0
  77. package/src/native-binding.ts +25 -0
  78. package/src/trader.ts +522 -0
  79. package/tradeapi/ThostFtdcMdApi.h +168 -0
  80. package/tradeapi/ThostFtdcTraderApi.h +914 -0
  81. package/tradeapi/ThostFtdcUserApiDataType.h +7068 -0
  82. package/tradeapi/ThostFtdcUserApiStruct.h +12386 -0
  83. package/tradeapi/error.dtd +9 -0
  84. package/tradeapi/error.xml +284 -0
  85. package/tradeapi/linux/thostmduserapi_se.so +0 -0
  86. package/tradeapi/linux/thosttraderapi_se.so +0 -0
  87. package/tradeapi/macos/thostmduserapi_se.framework/Versions/A/Headers/ThostFtdcMdApi.h +168 -0
  88. package/tradeapi/macos/thostmduserapi_se.framework/Versions/A/Headers/ThostFtdcUserApiDataType.h +7068 -0
  89. package/tradeapi/macos/thostmduserapi_se.framework/Versions/A/Headers/ThostFtdcUserApiStruct.h +12386 -0
  90. package/tradeapi/macos/thostmduserapi_se.framework/Versions/A/Resources/Info.plist +46 -0
  91. package/tradeapi/macos/thostmduserapi_se.framework/Versions/A/_CodeSignature/CodeResources +149 -0
  92. package/tradeapi/macos/thostmduserapi_se.framework/Versions/A/thostmduserapi_se +0 -0
  93. package/tradeapi/macos/thosttraderapi_se.framework/Versions/A/Headers/ThostFtdcTraderApi.h +914 -0
  94. package/tradeapi/macos/thosttraderapi_se.framework/Versions/A/Headers/ThostFtdcUserApiDataType.h +7068 -0
  95. package/tradeapi/macos/thosttraderapi_se.framework/Versions/A/Headers/ThostFtdcUserApiStruct.h +12386 -0
  96. package/tradeapi/macos/thosttraderapi_se.framework/Versions/A/Resources/Info.plist +46 -0
  97. package/tradeapi/macos/thosttraderapi_se.framework/Versions/A/_CodeSignature/CodeResources +149 -0
  98. package/tradeapi/macos/thosttraderapi_se.framework/Versions/A/thosttraderapi_se +0 -0
  99. package/tradeapi/windows/thostmduserapi_se.dll +0 -0
  100. package/tradeapi/windows/thostmduserapi_se.lib +0 -0
  101. package/tradeapi/windows/thosttraderapi_se.dll +0 -0
  102. package/tradeapi/windows/thosttraderapi_se.lib +0 -0
@@ -0,0 +1,175 @@
1
+ /*
2
+ * channel.cc - see channel.h
3
+ */
4
+
5
+ #include "channel.h"
6
+
7
+ #include <algorithm>
8
+ #include <cstring>
9
+
10
+ namespace ctp {
11
+
12
+ static inline size_t align8(size_t n) { return (n + 7) & ~static_cast<size_t>(7); }
13
+ static inline void putI32(uint8_t *p, int32_t v) { std::memcpy(p, &v, sizeof(v)); }
14
+
15
+ EventChannel::EventChannel(size_t numSlots, size_t maxPayload, DropPolicy policy)
16
+ : numSlots_(numSlots == 0 ? 1 : numSlots),
17
+ slotSize_(align8(SLOT_HEADER_SIZE + maxPayload)),
18
+ maxPayload_(maxPayload),
19
+ policy_(policy),
20
+ ring_(slotSize_ * numSlots_, 0) {}
21
+
22
+ EventChannel::~EventChannel() { stop(); }
23
+
24
+ napi_status EventChannel::start(napi_env env, napi_value drainCb) {
25
+ napi_value name;
26
+ napi_status st =
27
+ napi_create_string_utf8(env, "ctp-doorbell", NAPI_AUTO_LENGTH, &name);
28
+ if (st != napi_ok)
29
+ return st;
30
+ return napi_create_threadsafe_function(env, drainCb, nullptr, name, 0, 1,
31
+ nullptr, nullptr, this, onDoorbell,
32
+ &tsfn_);
33
+ }
34
+
35
+ void EventChannel::stop() {
36
+ if (tsfn_) {
37
+ napi_release_threadsafe_function(tsfn_, napi_tsfn_abort);
38
+ tsfn_ = nullptr;
39
+ }
40
+ }
41
+
42
+ bool EventChannel::push(int32_t eventType, int32_t requestId, int32_t isLast,
43
+ int32_t errorId, const char *errorMsg, int32_t structId,
44
+ const void *payload, int32_t payloadLen) {
45
+ const uint64_t w = writeIdx_.load(std::memory_order_relaxed);
46
+ if (policy_ == DropPolicy::Newest) {
47
+ // Reliable: refuse (and count) the newest record when full so nothing
48
+ // already queued is lost. Only the producer touches drops_ in this mode.
49
+ const uint64_t r = readIdx_.load(std::memory_order_acquire);
50
+ if (w - r >= numSlots_) {
51
+ drops_.fetch_add(1, std::memory_order_relaxed);
52
+ return false;
53
+ }
54
+ }
55
+ // DropPolicy::Oldest: never refuse. When full this overwrites the slot holding
56
+ // the oldest unread record (slot (w % numSlots) == slot (readIdx % numSlots)
57
+ // once w - readIdx == numSlots). The producer stays wait-free and deliberately
58
+ // does NOT read/advance readIdx_ or touch drops_ - doing so from the producer
59
+ // would race the consumer, the sole writer of both. The consumer reconciles
60
+ // the overrun in claim() (skip lapped records) and validate() (discard a read
61
+ // torn mid-overwrite), and owns the drop counter.
62
+
63
+ uint8_t *slot = ring_.data() + (w % numSlots_) * slotSize_;
64
+ putI32(slot + SLOT_EVENT_TYPE, eventType);
65
+ putI32(slot + SLOT_REQUEST_ID, requestId);
66
+ putI32(slot + SLOT_IS_LAST, isLast);
67
+ putI32(slot + SLOT_ERROR_ID, errorId);
68
+ putI32(slot + SLOT_STRUCT_ID, structId);
69
+
70
+ if (errorMsg && errorMsg[0]) {
71
+ std::strncpy(reinterpret_cast<char *>(slot + SLOT_ERROR_MSG), errorMsg,
72
+ SLOT_ERROR_MSG_CAP - 1);
73
+ slot[SLOT_ERROR_MSG + SLOT_ERROR_MSG_CAP - 1] = 0;
74
+ } else {
75
+ slot[SLOT_ERROR_MSG] = 0;
76
+ }
77
+
78
+ int32_t n = 0;
79
+ if (payload && payloadLen > 0) {
80
+ n = std::min<int32_t>(payloadLen, static_cast<int32_t>(maxPayload_));
81
+ std::memcpy(slot + SLOT_HEADER_SIZE, payload, static_cast<size_t>(n));
82
+ }
83
+ putI32(slot + SLOT_PAYLOAD_LEN, n);
84
+
85
+ writeIdx_.store(w + 1, std::memory_order_release);
86
+
87
+ if (!pending_.exchange(true, std::memory_order_acq_rel) && tsfn_) {
88
+ napi_call_threadsafe_function(tsfn_, nullptr, napi_tsfn_nonblocking);
89
+ }
90
+ return true;
91
+ }
92
+
93
+ uint32_t EventChannel::claim() {
94
+ pending_.store(false, std::memory_order_release);
95
+ // Full fence so clearing pending_ is ordered BEFORE reading writeIdx_ (a
96
+ // release store + acquire load on different atomics does NOT order StoreLoad,
97
+ // and x86 reorders it). Without this, a concurrent push could both observe
98
+ // pending_ still true (skip the doorbell) AND publish a writeIdx this load
99
+ // misses -> a stranded record (lost wakeup). The producer's exchange() is a
100
+ // locked RMW (already a full barrier), so only the consumer needs this.
101
+ std::atomic_thread_fence(std::memory_order_seq_cst);
102
+ const uint64_t w = writeIdx_.load(std::memory_order_acquire);
103
+ uint64_t r = readIdx_.load(std::memory_order_relaxed);
104
+ // DropPolicy::Oldest: if the producer lapped us while we were idle, the oldest
105
+ // (w - r) - numSlots records have been overwritten and are gone. Skip them so
106
+ // we only hand the consumer the freshest numSlots slots. Counting + advancing
107
+ // readIdx_ here is safe because the consumer is the sole writer of both readIdx_
108
+ // and (in this mode) drops_. Under DropPolicy::Newest the producer keeps
109
+ // w - r <= numSlots, so this branch never fires.
110
+ if (w - r > numSlots_) {
111
+ const uint64_t skip = (w - r) - numSlots_;
112
+ drops_.fetch_add(skip, std::memory_order_relaxed);
113
+ r += skip;
114
+ readIdx_.store(r, std::memory_order_release);
115
+ }
116
+ return static_cast<uint32_t>(w - r);
117
+ }
118
+
119
+ uint32_t EventChannel::validate(uint32_t claimed) {
120
+ // Consumer thread. The producer may have lapped the ring while we decoded the
121
+ // batch claim() handed us, overwriting the oldest records mid-read. Compare the
122
+ // current write index against the batch start (readIdx_, unchanged since claim()
123
+ // because only the consumer advances it, and we have not released yet): any
124
+ // record at or below the in-flight write slot was (or is being) torn and must
125
+ // be discarded.
126
+ //
127
+ // floor = w - numSlots + 1, NOT w - numSlots. push() writes physical slot
128
+ // (idx % numSlots) BEFORE publishing writeIdx_ = idx+1, so when we observe
129
+ // writeIdx_ == w the producer may be mid-overwriting the slot for index w —
130
+ // which is the SAME physical slot that holds index (w - numSlots). We cannot
131
+ // tell "finished w-1, idle" from "mid-writing w", so we conservatively treat
132
+ // index (w - numSlots) as torn too. Using w - numSlots here would deliver that
133
+ // boundary record while its slot is being overwritten — a torn quote reaching
134
+ // a handler (silent corruption under sustained overflow).
135
+ //
136
+ // Cost of being conservative: whenever the ring is observed EXACTLY full
137
+ // (w - r == numSlots) — including the producer simply being idle at a full ring,
138
+ // not mid-writing — this drops the single oldest record in the batch even if its
139
+ // slot was intact. That is one unnecessary drop of the *stalest* queued quote,
140
+ // and only once the consumer has already fallen a full ring (numSlots) behind,
141
+ // i.e. exactly the overload regime where drop-oldest is meant to shed the
142
+ // stalest quotes. So it is never data corruption and never more than one drop
143
+ // per drain, always the least-valuable record. The exact alternative (no
144
+ // over-drop AND no torn delivery) is a per-slot seqlock generation stamp;
145
+ // deemed not worth an extra producer atomic on the hot path to save one
146
+ // already-stale quote at the full-ring boundary.
147
+ const uint64_t w = writeIdx_.load(std::memory_order_acquire);
148
+ const uint64_t r = readIdx_.load(std::memory_order_relaxed);
149
+ const uint64_t floor = (w >= numSlots_) ? (w - numSlots_ + 1) : 0;
150
+ if (floor <= r)
151
+ return 0; // producer never reached our batch; every decoded record is clean
152
+ uint64_t torn = floor - r;
153
+ if (torn > claimed)
154
+ torn = claimed; // producer raced far past the batch; whole batch is torn
155
+ drops_.fetch_add(torn, std::memory_order_relaxed);
156
+ return static_cast<uint32_t>(torn);
157
+ }
158
+
159
+ void EventChannel::release(uint32_t n) {
160
+ readIdx_.store(readIdx_.load(std::memory_order_relaxed) + n,
161
+ std::memory_order_release);
162
+ }
163
+
164
+ void EventChannel::onDoorbell(napi_env env, napi_value jsCb, void *ctx,
165
+ void *data) {
166
+ (void)ctx;
167
+ (void)data;
168
+ if (env == nullptr || jsCb == nullptr)
169
+ return; // teardown drain
170
+ napi_value undef;
171
+ napi_get_undefined(env, &undef);
172
+ napi_call_function(env, undef, jsCb, 0, nullptr, nullptr);
173
+ }
174
+
175
+ } // namespace ctp
@@ -0,0 +1,117 @@
1
+ /*
2
+ * channel.h - lock-free SPSC ring delivering binary CTP records from the CTP
3
+ * callback thread (single producer) to the JS event loop (single consumer).
4
+ *
5
+ * The producer only memcpy's bytes + bumps an atomic index, then rings a
6
+ * coalesced doorbell (a threadsafe-function used purely as a wakeup). The JS
7
+ * consumer drains a whole batch per wakeup and decodes straight from the ring
8
+ * (zero-copy) into plain objects. The CTP thread is never blocked; what happens
9
+ * on overflow is set per channel by DropPolicy:
10
+ *
11
+ * - DropPolicy::Newest (the trader): when full the producer refuses the new
12
+ * record and bumps a counter. Nothing already queued is discarded, so an
13
+ * order/trade return is never silently lost - reliability over freshness.
14
+ * - DropPolicy::Oldest (market data): when full the producer overwrites the
15
+ * oldest unread record so the consumer always sees the freshest quotes.
16
+ * The producer stays wait-free and never touches readIdx_/drops_; the
17
+ * consumer detects the overrun (claim() skips lapped records, validate()
18
+ * discards any read torn mid-overwrite) and owns the drop counter. This
19
+ * keeps the SPSC single-writer invariant intact: producer writes only
20
+ * writeIdx_, consumer writes only readIdx_ (and, in this mode, drops_).
21
+ *
22
+ * Slot header layout (fixed; the JS drain in client.ts must match):
23
+ * [0] int32 eventType
24
+ * [4] int32 requestId
25
+ * [8] int32 isLast (-1 undefined / 0 false / 1 true)
26
+ * [12] int32 errorId (0 = no error)
27
+ * [16] int32 structId (-1 = no payload struct)
28
+ * [20] int32 payloadLen
29
+ * [24] char errorMsg[81]
30
+ * [112] payload bytes (8-aligned start)
31
+ */
32
+
33
+ #ifndef CTP_NATIVE_CHANNEL_H
34
+ #define CTP_NATIVE_CHANNEL_H
35
+
36
+ #include <napi.h>
37
+
38
+ #include <atomic>
39
+ #include <cstdint>
40
+ #include <vector>
41
+
42
+ namespace ctp {
43
+
44
+ enum {
45
+ SLOT_EVENT_TYPE = 0,
46
+ SLOT_REQUEST_ID = 4,
47
+ SLOT_IS_LAST = 8,
48
+ SLOT_ERROR_ID = 12,
49
+ SLOT_STRUCT_ID = 16,
50
+ SLOT_PAYLOAD_LEN = 20,
51
+ SLOT_ERROR_MSG = 24,
52
+ SLOT_ERROR_MSG_CAP = 81,
53
+ SLOT_HEADER_SIZE = 112,
54
+ };
55
+
56
+ // Overflow behaviour, fixed per channel at construction. See the file header.
57
+ enum class DropPolicy {
58
+ Newest, // refuse the incoming record when full (reliable; trader)
59
+ Oldest, // overwrite the oldest unread record when full (freshest; market data)
60
+ };
61
+
62
+ class EventChannel {
63
+ public:
64
+ EventChannel(size_t numSlots, size_t maxPayload,
65
+ DropPolicy policy = DropPolicy::Newest);
66
+ ~EventChannel();
67
+
68
+ // Wire the coalesced doorbell to a JS drain callback (JS thread).
69
+ napi_status start(napi_env env, napi_value drainCb);
70
+ // Abort the doorbell. MUST be called only after the producer has stopped.
71
+ void stop();
72
+
73
+ // Producer (CTP callback thread). Returns false only under DropPolicy::Newest
74
+ // when the ring is full (the record was refused + counted); DropPolicy::Oldest
75
+ // always returns true (it overwrites the oldest unread record).
76
+ bool push(int32_t eventType, int32_t requestId, int32_t isLast,
77
+ int32_t errorId, const char *errorMsg, int32_t structId,
78
+ const void *payload, int32_t payloadLen);
79
+
80
+ // Consumer (JS thread).
81
+ uint32_t claim(); // clear pending, return available record count
82
+ void release(uint32_t n); // free n drained slots
83
+ // DropPolicy::Oldest only: after claim() returned `claimed` and the consumer
84
+ // decoded that many records from the current readIdx_, report how many of the
85
+ // OLDEST decoded records the producer overwrote *during* the decode (it lapped
86
+ // the ring). Those records hold torn bytes and must be discarded; they are
87
+ // added to the drop counter. Always 0 under DropPolicy::Newest (the producer
88
+ // never overwrites unread slots).
89
+ uint32_t validate(uint32_t claimed);
90
+
91
+ uint64_t dropCount() const { return drops_.load(std::memory_order_relaxed); }
92
+ uint64_t readIndex() const { return readIdx_.load(std::memory_order_relaxed); }
93
+ bool dropOldest() const { return policy_ == DropPolicy::Oldest; }
94
+ size_t numSlots() const { return numSlots_; }
95
+ size_t slotSize() const { return slotSize_; }
96
+ size_t headerSize() const { return SLOT_HEADER_SIZE; }
97
+ uint8_t *data() { return ring_.data(); }
98
+ size_t byteLength() const { return ring_.size(); }
99
+
100
+ private:
101
+ static void onDoorbell(napi_env env, napi_value jsCb, void *ctx, void *data);
102
+
103
+ size_t numSlots_;
104
+ size_t slotSize_;
105
+ size_t maxPayload_;
106
+ DropPolicy policy_;
107
+ std::vector<uint8_t> ring_;
108
+ std::atomic<uint64_t> writeIdx_{0};
109
+ std::atomic<uint64_t> readIdx_{0};
110
+ std::atomic<uint64_t> drops_{0};
111
+ std::atomic<bool> pending_{false};
112
+ napi_threadsafe_function tsfn_{nullptr};
113
+ };
114
+
115
+ } // namespace ctp
116
+
117
+ #endif /* CTP_NATIVE_CHANNEL_H */
@@ -0,0 +1,54 @@
1
+ /*
2
+ * gbk.cc - see gbk.h
3
+ */
4
+
5
+ #include "gbk.h"
6
+
7
+ #ifdef _WIN32
8
+ #include <windows.h>
9
+
10
+ namespace ctp {
11
+ std::string gbkEncode(const char *utf8, size_t len) {
12
+ if (len == 0)
13
+ return std::string();
14
+ const int wlen =
15
+ MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), nullptr, 0);
16
+ if (wlen <= 0)
17
+ return std::string(utf8, len);
18
+ std::wstring wide(static_cast<size_t>(wlen), L'\0');
19
+ MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), &wide[0], wlen);
20
+ // 54936 = GB18030.
21
+ const int blen = WideCharToMultiByte(54936, 0, wide.data(), wlen, nullptr, 0,
22
+ nullptr, nullptr);
23
+ if (blen <= 0)
24
+ return std::string(utf8, len);
25
+ std::string out(static_cast<size_t>(blen), '\0');
26
+ WideCharToMultiByte(54936, 0, wide.data(), wlen, &out[0], blen, nullptr,
27
+ nullptr);
28
+ return out;
29
+ }
30
+ } // namespace ctp
31
+
32
+ #else
33
+ #include <iconv.h>
34
+
35
+ namespace ctp {
36
+ std::string gbkEncode(const char *utf8, size_t len) {
37
+ if (len == 0)
38
+ return std::string();
39
+ iconv_t cd = iconv_open("GB18030//TRANSLIT", "UTF-8");
40
+ if (cd == reinterpret_cast<iconv_t>(-1))
41
+ return std::string(utf8, len);
42
+ size_t inleft = len;
43
+ const size_t cap = len * 2 + 4;
44
+ std::string out(cap, '\0');
45
+ char *inbuf = const_cast<char *>(utf8);
46
+ char *outbuf = &out[0];
47
+ size_t outleft = cap;
48
+ iconv(cd, &inbuf, &inleft, &outbuf, &outleft);
49
+ iconv_close(cd);
50
+ out.resize(cap - outleft);
51
+ return out;
52
+ }
53
+ } // namespace ctp
54
+ #endif
@@ -0,0 +1,17 @@
1
+ /*
2
+ * gbk.h - encode UTF-8 -> GB18030 (CTP's on-the-wire charset) for the rare
3
+ * non-ASCII request field (e.g. bank-transfer customer names). Decoding is done
4
+ * in JS via TextDecoder('gb18030'); this is the outbound counterpart.
5
+ */
6
+
7
+ #ifndef CTP_NATIVE_GBK_H
8
+ #define CTP_NATIVE_GBK_H
9
+
10
+ #include <cstddef>
11
+ #include <string>
12
+
13
+ namespace ctp {
14
+ std::string gbkEncode(const char *utf8, size_t len);
15
+ }
16
+
17
+ #endif /* CTP_NATIVE_GBK_H */