@hitrading/ctp-node 2.0.0 → 4.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 (79) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +54 -32
  3. package/README.zh-CN.md +44 -27
  4. package/RELEASING.md +78 -0
  5. package/dist/client.d.ts +36 -15
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +234 -62
  8. package/dist/client.js.map +1 -1
  9. package/dist/codec.d.ts.map +1 -1
  10. package/dist/codec.js +84 -19
  11. package/dist/codec.js.map +1 -1
  12. package/dist/generated/structs.gen.d.ts +5461 -5461
  13. package/dist/generated/structs.gen.d.ts.map +1 -1
  14. package/dist/generated/trader.gen.d.ts.map +1 -1
  15. package/dist/generated/trader.gen.js +788 -94
  16. package/dist/generated/trader.gen.js.map +1 -1
  17. package/dist/index.cjs +1909 -417
  18. package/dist/index.d.cts +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/market-data.d.ts +41 -24
  23. package/dist/market-data.d.ts.map +1 -1
  24. package/dist/market-data.js +148 -29
  25. package/dist/market-data.js.map +1 -1
  26. package/dist/native-binding.d.ts.map +1 -1
  27. package/dist/native-binding.js +4 -0
  28. package/dist/native-binding.js.map +1 -1
  29. package/dist/trader.d.ts +136 -79
  30. package/dist/trader.d.ts.map +1 -1
  31. package/dist/trader.js +807 -182
  32. package/dist/trader.js.map +1 -1
  33. package/dist/validation.d.ts +27 -0
  34. package/dist/validation.d.ts.map +1 -0
  35. package/dist/validation.js +85 -0
  36. package/dist/validation.js.map +1 -0
  37. package/docs/API.md +1445 -0
  38. package/docs/API.zh-CN.md +1285 -0
  39. package/docs/MIGRATION.md +54 -0
  40. package/docs/assets/validation.svg +27 -0
  41. package/docs/integration.md +60 -0
  42. package/docs/native-hooks.md +281 -0
  43. package/docs/native-hooks.zh-CN.md +205 -0
  44. package/docs/troubleshooting.md +257 -0
  45. package/docs/troubleshooting.zh-CN.md +220 -0
  46. package/package.json +12 -4
  47. package/prebuilds/linux-x64/@hitrading+ctp-node.node +0 -0
  48. package/prebuilds/win32-x64/@hitrading+ctp-node.node +0 -0
  49. package/scripts/bench-decode.mjs +37 -0
  50. package/scripts/bench-fullmarket-offline.mjs +207 -0
  51. package/scripts/stress-fullmarket.mjs +255 -0
  52. package/src/addon.cc +2 -2
  53. package/src/client.ts +255 -65
  54. package/src/codec.ts +86 -19
  55. package/src/generated/structs.gen.ts +5461 -5461
  56. package/src/generated/trader.gen.ts +309 -94
  57. package/src/generated/traderreq.gen.cc +194 -18
  58. package/src/generated/traderreq.gen.h +4 -0
  59. package/src/generated/traderspi.gen.cc +129 -15
  60. package/src/generated/traderspi.gen.h +4 -2
  61. package/src/index.ts +11 -1
  62. package/src/market-data.ts +199 -46
  63. package/src/native/arm.cc +114 -30
  64. package/src/native/arm.h +16 -4
  65. package/src/native/channel.cc +209 -81
  66. package/src/native/channel.h +65 -24
  67. package/src/native/ctp_field.h +23 -0
  68. package/src/native/mdapi.cc +582 -69
  69. package/src/native/mdspi.cc +219 -16
  70. package/src/native/mdspi.h +59 -10
  71. package/src/native/order_capability.h +78 -0
  72. package/src/native/risk.cc +2030 -213
  73. package/src/native/risk.h +431 -78
  74. package/src/native/shared_handle.h +37 -0
  75. package/src/native/snapshot.h +75 -16
  76. package/src/native/traderapi.cc +769 -124
  77. package/src/native-binding.ts +4 -0
  78. package/src/trader.ts +1038 -207
  79. package/src/validation.ts +96 -0
package/dist/trader.d.ts CHANGED
@@ -3,43 +3,82 @@ import type { CallbackOptions } from "./client.js";
3
3
  import type { Order, Trade, InputOrder, RspUserLogin } from "./generated/structs.gen.js";
4
4
  import type { MarketData } from "./market-data.js";
5
5
  /** Pre-trade risk limits, enforced in C++ before each order is sent. */
6
- export interface RiskConfig {
6
+ export interface RiskLimits {
7
7
  /** Max volume per single order. Omit/0 = disabled. */
8
8
  maxOrderVolume?: number;
9
9
  /** Reject if order price deviates from the reference by > this ratio (e.g.
10
10
  * 0.02 = 2%). Feed the reference via trackMarketData(md) (the MD snapshot is
11
- * read in C++); with no reference the check is skipped. */
11
+ * read in C++); missing or stale data rejects opening orders. */
12
12
  maxPriceDeviation?: number;
13
- /** Max notional (price × volume) per order. Omit/0 = disabled. */
13
+ /** Max futures notional (price × volume × multiplier) per opening order.
14
+ * Unknown/unsupported product metadata fails closed. Omit/0 = disabled. */
14
15
  maxNotional?: number;
15
- /** Max order sends per second (token bucket). Omit/0 = disabled. */
16
+ /** Max opening-order sends per second (token bucket). Omit/0 = disabled. */
16
17
  maxOrdersPerSec?: number;
17
18
  /** Token-bucket burst; defaults to maxOrdersPerSec. */
18
19
  orderBurst?: number;
19
- /** @deprecated Use {@link maxMargin}. Back-compat alias; now also margin-based
20
- * (the tracked open cost is real margin once margin rates are known).
21
- * maxMargin takes precedence when both are set. */
22
- maxPositionCost?: number;
20
+ /** Independent rate for risk-reducing close inserts. Disabled by default so
21
+ * emergency exits are not throttled by the opening-order bucket. */
22
+ maxCloseOrdersPerSec?: number;
23
+ /** Close-order token-bucket burst; defaults to maxCloseOrdersPerSec. */
24
+ closeOrderBurst?: number;
25
+ /** Maximum age of the market-data reference used by the deviation guard.
26
+ * Default 3000 ms. Missing or older data fails closed when the guard is on. */
27
+ maxReferenceAgeMs?: number;
23
28
  /** Cap on total open-position MARGIN (Σ open price × volume × multiplier ×
24
- * marginRate) — the real capital occupied, a zero-lag hard cap enforced in
29
+ * absolute by-money/by-volume margin schedule) — a zero-lag hard cap enforced in
25
30
  * C++ on every opening order (regular AND armed). 0/undefined = disabled.
26
31
  * Margin rates are fed automatically from CTP's OnRspQryInstrumentMarginRate
27
32
  * inside C++ (populate them by calling reqQryInstrumentMarginRate); until a
28
- * contract's rate is known it counts at full notional (conservative).
33
+ * multiplier or usable absolute schedule is missing, opening orders fail
34
+ * closed. Both by-money and per-lot components are included; relative
35
+ * investor schedules are combined with their exchange base schedule.
29
36
  * Multipliers / existing positions are picked up via syncMultipliers() /
30
37
  * syncPositions(). */
31
- maxMargin?: number;
38
+ maxAccountMargin?: number;
32
39
  }
33
40
  /** A per-instrument lot cap: a single number caps both sides at that value;
34
41
  * `{ long, short }` caps each side separately (omit a side to leave it open). */
35
- export type LotCap = number | {
42
+ export type InstrumentPositionLimit = number | {
36
43
  long?: number;
37
44
  short?: number;
38
45
  };
46
+ /** One bucket in a complete manually reconciled held-position snapshot. */
47
+ export interface PositionSeed {
48
+ instrumentId: string;
49
+ side: "long" | "short";
50
+ hedgeFlag: "1" | "2" | "3" | "5" | "6" | "7";
51
+ volume: number;
52
+ margin: number;
53
+ }
54
+ /** A bounded margin-rate sync scoped to the hedge flag used by the orders that
55
+ * will consume those schedules in the native risk ledger. */
56
+ export interface MarginRateSyncOptions {
57
+ instrumentIds: string[];
58
+ hedgeFlag: "1" | "2" | "3" | "5" | "6" | "7";
59
+ }
60
+ /** The request-correlated identity established by a successful trader login. */
61
+ export interface TraderSessionIdentity {
62
+ readonly frontId: number;
63
+ readonly sessionId: number;
64
+ /** MaxOrderRef reported by this login response. The process-wide automatic
65
+ * allocator may retain a higher high-water mark from earlier sends. */
66
+ readonly maxOrderRef: number;
67
+ }
68
+ export interface TraderSessionResult {
69
+ identity: TraderSessionIdentity;
70
+ multipliers: number;
71
+ marginRates: number;
72
+ positions: number;
73
+ orders: number;
74
+ }
39
75
  /** Options for the one-call post-connect handshake, {@link Trader.session}. */
40
76
  export interface SessionOptions {
41
77
  brokerId: string;
42
78
  userId: string;
79
+ /** Trading account. Defaults to userId for ordinary retail accounts; set it
80
+ * explicitly when the login operator UserID differs from InvestorID. */
81
+ investorId?: string;
43
82
  password: string;
44
83
  /** Terminal authentication (real accounts require it; SimNow uses
45
84
  * appId "simnow_client_test" / authCode of 16 zeros). Omit both to skip. */
@@ -49,10 +88,14 @@ export interface SessionOptions {
49
88
  * before trading (brokers reject orders otherwise). Default true; set false
50
89
  * for environments that don't need it. */
51
90
  confirmSettlement?: boolean;
52
- /** Which risk inputs to fetch after login (default: all). `multipliers` may
53
- * be `true` (all instruments) or a list of symbols. */
91
+ /** Which risk inputs to fetch after login. Multipliers/positions/orders default
92
+ * on; margin rates require an explicit contract list and hedge flag.
93
+ * `multipliers` may be `true` (all instruments) or a list of symbols. */
54
94
  sync?: {
55
95
  multipliers?: boolean | string[];
96
+ /** Contracts and hedge flag whose margin schedules should be queried.
97
+ * Omitted by default because CTP requires one rate query per contract. */
98
+ marginRates?: MarginRateSyncOptions;
56
99
  positions?: boolean;
57
100
  orders?: boolean;
58
101
  };
@@ -78,25 +121,36 @@ export declare class Trader extends TraderBase {
78
121
  private investor?;
79
122
  private orderRefSeq;
80
123
  constructor(flowPath: string, fronts: string | string[]);
81
- getApiVersion(): string;
82
- getTradingDay(): string;
124
+ /** A raw login Promise may resolve only with a structurally usable session.
125
+ * Account confirmation itself happens in session(), after request-vs-response
126
+ * identity validation; merely observing a protocol event never grants order
127
+ * authority. */
128
+ protected onRequestResolved(eventName: string | undefined, value: unknown, _options: CallbackOptions): void;
129
+ /** Generated login/logout methods call this only after their request has
130
+ * encoded successfully. Revoke the confirmed JS account at that same atomic
131
+ * transition boundary, so a concurrent sync helper cannot start with the old
132
+ * identity while native risk state is already fail-closed for the new session. */
133
+ protected beginRequestContextTransition(reason: string): void;
134
+ protected shouldTimeoutRequest(requestId: number, sessionTransition: boolean): boolean;
135
+ get apiVersion(): string;
136
+ get tradingDay(): string;
83
137
  /**
84
138
  * One-call post-connect handshake. Call it from the `front-connected` handler
85
139
  * (and again after a reconnect): authenticate (if appId/authCode given) →
86
- * login → confirm settlement → sync multipliers / positions / orders. Each
140
+ * login → confirm settlement → sync multipliers / margin rates / orders /
141
+ * positions. Each
87
142
  * step just wraps the matching req / sync method, so you can hand-roll your
88
- * own flow instead when you need finer control. Returns the row counts from
89
- * the sync steps. Must run on a connected front (queries need the session up).
143
+ * own flow instead when you need finer control. Returns the request-correlated
144
+ * login identity and row counts from the sync steps. Must run on a connected
145
+ * front (queries need the session up).
90
146
  */
91
- session(opts: SessionOptions): Promise<{
92
- multipliers: number;
93
- positions: number;
94
- orders: number;
95
- }>;
147
+ session(opts: SessionOptions): Promise<TraderSessionResult>;
96
148
  /** Assign a unique numeric OrderRef when the caller left it blank. CTP treats
97
149
  * OrderRef as a per-session sequence and rejects a duplicate or non-numeric
98
150
  * ref with "不允许重复报单", so an unset ref would otherwise collide. */
99
151
  private withAutoOrderRef;
152
+ private commitOrderRef;
153
+ private validateOrder;
100
154
  /**
101
155
  * Insert an order through the C++ pre-trade risk gate. Resolves on submission:
102
156
  * CTP sends no success acknowledgement for an accepted order - only
@@ -107,73 +161,74 @@ export declare class Trader extends TraderBase {
107
161
  */
108
162
  reqOrderInsert(req?: Partial<InputOrder>): Promise<void>;
109
163
  /** Publish pre-trade risk limits to the C++ enforcer (takes effect at once). */
110
- riskSet(config: RiskConfig): this;
111
- /** Kill-switch: C++ immediately blocks every order-opening send that reaches
112
- * the exchange at once — regular, exec, quote, for-quote, option-self-close
113
- * and comb-action inserts. Cancels and other *actions* are deliberately left
114
- * open so you can still pull working orders while halted; parked/staged orders
115
- * (not sent to the exchange immediately) are likewise not gated. Takes effect
116
- * at once; reverse with {@link resume}. */
117
- halt(): this;
118
- /** Release the kill-switch (see {@link halt}). */
164
+ setRiskLimits(config: RiskLimits): this;
165
+ /** Enter REDUCE_ONLY atomically at the final vendor-API send barrier. Armed
166
+ * opens remain registered but cannot send until resume(). */
167
+ reduceOnly(): this;
168
+ /** Enter HALT_ALL atomically: both opening and closing order inserts, advanced
169
+ * mutations and bank/futures transfers are refused, and all existing armed
170
+ * triggers are cleared. New arm() calls are rejected until resume().
171
+ * Cancellation actions remain available so working
172
+ * exchange orders can still be withdrawn. */
173
+ haltAll(): this;
174
+ /** Return to NORMAL mode after reduceOnly() or haltAll(). */
119
175
  resume(): this;
120
176
  /** Use a MarketData feed as the live reference for the maxPriceDeviation check.
121
177
  * Wires the feed's C++ snapshot cache straight into this Trader's risk engine,
122
178
  * so the deviation check reads current prices in C++ on the order path (no JS
123
179
  * round-trip, and it also covers armed orders that fire with no JS in the loop).
124
- * Without this, no reference is set and the deviation check is skipped. */
180
+ * Without a fresh reference, an enabled deviation check fails closed. */
125
181
  trackMarketData(md: MarketData): this;
126
182
  /**
127
183
  * Cap the open position (in lots) for one instrument, enforced in C++ on
128
184
  * every opening order. Pass a number to cap both sides at once, or
129
185
  * `{ long, short }` to cap each side separately. Within `{ long, short }`,
130
186
  * **omitting a side leaves that side's current cap unchanged** (on a re-call it
131
- * is NOT reset to uncapped), and passing `<= 0` for a side removes its cap.
187
+ * is NOT reset to uncapped), and passing `0` for a side removes its cap.
132
188
  * Long and short are always tracked independently.
133
189
  *
134
- * The check is fill-based (counts confirmed position, like maxPositionCost),
135
- * so rapid bursts of opens can momentarily overshoot before the fills land —
136
- * size the cap with that in mind.
190
+ * Held positions and in-flight working opens are counted atomically.
137
191
  *
138
- * td.setMaxPosition("rb2610", 100); // long<=100 and short<=100
139
- * td.setMaxPosition("ru2610", { long: 100, short: 20 });
192
+ * td.setInstrumentPositionLimit("rb2610", 100);
193
+ * td.setInstrumentPositionLimit("ru2610", { long: 100, short: 20 });
140
194
  */
141
- setMaxPosition(instrumentId: string, max: LotCap): this;
195
+ setInstrumentPositionLimit(instrumentId: string, limit: InstrumentPositionLimit): this;
142
196
  /** Cap several instruments at once, e.g.
143
197
  * `{ rb2610: 100, ru2610: { long: 100, short: 20 } }`. */
144
- setMaxPositions(limits: Record<string, LotCap>): this;
198
+ setInstrumentPositionLimits(limits: Record<string, InstrumentPositionLimit>): this;
199
+ private normalizePositionLimit;
145
200
  /**
146
- * Cap one instrument's open-position cost (Σ open price × volume × multiplier,
147
- * long and short summed - a gross capital/concentration limit), enforced in
148
- * C++ on every opening order. This is per-instrument and independent of the
149
- * account-wide cap set via riskSet({ maxPositionCost }); both apply. Pass
150
- * `maxCost <= 0` to remove it. Fill-based, same caveat as maxPositionCost.
201
+ * Cap one instrument's scheduled open margin (CTP by-money + by-volume,
202
+ * long and short summed), enforced in C++ on every opening order. This is
203
+ * independent of the account-wide maxAccountMargin cap; both apply. Pass
204
+ * `limit = 0` to remove it. Held and in-flight exposure both count.
151
205
  */
152
- setMaxPositionCost(instrumentId: string, maxCost: number): this;
153
- /** Cap several instruments' open-position cost at once, e.g.
206
+ setInstrumentMarginLimit(instrumentId: string, limit: number): this;
207
+ /** Cap several instruments' scheduled open margin at once, e.g.
154
208
  * `{ ag2608: 2_000_000, au2608: 5_000_000 }`. */
155
- setMaxPositionCosts(limits: Record<string, number>): this;
156
- /** Seed a pre-existing position into the margin/cost cap. `margin` is the real
157
- * capital occupied (CTP InvestorPosition.UseMargin) — the unit the maxMargin
158
- * cap tracks. A deliberate resync op (overwrites the held side), so it stays a
159
- * JS-driven call, unlike the passive multiplier / margin-rate feeds (sourced in
160
- * C++). */
161
- seedPosition(instrumentId: string, side: "long" | "short", volume: number, margin: number): this;
162
- /** Seed open-position MARGIN from reqQryInvestorPosition() rows for GROSS-mode
163
- * accounts (posiDirection '2' = long, '3' = short; any other value, incl. net
164
- * '1', is bucketed as short). Uses each row's real UseMargin. Cost/margin caps
165
- * sum both sides so the bucket doesn't matter for them, but a per-side *volume*
166
- * cap on a net-mode instrument would track the wrong side — for net-mode
167
- * accounts, seed those via seedPosition() with the side you intend. */
209
+ setInstrumentMarginLimits(limits: Record<string, number>): this;
210
+ /** Atomically replace held positions from a complete manually reconciled
211
+ * snapshot. `margin` is CTP InvestorPosition.UseMargin. An empty array is an
212
+ * authoritative flat book. Partial/incremental seeding is intentionally not
213
+ * exposed because armed orders can run between JS calls. */
214
+ seedPositions(positions: ReadonlyArray<PositionSeed>): this;
215
+ private replacePositionSeeds;
216
+ /** Atomically replace held position margin from complete gross-mode query rows
217
+ * (`posiDirection` '2' long, '3' short). Net/unknown direction is rejected
218
+ * because guessing a side corrupts per-side volume caps. */
168
219
  seedFromPositions(positions: ReadonlyArray<{
169
220
  instrumentId: string;
170
221
  posiDirection: string;
222
+ hedgeFlag: string;
171
223
  position: number;
172
224
  useMargin: number;
173
225
  }>): this;
174
- /** Current total open-position cost tracked by the C++ risk engine. */
175
- positionCost(): number;
176
- /** Clear all tracked position cost. */
226
+ private aggregatePositions;
227
+ /** Current total open-position margin tracked by the C++ risk engine. */
228
+ get accountMargin(): number;
229
+ /** Clear held position state only and mark it uncertain. Working-order
230
+ * reservations are preserved; openings remain blocked until a complete
231
+ * seedFromPositions() or syncPositions() succeeds. */
177
232
  resetPositions(): this;
178
233
  /**
179
234
  * Run a CTP query with flow-control retries. CTP rate-limits queries (~1/sec)
@@ -184,18 +239,23 @@ export declare class Trader extends TraderBase {
184
239
  * position book, so a flat account doesn't waste the full retry budget).
185
240
  */
186
241
  private queryWithRetry;
242
+ /** Empty position/order snapshots are ambiguous immediately after login. Require
243
+ * the same empty result twice, one query interval apart, before treating it as
244
+ * authoritative. */
245
+ private authoritativeQuery;
187
246
  /** Query instruments so the C++ risk engine picks up their multipliers (it
188
247
  * sources them directly from OnRspQryInstrument — no JS feed). No args queries
189
248
  * all instruments (one request); otherwise the given symbols. Retries through
190
249
  * cold-start flow control. Returns the count of contracts with a multiplier. */
191
250
  syncMultipliers(instrumentIds?: string[]): Promise<number>;
192
- /** Seed open-position MARGIN from CTP (reqQryInvestorPosition) into the cap.
193
- * Uses the logged-in account unless brokerId/investorId are supplied. A
194
- * deliberate resync (resets the held book first), so it stays JS-driven. */
195
- syncPositions(opts?: {
196
- brokerId?: string;
197
- investorId?: string;
198
- }): Promise<number>;
251
+ /** Query investor margin schedules for a bounded universe. The exchange-base
252
+ * query is issued only when the investor row is relative; the shared query
253
+ * scheduler enforces spacing. Returns the number of usable schedules. */
254
+ syncMarginRates(instrumentIds: string[], hedgeFlag?: "1" | "2" | "3" | "5" | "6" | "7"): Promise<number>;
255
+ /** Replace held position margin from CTP (`reqQryInvestorPosition`). The
256
+ * replacement is revision-checked: if an order/trade callback races the
257
+ * snapshot it retries without clearing live state or reservations. */
258
+ syncPositions(): Promise<number>;
199
259
  /**
200
260
  * Rebuild the in-flight reservation from CTP's currently-working orders
201
261
  * (reqQryOrder) - an authoritative resync. Call it after login and after any
@@ -205,10 +265,7 @@ export declare class Trader extends TraderBase {
205
265
  * of working open orders re-reserved. Run syncMultipliers() first so the
206
266
  * reserved cost uses the right contract multiplier.
207
267
  */
208
- syncOrders(opts?: {
209
- brokerId?: string;
210
- investorId?: string;
211
- }): Promise<number>;
268
+ syncOrders(): Promise<number>;
212
269
  /**
213
270
  * Arm a latency-critical trigger: when `md` sees the condition, the order is
214
271
  * sent from C++ on the callback thread (through this Trader's risk gate),
@@ -220,7 +277,7 @@ export declare class Trader extends TraderBase {
220
277
  * how many fired and were sent vs were refused by the risk gate / send.
221
278
  * A blocked armed order is otherwise invisible, so poll this after a trigger
222
279
  * you expected to fire. */
223
- armStats(): {
280
+ get armStats(): {
224
281
  fired: number;
225
282
  blocked: number;
226
283
  };
@@ -234,8 +291,8 @@ export declare class Trader extends TraderBase {
234
291
  on(event: "rtn-trade", cb: (data: Trade, opts: CallbackOptions) => void): this;
235
292
  on(event: "front-connected", cb: (data: undefined, opts: CallbackOptions) => void): this;
236
293
  on(event: "front-disconnected", cb: (reason: number, opts: CallbackOptions) => void): this;
237
- on(event: "rsp-user-login", cb: (data: RspUserLogin, opts: CallbackOptions) => void): this;
238
- on(event: "err-rtn-order-insert", cb: (data: InputOrder, opts: CallbackOptions) => void): this;
294
+ on(event: "rsp-user-login", cb: (data: RspUserLogin | undefined, opts: CallbackOptions) => void): this;
295
+ on(event: "err-rtn-order-insert", cb: (data: InputOrder | undefined, opts: CallbackOptions) => void): this;
239
296
  on(event: string, cb: (...args: never[]) => void): this;
240
297
  }
241
298
  export { TraderEvent };
@@ -1 +1 @@
1
- {"version":3,"file":"trader.d.ts","sourceRoot":"","sources":["../src/trader.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAiB,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAEn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