@hitrading/ctp-node 2.0.0 → 3.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 +67 -0
  2. package/README.md +47 -32
  3. package/README.zh-CN.md +37 -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 +1875 -415
  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 +111 -71
  30. package/dist/trader.d.ts.map +1 -1
  31. package/dist/trader.js +774 -180
  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 +1437 -0
  38. package/docs/API.zh-CN.md +1278 -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 +8 -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 +75 -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 +753 -124
  77. package/src/native-binding.ts +4 -0
  78. package/src/trader.ts +971 -204
  79. package/src/validation.ts +96 -0
package/dist/trader.d.ts CHANGED
@@ -3,43 +3,61 @@ 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
+ }
39
54
  /** Options for the one-call post-connect handshake, {@link Trader.session}. */
40
55
  export interface SessionOptions {
41
56
  brokerId: string;
42
57
  userId: string;
58
+ /** Trading account. Defaults to userId for ordinary retail accounts; set it
59
+ * explicitly when the login operator UserID differs from InvestorID. */
60
+ investorId?: string;
43
61
  password: string;
44
62
  /** Terminal authentication (real accounts require it; SimNow uses
45
63
  * appId "simnow_client_test" / authCode of 16 zeros). Omit both to skip. */
@@ -49,10 +67,14 @@ export interface SessionOptions {
49
67
  * before trading (brokers reject orders otherwise). Default true; set false
50
68
  * for environments that don't need it. */
51
69
  confirmSettlement?: boolean;
52
- /** Which risk inputs to fetch after login (default: all). `multipliers` may
70
+ /** Which risk inputs to fetch after login. Multipliers/positions/orders default
71
+ * on; margin rates require an explicit contract list. `multipliers` may
53
72
  * be `true` (all instruments) or a list of symbols. */
54
73
  sync?: {
55
74
  multipliers?: boolean | string[];
75
+ /** Contracts whose speculation margin schedules should be queried. Omitted
76
+ * by default because CTP requires one rate query per contract. */
77
+ marginRates?: string[];
56
78
  positions?: boolean;
57
79
  orders?: boolean;
58
80
  };
@@ -78,18 +100,31 @@ export declare class Trader extends TraderBase {
78
100
  private investor?;
79
101
  private orderRefSeq;
80
102
  constructor(flowPath: string, fronts: string | string[]);
81
- getApiVersion(): string;
82
- getTradingDay(): string;
103
+ /** A raw login Promise may resolve only with a structurally usable session.
104
+ * Account confirmation itself happens in session(), after request-vs-response
105
+ * identity validation; merely observing a protocol event never grants order
106
+ * authority. */
107
+ protected onRequestResolved(eventName: string | undefined, value: unknown, _options: CallbackOptions): void;
108
+ /** Generated login/logout methods call this only after their request has
109
+ * encoded successfully. Revoke the confirmed JS account at that same atomic
110
+ * transition boundary, so a concurrent sync helper cannot start with the old
111
+ * identity while native risk state is already fail-closed for the new session. */
112
+ protected beginRequestContextTransition(reason: string): void;
113
+ protected shouldTimeoutRequest(requestId: number, sessionTransition: boolean): boolean;
114
+ get apiVersion(): string;
115
+ get tradingDay(): string;
83
116
  /**
84
117
  * One-call post-connect handshake. Call it from the `front-connected` handler
85
118
  * (and again after a reconnect): authenticate (if appId/authCode given) →
86
- * login → confirm settlement → sync multipliers / positions / orders. Each
119
+ * login → confirm settlement → sync multipliers / margin rates / orders /
120
+ * positions. Each
87
121
  * step just wraps the matching req / sync method, so you can hand-roll your
88
122
  * own flow instead when you need finer control. Returns the row counts from
89
123
  * the sync steps. Must run on a connected front (queries need the session up).
90
124
  */
91
125
  session(opts: SessionOptions): Promise<{
92
126
  multipliers: number;
127
+ marginRates: number;
93
128
  positions: number;
94
129
  orders: number;
95
130
  }>;
@@ -97,6 +132,8 @@ export declare class Trader extends TraderBase {
97
132
  * OrderRef as a per-session sequence and rejects a duplicate or non-numeric
98
133
  * ref with "不允许重复报单", so an unset ref would otherwise collide. */
99
134
  private withAutoOrderRef;
135
+ private commitOrderRef;
136
+ private validateOrder;
100
137
  /**
101
138
  * Insert an order through the C++ pre-trade risk gate. Resolves on submission:
102
139
  * CTP sends no success acknowledgement for an accepted order - only
@@ -107,73 +144,74 @@ export declare class Trader extends TraderBase {
107
144
  */
108
145
  reqOrderInsert(req?: Partial<InputOrder>): Promise<void>;
109
146
  /** 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}). */
147
+ setRiskLimits(config: RiskLimits): this;
148
+ /** Enter REDUCE_ONLY atomically at the final vendor-API send barrier. Armed
149
+ * opens remain registered but cannot send until resume(). */
150
+ reduceOnly(): this;
151
+ /** Enter HALT_ALL atomically: both opening and closing order inserts, advanced
152
+ * mutations and bank/futures transfers are refused, and all existing armed
153
+ * triggers are cleared. New arm() calls are rejected until resume().
154
+ * Cancellation actions remain available so working
155
+ * exchange orders can still be withdrawn. */
156
+ haltAll(): this;
157
+ /** Return to NORMAL mode after reduceOnly() or haltAll(). */
119
158
  resume(): this;
120
159
  /** Use a MarketData feed as the live reference for the maxPriceDeviation check.
121
160
  * Wires the feed's C++ snapshot cache straight into this Trader's risk engine,
122
161
  * so the deviation check reads current prices in C++ on the order path (no JS
123
162
  * 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. */
163
+ * Without a fresh reference, an enabled deviation check fails closed. */
125
164
  trackMarketData(md: MarketData): this;
126
165
  /**
127
166
  * Cap the open position (in lots) for one instrument, enforced in C++ on
128
167
  * every opening order. Pass a number to cap both sides at once, or
129
168
  * `{ long, short }` to cap each side separately. Within `{ long, short }`,
130
169
  * **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.
170
+ * is NOT reset to uncapped), and passing `0` for a side removes its cap.
132
171
  * Long and short are always tracked independently.
133
172
  *
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.
173
+ * Held positions and in-flight working opens are counted atomically.
137
174
  *
138
- * td.setMaxPosition("rb2610", 100); // long<=100 and short<=100
139
- * td.setMaxPosition("ru2610", { long: 100, short: 20 });
175
+ * td.setInstrumentPositionLimit("rb2610", 100);
176
+ * td.setInstrumentPositionLimit("ru2610", { long: 100, short: 20 });
140
177
  */
141
- setMaxPosition(instrumentId: string, max: LotCap): this;
178
+ setInstrumentPositionLimit(instrumentId: string, limit: InstrumentPositionLimit): this;
142
179
  /** Cap several instruments at once, e.g.
143
180
  * `{ rb2610: 100, ru2610: { long: 100, short: 20 } }`. */
144
- setMaxPositions(limits: Record<string, LotCap>): this;
181
+ setInstrumentPositionLimits(limits: Record<string, InstrumentPositionLimit>): this;
182
+ private normalizePositionLimit;
145
183
  /**
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.
184
+ * Cap one instrument's scheduled open margin (CTP by-money + by-volume,
185
+ * long and short summed), enforced in C++ on every opening order. This is
186
+ * independent of the account-wide maxAccountMargin cap; both apply. Pass
187
+ * `limit = 0` to remove it. Held and in-flight exposure both count.
151
188
  */
152
- setMaxPositionCost(instrumentId: string, maxCost: number): this;
153
- /** Cap several instruments' open-position cost at once, e.g.
189
+ setInstrumentMarginLimit(instrumentId: string, limit: number): this;
190
+ /** Cap several instruments' scheduled open margin at once, e.g.
154
191
  * `{ 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. */
192
+ setInstrumentMarginLimits(limits: Record<string, number>): this;
193
+ /** Atomically replace held positions from a complete manually reconciled
194
+ * snapshot. `margin` is CTP InvestorPosition.UseMargin. An empty array is an
195
+ * authoritative flat book. Partial/incremental seeding is intentionally not
196
+ * exposed because armed orders can run between JS calls. */
197
+ seedPositions(positions: ReadonlyArray<PositionSeed>): this;
198
+ private replacePositionSeeds;
199
+ /** Atomically replace held position margin from complete gross-mode query rows
200
+ * (`posiDirection` '2' long, '3' short). Net/unknown direction is rejected
201
+ * because guessing a side corrupts per-side volume caps. */
168
202
  seedFromPositions(positions: ReadonlyArray<{
169
203
  instrumentId: string;
170
204
  posiDirection: string;
205
+ hedgeFlag: string;
171
206
  position: number;
172
207
  useMargin: number;
173
208
  }>): this;
174
- /** Current total open-position cost tracked by the C++ risk engine. */
175
- positionCost(): number;
176
- /** Clear all tracked position cost. */
209
+ private aggregatePositions;
210
+ /** Current total open-position margin tracked by the C++ risk engine. */
211
+ get accountMargin(): number;
212
+ /** Clear held position state only and mark it uncertain. Working-order
213
+ * reservations are preserved; openings remain blocked until a complete
214
+ * seedFromPositions() or syncPositions() succeeds. */
177
215
  resetPositions(): this;
178
216
  /**
179
217
  * Run a CTP query with flow-control retries. CTP rate-limits queries (~1/sec)
@@ -184,18 +222,23 @@ export declare class Trader extends TraderBase {
184
222
  * position book, so a flat account doesn't waste the full retry budget).
185
223
  */
186
224
  private queryWithRetry;
225
+ /** Empty position/order snapshots are ambiguous immediately after login. Require
226
+ * the same empty result twice, one query interval apart, before treating it as
227
+ * authoritative. */
228
+ private authoritativeQuery;
187
229
  /** Query instruments so the C++ risk engine picks up their multipliers (it
188
230
  * sources them directly from OnRspQryInstrument — no JS feed). No args queries
189
231
  * all instruments (one request); otherwise the given symbols. Retries through
190
232
  * cold-start flow control. Returns the count of contracts with a multiplier. */
191
233
  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>;
234
+ /** Query investor margin schedules for a bounded universe. The exchange-base
235
+ * query is issued only when the investor row is relative; the shared query
236
+ * scheduler enforces spacing. Returns the number of usable schedules. */
237
+ syncMarginRates(instrumentIds: string[], hedgeFlag?: "1" | "2" | "3" | "5" | "6" | "7"): Promise<number>;
238
+ /** Replace held position margin from CTP (`reqQryInvestorPosition`). The
239
+ * replacement is revision-checked: if an order/trade callback races the
240
+ * snapshot it retries without clearing live state or reservations. */
241
+ syncPositions(): Promise<number>;
199
242
  /**
200
243
  * Rebuild the in-flight reservation from CTP's currently-working orders
201
244
  * (reqQryOrder) - an authoritative resync. Call it after login and after any
@@ -205,10 +248,7 @@ export declare class Trader extends TraderBase {
205
248
  * of working open orders re-reserved. Run syncMultipliers() first so the
206
249
  * reserved cost uses the right contract multiplier.
207
250
  */
208
- syncOrders(opts?: {
209
- brokerId?: string;
210
- investorId?: string;
211
- }): Promise<number>;
251
+ syncOrders(): Promise<number>;
212
252
  /**
213
253
  * Arm a latency-critical trigger: when `md` sees the condition, the order is
214
254
  * sent from C++ on the callback thread (through this Trader's risk gate),
@@ -220,7 +260,7 @@ export declare class Trader extends TraderBase {
220
260
  * how many fired and were sent vs were refused by the risk gate / send.
221
261
  * A blocked armed order is otherwise invisible, so poll this after a trigger
222
262
  * you expected to fire. */
223
- armStats(): {
263
+ get armStats(): {
224
264
  fired: number;
225
265
  blocked: number;
226
266
  };
@@ -234,8 +274,8 @@ export declare class Trader extends TraderBase {
234
274
  on(event: "rtn-trade", cb: (data: Trade, opts: CallbackOptions) => void): this;
235
275
  on(event: "front-connected", cb: (data: undefined, opts: CallbackOptions) => void): this;
236
276
  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;
277
+ on(event: "rsp-user-login", cb: (data: RspUserLogin | undefined, opts: CallbackOptions) => void): this;
278
+ on(event: "err-rtn-order-insert", cb: (data: InputOrder | undefined, opts: CallbackOptions) => void): this;
239
279
  on(event: string, cb: (...args: never[]) => void): this;
240
280
  }
241
281
  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;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,wEAAwE;AACxE,MAAM,WAAW,UAAU;IACzB,sDAAsD;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;gEAE4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;wDAEoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;2BAOuB;IACvB,SAAS,CAAC,EAAE,M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