@0xmonaco/types 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/margin-accounts/index.d.ts +106 -0
- package/dist/margin-accounts/index.js +0 -0
- package/dist/market/index.d.ts +105 -16
- package/dist/positions/index.d.ts +128 -0
- package/dist/positions/index.js +0 -0
- package/dist/profile/index.d.ts +19 -17
- package/dist/sdk/index.d.ts +11 -4
- package/dist/trading/index.d.ts +25 -5
- package/dist/trading/orders.d.ts +27 -1
- package/dist/trading/responses.d.ts +84 -15
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.js +2 -0
- package/dist/validation/margin-accounts.d.ts +55 -0
- package/dist/validation/margin-accounts.js +59 -0
- package/dist/validation/market.d.ts +2 -2
- package/dist/validation/market.js +2 -2
- package/dist/validation/positions.d.ts +89 -0
- package/dist/validation/positions.js +93 -0
- package/dist/validation/profile.d.ts +2 -2
- package/dist/validation/profile.js +2 -2
- package/dist/validation/trading.d.ts +123 -2
- package/dist/validation/trading.js +126 -5
- package/dist/websocket/events/conditional-order-events.d.ts +33 -0
- package/dist/websocket/events/conditional-order-events.js +0 -0
- package/dist/websocket/events/index.d.ts +1 -0
- package/dist/websocket/events/index.js +1 -0
- package/dist/websocket/events/orders-events.d.ts +2 -2
- package/package.json +1 -1
|
@@ -19,6 +19,14 @@ export declare const TradingModeSchema: z.ZodEnum<{
|
|
|
19
19
|
SPOT: "SPOT";
|
|
20
20
|
MARGIN: "MARGIN";
|
|
21
21
|
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Position side validation
|
|
24
|
+
*/
|
|
25
|
+
export declare const PositionSideSchema: z.ZodEnum<{
|
|
26
|
+
LONG: "LONG";
|
|
27
|
+
SHORT: "SHORT";
|
|
28
|
+
NONE: "NONE";
|
|
29
|
+
}>;
|
|
22
30
|
/**
|
|
23
31
|
* Time in force validation
|
|
24
32
|
*/
|
|
@@ -27,6 +35,10 @@ export declare const TimeInForceSchema: z.ZodEnum<{
|
|
|
27
35
|
IOC: "IOC";
|
|
28
36
|
FOK: "FOK";
|
|
29
37
|
}>;
|
|
38
|
+
export declare const ConditionalTimeInForceSchema: z.ZodEnum<{
|
|
39
|
+
GTC: "GTC";
|
|
40
|
+
IOC: "IOC";
|
|
41
|
+
}>;
|
|
30
42
|
/**
|
|
31
43
|
* Positive decimal string validation (for quantities and prices)
|
|
32
44
|
*/
|
|
@@ -66,6 +78,14 @@ export declare const PlaceLimitOrderSchema: z.ZodObject<{
|
|
|
66
78
|
IOC: "IOC";
|
|
67
79
|
FOK: "FOK";
|
|
68
80
|
}>>;
|
|
81
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
82
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
83
|
+
LONG: "LONG";
|
|
84
|
+
SHORT: "SHORT";
|
|
85
|
+
NONE: "NONE";
|
|
86
|
+
}>>;
|
|
87
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
88
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
69
89
|
}, z.core.$strip>>;
|
|
70
90
|
}, z.core.$strip>;
|
|
71
91
|
/**
|
|
@@ -84,6 +104,14 @@ export declare const PlaceMarketOrderSchema: z.ZodObject<{
|
|
|
84
104
|
MARGIN: "MARGIN";
|
|
85
105
|
}>>;
|
|
86
106
|
slippageTolerance: z.ZodOptional<z.ZodNumber>;
|
|
107
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
108
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
LONG: "LONG";
|
|
110
|
+
SHORT: "SHORT";
|
|
111
|
+
NONE: "NONE";
|
|
112
|
+
}>>;
|
|
113
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
114
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
87
115
|
}, z.core.$strip>>;
|
|
88
116
|
}, z.core.$strip>;
|
|
89
117
|
/**
|
|
@@ -114,7 +142,7 @@ export declare const ReplaceOrderSchema: z.ZodObject<{
|
|
|
114
142
|
* Validates parameters for fetching paginated orders.
|
|
115
143
|
* Matches the getPaginatedOrders method signature which accepts:
|
|
116
144
|
* - status: OrderStatus (optional filter)
|
|
117
|
-
* -
|
|
145
|
+
* - trading_pair_id: trading pair UUID (optional filter)
|
|
118
146
|
* - page: number (default: 1)
|
|
119
147
|
* - page_size: number (default: 10, max: 100)
|
|
120
148
|
*/
|
|
@@ -129,7 +157,12 @@ export declare const GetPaginatedOrdersSchema: z.ZodObject<{
|
|
|
129
157
|
REJECTED: "REJECTED";
|
|
130
158
|
EXPIRED: "EXPIRED";
|
|
131
159
|
}>>;
|
|
132
|
-
|
|
160
|
+
trading_pair_id: z.ZodOptional<z.ZodUUID>;
|
|
161
|
+
trading_mode: z.ZodOptional<z.ZodEnum<{
|
|
162
|
+
SPOT: "SPOT";
|
|
163
|
+
MARGIN: "MARGIN";
|
|
164
|
+
}>>;
|
|
165
|
+
margin_account_id: z.ZodOptional<z.ZodUUID>;
|
|
133
166
|
page: z.ZodOptional<z.ZodNumber>;
|
|
134
167
|
page_size: z.ZodOptional<z.ZodNumber>;
|
|
135
168
|
}, z.core.$strip>;
|
|
@@ -140,6 +173,76 @@ export declare const OrderTypeSchema: z.ZodEnum<{
|
|
|
140
173
|
LIMIT: "LIMIT";
|
|
141
174
|
MARKET: "MARKET";
|
|
142
175
|
}>;
|
|
176
|
+
export declare const ConditionalOrderConditionTypeSchema: z.ZodEnum<{
|
|
177
|
+
STOP_LOSS: "STOP_LOSS";
|
|
178
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
179
|
+
}>;
|
|
180
|
+
export declare const ConditionalOrderTriggerSourceSchema: z.ZodEnum<{
|
|
181
|
+
MARK_PRICE: "MARK_PRICE";
|
|
182
|
+
}>;
|
|
183
|
+
export declare const ConditionalOrderStateSchema: z.ZodEnum<{
|
|
184
|
+
CANCELLED: "CANCELLED";
|
|
185
|
+
EXPIRED: "EXPIRED";
|
|
186
|
+
ACTIVE: "ACTIVE";
|
|
187
|
+
TRIGGERING: "TRIGGERING";
|
|
188
|
+
TRIGGERED: "TRIGGERED";
|
|
189
|
+
FAILED: "FAILED";
|
|
190
|
+
}>;
|
|
191
|
+
export declare const ClosePositionSideSchema: z.ZodEnum<{
|
|
192
|
+
LONG: "LONG";
|
|
193
|
+
SHORT: "SHORT";
|
|
194
|
+
}>;
|
|
195
|
+
export declare const SlippageToleranceBpsSchema: z.ZodNumber;
|
|
196
|
+
export declare const CreateConditionalOrderSchema: z.ZodObject<{
|
|
197
|
+
tradingPairId: z.ZodUUID;
|
|
198
|
+
marginAccountId: z.ZodUUID;
|
|
199
|
+
conditionType: z.ZodEnum<{
|
|
200
|
+
STOP_LOSS: "STOP_LOSS";
|
|
201
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
202
|
+
}>;
|
|
203
|
+
triggerPrice: z.ZodString;
|
|
204
|
+
triggerSource: z.ZodOptional<z.ZodEnum<{
|
|
205
|
+
MARK_PRICE: "MARK_PRICE";
|
|
206
|
+
}>>;
|
|
207
|
+
side: z.ZodEnum<{
|
|
208
|
+
BUY: "BUY";
|
|
209
|
+
SELL: "SELL";
|
|
210
|
+
}>;
|
|
211
|
+
positionSide: z.ZodEnum<{
|
|
212
|
+
LONG: "LONG";
|
|
213
|
+
SHORT: "SHORT";
|
|
214
|
+
}>;
|
|
215
|
+
orderType: z.ZodEnum<{
|
|
216
|
+
LIMIT: "LIMIT";
|
|
217
|
+
MARKET: "MARKET";
|
|
218
|
+
}>;
|
|
219
|
+
limitPrice: z.ZodOptional<z.ZodString>;
|
|
220
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
221
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
timeInForce: z.ZodOptional<z.ZodEnum<{
|
|
223
|
+
GTC: "GTC";
|
|
224
|
+
IOC: "IOC";
|
|
225
|
+
}>>;
|
|
226
|
+
slippageToleranceBps: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
expiresAt: z.ZodOptional<z.ZodISODateTime>;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
export declare const CancelConditionalOrderSchema: z.ZodObject<{
|
|
230
|
+
conditionalOrderId: z.ZodUUID;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
export declare const ListConditionalOrdersSchema: z.ZodObject<{
|
|
233
|
+
margin_account_id: z.ZodOptional<z.ZodUUID>;
|
|
234
|
+
trading_pair_id: z.ZodOptional<z.ZodUUID>;
|
|
235
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
236
|
+
CANCELLED: "CANCELLED";
|
|
237
|
+
EXPIRED: "EXPIRED";
|
|
238
|
+
ACTIVE: "ACTIVE";
|
|
239
|
+
TRIGGERING: "TRIGGERING";
|
|
240
|
+
TRIGGERED: "TRIGGERED";
|
|
241
|
+
FAILED: "FAILED";
|
|
242
|
+
}>>;
|
|
243
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
244
|
+
page_size: z.ZodOptional<z.ZodNumber>;
|
|
245
|
+
}, z.core.$strip>;
|
|
143
246
|
/**
|
|
144
247
|
* Single batch create order item validation schema
|
|
145
248
|
*
|
|
@@ -161,6 +264,7 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
|
|
|
161
264
|
quantity: z.ZodString;
|
|
162
265
|
tradingMode: z.ZodOptional<z.ZodEnum<{
|
|
163
266
|
SPOT: "SPOT";
|
|
267
|
+
MARGIN: "MARGIN";
|
|
164
268
|
}>>;
|
|
165
269
|
slippageTolerance: z.ZodOptional<z.ZodNumber>;
|
|
166
270
|
useMasterBalance: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -170,6 +274,14 @@ export declare const BatchCreateOrderItemSchema: z.ZodObject<{
|
|
|
170
274
|
IOC: "IOC";
|
|
171
275
|
FOK: "FOK";
|
|
172
276
|
}>>;
|
|
277
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
278
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
279
|
+
LONG: "LONG";
|
|
280
|
+
SHORT: "SHORT";
|
|
281
|
+
NONE: "NONE";
|
|
282
|
+
}>>;
|
|
283
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
284
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
173
285
|
}, z.core.$strip>;
|
|
174
286
|
/**
|
|
175
287
|
* Batch Create Orders validation schema
|
|
@@ -191,6 +303,7 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
|
|
|
191
303
|
quantity: z.ZodString;
|
|
192
304
|
tradingMode: z.ZodOptional<z.ZodEnum<{
|
|
193
305
|
SPOT: "SPOT";
|
|
306
|
+
MARGIN: "MARGIN";
|
|
194
307
|
}>>;
|
|
195
308
|
slippageTolerance: z.ZodOptional<z.ZodNumber>;
|
|
196
309
|
useMasterBalance: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -200,6 +313,14 @@ export declare const BatchCreateOrdersSchema: z.ZodObject<{
|
|
|
200
313
|
IOC: "IOC";
|
|
201
314
|
FOK: "FOK";
|
|
202
315
|
}>>;
|
|
316
|
+
marginAccountId: z.ZodOptional<z.ZodUUID>;
|
|
317
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
318
|
+
LONG: "LONG";
|
|
319
|
+
SHORT: "SHORT";
|
|
320
|
+
NONE: "NONE";
|
|
321
|
+
}>>;
|
|
322
|
+
leverage: z.ZodOptional<z.ZodString>;
|
|
323
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
203
324
|
}, z.core.$strip>>;
|
|
204
325
|
}, z.core.$strip>;
|
|
205
326
|
/**
|
|
@@ -18,12 +18,21 @@ export const OrderSideSchema = z.enum(["BUY", "SELL"], {
|
|
|
18
18
|
export const TradingModeSchema = z.enum(["SPOT", "MARGIN"], {
|
|
19
19
|
message: 'Trading mode must be "SPOT" or "MARGIN"',
|
|
20
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* Position side validation
|
|
23
|
+
*/
|
|
24
|
+
export const PositionSideSchema = z.enum(["LONG", "SHORT", "NONE"], {
|
|
25
|
+
message: 'Position side must be "LONG", "SHORT", or "NONE"',
|
|
26
|
+
});
|
|
21
27
|
/**
|
|
22
28
|
* Time in force validation
|
|
23
29
|
*/
|
|
24
30
|
export const TimeInForceSchema = z.enum(["GTC", "IOC", "FOK"], {
|
|
25
31
|
message: 'Time in force must be "GTC", "IOC", or "FOK"',
|
|
26
32
|
});
|
|
33
|
+
export const ConditionalTimeInForceSchema = z.enum(["GTC", "IOC"], {
|
|
34
|
+
message: 'Conditional order time in force must be "GTC" or "IOC"',
|
|
35
|
+
});
|
|
27
36
|
/**
|
|
28
37
|
* Positive decimal string validation (for quantities and prices)
|
|
29
38
|
*/
|
|
@@ -58,7 +67,8 @@ export const SlippageToleranceSchema = z
|
|
|
58
67
|
/**
|
|
59
68
|
* Place Limit Order validation schema
|
|
60
69
|
*/
|
|
61
|
-
export const PlaceLimitOrderSchema = z
|
|
70
|
+
export const PlaceLimitOrderSchema = z
|
|
71
|
+
.object({
|
|
62
72
|
tradingPairId: UUIDSchema,
|
|
63
73
|
side: OrderSideSchema,
|
|
64
74
|
quantity: PositiveDecimalStringSchema,
|
|
@@ -69,13 +79,30 @@ export const PlaceLimitOrderSchema = z.object({
|
|
|
69
79
|
useMasterBalance: z.boolean().optional(),
|
|
70
80
|
expirationDate: ISO8601DateSchema.optional(),
|
|
71
81
|
timeInForce: TimeInForceSchema.optional(),
|
|
82
|
+
marginAccountId: UUIDSchema.optional(),
|
|
83
|
+
positionSide: PositionSideSchema.optional(),
|
|
84
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
85
|
+
reduceOnly: z.boolean().optional(),
|
|
72
86
|
})
|
|
73
87
|
.optional(),
|
|
88
|
+
})
|
|
89
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.marginAccountId !== undefined, {
|
|
90
|
+
message: "marginAccountId is required for MARGIN orders",
|
|
91
|
+
path: ["options", "marginAccountId"],
|
|
92
|
+
})
|
|
93
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
|
|
94
|
+
message: "positionSide is required for MARGIN orders",
|
|
95
|
+
path: ["options", "positionSide"],
|
|
96
|
+
})
|
|
97
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
|
|
98
|
+
message: "leverage is required for MARGIN orders",
|
|
99
|
+
path: ["options", "leverage"],
|
|
74
100
|
});
|
|
75
101
|
/**
|
|
76
102
|
* Place Market Order validation schema
|
|
77
103
|
*/
|
|
78
|
-
export const PlaceMarketOrderSchema = z
|
|
104
|
+
export const PlaceMarketOrderSchema = z
|
|
105
|
+
.object({
|
|
79
106
|
tradingPairId: UUIDSchema,
|
|
80
107
|
side: OrderSideSchema,
|
|
81
108
|
quantity: PositiveDecimalStringSchema,
|
|
@@ -83,8 +110,24 @@ export const PlaceMarketOrderSchema = z.object({
|
|
|
83
110
|
.object({
|
|
84
111
|
tradingMode: TradingModeSchema.optional(),
|
|
85
112
|
slippageTolerance: SlippageToleranceSchema,
|
|
113
|
+
marginAccountId: UUIDSchema.optional(),
|
|
114
|
+
positionSide: PositionSideSchema.optional(),
|
|
115
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
116
|
+
reduceOnly: z.boolean().optional(),
|
|
86
117
|
})
|
|
87
118
|
.optional(),
|
|
119
|
+
})
|
|
120
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.marginAccountId !== undefined, {
|
|
121
|
+
message: "marginAccountId is required for MARGIN orders",
|
|
122
|
+
path: ["options", "marginAccountId"],
|
|
123
|
+
})
|
|
124
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.positionSide !== undefined, {
|
|
125
|
+
message: "positionSide is required for MARGIN orders",
|
|
126
|
+
path: ["options", "positionSide"],
|
|
127
|
+
})
|
|
128
|
+
.refine((data) => data.options?.tradingMode !== "MARGIN" || data.options.leverage !== undefined, {
|
|
129
|
+
message: "leverage is required for MARGIN orders",
|
|
130
|
+
path: ["options", "leverage"],
|
|
88
131
|
});
|
|
89
132
|
/**
|
|
90
133
|
* Cancel Order validation schema
|
|
@@ -114,13 +157,15 @@ export const ReplaceOrderSchema = z.object({
|
|
|
114
157
|
* Validates parameters for fetching paginated orders.
|
|
115
158
|
* Matches the getPaginatedOrders method signature which accepts:
|
|
116
159
|
* - status: OrderStatus (optional filter)
|
|
117
|
-
* -
|
|
160
|
+
* - trading_pair_id: trading pair UUID (optional filter)
|
|
118
161
|
* - page: number (default: 1)
|
|
119
162
|
* - page_size: number (default: 10, max: 100)
|
|
120
163
|
*/
|
|
121
164
|
export const GetPaginatedOrdersSchema = z.object({
|
|
122
165
|
status: z.enum(ORDER_STATUS_VALUES).optional(),
|
|
123
|
-
|
|
166
|
+
trading_pair_id: UUIDSchema.optional(),
|
|
167
|
+
trading_mode: TradingModeSchema.optional(),
|
|
168
|
+
margin_account_id: UUIDSchema.optional(),
|
|
124
169
|
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
125
170
|
page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
126
171
|
});
|
|
@@ -130,6 +175,66 @@ export const GetPaginatedOrdersSchema = z.object({
|
|
|
130
175
|
export const OrderTypeSchema = z.enum(["LIMIT", "MARKET"], {
|
|
131
176
|
message: 'Order type must be "LIMIT" or "MARKET"',
|
|
132
177
|
});
|
|
178
|
+
export const ConditionalOrderConditionTypeSchema = z.enum(["STOP_LOSS", "TAKE_PROFIT"], {
|
|
179
|
+
message: 'conditionType must be "STOP_LOSS" or "TAKE_PROFIT"',
|
|
180
|
+
});
|
|
181
|
+
export const ConditionalOrderTriggerSourceSchema = z.enum(["MARK_PRICE"], {
|
|
182
|
+
message: 'triggerSource must be "MARK_PRICE"',
|
|
183
|
+
});
|
|
184
|
+
export const ConditionalOrderStateSchema = z.enum(["ACTIVE", "TRIGGERING", "TRIGGERED", "CANCELLED", "EXPIRED", "FAILED"], {
|
|
185
|
+
message: "Invalid conditional order state",
|
|
186
|
+
});
|
|
187
|
+
export const ClosePositionSideSchema = z.enum(["LONG", "SHORT"], {
|
|
188
|
+
message: 'Position side must be "LONG" or "SHORT"',
|
|
189
|
+
});
|
|
190
|
+
export const SlippageToleranceBpsSchema = z
|
|
191
|
+
.number()
|
|
192
|
+
.int()
|
|
193
|
+
.min(0, "Slippage tolerance must be at least 0 bps")
|
|
194
|
+
.max(10000, "Slippage tolerance cannot exceed 10000 bps");
|
|
195
|
+
export const CreateConditionalOrderSchema = z
|
|
196
|
+
.object({
|
|
197
|
+
tradingPairId: UUIDSchema,
|
|
198
|
+
marginAccountId: UUIDSchema,
|
|
199
|
+
conditionType: ConditionalOrderConditionTypeSchema,
|
|
200
|
+
triggerPrice: PositiveDecimalStringSchema,
|
|
201
|
+
triggerSource: ConditionalOrderTriggerSourceSchema.optional(),
|
|
202
|
+
side: OrderSideSchema,
|
|
203
|
+
positionSide: ClosePositionSideSchema,
|
|
204
|
+
orderType: OrderTypeSchema,
|
|
205
|
+
limitPrice: PositiveDecimalStringSchema.optional(),
|
|
206
|
+
quantity: PositiveDecimalStringSchema.optional(),
|
|
207
|
+
reduceOnly: z.boolean().optional(),
|
|
208
|
+
timeInForce: ConditionalTimeInForceSchema.optional(),
|
|
209
|
+
slippageToleranceBps: SlippageToleranceBpsSchema.optional(),
|
|
210
|
+
expiresAt: ISO8601DateSchema.optional(),
|
|
211
|
+
})
|
|
212
|
+
.refine((data) => data.orderType !== "LIMIT" || data.limitPrice !== undefined, {
|
|
213
|
+
message: "limitPrice is required for LIMIT conditional orders",
|
|
214
|
+
path: ["limitPrice"],
|
|
215
|
+
})
|
|
216
|
+
.refine((data) => data.orderType !== "MARKET" || data.limitPrice === undefined, {
|
|
217
|
+
message: "limitPrice must not be provided for MARKET conditional orders",
|
|
218
|
+
path: ["limitPrice"],
|
|
219
|
+
})
|
|
220
|
+
.refine((data) => data.orderType !== "MARKET" || data.timeInForce === undefined, {
|
|
221
|
+
message: "timeInForce is only allowed for LIMIT conditional orders",
|
|
222
|
+
path: ["timeInForce"],
|
|
223
|
+
})
|
|
224
|
+
.refine((data) => data.orderType !== "LIMIT" || data.slippageToleranceBps === undefined, {
|
|
225
|
+
message: "slippageToleranceBps is only allowed for MARKET conditional orders",
|
|
226
|
+
path: ["slippageToleranceBps"],
|
|
227
|
+
});
|
|
228
|
+
export const CancelConditionalOrderSchema = z.object({
|
|
229
|
+
conditionalOrderId: UUIDSchema,
|
|
230
|
+
});
|
|
231
|
+
export const ListConditionalOrdersSchema = z.object({
|
|
232
|
+
margin_account_id: UUIDSchema.optional(),
|
|
233
|
+
trading_pair_id: UUIDSchema.optional(),
|
|
234
|
+
state: ConditionalOrderStateSchema.optional(),
|
|
235
|
+
page: z.number().int().min(1, "Page must be at least 1").optional(),
|
|
236
|
+
page_size: z.number().int().min(1, "Page size must be at least 1").max(100, "Page size cannot exceed 100").optional(),
|
|
237
|
+
});
|
|
133
238
|
/**
|
|
134
239
|
* Single batch create order item validation schema
|
|
135
240
|
*
|
|
@@ -144,11 +249,15 @@ export const BatchCreateOrderItemSchema = z
|
|
|
144
249
|
side: OrderSideSchema,
|
|
145
250
|
price: PositiveDecimalStringSchema.optional(),
|
|
146
251
|
quantity: PositiveDecimalStringSchema,
|
|
147
|
-
tradingMode:
|
|
252
|
+
tradingMode: TradingModeSchema.optional(),
|
|
148
253
|
slippageTolerance: SlippageToleranceSchema,
|
|
149
254
|
useMasterBalance: z.boolean().optional(),
|
|
150
255
|
expirationDate: ISO8601DateSchema.optional(),
|
|
151
256
|
timeInForce: TimeInForceSchema.optional(),
|
|
257
|
+
marginAccountId: UUIDSchema.optional(),
|
|
258
|
+
positionSide: PositionSideSchema.optional(),
|
|
259
|
+
leverage: PositiveDecimalStringSchema.optional(),
|
|
260
|
+
reduceOnly: z.boolean().optional(),
|
|
152
261
|
})
|
|
153
262
|
.refine((data) => data.orderType !== "LIMIT" || data.price !== undefined, {
|
|
154
263
|
message: "Price is required for LIMIT orders",
|
|
@@ -157,6 +266,18 @@ export const BatchCreateOrderItemSchema = z
|
|
|
157
266
|
.refine((data) => data.orderType !== "MARKET" || data.price === undefined, {
|
|
158
267
|
message: "Price must not be provided for MARKET orders",
|
|
159
268
|
path: ["price"],
|
|
269
|
+
})
|
|
270
|
+
.refine((data) => data.tradingMode !== "MARGIN" || data.marginAccountId !== undefined, {
|
|
271
|
+
message: "marginAccountId is required for MARGIN orders",
|
|
272
|
+
path: ["marginAccountId"],
|
|
273
|
+
})
|
|
274
|
+
.refine((data) => data.tradingMode !== "MARGIN" || data.positionSide !== undefined, {
|
|
275
|
+
message: "positionSide is required for MARGIN orders",
|
|
276
|
+
path: ["positionSide"],
|
|
277
|
+
})
|
|
278
|
+
.refine((data) => data.tradingMode !== "MARGIN" || data.leverage !== undefined, {
|
|
279
|
+
message: "leverage is required for MARGIN orders",
|
|
280
|
+
path: ["leverage"],
|
|
160
281
|
});
|
|
161
282
|
/**
|
|
162
283
|
* Batch Create Orders validation schema
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, OrderSide, OrderType, PositionSide, TimeInForce } from "../../trading";
|
|
2
|
+
export type ConditionalOrderEventReason = "created" | "cancelled" | "triggered" | "failed" | "oco_cancelled";
|
|
3
|
+
export interface ConditionalOrderEventData {
|
|
4
|
+
conditionalOrderId: string;
|
|
5
|
+
tradingPairId: string;
|
|
6
|
+
marginAccountId: string;
|
|
7
|
+
positionId?: string;
|
|
8
|
+
linkedGroupId?: string;
|
|
9
|
+
conditionType: ConditionalOrderConditionType;
|
|
10
|
+
triggerSource: ConditionalOrderTriggerSource;
|
|
11
|
+
triggerPrice: string;
|
|
12
|
+
side: OrderSide;
|
|
13
|
+
positionSide: PositionSide;
|
|
14
|
+
orderType: OrderType;
|
|
15
|
+
limitPrice?: string;
|
|
16
|
+
quantity?: string;
|
|
17
|
+
slippageToleranceBps?: number;
|
|
18
|
+
reduceOnly: boolean;
|
|
19
|
+
timeInForce?: Extract<TimeInForce, "GTC" | "IOC">;
|
|
20
|
+
state: ConditionalOrderState;
|
|
21
|
+
triggeredOrderId?: string;
|
|
22
|
+
triggeredAt?: string;
|
|
23
|
+
cancelledAt?: string;
|
|
24
|
+
expiresAt?: string;
|
|
25
|
+
failureReason?: string;
|
|
26
|
+
reason: ConditionalOrderEventReason;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ConditionalOrderEvent {
|
|
30
|
+
eventType: "conditional_order_update";
|
|
31
|
+
userId: string;
|
|
32
|
+
data: ConditionalOrderEventData;
|
|
33
|
+
}
|
|
File without changes
|
|
@@ -38,7 +38,7 @@ export interface CommonOrderEventData {
|
|
|
38
38
|
/** Application ID (UUID) - present in several events */
|
|
39
39
|
applicationId?: string;
|
|
40
40
|
/** Trading pair symbol (e.g., "BTC/USDC") */
|
|
41
|
-
|
|
41
|
+
symbol: string;
|
|
42
42
|
/** Trading mode (e.g., "SPOT", "MARGIN") */
|
|
43
43
|
tradingMode: TradingMode;
|
|
44
44
|
/** Order type - present in most events */
|
|
@@ -278,7 +278,7 @@ export interface BackendCommonOrderEventData {
|
|
|
278
278
|
/** Trading pair ID (UUID) */
|
|
279
279
|
trading_pair_id?: string;
|
|
280
280
|
/** Trading pair symbol (e.g., "BTC/USDC") */
|
|
281
|
-
|
|
281
|
+
symbol: string;
|
|
282
282
|
/** Trading mode (e.g., "Spot", "Margin") */
|
|
283
283
|
trading_mode: string;
|
|
284
284
|
}
|