@0xmonaco/types 1.0.65 → 1.0.66
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/dist/positions/index.d.ts +41 -1
- package/dist/trading/index.d.ts +6 -2
- package/dist/trading/orders.d.ts +4 -2
- package/dist/trading/responses.d.ts +61 -0
- package/dist/validation/positions.d.ts +8 -0
- package/dist/validation/positions.js +5 -3
- package/dist/validation/trading.d.ts +42 -0
- package/dist/validation/trading.js +40 -7
- package/dist/websocket/base.d.ts +68 -14
- package/dist/websocket/events/conditional-order-events.d.ts +29 -1
- package/dist/wire/schema.d.ts +110 -4
- package/package.json +2 -2
|
@@ -249,16 +249,56 @@ export interface TpSlLeg {
|
|
|
249
249
|
slippageToleranceBps?: number;
|
|
250
250
|
expiresAt?: string;
|
|
251
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* A trailing stop attached to an open position (0XM-2827).
|
|
254
|
+
*
|
|
255
|
+
* A reduce-only MARKET close whose trigger trails the best mark price reached
|
|
256
|
+
* since it armed (the watermark) by `trailBps`: for a long, trigger =
|
|
257
|
+
* watermark × (1 − trailBps/10000) and it fires when the mark falls to or below
|
|
258
|
+
* it; a short mirrors it. The trigger only ever moves in the position's
|
|
259
|
+
* favour. One trailing stop per position — a second attach is rejected with
|
|
260
|
+
* HTTP 409. It coexists with `takeProfit` / `stopLoss` and never joins `oco`.
|
|
261
|
+
* There is no modify: cancel and recreate. Fires through the standard
|
|
262
|
+
* conditional market close (1,200 bps protective band, optional slippage cap).
|
|
263
|
+
*/
|
|
264
|
+
export interface TrailingStopLeg {
|
|
265
|
+
/** Retracement behind the watermark in basis points; integer, 10 to 2000 inclusive */
|
|
266
|
+
trailBps: number;
|
|
267
|
+
/**
|
|
268
|
+
* Mark level at which tracking starts, seeding the watermark there. Omitted,
|
|
269
|
+
* tracking starts at the current mark. Rejected if the mark has already
|
|
270
|
+
* reached it. The row stays `ACTIVE` while waiting and `trailArmedAt` is set
|
|
271
|
+
* once it arms.
|
|
272
|
+
*/
|
|
273
|
+
activationPrice?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Deliberate partial size that never resizes. Mutually exclusive with
|
|
276
|
+
* `closePosition: true`; required when `closePosition: false`.
|
|
277
|
+
*/
|
|
278
|
+
quantity?: string;
|
|
279
|
+
/**
|
|
280
|
+
* Resolve the full live position size when triggered. Mutually exclusive
|
|
281
|
+
* with `quantity`. Omitting both also means full-position close.
|
|
282
|
+
*/
|
|
283
|
+
closePosition?: boolean;
|
|
284
|
+
/** Slippage cap for the triggered MARKET close, 0 to 10000 basis points */
|
|
285
|
+
slippageToleranceBps?: number;
|
|
286
|
+
/** Optional conditional order expiry timestamp (ISO 8601) */
|
|
287
|
+
expiresAt?: string;
|
|
288
|
+
}
|
|
252
289
|
export interface AttachPositionTpSlRequest {
|
|
253
290
|
takeProfit?: TpSlLeg;
|
|
254
291
|
stopLoss?: TpSlLeg;
|
|
255
|
-
/**
|
|
292
|
+
/** Trailing stop; may be the only leg. Never part of `oco`. */
|
|
293
|
+
trailingStop?: TrailingStopLeg;
|
|
294
|
+
/** Cancel the sibling after one leg triggers. Requires both fixed legs. */
|
|
256
295
|
oco?: boolean;
|
|
257
296
|
}
|
|
258
297
|
export interface AttachPositionTpSlResponse {
|
|
259
298
|
positionId: string;
|
|
260
299
|
takeProfitOrderId?: string;
|
|
261
300
|
stopLossOrderId?: string;
|
|
301
|
+
trailingStopOrderId?: string;
|
|
262
302
|
status: "SUCCESS" | "FAILED";
|
|
263
303
|
message: string;
|
|
264
304
|
}
|
package/dist/trading/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { BaseAPI } from "../api/index";
|
|
7
7
|
import type { MarginMode } from "../margin-accounts";
|
|
8
8
|
import type { Order, OrderSide, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode } from "./orders";
|
|
9
|
-
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, ParentTpSlLegParams, ReplaceOrderResponse, TwapOrder } from "./responses";
|
|
9
|
+
import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TwapOrder } from "./responses";
|
|
10
10
|
/**
|
|
11
11
|
* Trading API interface.
|
|
12
12
|
* Provides methods for placing and managing orders.
|
|
@@ -66,6 +66,8 @@ export interface TradingAPI extends BaseAPI {
|
|
|
66
66
|
idempotencyKey?: string;
|
|
67
67
|
takeProfit?: ParentTpSlLegParams;
|
|
68
68
|
stopLoss?: ParentTpSlLegParams;
|
|
69
|
+
/** Trailing stop that arms when this order fully fills; margin entry orders only. */
|
|
70
|
+
trailingStop?: ParentTrailingStopLegParams;
|
|
69
71
|
}): Promise<CreateOrderResponse>;
|
|
70
72
|
/**
|
|
71
73
|
* Places a market order for immediate execution.
|
|
@@ -110,6 +112,8 @@ export interface TradingAPI extends BaseAPI {
|
|
|
110
112
|
idempotencyKey?: string;
|
|
111
113
|
takeProfit?: ParentTpSlLegParams;
|
|
112
114
|
stopLoss?: ParentTpSlLegParams;
|
|
115
|
+
/** Trailing stop that arms when this order fully fills; margin entry orders only. */
|
|
116
|
+
trailingStop?: ParentTrailingStopLegParams;
|
|
113
117
|
}): Promise<CreateOrderResponse>;
|
|
114
118
|
/**
|
|
115
119
|
* Cancels an existing order.
|
|
@@ -263,4 +267,4 @@ export interface TradingAPI extends BaseAPI {
|
|
|
263
267
|
}
|
|
264
268
|
export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, ListedOrderType, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
|
|
265
269
|
export { ORDER_STATUS_VALUES } from "./orders";
|
|
266
|
-
export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ReplaceOrderResponse, TriggeredOrderSummary, TwapOrder, UpdatedFields, } from "./responses";
|
|
270
|
+
export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ParentTrailingStopLegParams, ReplaceOrderResponse, TriggeredOrderSummary, TwapOrder, UpdatedFields, } from "./responses";
|
package/dist/trading/orders.d.ts
CHANGED
|
@@ -265,9 +265,11 @@ export type TimeInForce = "GTC" | "IOC" | "FOK" | "GTD";
|
|
|
265
265
|
*/
|
|
266
266
|
export type SelfTradePreventionMode = "CANCEL_MAKER" | "CANCEL_TAKER" | "CANCEL_BOTH" | "SKIP";
|
|
267
267
|
/**
|
|
268
|
-
* Conditional
|
|
268
|
+
* Conditional order condition type: a fixed stop-loss or take-profit, or a
|
|
269
|
+
* trailing stop whose trigger follows the best mark reached since it armed
|
|
270
|
+
* (0XM-2827).
|
|
269
271
|
*/
|
|
270
|
-
export type ConditionalOrderConditionType = "STOP_LOSS" | "TAKE_PROFIT";
|
|
272
|
+
export type ConditionalOrderConditionType = "STOP_LOSS" | "TAKE_PROFIT" | "TRAILING_STOP";
|
|
271
273
|
/**
|
|
272
274
|
* Conditional order trigger source. v1 supports mark-price triggers.
|
|
273
275
|
*/
|
|
@@ -71,6 +71,42 @@ export interface ParentTpSlLegParams {
|
|
|
71
71
|
*/
|
|
72
72
|
closePosition?: boolean;
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* A trailing stop attached to a margin entry order at placement (0XM-2827).
|
|
76
|
+
*
|
|
77
|
+
* A reduce-only MARKET close whose trigger trails the best mark price reached
|
|
78
|
+
* since it armed (the watermark) by `trailBps`: for a long, trigger =
|
|
79
|
+
* watermark × (1 − trailBps/10000) and it fires when the mark falls to or below
|
|
80
|
+
* it; a short mirrors it. The trigger only ever moves in the position's
|
|
81
|
+
* favour. It arms only when the entry order FULLY fills and is cancelled with
|
|
82
|
+
* the order otherwise. One trailing stop per position — a second is rejected
|
|
83
|
+
* with HTTP 409. It coexists with `takeProfit` / `stopLoss` and never joins
|
|
84
|
+
* their OCO link. There is no modify: cancel and recreate.
|
|
85
|
+
*/
|
|
86
|
+
export interface ParentTrailingStopLegParams {
|
|
87
|
+
/** Retracement behind the watermark in basis points; integer, 10 to 2000 inclusive */
|
|
88
|
+
trailBps: number;
|
|
89
|
+
/**
|
|
90
|
+
* Mark level at which tracking starts, seeding the watermark there. Omitted,
|
|
91
|
+
* tracking starts at the first mark after the fill. Rejected if the mark has
|
|
92
|
+
* already reached it.
|
|
93
|
+
*/
|
|
94
|
+
activationPrice?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Deliberate partial size that never resizes. Mutually exclusive with
|
|
97
|
+
* `closePosition: true`; required when `closePosition: false`.
|
|
98
|
+
*/
|
|
99
|
+
quantity?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Resolve the full live position size when triggered. Mutually exclusive
|
|
102
|
+
* with `quantity`. Omitting both also means full-position close.
|
|
103
|
+
*/
|
|
104
|
+
closePosition?: boolean;
|
|
105
|
+
/** Slippage cap for the triggered MARKET close, 0 to 10000 basis points */
|
|
106
|
+
slippageToleranceBps?: number;
|
|
107
|
+
/** Optional conditional order expiry timestamp (ISO 8601) */
|
|
108
|
+
expiresAt?: string;
|
|
109
|
+
}
|
|
74
110
|
/**
|
|
75
111
|
* Response from creating an order.
|
|
76
112
|
*
|
|
@@ -99,6 +135,8 @@ export interface CreateOrderResponse {
|
|
|
99
135
|
takeProfitOrderId?: string;
|
|
100
136
|
/** Conditional order ID for an attached stop-loss leg */
|
|
101
137
|
stopLossOrderId?: string;
|
|
138
|
+
/** Conditional order ID for an attached trailing stop */
|
|
139
|
+
trailingStopOrderId?: string;
|
|
102
140
|
}
|
|
103
141
|
/**
|
|
104
142
|
* Response from cancelling an order.
|
|
@@ -518,6 +556,29 @@ export interface ConditionalOrder {
|
|
|
518
556
|
cancelledAt?: string;
|
|
519
557
|
expiresAt?: string;
|
|
520
558
|
failureReason?: string;
|
|
559
|
+
/**
|
|
560
|
+
* `TRAILING_STOP` only: retracement in basis points behind the watermark.
|
|
561
|
+
* Absent on TP/SL rows. Wire: `trailBps`.
|
|
562
|
+
*/
|
|
563
|
+
trailBps?: number;
|
|
564
|
+
/**
|
|
565
|
+
* `TRAILING_STOP` only: the mark level that starts tracking. Absent when the
|
|
566
|
+
* stop armed immediately. Wire: `activationPrice`.
|
|
567
|
+
*/
|
|
568
|
+
activationPrice?: string;
|
|
569
|
+
/**
|
|
570
|
+
* `TRAILING_STOP` only: best mark (highest for a long, lowest for a short)
|
|
571
|
+
* observed since arming. `triggerPrice` is derived from it and only ever
|
|
572
|
+
* moves in the position's favour. Absent until the first mark is observed
|
|
573
|
+
* after arming. Wire: `watermarkPrice`.
|
|
574
|
+
*/
|
|
575
|
+
watermarkPrice?: string;
|
|
576
|
+
/**
|
|
577
|
+
* `TRAILING_STOP` only: when tracking began (ISO 8601). Absent while the
|
|
578
|
+
* stop is still waiting for `activationPrice` — `state` stays `ACTIVE` in
|
|
579
|
+
* both phases. Wire: `trailArmedAt`.
|
|
580
|
+
*/
|
|
581
|
+
trailArmedAt?: string;
|
|
521
582
|
createdAt: string;
|
|
522
583
|
updatedAt: string;
|
|
523
584
|
/**
|
|
@@ -72,6 +72,14 @@ export declare const AttachPositionTpSlSchema: z.ZodObject<{
|
|
|
72
72
|
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
73
73
|
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
74
74
|
}, z.core.$strip>>;
|
|
75
|
+
trailingStop: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
trailBps: z.ZodNumber;
|
|
77
|
+
activationPrice: z.ZodOptional<z.ZodString>;
|
|
78
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
79
|
+
closePosition: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
75
83
|
oco: z.ZodOptional<z.ZodBoolean>;
|
|
76
84
|
}, z.core.$strip>;
|
|
77
85
|
}, z.core.$strip>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Positions API Validation Schemas
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { ConditionalTimeInForceSchema, ISO8601DateSchema, OrderTypeSchema, PositiveDecimalStringSchema, SlippageToleranceBpsSchema, UUIDSchema, } from "./trading";
|
|
5
|
+
import { ConditionalTimeInForceSchema, ISO8601DateSchema, OrderTypeSchema, PositiveDecimalStringSchema, SlippageToleranceBpsSchema, TrailingStopLegSchema, UUIDSchema, } from "./trading";
|
|
6
6
|
const PaginationSchema = z.object({
|
|
7
7
|
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
8
8
|
pageSize: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
@@ -88,11 +88,13 @@ export const AttachPositionTpSlSchema = PositionIdSchema.extend({
|
|
|
88
88
|
.object({
|
|
89
89
|
takeProfit: TpSlLegSchema.optional(),
|
|
90
90
|
stopLoss: TpSlLegSchema.optional(),
|
|
91
|
+
trailingStop: TrailingStopLegSchema.optional(),
|
|
91
92
|
oco: z.boolean().optional(),
|
|
92
93
|
})
|
|
93
|
-
.refine((data) => data.takeProfit !== undefined || data.stopLoss !== undefined, {
|
|
94
|
-
message: "At least one of takeProfit or
|
|
94
|
+
.refine((data) => data.takeProfit !== undefined || data.stopLoss !== undefined || data.trailingStop !== undefined, {
|
|
95
|
+
message: "At least one of takeProfit, stopLoss, or trailingStop is required",
|
|
95
96
|
})
|
|
97
|
+
// A trailing stop never takes part in OCO: the pair is the two fixed legs.
|
|
96
98
|
.refine((data) => data.oco !== true || (data.takeProfit !== undefined && data.stopLoss !== undefined), {
|
|
97
99
|
message: "oco=true requires both takeProfit and stopLoss",
|
|
98
100
|
path: ["oco"],
|
|
@@ -101,6 +101,31 @@ export declare const ParentTpSlLegSchema: z.ZodObject<{
|
|
|
101
101
|
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
102
102
|
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
103
103
|
}, z.core.$strip>;
|
|
104
|
+
/** Trailing-stop retracement: an integer from 10 to 2000 basis points (0XM-2827). */
|
|
105
|
+
export declare const TrailBpsSchema: z.ZodNumber;
|
|
106
|
+
/**
|
|
107
|
+
* The trailing-stop leg, shared by the position-attached rail and the
|
|
108
|
+
* entry-order rail: the shape is identical on both. The close is always a
|
|
109
|
+
* reduce-only MARKET order, so there is no order type, limit price or time in
|
|
110
|
+
* force to check — only the ratchet distance, the optional activation level,
|
|
111
|
+
* the same sizing contract a TP/SL leg carries, and the slippage cap.
|
|
112
|
+
*/
|
|
113
|
+
export declare const TrailingStopLegSchema: z.ZodObject<{
|
|
114
|
+
trailBps: z.ZodNumber;
|
|
115
|
+
activationPrice: z.ZodOptional<z.ZodString>;
|
|
116
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
117
|
+
closePosition: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
119
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
export declare const ParentTrailingStopLegSchema: z.ZodObject<{
|
|
122
|
+
trailBps: z.ZodNumber;
|
|
123
|
+
activationPrice: z.ZodOptional<z.ZodString>;
|
|
124
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
125
|
+
closePosition: z.ZodOptional<z.ZodBoolean>;
|
|
126
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
127
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
128
|
+
}, z.core.$strip>;
|
|
104
129
|
/**
|
|
105
130
|
* Place Limit Order validation schema
|
|
106
131
|
*/
|
|
@@ -180,6 +205,14 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
|
|
|
180
205
|
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
181
206
|
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
182
207
|
}, z.core.$strip>>;
|
|
208
|
+
trailingStop: z.ZodOptional<z.ZodObject<{
|
|
209
|
+
trailBps: z.ZodNumber;
|
|
210
|
+
activationPrice: z.ZodOptional<z.ZodString>;
|
|
211
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
212
|
+
closePosition: z.ZodOptional<z.ZodBoolean>;
|
|
213
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
214
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
215
|
+
}, z.core.$strip>>;
|
|
183
216
|
}, z.core.$strip>>;
|
|
184
217
|
}, z.core.$strip>;
|
|
185
218
|
/**
|
|
@@ -252,6 +285,14 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
|
|
|
252
285
|
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
253
286
|
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
254
287
|
}, z.core.$strip>>;
|
|
288
|
+
trailingStop: z.ZodOptional<z.ZodObject<{
|
|
289
|
+
trailBps: z.ZodNumber;
|
|
290
|
+
activationPrice: z.ZodOptional<z.ZodString>;
|
|
291
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
292
|
+
closePosition: z.ZodOptional<z.ZodBoolean>;
|
|
293
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
295
|
+
}, z.core.$strip>>;
|
|
255
296
|
}, z.core.$strip>>;
|
|
256
297
|
}, z.core.$strip>;
|
|
257
298
|
/**
|
|
@@ -327,6 +368,7 @@ export declare const GetPaginatedOrdersSchema: z.ZodObject<{
|
|
|
327
368
|
export declare const ConditionalOrderConditionTypeSchema: z.ZodEnum<{
|
|
328
369
|
STOP_LOSS: "STOP_LOSS";
|
|
329
370
|
TAKE_PROFIT: "TAKE_PROFIT";
|
|
371
|
+
TRAILING_STOP: "TRAILING_STOP";
|
|
330
372
|
}>;
|
|
331
373
|
export declare const ConditionalOrderTriggerSourceSchema: z.ZodEnum<{
|
|
332
374
|
MARK_PRICE: "MARK_PRICE";
|
|
@@ -138,7 +138,38 @@ export const ParentTpSlLegSchema = z
|
|
|
138
138
|
message: "quantity is required when closePosition is false",
|
|
139
139
|
path: ["closePosition"],
|
|
140
140
|
});
|
|
141
|
-
|
|
141
|
+
/** Trailing-stop retracement: an integer from 10 to 2000 basis points (0XM-2827). */
|
|
142
|
+
export const TrailBpsSchema = z
|
|
143
|
+
.number()
|
|
144
|
+
.int("trailBps must be an integer number of basis points")
|
|
145
|
+
.min(10, "trailBps must be at least 10 bps")
|
|
146
|
+
.max(2000, "trailBps cannot exceed 2000 bps");
|
|
147
|
+
/**
|
|
148
|
+
* The trailing-stop leg, shared by the position-attached rail and the
|
|
149
|
+
* entry-order rail: the shape is identical on both. The close is always a
|
|
150
|
+
* reduce-only MARKET order, so there is no order type, limit price or time in
|
|
151
|
+
* force to check — only the ratchet distance, the optional activation level,
|
|
152
|
+
* the same sizing contract a TP/SL leg carries, and the slippage cap.
|
|
153
|
+
*/
|
|
154
|
+
export const TrailingStopLegSchema = z
|
|
155
|
+
.object({
|
|
156
|
+
trailBps: TrailBpsSchema,
|
|
157
|
+
activationPrice: PositiveDecimalStringSchema.optional(),
|
|
158
|
+
quantity: PositiveDecimalStringSchema.optional(),
|
|
159
|
+
closePosition: z.boolean().optional(),
|
|
160
|
+
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
161
|
+
expiresAt: ISO8601DateSchema.optional(),
|
|
162
|
+
})
|
|
163
|
+
.refine((data) => data.closePosition !== true || data.quantity === undefined, {
|
|
164
|
+
message: "quantity must be omitted when closePosition is true",
|
|
165
|
+
path: ["quantity"],
|
|
166
|
+
})
|
|
167
|
+
.refine((data) => data.quantity !== undefined || data.closePosition !== false, {
|
|
168
|
+
message: "quantity is required when closePosition is false",
|
|
169
|
+
path: ["closePosition"],
|
|
170
|
+
});
|
|
171
|
+
export const ParentTrailingStopLegSchema = TrailingStopLegSchema;
|
|
172
|
+
const hasParentTpSl = (options) => options?.takeProfit !== undefined || options?.stopLoss !== undefined || options?.trailingStop !== undefined;
|
|
142
173
|
const legacyPositionSideMatchesOrderSide = (side, positionSide) => positionSide === undefined || (positionSide !== "NONE" && ((side === "BUY" && positionSide === "LONG") || (side === "SELL" && positionSide === "SHORT")));
|
|
143
174
|
/**
|
|
144
175
|
* Place Limit Order validation schema
|
|
@@ -173,6 +204,7 @@ export const PlaceLimitOrderSchema = z
|
|
|
173
204
|
selfTradePreventionMode: SelfTradePreventionModeSchema.optional(),
|
|
174
205
|
takeProfit: ParentTpSlLegSchema.optional(),
|
|
175
206
|
stopLoss: ParentTpSlLegSchema.optional(),
|
|
207
|
+
trailingStop: ParentTrailingStopLegSchema.optional(),
|
|
176
208
|
})
|
|
177
209
|
.optional(),
|
|
178
210
|
})
|
|
@@ -185,11 +217,11 @@ export const PlaceLimitOrderSchema = z
|
|
|
185
217
|
path: ["options", "leverage"],
|
|
186
218
|
})
|
|
187
219
|
.refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
|
|
188
|
-
message: "takeProfit/stopLoss are only supported for MARGIN orders",
|
|
220
|
+
message: "takeProfit/stopLoss/trailingStop are only supported for MARGIN orders",
|
|
189
221
|
path: ["options"],
|
|
190
222
|
})
|
|
191
223
|
.refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
|
|
192
|
-
message: "takeProfit/stopLoss cannot be attached to reduce-only orders",
|
|
224
|
+
message: "takeProfit/stopLoss/trailingStop cannot be attached to reduce-only orders",
|
|
193
225
|
path: ["options"],
|
|
194
226
|
})
|
|
195
227
|
.refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
|
|
@@ -252,6 +284,7 @@ export const PlaceMarketOrderSchema = z
|
|
|
252
284
|
selfTradePreventionMode: SelfTradePreventionModeSchema.optional(),
|
|
253
285
|
takeProfit: ParentTpSlLegSchema.optional(),
|
|
254
286
|
stopLoss: ParentTpSlLegSchema.optional(),
|
|
287
|
+
trailingStop: ParentTrailingStopLegSchema.optional(),
|
|
255
288
|
})
|
|
256
289
|
.optional(),
|
|
257
290
|
})
|
|
@@ -264,11 +297,11 @@ export const PlaceMarketOrderSchema = z
|
|
|
264
297
|
path: ["options", "leverage"],
|
|
265
298
|
})
|
|
266
299
|
.refine((data) => !hasParentTpSl(data.options) || data.options?.tradingMode === "MARGIN", {
|
|
267
|
-
message: "takeProfit/stopLoss are only supported for MARGIN orders",
|
|
300
|
+
message: "takeProfit/stopLoss/trailingStop are only supported for MARGIN orders",
|
|
268
301
|
path: ["options"],
|
|
269
302
|
})
|
|
270
303
|
.refine((data) => !hasParentTpSl(data.options) || data.options?.reduceOnly !== true, {
|
|
271
|
-
message: "takeProfit/stopLoss cannot be attached to reduce-only orders",
|
|
304
|
+
message: "takeProfit/stopLoss/trailingStop cannot be attached to reduce-only orders",
|
|
272
305
|
path: ["options"],
|
|
273
306
|
})
|
|
274
307
|
.refine((data) => data.options?.riskBucketCollateral === undefined || data.options?.tradingMode === "MARGIN", {
|
|
@@ -372,8 +405,8 @@ export const GetPaginatedOrdersSchema = z
|
|
|
372
405
|
});
|
|
373
406
|
}
|
|
374
407
|
});
|
|
375
|
-
export const ConditionalOrderConditionTypeSchema = z.enum(["STOP_LOSS", "TAKE_PROFIT"], {
|
|
376
|
-
message: 'conditionType must be "STOP_LOSS" or "
|
|
408
|
+
export const ConditionalOrderConditionTypeSchema = z.enum(["STOP_LOSS", "TAKE_PROFIT", "TRAILING_STOP"], {
|
|
409
|
+
message: 'conditionType must be "STOP_LOSS", "TAKE_PROFIT", or "TRAILING_STOP"',
|
|
377
410
|
});
|
|
378
411
|
export const ConditionalOrderTriggerSourceSchema = z.enum(["MARK_PRICE"], {
|
|
379
412
|
message: 'triggerSource must be "MARK_PRICE"',
|
package/dist/websocket/base.d.ts
CHANGED
|
@@ -82,9 +82,39 @@ export interface WebSocketErrorInfo {
|
|
|
82
82
|
code: WebSocketErrorCode | (string & {});
|
|
83
83
|
/** Human-readable description; for logging and display, never for branching. */
|
|
84
84
|
message: string;
|
|
85
|
+
/**
|
|
86
|
+
* The channel a per-channel failure concerns, echoed exactly as this client
|
|
87
|
+
* sent it (an unparseable string included). Present on
|
|
88
|
+
* `INVALID_SUBSCRIPTION`, `AUTH_REQUIRED`, `SUBSCRIPTION_LIMIT` and
|
|
89
|
+
* `SNAPSHOT_UNAVAILABLE`; absent on connection-wide failures.
|
|
90
|
+
*
|
|
91
|
+
* `Subscribed` / `Unsubscribed` acks list only the channels a request
|
|
92
|
+
* changed, so a rejected channel is missing from the ack and reported by
|
|
93
|
+
* its own `Error` frame instead — this is how to pair the two, e.g. to
|
|
94
|
+
* resync only the channel whose snapshot was unavailable.
|
|
95
|
+
*/
|
|
96
|
+
channel?: string;
|
|
85
97
|
}
|
|
86
98
|
/** Handler invoked for every `Error` frame the server sends. */
|
|
87
99
|
export type ErrorHandler = (info: WebSocketErrorInfo) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Why the connection stopped reconnecting and needs fresh credentials.
|
|
102
|
+
* Delivered by {@link MonacoWebSocketConfig.onReauthenticationRequired}.
|
|
103
|
+
*/
|
|
104
|
+
export interface WebSocketReauthenticationInfo {
|
|
105
|
+
/**
|
|
106
|
+
* The `Error` frame code that ended the connection: `SESSION_INVALID` (the
|
|
107
|
+
* session was revoked or expired after the handshake) or `AUTH_FAILED` (the
|
|
108
|
+
* `Authenticate` handshake itself was rejected).
|
|
109
|
+
*/
|
|
110
|
+
code: "SESSION_INVALID" | "AUTH_FAILED";
|
|
111
|
+
/** Human-readable description from the `Error` frame; for logging and display, never for branching. */
|
|
112
|
+
message: string;
|
|
113
|
+
/** WebSocket close code of the connection that was lost (1008 for `SESSION_INVALID`). */
|
|
114
|
+
closeCode: number;
|
|
115
|
+
}
|
|
116
|
+
/** Handler invoked when the connection lost its authentication terminally. */
|
|
117
|
+
export type ReauthenticationRequiredHandler = (info: WebSocketReauthenticationInfo) => void;
|
|
88
118
|
/**
|
|
89
119
|
* Reconnect/resync knobs and callbacks for the Monaco WebSocket client.
|
|
90
120
|
*
|
|
@@ -121,23 +151,47 @@ export interface MonacoWebSocketConfig {
|
|
|
121
151
|
/**
|
|
122
152
|
* Called for every `Error` frame the server sends on this connection.
|
|
123
153
|
*
|
|
124
|
-
* `Error` frames
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
154
|
+
* `Error` frames match no subscription, so they reach no channel handler —
|
|
155
|
+
* without this callback a failed subscribe, an invalidated session, or an
|
|
156
|
+
* unreadable subscribe-time snapshot is invisible to the app. A failure
|
|
157
|
+
* caused by one requested channel additionally carries
|
|
158
|
+
* {@link WebSocketErrorInfo.channel}, the channel string this client sent;
|
|
159
|
+
* a connection-wide failure carries none. Branch on `code`:
|
|
128
160
|
*
|
|
129
|
-
* - `SNAPSHOT_UNAVAILABLE` — live diffs flow but
|
|
130
|
-
* refetch it. The subscription itself is fine.
|
|
131
|
-
* - `SESSION_INVALID` —
|
|
132
|
-
*
|
|
133
|
-
* - `AUTH_REQUIRED` — a rejected SUBSCRIBE
|
|
134
|
-
*
|
|
135
|
-
* so it treats the channel as subscribed and sends no new
|
|
136
|
-
* Re-authenticating alone leaves it dead. Release the last
|
|
137
|
-
* channel and subscribe again after authenticating
|
|
138
|
-
* this automatically).
|
|
161
|
+
* - `SNAPSHOT_UNAVAILABLE` — live diffs flow but that channel's baseline is
|
|
162
|
+
* missing; refetch it for `channel` alone. The subscription itself is fine.
|
|
163
|
+
* - `SESSION_INVALID` — the session was revoked or expired; the connection
|
|
164
|
+
* closes and {@link onReauthenticationRequired} follows. No `channel`.
|
|
165
|
+
* - `AUTH_REQUIRED` — a rejected SUBSCRIBE of `channel`, not an invalidated
|
|
166
|
+
* session: it was never registered, and this client still holds your
|
|
167
|
+
* handler, so it treats the channel as subscribed and sends no new
|
|
168
|
+
* `Subscribe`. Re-authenticating alone leaves it dead. Release the last
|
|
169
|
+
* handler for that channel and subscribe again after authenticating
|
|
170
|
+
* (0XM-2644 tracks doing this automatically).
|
|
139
171
|
*/
|
|
140
172
|
onError?: ErrorHandler;
|
|
173
|
+
/**
|
|
174
|
+
* Called once when the connection lost its authentication terminally: the
|
|
175
|
+
* server invalidated the session (`SESSION_INVALID`, then a 1008 close) or
|
|
176
|
+
* rejected this connection's `Authenticate` handshake (`AUTH_FAILED`).
|
|
177
|
+
*
|
|
178
|
+
* Reconnecting with the same credentials would only be rejected again, so
|
|
179
|
+
* the client does not reconnect automatically after either. It forgets the
|
|
180
|
+
* rejected session keypair, keeps your subscription handlers, and reports
|
|
181
|
+
* `"disconnected"`. Obtain a fresh session and pass it to
|
|
182
|
+
* `setSessionKeypair` (the SDK's `login` does this): the client reconnects,
|
|
183
|
+
* authenticates with it, resubscribes every held channel, and fires
|
|
184
|
+
* {@link onResync} so you can reconcile what was missed — also when
|
|
185
|
+
* {@link autoReconnect} is off. A session you already replaced before the
|
|
186
|
+
* close (e.g. from {@link onError}) is kept, and the client reconnects with
|
|
187
|
+
* it instead of calling this. Supply the fresh session rather than calling
|
|
188
|
+
* `connect()` first: a session-less socket re-sends user-specific channels
|
|
189
|
+
* unauthenticated, and the server rejects them with `AUTH_REQUIRED`.
|
|
190
|
+
*
|
|
191
|
+
* Every other abnormal close — including a 1008 for exceeding the message
|
|
192
|
+
* rate cap and a 1013 slow-client shed — keeps the backoff reconnect.
|
|
193
|
+
*/
|
|
194
|
+
onReauthenticationRequired?: ReauthenticationRequiredHandler;
|
|
141
195
|
}
|
|
142
196
|
/**
|
|
143
197
|
* Raw event message interface
|
|
@@ -7,8 +7,13 @@ import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalO
|
|
|
7
7
|
* wire field is a free-form server string rather than a closed enum, so this
|
|
8
8
|
* alias is documentation and a narrowing aid only. Match on it with a default
|
|
9
9
|
* branch; see `ConditionalOrderEventData.reason`.
|
|
10
|
+
*
|
|
11
|
+
* A `TRAILING_STOP` row adds two: `armed` when tracking begins (its
|
|
12
|
+
* `activationPrice` was reached, or immediately when none was set) and
|
|
13
|
+
* `ratcheted` on every move of its trigger, carrying the new `triggerPrice`
|
|
14
|
+
* and the `watermarkPrice` it was derived from (0XM-2827).
|
|
10
15
|
*/
|
|
11
|
-
export type ConditionalOrderEventReason = "created" | "activated" | "cancelled" | "parent_cancelled" | "triggered" | "failed" | "oco_cancelled";
|
|
16
|
+
export type ConditionalOrderEventReason = "created" | "activated" | "cancelled" | "parent_cancelled" | "triggered" | "failed" | "oco_cancelled" | "armed" | "ratcheted";
|
|
12
17
|
/**
|
|
13
18
|
* A conditional (TP/SL) order's current state.
|
|
14
19
|
*
|
|
@@ -82,6 +87,29 @@ export interface ConditionalOrderEventData {
|
|
|
82
87
|
cancelledAt?: string;
|
|
83
88
|
expiresAt?: string;
|
|
84
89
|
failureReason?: string;
|
|
90
|
+
/**
|
|
91
|
+
* `TRAILING_STOP` only: retracement in basis points behind the watermark.
|
|
92
|
+
* Absent (`null` on the wire) on TP/SL rows. Wire: `trail_bps`.
|
|
93
|
+
*/
|
|
94
|
+
trailBps?: number;
|
|
95
|
+
/**
|
|
96
|
+
* `TRAILING_STOP` only: the mark level that starts tracking. Absent when the
|
|
97
|
+
* stop armed immediately. Wire: `activation_price`.
|
|
98
|
+
*/
|
|
99
|
+
activationPrice?: string;
|
|
100
|
+
/**
|
|
101
|
+
* `TRAILING_STOP` only: best mark (highest for a long, lowest for a short)
|
|
102
|
+
* observed since arming — `triggerPrice` is derived from it and only ever
|
|
103
|
+
* moves in the position's favour. A `ratcheted` frame carries both. Absent
|
|
104
|
+
* until the first mark is observed after arming. Wire: `watermark_price`.
|
|
105
|
+
*/
|
|
106
|
+
watermarkPrice?: string;
|
|
107
|
+
/**
|
|
108
|
+
* `TRAILING_STOP` only: when tracking began (ISO 8601). Absent while the
|
|
109
|
+
* stop is still waiting for `activationPrice` — `state` stays `ACTIVE` in
|
|
110
|
+
* both phases. Wire: `trail_armed_at`.
|
|
111
|
+
*/
|
|
112
|
+
trailArmedAt?: string;
|
|
85
113
|
/**
|
|
86
114
|
* What produced this update. Free-form on the wire — the server field is a
|
|
87
115
|
* plain string, not an enum — but a live update's canonical values are the
|
package/dist/wire/schema.d.ts
CHANGED
|
@@ -2972,13 +2972,18 @@ export interface components {
|
|
|
2972
2972
|
updatedAt?: string | null;
|
|
2973
2973
|
};
|
|
2974
2974
|
AttachPositionTpSlRequest: {
|
|
2975
|
+
/**
|
|
2976
|
+
* @description Trailing stop (0XM-2827). May be attached alone or alongside take_profit /
|
|
2977
|
+
* stop_loss; it never takes part in oco and coexists with fixed legs.
|
|
2978
|
+
*/
|
|
2979
|
+
trailingStop?: components["schemas"]["TrailingStopLeg"] | null;
|
|
2980
|
+
takeProfit?: components["schemas"]["TpSlLeg"];
|
|
2981
|
+
stopLoss?: components["schemas"]["TpSlLeg"];
|
|
2975
2982
|
/**
|
|
2976
2983
|
* @description One-cancels-the-other. Defaults to false. When true, both take_profit and
|
|
2977
2984
|
* stop_loss are required and the sibling is cancelled after either triggers.
|
|
2978
2985
|
*/
|
|
2979
2986
|
oco?: boolean | null;
|
|
2980
|
-
takeProfit?: components["schemas"]["TpSlLeg"];
|
|
2981
|
-
stopLoss?: components["schemas"]["TpSlLeg"];
|
|
2982
2987
|
};
|
|
2983
2988
|
AttachPositionTpSlResponse: {
|
|
2984
2989
|
positionId?: string | null;
|
|
@@ -2986,6 +2991,7 @@ export interface components {
|
|
|
2986
2991
|
stopLossOrderId?: string | null;
|
|
2987
2992
|
status?: string | null;
|
|
2988
2993
|
message?: string | null;
|
|
2994
|
+
trailingStopOrderId?: string | null;
|
|
2989
2995
|
};
|
|
2990
2996
|
BatchCancelAllResponse: {
|
|
2991
2997
|
/**
|
|
@@ -3691,6 +3697,17 @@ export interface components {
|
|
|
3691
3697
|
version?: number | null;
|
|
3692
3698
|
/** @description Present only when state is TRIGGERED: the execution outcome of the order this conditional fired into (triggeredOrderId) — status, filled quantity, volume-weighted average fill price, taker fees and fill time — read from that order at request time. Trigger price and fill price are different numbers: the trigger fires on the mark price and the leg then trades against the book, so a MARKET leg fills at least the half-spread plus its own impact away from triggerPrice, and a LIMIT leg may still be resting (SUBMITTED / PARTIALLY_FILLED) or have been cut by the protective band (CANCELLED with a terminalReason). Absent while waiting on the trigger, on the conditional_orders WebSocket frames, and in the rare case the triggered order cannot be read. */
|
|
3693
3699
|
triggeredOrder?: components["schemas"]["TriggeredOrderSummary"] | null;
|
|
3700
|
+
/**
|
|
3701
|
+
* Format: int32
|
|
3702
|
+
* @description TRAILING_STOP only: retracement in basis points behind the watermark.
|
|
3703
|
+
*/
|
|
3704
|
+
trailBps?: number | null;
|
|
3705
|
+
/** @description TRAILING_STOP only: mark level that starts tracking. Absent when the stop armed immediately. */
|
|
3706
|
+
activationPrice?: string | null;
|
|
3707
|
+
/** @description TRAILING_STOP only: best mark (highest for a long, lowest for a short) observed since arming. triggerPrice is derived from it and only ever moves in the position's favour. Absent until the first mark is observed after arming. */
|
|
3708
|
+
watermarkPrice?: string | null;
|
|
3709
|
+
/** @description TRAILING_STOP only: when tracking began. Absent while the stop is still waiting for activationPrice (state stays ACTIVE in both phases). */
|
|
3710
|
+
trailArmedAt?: string | null;
|
|
3694
3711
|
};
|
|
3695
3712
|
CreateDelegatedSessionRequest: {
|
|
3696
3713
|
/**
|
|
@@ -3866,6 +3883,8 @@ export interface components {
|
|
|
3866
3883
|
* @enum {string|null}
|
|
3867
3884
|
*/
|
|
3868
3885
|
selfTradePreventionMode?: "CANCEL_MAKER" | "CANCEL_TAKER" | "CANCEL_BOTH" | "SKIP" | null;
|
|
3886
|
+
/** @description Trailing stop attached to this entry order (margin only). Arms only when the order fully fills; cancelled with the order otherwise. One per position. */
|
|
3887
|
+
trailingStop?: components["schemas"]["ParentTrailingStopLeg"] | null;
|
|
3869
3888
|
};
|
|
3870
3889
|
CreateOrderResponse: {
|
|
3871
3890
|
/**
|
|
@@ -3912,6 +3931,11 @@ export interface components {
|
|
|
3912
3931
|
* @description Delegated agent UUID when submitted through a delegated session
|
|
3913
3932
|
*/
|
|
3914
3933
|
delegationId?: string | null;
|
|
3934
|
+
/**
|
|
3935
|
+
* Format: uuid
|
|
3936
|
+
* @description Conditional order id of the trailing stop attached to this entry order, when one was requested
|
|
3937
|
+
*/
|
|
3938
|
+
trailingStopOrderId?: string | null;
|
|
3915
3939
|
};
|
|
3916
3940
|
CreateTwapOrderRequest: {
|
|
3917
3941
|
/**
|
|
@@ -5570,7 +5594,7 @@ export interface components {
|
|
|
5570
5594
|
cumFees?: string | null;
|
|
5571
5595
|
/**
|
|
5572
5596
|
* Format: int64
|
|
5573
|
-
* @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery,
|
|
5597
|
+
* @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, persists the account's snapshot and restamps the positions it changed), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. The version advances exactly when the row's versioned content changed at that sequence, a change undone within one persistence batch included; a position a command left unchanged keeps its version, so a RANKED live frame for an untouched sibling of a filled position can carry a higher version than the persisted row while describing identical content — rank it as newer, and nothing changes. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
|
|
5574
5598
|
* @example 918342
|
|
5575
5599
|
*/
|
|
5576
5600
|
version?: number | null;
|
|
@@ -6723,6 +6747,46 @@ export interface components {
|
|
|
6723
6747
|
*/
|
|
6724
6748
|
closePosition?: boolean | null;
|
|
6725
6749
|
};
|
|
6750
|
+
/**
|
|
6751
|
+
* @description Trailing stop leg on an entry order (0XM-2827). Same ratchet semantics as
|
|
6752
|
+
* TrailingStopLeg on the position-attached rail: reduce-only MARKET close,
|
|
6753
|
+
* trigger trails the watermark by trail_bps in the position's favour, fires
|
|
6754
|
+
* through the standard conditional market close path.
|
|
6755
|
+
*/
|
|
6756
|
+
ParentTrailingStopLeg: {
|
|
6757
|
+
/**
|
|
6758
|
+
* Format: int32
|
|
6759
|
+
* @description Retracement in basis points behind the best mark reached since arming; integer, 10 to 2000 inclusive.
|
|
6760
|
+
* @example 150
|
|
6761
|
+
*/
|
|
6762
|
+
trailBps?: number | null;
|
|
6763
|
+
/**
|
|
6764
|
+
* @description Optional mark level that starts tracking once the entry has fully filled. Omit to start tracking at the first mark after the fill. Rejected at attach time if already met by the current mark.
|
|
6765
|
+
* @example 66000
|
|
6766
|
+
*/
|
|
6767
|
+
activationPrice?: string | null;
|
|
6768
|
+
/**
|
|
6769
|
+
* @description Deliberate partial size that never resizes. Mutually exclusive with closePosition; omit both to close the full live position at trigger time.
|
|
6770
|
+
* @example 0.5
|
|
6771
|
+
*/
|
|
6772
|
+
quantity?: string | null;
|
|
6773
|
+
/**
|
|
6774
|
+
* @description Resolve the full live position size when triggered. Mutually exclusive with quantity.
|
|
6775
|
+
* @example true
|
|
6776
|
+
*/
|
|
6777
|
+
closePosition?: boolean | null;
|
|
6778
|
+
/**
|
|
6779
|
+
* Format: int32
|
|
6780
|
+
* @description Slippage cap in basis points for the triggered MARKET close (TP/SL parity).
|
|
6781
|
+
* @example 1000
|
|
6782
|
+
*/
|
|
6783
|
+
slippageToleranceBps?: number | null;
|
|
6784
|
+
/**
|
|
6785
|
+
* @description Optional expiry timestamp (ISO 8601)
|
|
6786
|
+
* @example 2026-06-01T00:00:00Z
|
|
6787
|
+
*/
|
|
6788
|
+
expiresAt?: string | null;
|
|
6789
|
+
};
|
|
6726
6790
|
/**
|
|
6727
6791
|
* @description A single pending withdrawal in a list response. A lightweight summary — the
|
|
6728
6792
|
* executable calldata is not included (it does not exist until the withdrawal
|
|
@@ -7187,7 +7251,7 @@ export interface components {
|
|
|
7187
7251
|
cumFees?: string | null;
|
|
7188
7252
|
/**
|
|
7189
7253
|
* Format: int64
|
|
7190
|
-
* @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: it means the row predates this field or came from a producer that does not stamp it, so treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery,
|
|
7254
|
+
* @description Opaque, non-negative producer-owned version for this position row. Compare only within the same position; higher is newer. 0 is the unranked legacy sentinel and never participates in ordering: it means the row predates this field or came from a producer that does not stamp it, so treat it exactly as an absent version and fall back to a full field comparison rather than ranking it as oldest. It advances on sequenced position mutations (open, add, reduce, close, funding, margin transfer, liquidation, ADL) and is shared by the persisted read, the WebSocket positions snapshot and a RANKED live position_update frame. A live frame is ranked only when it is a faithful projection of the row persisted at that sequence: in practice the fills that leave a position open. Frames that re-read live risk state after sequencing (funding, margin_added/margin_reduced) and terminal frames (which report size 0 and LIQUIDATED, while the stored row keeps its size and records CLOSED) omit the version even though the mutation did advance the persisted one, so an absent version never implies that nothing was persisted. mark_price, unrealized_pnl, liquidation_price, leverage, maintenance_margin_required and initial_margin_required are UNVERSIONED valuation fields, re-derived per payload rather than served from the versioned row: the version does not advance for them (five move with the oracle mark; leverage does not, being opening notional over posted margin, but the live surfaces derive it while the persisted row serves its stored column, so it can still disagree at an unchanged version) (a valuation-only oracle tick persists nothing; a state-transitioning one, a breach or recovery, persists the account's snapshot and restamps the positions it changed), so the merge rule is per field group — on an equal version skip the versioned fields but still take all six from the newer payload, because discarding a whole payload on an equal version freezes displayed PnL and can leave a stale margin requirement on screen. isolated_margin is the one exception among the versioned fields: the WebSocket positions snapshot overlays it from an independent live matching-engine read rather than the versioned row, so take it from the newest payload on an equal version too or a consumer can retain stale backing. The version advances exactly when the row's versioned content changed at that sequence, a change undone within one persistence batch included; a position a command left unchanged keeps its version, so a RANKED live frame for an untouched sibling of a filled position can carry a higher version than the persisted row while describing identical content — rank it as newer, and nothing changes. A response served from live matching-engine state reports 0 (unranked): the engine holds the state but not the version.
|
|
7191
7255
|
* @example 918342
|
|
7192
7256
|
*/
|
|
7193
7257
|
version?: number | null;
|
|
@@ -8524,6 +8588,41 @@ export interface components {
|
|
|
8524
8588
|
*/
|
|
8525
8589
|
quoteAssetName?: string | null;
|
|
8526
8590
|
};
|
|
8591
|
+
/**
|
|
8592
|
+
* @description Trailing stop leg (0XM-2827). Reduce-only MARKET close whose trigger trails
|
|
8593
|
+
* the best mark price reached since it armed (the "watermark") by `trail_bps`:
|
|
8594
|
+
* for a long, trigger = watermark x (1 - trail_bps/10000) and fires when mark
|
|
8595
|
+
* falls to or below it; for a short, trigger = watermark x (1 + trail_bps/10000)
|
|
8596
|
+
* and fires when mark rises to or above it. The trigger only ever moves in the
|
|
8597
|
+
* position's favour. One trailing stop per position; a second attach is
|
|
8598
|
+
* rejected with a conflict, never a replace. Fires through the same market
|
|
8599
|
+
* close path as a TP/SL (1,200 bps protective band, optional slippage cap).
|
|
8600
|
+
*/
|
|
8601
|
+
TrailingStopLeg: {
|
|
8602
|
+
/**
|
|
8603
|
+
* Format: int32
|
|
8604
|
+
* @description Retracement in basis points, integer, 10 to 2000 inclusive.
|
|
8605
|
+
*/
|
|
8606
|
+
trailBps?: number | null;
|
|
8607
|
+
/**
|
|
8608
|
+
* @description Optional mark level that starts tracking. Omitted: tracking starts
|
|
8609
|
+
* immediately at the current mark. Present: rejected if the mark has
|
|
8610
|
+
* already reached it; once reached, the watermark seeds at this level.
|
|
8611
|
+
*/
|
|
8612
|
+
activationPrice?: string | null;
|
|
8613
|
+
/**
|
|
8614
|
+
* @description Deliberate partial size; mutually exclusive with close_position. Omit both
|
|
8615
|
+
* to close the full live position at trigger time. Same contract as TpSlLeg.
|
|
8616
|
+
*/
|
|
8617
|
+
quantity?: string | null;
|
|
8618
|
+
closePosition?: boolean | null;
|
|
8619
|
+
/**
|
|
8620
|
+
* Format: int32
|
|
8621
|
+
* @description Slippage cap for the triggered MARKET close, 0 to 10000 bps (TP/SL parity).
|
|
8622
|
+
*/
|
|
8623
|
+
slippageToleranceBps?: number | null;
|
|
8624
|
+
expiresAt?: string | null;
|
|
8625
|
+
};
|
|
8527
8626
|
TransferCollateralFromMarginAccountRequest: {
|
|
8528
8627
|
/** @description Parent margin account UUID that releases collateral. */
|
|
8529
8628
|
marginAccountId?: string | null;
|
|
@@ -14294,6 +14393,13 @@ export interface operations {
|
|
|
14294
14393
|
"application/json": components["schemas"]["AttachPositionTpSlResponse"];
|
|
14295
14394
|
};
|
|
14296
14395
|
};
|
|
14396
|
+
/** @description Order rate limit exceeded — each attach draws one item from the per-account order-creation budget it shares with order creates (and the budget the account family shares); retry after the interval in details.retryAfter */
|
|
14397
|
+
429: {
|
|
14398
|
+
headers: {
|
|
14399
|
+
[name: string]: unknown;
|
|
14400
|
+
};
|
|
14401
|
+
content?: never;
|
|
14402
|
+
};
|
|
14297
14403
|
};
|
|
14298
14404
|
};
|
|
14299
14405
|
get_pulse: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.66",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://docs.0xmonaco.com/sdk/typescript",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint": "biome lint ."
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@0xmonaco/contracts": "1.0.
|
|
19
|
+
"@0xmonaco/contracts": "1.0.66",
|
|
20
20
|
"zod": "^4.1.12"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|