@pear-protocol/types 0.0.1
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/auth/entities.d.ts +9 -0
- package/dist/auth/entities.js +8 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/payloads.d.ts +50 -0
- package/dist/auth/payloads.js +39 -0
- package/dist/auth/response.d.ts +55 -0
- package/dist/auth/response.js +21 -0
- package/dist/bundle.d.ts +17 -0
- package/dist/bundle.js +17 -0
- package/dist/common/array.d.ts +10 -0
- package/dist/common/array.js +10 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.js +3 -0
- package/dist/common/refinement.d.ts +20 -0
- package/dist/common/refinement.js +60 -0
- package/dist/common/request.d.ts +11 -0
- package/dist/common/request.js +24 -0
- package/dist/common/response.d.ts +12 -0
- package/dist/common/response.js +28 -0
- package/dist/common/schema.d.ts +8 -0
- package/dist/common/schema.js +10 -0
- package/dist/common/trade-legs.d.ts +34 -0
- package/dist/common/trade-legs.js +30 -0
- package/dist/connector/index.d.ts +8 -0
- package/dist/connector/index.js +5 -0
- package/dist/execution/entities.d.ts +741 -0
- package/dist/execution/entities.js +125 -0
- package/dist/execution/index.d.ts +3 -0
- package/dist/execution/index.js +3 -0
- package/dist/execution/queries.d.ts +20 -0
- package/dist/execution/queries.js +14 -0
- package/dist/execution/responses.d.ts +218 -0
- package/dist/execution/responses.js +9 -0
- package/dist/fill/entities.d.ts +25 -0
- package/dist/fill/entities.js +61 -0
- package/dist/fill/index.d.ts +3 -0
- package/dist/fill/index.js +3 -0
- package/dist/fill/queries.d.ts +13 -0
- package/dist/fill/queries.js +11 -0
- package/dist/fill/responses.d.ts +55 -0
- package/dist/fill/responses.js +12 -0
- package/dist/funding/entities.d.ts +11 -0
- package/dist/funding/entities.js +16 -0
- package/dist/funding/index.d.ts +3 -0
- package/dist/funding/index.js +3 -0
- package/dist/funding/queries.d.ts +10 -0
- package/dist/funding/queries.js +8 -0
- package/dist/funding/responses.d.ts +8 -0
- package/dist/funding/responses.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/instrument/entities.d.ts +43 -0
- package/dist/instrument/entities.js +48 -0
- package/dist/instrument/index.d.ts +3 -0
- package/dist/instrument/index.js +3 -0
- package/dist/instrument/queries.d.ts +10 -0
- package/dist/instrument/queries.js +8 -0
- package/dist/instrument/responses.d.ts +37 -0
- package/dist/instrument/responses.js +11 -0
- package/dist/instrument-precision/index.d.ts +18 -0
- package/dist/instrument-precision/index.js +51 -0
- package/dist/misc/index.d.ts +3 -0
- package/dist/misc/index.js +1 -0
- package/dist/order/entities.d.ts +73 -0
- package/dist/order/entities.js +73 -0
- package/dist/order/index.d.ts +1 -0
- package/dist/order/index.js +1 -0
- package/dist/position/entities.d.ts +53 -0
- package/dist/position/entities.js +55 -0
- package/dist/position/index.d.ts +3 -0
- package/dist/position/index.js +3 -0
- package/dist/position/queries.d.ts +16 -0
- package/dist/position/queries.js +28 -0
- package/dist/position/responses.d.ts +28 -0
- package/dist/position/responses.js +8 -0
- package/dist/price/entities.d.ts +8 -0
- package/dist/price/entities.js +7 -0
- package/dist/price/index.d.ts +3 -0
- package/dist/price/index.js +3 -0
- package/dist/price/queries.d.ts +10 -0
- package/dist/price/queries.js +8 -0
- package/dist/price/responses.d.ts +6 -0
- package/dist/price/responses.js +15 -0
- package/dist/schedule/entities.d.ts +380 -0
- package/dist/schedule/entities.js +159 -0
- package/dist/schedule/index.d.ts +4 -0
- package/dist/schedule/index.js +4 -0
- package/dist/schedule/payloads.d.ts +72 -0
- package/dist/schedule/payloads.js +102 -0
- package/dist/schedule/queries.d.ts +18 -0
- package/dist/schedule/queries.js +12 -0
- package/dist/schedule/responses.d.ts +279 -0
- package/dist/schedule/responses.js +10 -0
- package/dist/trade/index.d.ts +2 -0
- package/dist/trade/index.js +2 -0
- package/dist/trade/payloads.d.ts +217 -0
- package/dist/trade/payloads.js +35 -0
- package/dist/trade/responses.d.ts +861 -0
- package/dist/trade/responses.js +9 -0
- package/dist/trade-accounts/entities.d.ts +50 -0
- package/dist/trade-accounts/entities.js +18 -0
- package/dist/trade-accounts/index.d.ts +3 -0
- package/dist/trade-accounts/index.js +3 -0
- package/dist/trade-accounts/payloads.d.ts +137 -0
- package/dist/trade-accounts/payloads.js +84 -0
- package/dist/trade-accounts/response.d.ts +65 -0
- package/dist/trade-accounts/response.js +41 -0
- package/dist/trigger/entities/conditions.d.ts +407 -0
- package/dist/trigger/entities/conditions.js +239 -0
- package/dist/trigger/entities/index.d.ts +1549 -0
- package/dist/trigger/entities/index.js +123 -0
- package/dist/trigger/index.d.ts +6 -0
- package/dist/trigger/index.js +6 -0
- package/dist/trigger/payloads/conditions.d.ts +340 -0
- package/dist/trigger/payloads/conditions.js +109 -0
- package/dist/trigger/payloads/index.d.ts +470 -0
- package/dist/trigger/payloads/index.js +47 -0
- package/dist/trigger/queries.d.ts +18 -0
- package/dist/trigger/queries.js +12 -0
- package/dist/trigger/responses.d.ts +1001 -0
- package/dist/trigger/responses.js +10 -0
- package/dist/users/entities.d.ts +16 -0
- package/dist/users/entities.js +14 -0
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.js +3 -0
- package/dist/users/payloads.d.ts +5 -0
- package/dist/users/payloads.js +7 -0
- package/dist/users/response.d.ts +23 -0
- package/dist/users/response.js +12 -0
- package/package.json +35 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TradeLegPostOnly, TradeLeg } from '../../common/trade-legs';
|
|
3
|
+
import { Connector } from '../../connector';
|
|
4
|
+
import { Fill } from '../../fill';
|
|
5
|
+
import { TriggerConditionOpen, TriggerConditionAdjust, TriggerConditionClose } from './conditions';
|
|
6
|
+
|
|
7
|
+
const TriggerIntent = z.enum(["OPEN", "CLOSE"]);
|
|
8
|
+
const TriggerStatus = z.enum(["ACTIVE", "TRIGGERED", "CANCELLED"]);
|
|
9
|
+
const TriggerCancelledReason = z.enum(["POSITION_CLOSED", "USER", "SYSTEM"]);
|
|
10
|
+
const BaseTrigger = z.object({
|
|
11
|
+
/**
|
|
12
|
+
* Trigger UUID
|
|
13
|
+
*/
|
|
14
|
+
id: z.uuid(),
|
|
15
|
+
/**
|
|
16
|
+
* Trade account UUID
|
|
17
|
+
*/
|
|
18
|
+
tradeAccountId: z.uuid(),
|
|
19
|
+
/**
|
|
20
|
+
* Connector
|
|
21
|
+
*/
|
|
22
|
+
connector: Connector,
|
|
23
|
+
/**
|
|
24
|
+
* Status of the trigger
|
|
25
|
+
*/
|
|
26
|
+
status: TriggerStatus,
|
|
27
|
+
/**
|
|
28
|
+
* When the trigger was triggered
|
|
29
|
+
*/
|
|
30
|
+
triggeredAt: z.string().optional(),
|
|
31
|
+
/**
|
|
32
|
+
* When the trigger was cancelled
|
|
33
|
+
*/
|
|
34
|
+
cancelledAt: z.string().optional(),
|
|
35
|
+
/**
|
|
36
|
+
* Reason for the trigger being cancelled
|
|
37
|
+
*/
|
|
38
|
+
cancelledReason: TriggerCancelledReason.optional(),
|
|
39
|
+
/**
|
|
40
|
+
* Fills for the trigger
|
|
41
|
+
*/
|
|
42
|
+
fills: z.array(Fill).optional(),
|
|
43
|
+
/**
|
|
44
|
+
* Created at timestamp
|
|
45
|
+
*/
|
|
46
|
+
createdAt: z.string(),
|
|
47
|
+
/**
|
|
48
|
+
* Updated at timestamp
|
|
49
|
+
*/
|
|
50
|
+
updatedAt: z.string()
|
|
51
|
+
});
|
|
52
|
+
const TriggerMarketOpen = BaseTrigger.extend({
|
|
53
|
+
/**
|
|
54
|
+
* Intent
|
|
55
|
+
*/
|
|
56
|
+
intent: z.literal("OPEN"),
|
|
57
|
+
/**
|
|
58
|
+
* Order type
|
|
59
|
+
*/
|
|
60
|
+
type: z.literal("MARKET"),
|
|
61
|
+
/**
|
|
62
|
+
* Condition (only open conditions allowed)
|
|
63
|
+
*/
|
|
64
|
+
condition: TriggerConditionOpen,
|
|
65
|
+
/**
|
|
66
|
+
* Context
|
|
67
|
+
*/
|
|
68
|
+
context: z.object({
|
|
69
|
+
type: z.literal("MARKET"),
|
|
70
|
+
legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly)
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
const TriggerMarketAdjust = BaseTrigger.extend({
|
|
74
|
+
/**
|
|
75
|
+
* Intent
|
|
76
|
+
*/
|
|
77
|
+
intent: z.literal("ADJUST"),
|
|
78
|
+
/**
|
|
79
|
+
* Order type
|
|
80
|
+
*/
|
|
81
|
+
type: z.literal("MARKET"),
|
|
82
|
+
/**
|
|
83
|
+
* Condition (only adjust conditions allowed)
|
|
84
|
+
*/
|
|
85
|
+
condition: TriggerConditionAdjust,
|
|
86
|
+
/**
|
|
87
|
+
* Context
|
|
88
|
+
*/
|
|
89
|
+
context: z.object({
|
|
90
|
+
type: z.literal("MARKET"),
|
|
91
|
+
position: z.object({ id: z.uuid(), initialExposure: z.record(z.string(), z.string()) }),
|
|
92
|
+
legs: z.tuple([TradeLeg]).rest(TradeLeg)
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
const TriggerMarketClose = BaseTrigger.extend({
|
|
96
|
+
/**
|
|
97
|
+
* Intent
|
|
98
|
+
*/
|
|
99
|
+
intent: z.literal("CLOSE"),
|
|
100
|
+
/**
|
|
101
|
+
* Order type
|
|
102
|
+
*/
|
|
103
|
+
type: z.literal("MARKET"),
|
|
104
|
+
/**
|
|
105
|
+
* Condition (only close conditions allowed)
|
|
106
|
+
*/
|
|
107
|
+
condition: TriggerConditionClose,
|
|
108
|
+
/**
|
|
109
|
+
* Context
|
|
110
|
+
*/
|
|
111
|
+
context: z.object({
|
|
112
|
+
type: z.literal("MARKET"),
|
|
113
|
+
position: z.object({ id: z.uuid(), initialExposure: z.record(z.string(), z.string()) })
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
const TriggerMarket = z.discriminatedUnion("intent", [
|
|
117
|
+
TriggerMarketOpen,
|
|
118
|
+
TriggerMarketAdjust,
|
|
119
|
+
TriggerMarketClose
|
|
120
|
+
]);
|
|
121
|
+
const Trigger = z.discriminatedUnion("type", [TriggerMarket]);
|
|
122
|
+
|
|
123
|
+
export { Trigger, TriggerCancelledReason, TriggerIntent, TriggerMarket, TriggerMarketAdjust, TriggerMarketClose, TriggerMarketOpen, TriggerStatus };
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const CreateTriggerConditionRatioV1: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"ratio_v1">;
|
|
4
|
+
data: z.ZodObject<{
|
|
5
|
+
priceSource: z.ZodEnum<{
|
|
6
|
+
mid: "mid";
|
|
7
|
+
mark: "mark";
|
|
8
|
+
}>;
|
|
9
|
+
symbol_a: z.ZodString;
|
|
10
|
+
symbol_b: z.ZodString;
|
|
11
|
+
direction: z.ZodEnum<{
|
|
12
|
+
ABOVE: "ABOVE";
|
|
13
|
+
BELOW: "BELOW";
|
|
14
|
+
}>;
|
|
15
|
+
threshold: z.ZodNumber;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const CreateTriggerConditionPriceV1: z.ZodObject<{
|
|
19
|
+
type: z.ZodLiteral<"price_v1">;
|
|
20
|
+
data: z.ZodObject<{
|
|
21
|
+
priceSource: z.ZodEnum<{
|
|
22
|
+
mid: "mid";
|
|
23
|
+
mark: "mark";
|
|
24
|
+
}>;
|
|
25
|
+
symbol: z.ZodString;
|
|
26
|
+
direction: z.ZodEnum<{
|
|
27
|
+
ABOVE: "ABOVE";
|
|
28
|
+
BELOW: "BELOW";
|
|
29
|
+
}>;
|
|
30
|
+
threshold: z.ZodNumber;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
declare const CreateTriggerConditionIndexV1: z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"index_v1">;
|
|
35
|
+
data: z.ZodObject<{
|
|
36
|
+
priceSource: z.ZodEnum<{
|
|
37
|
+
mid: "mid";
|
|
38
|
+
mark: "mark";
|
|
39
|
+
}>;
|
|
40
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
41
|
+
symbol: z.ZodString;
|
|
42
|
+
weight: z.ZodNumber;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
direction: z.ZodEnum<{
|
|
45
|
+
ABOVE: "ABOVE";
|
|
46
|
+
BELOW: "BELOW";
|
|
47
|
+
}>;
|
|
48
|
+
threshold: z.ZodNumber;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
declare const CreateTriggerConditionWeightedRatioV1: z.ZodObject<{
|
|
52
|
+
type: z.ZodLiteral<"weighted_ratio_v1">;
|
|
53
|
+
data: z.ZodObject<{
|
|
54
|
+
priceSource: z.ZodEnum<{
|
|
55
|
+
mid: "mid";
|
|
56
|
+
mark: "mark";
|
|
57
|
+
}>;
|
|
58
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
59
|
+
symbol: z.ZodString;
|
|
60
|
+
side: z.ZodEnum<{
|
|
61
|
+
BUY: "BUY";
|
|
62
|
+
SELL: "SELL";
|
|
63
|
+
}>;
|
|
64
|
+
weight: z.ZodNumber;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
direction: z.ZodEnum<{
|
|
67
|
+
ABOVE: "ABOVE";
|
|
68
|
+
BELOW: "BELOW";
|
|
69
|
+
}>;
|
|
70
|
+
threshold: z.ZodNumber;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
declare const CreateTriggerConditionPositionValueV1: z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<"position_value_v1">;
|
|
75
|
+
data: z.ZodObject<{
|
|
76
|
+
priceSource: z.ZodEnum<{
|
|
77
|
+
mid: "mid";
|
|
78
|
+
mark: "mark";
|
|
79
|
+
}>;
|
|
80
|
+
direction: z.ZodEnum<{
|
|
81
|
+
ABOVE: "ABOVE";
|
|
82
|
+
BELOW: "BELOW";
|
|
83
|
+
}>;
|
|
84
|
+
threshold: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
declare const CreateTriggerConditionPositionUPnLValueV1: z.ZodObject<{
|
|
88
|
+
type: z.ZodLiteral<"position_upnl_value_v1">;
|
|
89
|
+
data: z.ZodObject<{
|
|
90
|
+
priceSource: z.ZodEnum<{
|
|
91
|
+
mid: "mid";
|
|
92
|
+
mark: "mark";
|
|
93
|
+
}>;
|
|
94
|
+
direction: z.ZodEnum<{
|
|
95
|
+
ABOVE: "ABOVE";
|
|
96
|
+
BELOW: "BELOW";
|
|
97
|
+
}>;
|
|
98
|
+
threshold: z.ZodNumber;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
declare const CreateTriggerConditionPositionUPnLPercentageV1: z.ZodObject<{
|
|
102
|
+
type: z.ZodLiteral<"position_upnl_percentage_v1">;
|
|
103
|
+
data: z.ZodObject<{
|
|
104
|
+
priceSource: z.ZodEnum<{
|
|
105
|
+
mid: "mid";
|
|
106
|
+
mark: "mark";
|
|
107
|
+
}>;
|
|
108
|
+
direction: z.ZodEnum<{
|
|
109
|
+
ABOVE: "ABOVE";
|
|
110
|
+
BELOW: "BELOW";
|
|
111
|
+
}>;
|
|
112
|
+
threshold_bps: z.ZodNumber;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
export declare const CreateTriggerConditionOpen: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
116
|
+
type: z.ZodLiteral<"ratio_v1">;
|
|
117
|
+
data: z.ZodObject<{
|
|
118
|
+
priceSource: z.ZodEnum<{
|
|
119
|
+
mid: "mid";
|
|
120
|
+
mark: "mark";
|
|
121
|
+
}>;
|
|
122
|
+
symbol_a: z.ZodString;
|
|
123
|
+
symbol_b: z.ZodString;
|
|
124
|
+
direction: z.ZodEnum<{
|
|
125
|
+
ABOVE: "ABOVE";
|
|
126
|
+
BELOW: "BELOW";
|
|
127
|
+
}>;
|
|
128
|
+
threshold: z.ZodNumber;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
131
|
+
type: z.ZodLiteral<"price_v1">;
|
|
132
|
+
data: z.ZodObject<{
|
|
133
|
+
priceSource: z.ZodEnum<{
|
|
134
|
+
mid: "mid";
|
|
135
|
+
mark: "mark";
|
|
136
|
+
}>;
|
|
137
|
+
symbol: z.ZodString;
|
|
138
|
+
direction: z.ZodEnum<{
|
|
139
|
+
ABOVE: "ABOVE";
|
|
140
|
+
BELOW: "BELOW";
|
|
141
|
+
}>;
|
|
142
|
+
threshold: z.ZodNumber;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
145
|
+
type: z.ZodLiteral<"index_v1">;
|
|
146
|
+
data: z.ZodObject<{
|
|
147
|
+
priceSource: z.ZodEnum<{
|
|
148
|
+
mid: "mid";
|
|
149
|
+
mark: "mark";
|
|
150
|
+
}>;
|
|
151
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
152
|
+
symbol: z.ZodString;
|
|
153
|
+
weight: z.ZodNumber;
|
|
154
|
+
}, z.core.$strip>>;
|
|
155
|
+
direction: z.ZodEnum<{
|
|
156
|
+
ABOVE: "ABOVE";
|
|
157
|
+
BELOW: "BELOW";
|
|
158
|
+
}>;
|
|
159
|
+
threshold: z.ZodNumber;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
162
|
+
type: z.ZodLiteral<"weighted_ratio_v1">;
|
|
163
|
+
data: z.ZodObject<{
|
|
164
|
+
priceSource: z.ZodEnum<{
|
|
165
|
+
mid: "mid";
|
|
166
|
+
mark: "mark";
|
|
167
|
+
}>;
|
|
168
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
169
|
+
symbol: z.ZodString;
|
|
170
|
+
side: z.ZodEnum<{
|
|
171
|
+
BUY: "BUY";
|
|
172
|
+
SELL: "SELL";
|
|
173
|
+
}>;
|
|
174
|
+
weight: z.ZodNumber;
|
|
175
|
+
}, z.core.$strip>>;
|
|
176
|
+
direction: z.ZodEnum<{
|
|
177
|
+
ABOVE: "ABOVE";
|
|
178
|
+
BELOW: "BELOW";
|
|
179
|
+
}>;
|
|
180
|
+
threshold: z.ZodNumber;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
}, z.core.$strip>], "type">;
|
|
183
|
+
export declare const CreateTriggerConditionClose: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
184
|
+
type: z.ZodLiteral<"ratio_v1">;
|
|
185
|
+
data: z.ZodObject<{
|
|
186
|
+
priceSource: z.ZodEnum<{
|
|
187
|
+
mid: "mid";
|
|
188
|
+
mark: "mark";
|
|
189
|
+
}>;
|
|
190
|
+
symbol_a: z.ZodString;
|
|
191
|
+
symbol_b: z.ZodString;
|
|
192
|
+
direction: z.ZodEnum<{
|
|
193
|
+
ABOVE: "ABOVE";
|
|
194
|
+
BELOW: "BELOW";
|
|
195
|
+
}>;
|
|
196
|
+
threshold: z.ZodNumber;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
199
|
+
type: z.ZodLiteral<"price_v1">;
|
|
200
|
+
data: z.ZodObject<{
|
|
201
|
+
priceSource: z.ZodEnum<{
|
|
202
|
+
mid: "mid";
|
|
203
|
+
mark: "mark";
|
|
204
|
+
}>;
|
|
205
|
+
symbol: z.ZodString;
|
|
206
|
+
direction: z.ZodEnum<{
|
|
207
|
+
ABOVE: "ABOVE";
|
|
208
|
+
BELOW: "BELOW";
|
|
209
|
+
}>;
|
|
210
|
+
threshold: z.ZodNumber;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
213
|
+
type: z.ZodLiteral<"index_v1">;
|
|
214
|
+
data: z.ZodObject<{
|
|
215
|
+
priceSource: z.ZodEnum<{
|
|
216
|
+
mid: "mid";
|
|
217
|
+
mark: "mark";
|
|
218
|
+
}>;
|
|
219
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
220
|
+
symbol: z.ZodString;
|
|
221
|
+
weight: z.ZodNumber;
|
|
222
|
+
}, z.core.$strip>>;
|
|
223
|
+
direction: z.ZodEnum<{
|
|
224
|
+
ABOVE: "ABOVE";
|
|
225
|
+
BELOW: "BELOW";
|
|
226
|
+
}>;
|
|
227
|
+
threshold: z.ZodNumber;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
230
|
+
type: z.ZodLiteral<"weighted_ratio_v1">;
|
|
231
|
+
data: z.ZodObject<{
|
|
232
|
+
priceSource: z.ZodEnum<{
|
|
233
|
+
mid: "mid";
|
|
234
|
+
mark: "mark";
|
|
235
|
+
}>;
|
|
236
|
+
basket: z.ZodArray<z.ZodObject<{
|
|
237
|
+
symbol: z.ZodString;
|
|
238
|
+
side: z.ZodEnum<{
|
|
239
|
+
BUY: "BUY";
|
|
240
|
+
SELL: "SELL";
|
|
241
|
+
}>;
|
|
242
|
+
weight: z.ZodNumber;
|
|
243
|
+
}, z.core.$strip>>;
|
|
244
|
+
direction: z.ZodEnum<{
|
|
245
|
+
ABOVE: "ABOVE";
|
|
246
|
+
BELOW: "BELOW";
|
|
247
|
+
}>;
|
|
248
|
+
threshold: z.ZodNumber;
|
|
249
|
+
}, z.core.$strip>;
|
|
250
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
251
|
+
type: z.ZodLiteral<"position_value_v1">;
|
|
252
|
+
data: z.ZodObject<{
|
|
253
|
+
priceSource: z.ZodEnum<{
|
|
254
|
+
mid: "mid";
|
|
255
|
+
mark: "mark";
|
|
256
|
+
}>;
|
|
257
|
+
direction: z.ZodEnum<{
|
|
258
|
+
ABOVE: "ABOVE";
|
|
259
|
+
BELOW: "BELOW";
|
|
260
|
+
}>;
|
|
261
|
+
threshold: z.ZodNumber;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
264
|
+
type: z.ZodLiteral<"position_upnl_value_v1">;
|
|
265
|
+
data: z.ZodObject<{
|
|
266
|
+
priceSource: z.ZodEnum<{
|
|
267
|
+
mid: "mid";
|
|
268
|
+
mark: "mark";
|
|
269
|
+
}>;
|
|
270
|
+
direction: z.ZodEnum<{
|
|
271
|
+
ABOVE: "ABOVE";
|
|
272
|
+
BELOW: "BELOW";
|
|
273
|
+
}>;
|
|
274
|
+
threshold: z.ZodNumber;
|
|
275
|
+
}, z.core.$strip>;
|
|
276
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
277
|
+
type: z.ZodLiteral<"position_upnl_percentage_v1">;
|
|
278
|
+
data: z.ZodObject<{
|
|
279
|
+
priceSource: z.ZodEnum<{
|
|
280
|
+
mid: "mid";
|
|
281
|
+
mark: "mark";
|
|
282
|
+
}>;
|
|
283
|
+
direction: z.ZodEnum<{
|
|
284
|
+
ABOVE: "ABOVE";
|
|
285
|
+
BELOW: "BELOW";
|
|
286
|
+
}>;
|
|
287
|
+
threshold_bps: z.ZodNumber;
|
|
288
|
+
}, z.core.$strip>;
|
|
289
|
+
}, z.core.$strip>], "type">;
|
|
290
|
+
export declare const CreateTriggerConditionAttach: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
291
|
+
type: z.ZodLiteral<"position_value_v1">;
|
|
292
|
+
data: z.ZodObject<{
|
|
293
|
+
priceSource: z.ZodEnum<{
|
|
294
|
+
mid: "mid";
|
|
295
|
+
mark: "mark";
|
|
296
|
+
}>;
|
|
297
|
+
direction: z.ZodEnum<{
|
|
298
|
+
ABOVE: "ABOVE";
|
|
299
|
+
BELOW: "BELOW";
|
|
300
|
+
}>;
|
|
301
|
+
threshold: z.ZodNumber;
|
|
302
|
+
}, z.core.$strip>;
|
|
303
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
304
|
+
type: z.ZodLiteral<"position_upnl_value_v1">;
|
|
305
|
+
data: z.ZodObject<{
|
|
306
|
+
priceSource: z.ZodEnum<{
|
|
307
|
+
mid: "mid";
|
|
308
|
+
mark: "mark";
|
|
309
|
+
}>;
|
|
310
|
+
direction: z.ZodEnum<{
|
|
311
|
+
ABOVE: "ABOVE";
|
|
312
|
+
BELOW: "BELOW";
|
|
313
|
+
}>;
|
|
314
|
+
threshold: z.ZodNumber;
|
|
315
|
+
}, z.core.$strip>;
|
|
316
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
317
|
+
type: z.ZodLiteral<"position_upnl_percentage_v1">;
|
|
318
|
+
data: z.ZodObject<{
|
|
319
|
+
priceSource: z.ZodEnum<{
|
|
320
|
+
mid: "mid";
|
|
321
|
+
mark: "mark";
|
|
322
|
+
}>;
|
|
323
|
+
direction: z.ZodEnum<{
|
|
324
|
+
ABOVE: "ABOVE";
|
|
325
|
+
BELOW: "BELOW";
|
|
326
|
+
}>;
|
|
327
|
+
threshold_bps: z.ZodNumber;
|
|
328
|
+
}, z.core.$strip>;
|
|
329
|
+
}, z.core.$strip>], "type">;
|
|
330
|
+
export type CreateTriggerConditionRatioV1 = z.output<typeof CreateTriggerConditionRatioV1>;
|
|
331
|
+
export type CreateTriggerConditionPriceV1 = z.output<typeof CreateTriggerConditionPriceV1>;
|
|
332
|
+
export type CreateTriggerConditionIndexV1 = z.output<typeof CreateTriggerConditionIndexV1>;
|
|
333
|
+
export type CreateTriggerConditionWeightedRatioV1 = z.output<typeof CreateTriggerConditionWeightedRatioV1>;
|
|
334
|
+
export type CreateTriggerConditionPositionValueV1 = z.output<typeof CreateTriggerConditionPositionValueV1>;
|
|
335
|
+
export type CreateTriggerConditionPositionUPnLValueV1 = z.output<typeof CreateTriggerConditionPositionUPnLValueV1>;
|
|
336
|
+
export type CreateTriggerConditionPositionUPnLPercentageV1 = z.output<typeof CreateTriggerConditionPositionUPnLPercentageV1>;
|
|
337
|
+
export type CreateTriggerConditionOpen = z.output<typeof CreateTriggerConditionOpen>;
|
|
338
|
+
export type CreateTriggerConditionClose = z.output<typeof CreateTriggerConditionClose>;
|
|
339
|
+
export type CreateTriggerConditionAttach = z.output<typeof CreateTriggerConditionAttach>;
|
|
340
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { RefineTwoUniqueSymbols, RefineMinimumTwoSymbols, RefineWeightingSum, RefineUniqueSymbols, RefineMinimumOneBuyOneSell } from '../../common/refinement';
|
|
3
|
+
import { Side } from '../../common/schema';
|
|
4
|
+
import { InstrumentId } from '../../instrument';
|
|
5
|
+
|
|
6
|
+
const TriggerDirectionEnum = z.enum(["ABOVE", "BELOW"], {
|
|
7
|
+
message: "Trigger direction must be ABOVE or BELOW"
|
|
8
|
+
});
|
|
9
|
+
const TriggerThreshold = z.number().positive({
|
|
10
|
+
message: "Threshold must be greater than 0"
|
|
11
|
+
});
|
|
12
|
+
const PriceSource = z.enum(["mid", "mark"], {
|
|
13
|
+
message: "Price source must be mid or mark"
|
|
14
|
+
});
|
|
15
|
+
const AssetWeight = z.number().positive({ message: "Weight must be greater than 0" }).max(1, { message: "Weight must be less than 1" });
|
|
16
|
+
const CreateTriggerConditionRatioV1 = z.object({
|
|
17
|
+
type: z.literal("ratio_v1"),
|
|
18
|
+
data: z.object({
|
|
19
|
+
priceSource: PriceSource,
|
|
20
|
+
symbol_a: InstrumentId,
|
|
21
|
+
symbol_b: InstrumentId,
|
|
22
|
+
direction: TriggerDirectionEnum,
|
|
23
|
+
threshold: TriggerThreshold
|
|
24
|
+
}).superRefine(RefineTwoUniqueSymbols)
|
|
25
|
+
});
|
|
26
|
+
const CreateTriggerConditionPriceV1 = z.object({
|
|
27
|
+
type: z.literal("price_v1"),
|
|
28
|
+
data: z.object({
|
|
29
|
+
priceSource: PriceSource,
|
|
30
|
+
symbol: InstrumentId,
|
|
31
|
+
direction: TriggerDirectionEnum,
|
|
32
|
+
threshold: TriggerThreshold
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
const CreateTriggerConditionIndexV1 = z.object({
|
|
36
|
+
type: z.literal("index_v1"),
|
|
37
|
+
data: z.object({
|
|
38
|
+
priceSource: PriceSource,
|
|
39
|
+
basket: z.array(
|
|
40
|
+
z.object({
|
|
41
|
+
symbol: InstrumentId,
|
|
42
|
+
weight: AssetWeight
|
|
43
|
+
})
|
|
44
|
+
).superRefine(RefineMinimumTwoSymbols).superRefine(RefineWeightingSum).superRefine(RefineUniqueSymbols),
|
|
45
|
+
direction: TriggerDirectionEnum,
|
|
46
|
+
threshold: TriggerThreshold
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
const CreateTriggerConditionWeightedRatioV1 = z.object({
|
|
50
|
+
type: z.literal("weighted_ratio_v1"),
|
|
51
|
+
data: z.object({
|
|
52
|
+
priceSource: PriceSource,
|
|
53
|
+
basket: z.array(
|
|
54
|
+
z.object({
|
|
55
|
+
symbol: InstrumentId,
|
|
56
|
+
side: Side,
|
|
57
|
+
weight: AssetWeight
|
|
58
|
+
})
|
|
59
|
+
).superRefine(RefineMinimumTwoSymbols).superRefine(RefineUniqueSymbols).superRefine(RefineWeightingSum).superRefine(RefineMinimumOneBuyOneSell),
|
|
60
|
+
direction: TriggerDirectionEnum,
|
|
61
|
+
threshold: TriggerThreshold
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
const CreateTriggerConditionPositionValueV1 = z.object({
|
|
65
|
+
type: z.literal("position_value_v1"),
|
|
66
|
+
data: z.object({
|
|
67
|
+
priceSource: PriceSource,
|
|
68
|
+
direction: TriggerDirectionEnum,
|
|
69
|
+
threshold: TriggerThreshold
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
const CreateTriggerConditionPositionUPnLValueV1 = z.object({
|
|
73
|
+
type: z.literal("position_upnl_value_v1"),
|
|
74
|
+
data: z.object({
|
|
75
|
+
priceSource: PriceSource,
|
|
76
|
+
direction: TriggerDirectionEnum,
|
|
77
|
+
threshold: TriggerThreshold
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
const CreateTriggerConditionPositionUPnLPercentageV1 = z.object({
|
|
81
|
+
type: z.literal("position_upnl_percentage_v1"),
|
|
82
|
+
data: z.object({
|
|
83
|
+
priceSource: PriceSource,
|
|
84
|
+
direction: TriggerDirectionEnum,
|
|
85
|
+
threshold_bps: TriggerThreshold
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
const CreateTriggerConditionOpen = z.discriminatedUnion("type", [
|
|
89
|
+
CreateTriggerConditionRatioV1,
|
|
90
|
+
CreateTriggerConditionPriceV1,
|
|
91
|
+
CreateTriggerConditionIndexV1,
|
|
92
|
+
CreateTriggerConditionWeightedRatioV1
|
|
93
|
+
]);
|
|
94
|
+
const CreateTriggerConditionClose = z.discriminatedUnion("type", [
|
|
95
|
+
CreateTriggerConditionRatioV1,
|
|
96
|
+
CreateTriggerConditionPriceV1,
|
|
97
|
+
CreateTriggerConditionIndexV1,
|
|
98
|
+
CreateTriggerConditionWeightedRatioV1,
|
|
99
|
+
CreateTriggerConditionPositionValueV1,
|
|
100
|
+
CreateTriggerConditionPositionUPnLValueV1,
|
|
101
|
+
CreateTriggerConditionPositionUPnLPercentageV1
|
|
102
|
+
]);
|
|
103
|
+
const CreateTriggerConditionAttach = z.discriminatedUnion("type", [
|
|
104
|
+
CreateTriggerConditionPositionValueV1,
|
|
105
|
+
CreateTriggerConditionPositionUPnLValueV1,
|
|
106
|
+
CreateTriggerConditionPositionUPnLPercentageV1
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
export { CreateTriggerConditionAttach, CreateTriggerConditionClose, CreateTriggerConditionOpen };
|