@pear-protocol/types 1.1.0 → 1.3.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/execution/entities.d.ts +175 -0
- package/dist/execution/entities.js +18 -3
- package/dist/execution/responses.d.ts +57 -0
- package/dist/schedule/entities.d.ts +6 -0
- package/dist/schedule/entities.js +7 -1
- package/dist/schedule/responses.d.ts +4 -0
- package/dist/tca/responses.d.ts +128 -0
- package/dist/tca/responses.js +19 -1
- package/dist/trade/payloads.d.ts +10 -2
- package/dist/trade/payloads.js +9 -1
- package/dist/trade/responses.d.ts +506 -0
- package/dist/trade/responses.js +2 -1
- package/dist/trigger/common/index.d.ts +1 -0
- package/dist/trigger/common/index.js +7 -1
- package/dist/trigger/entities/index.d.ts +51 -0
- package/dist/trigger/entities/index.js +11 -3
- package/dist/trigger/payloads/config.d.ts +1 -0
- package/dist/trigger/payloads/config.js +3 -0
- package/dist/trigger/payloads/index.d.ts +290 -147
- package/dist/trigger/payloads/index.js +29 -16
- package/dist/trigger/responses.d.ts +26 -0
- package/package.json +1 -1
|
@@ -2,20 +2,43 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ClientIdCode } from '../../common/client-id';
|
|
3
3
|
import { RefineMinimumOneSymbol, RefineUniqueSymbols } from '../../common/refinement';
|
|
4
4
|
import { TradeLegPostOnly } from '../../common/trade-legs';
|
|
5
|
-
import { TrailingMode, BracketType } from '../common';
|
|
5
|
+
import { TrailingMode, TpSlBracketType, BracketType } from '../common';
|
|
6
6
|
import { RefineStaticLogicalRules } from '../refinement/static.refinement';
|
|
7
7
|
import { RefineTrailingConfig, RefineTrailingLogicalRules } from '../refinement/trailing.refinement';
|
|
8
|
-
import {
|
|
8
|
+
import { CreateTriggerConditionAttachStatic, CreateTriggerConditionAttachTrailing, CreateTriggerConditionOpen, CreateTriggerConditionCloseStatic, CreateTriggerConditionCloseTrailing } from './conditions';
|
|
9
|
+
import { MAX_ATTACH_TRIGGERS } from './config';
|
|
9
10
|
|
|
10
11
|
const TrailingConfig = z.object({
|
|
11
12
|
mode: TrailingMode,
|
|
12
13
|
deltaValue: z.number(),
|
|
13
14
|
activationValue: z.number().optional()
|
|
14
15
|
}).superRefine(RefineTrailingConfig);
|
|
16
|
+
const AttachTriggerMarketCloseStatic = z.object({
|
|
17
|
+
intent: z.literal("CLOSE"),
|
|
18
|
+
type: z.literal("MARKET"),
|
|
19
|
+
bracketType: TpSlBracketType,
|
|
20
|
+
condition: CreateTriggerConditionAttachStatic
|
|
21
|
+
}).superRefine(RefineStaticLogicalRules);
|
|
22
|
+
const AttachTriggerMarketCloseTrailing = z.object({
|
|
23
|
+
intent: z.literal("CLOSE"),
|
|
24
|
+
type: z.literal("MARKET"),
|
|
25
|
+
condition: CreateTriggerConditionAttachTrailing,
|
|
26
|
+
trailing: TrailingConfig
|
|
27
|
+
}).superRefine(RefineTrailingLogicalRules);
|
|
28
|
+
const AttachTriggerMarketClose = z.union([AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing]);
|
|
15
29
|
const CreateTriggerMarketOpen = z.object({
|
|
16
30
|
intent: z.literal("OPEN"),
|
|
17
31
|
type: z.literal("MARKET"),
|
|
18
32
|
condition: CreateTriggerConditionOpen,
|
|
33
|
+
attachTriggers: z.array(AttachTriggerMarketClose).max(MAX_ATTACH_TRIGGERS, `A market-open trigger can attach at most ${MAX_ATTACH_TRIGGERS} close triggers.`).superRefine((attachTriggers, ctx) => {
|
|
34
|
+
const trailingCount = attachTriggers.filter(isAttachTriggerMarketCloseTrailing).length;
|
|
35
|
+
if (trailingCount > 1) {
|
|
36
|
+
ctx.addIssue({
|
|
37
|
+
code: "custom",
|
|
38
|
+
message: "A market-open trigger can attach at most one trailing close trigger."
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}).optional(),
|
|
19
42
|
payload: z.object({
|
|
20
43
|
type: z.literal("MARKET"),
|
|
21
44
|
legs: z.tuple([TradeLegPostOnly]).rest(TradeLegPostOnly).superRefine(RefineMinimumOneSymbol).superRefine(RefineUniqueSymbols).describe("Array of legs to make up the exposure")
|
|
@@ -48,20 +71,10 @@ const CreateTriggerMarketCloseTrailing = z.object({
|
|
|
48
71
|
clientId: ClientIdCode
|
|
49
72
|
}).superRefine(RefineTrailingLogicalRules);
|
|
50
73
|
const CreateTriggerMarketClose = z.union([CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing]);
|
|
51
|
-
const AttachTriggerMarketCloseStatic = z.object({
|
|
52
|
-
intent: z.literal("CLOSE"),
|
|
53
|
-
type: z.literal("MARKET"),
|
|
54
|
-
bracketType: BracketType,
|
|
55
|
-
condition: CreateTriggerConditionAttachStatic
|
|
56
|
-
}).superRefine(RefineStaticLogicalRules);
|
|
57
|
-
const AttachTriggerMarketCloseTrailing = z.object({
|
|
58
|
-
intent: z.literal("CLOSE"),
|
|
59
|
-
type: z.literal("MARKET"),
|
|
60
|
-
condition: CreateTriggerConditionAttachTrailing,
|
|
61
|
-
trailing: TrailingConfig
|
|
62
|
-
}).superRefine(RefineTrailingLogicalRules);
|
|
63
|
-
const AttachTriggerMarketClose = z.union([AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing]);
|
|
64
74
|
const CreateTriggerOpen = z.discriminatedUnion("type", [CreateTriggerMarketOpen]);
|
|
65
75
|
const CreateTriggerClose = CreateTriggerMarketClose;
|
|
76
|
+
function isAttachTriggerMarketCloseTrailing(attachedTrigger) {
|
|
77
|
+
return "trailing" in attachedTrigger && attachedTrigger.trailing !== void 0;
|
|
78
|
+
}
|
|
66
79
|
|
|
67
|
-
export { AttachTriggerMarketClose, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig };
|
|
80
|
+
export { AttachTriggerMarketClose, AttachTriggerMarketCloseStatic, AttachTriggerMarketCloseTrailing, CreateTriggerClose, CreateTriggerMarketClose, CreateTriggerMarketCloseStatic, CreateTriggerMarketCloseTrailing, CreateTriggerMarketOpen, CreateTriggerOpen, TrailingConfig, isAttachTriggerMarketCloseTrailing };
|
|
@@ -24,6 +24,7 @@ export declare const TriggerListResponse: z.ZodObject<{
|
|
|
24
24
|
POSITION_CLOSED: "POSITION_CLOSED";
|
|
25
25
|
SYSTEM: "SYSTEM";
|
|
26
26
|
POSITION_NETTED: "POSITION_NETTED";
|
|
27
|
+
POSITION_REVERSED: "POSITION_REVERSED";
|
|
27
28
|
}>>;
|
|
28
29
|
fills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
30
|
id: z.ZodUUID;
|
|
@@ -187,6 +188,16 @@ export declare const TriggerListResponse: z.ZodObject<{
|
|
|
187
188
|
}>;
|
|
188
189
|
amount: z.ZodString;
|
|
189
190
|
}, z.core.$strip>>;
|
|
191
|
+
attachedTriggers: z.ZodArray<z.ZodObject<{
|
|
192
|
+
kind: z.ZodEnum<{
|
|
193
|
+
STATIC: "STATIC";
|
|
194
|
+
TRAILING: "TRAILING";
|
|
195
|
+
}>;
|
|
196
|
+
bracketType: z.ZodEnum<{
|
|
197
|
+
STOP_LOSS: "STOP_LOSS";
|
|
198
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
199
|
+
}>;
|
|
200
|
+
}, z.core.$strip>>;
|
|
190
201
|
}, z.core.$strip>;
|
|
191
202
|
}, z.core.$strip>, z.ZodObject<{
|
|
192
203
|
id: z.ZodUUID;
|
|
@@ -210,6 +221,7 @@ export declare const TriggerListResponse: z.ZodObject<{
|
|
|
210
221
|
POSITION_CLOSED: "POSITION_CLOSED";
|
|
211
222
|
SYSTEM: "SYSTEM";
|
|
212
223
|
POSITION_NETTED: "POSITION_NETTED";
|
|
224
|
+
POSITION_REVERSED: "POSITION_REVERSED";
|
|
213
225
|
}>>;
|
|
214
226
|
fills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
215
227
|
id: z.ZodUUID;
|
|
@@ -452,6 +464,7 @@ export declare const TriggerListResponse: z.ZodObject<{
|
|
|
452
464
|
POSITION_CLOSED: "POSITION_CLOSED";
|
|
453
465
|
SYSTEM: "SYSTEM";
|
|
454
466
|
POSITION_NETTED: "POSITION_NETTED";
|
|
467
|
+
POSITION_REVERSED: "POSITION_REVERSED";
|
|
455
468
|
}>>;
|
|
456
469
|
fills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
457
470
|
id: z.ZodUUID;
|
|
@@ -732,6 +745,7 @@ export declare const CreateTriggerResponse: z.ZodObject<{
|
|
|
732
745
|
POSITION_CLOSED: "POSITION_CLOSED";
|
|
733
746
|
SYSTEM: "SYSTEM";
|
|
734
747
|
POSITION_NETTED: "POSITION_NETTED";
|
|
748
|
+
POSITION_REVERSED: "POSITION_REVERSED";
|
|
735
749
|
}>>;
|
|
736
750
|
fills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
737
751
|
id: z.ZodUUID;
|
|
@@ -895,6 +909,16 @@ export declare const CreateTriggerResponse: z.ZodObject<{
|
|
|
895
909
|
}>;
|
|
896
910
|
amount: z.ZodString;
|
|
897
911
|
}, z.core.$strip>>;
|
|
912
|
+
attachedTriggers: z.ZodArray<z.ZodObject<{
|
|
913
|
+
kind: z.ZodEnum<{
|
|
914
|
+
STATIC: "STATIC";
|
|
915
|
+
TRAILING: "TRAILING";
|
|
916
|
+
}>;
|
|
917
|
+
bracketType: z.ZodEnum<{
|
|
918
|
+
STOP_LOSS: "STOP_LOSS";
|
|
919
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
920
|
+
}>;
|
|
921
|
+
}, z.core.$strip>>;
|
|
898
922
|
}, z.core.$strip>;
|
|
899
923
|
}, z.core.$strip>, z.ZodObject<{
|
|
900
924
|
id: z.ZodUUID;
|
|
@@ -918,6 +942,7 @@ export declare const CreateTriggerResponse: z.ZodObject<{
|
|
|
918
942
|
POSITION_CLOSED: "POSITION_CLOSED";
|
|
919
943
|
SYSTEM: "SYSTEM";
|
|
920
944
|
POSITION_NETTED: "POSITION_NETTED";
|
|
945
|
+
POSITION_REVERSED: "POSITION_REVERSED";
|
|
921
946
|
}>>;
|
|
922
947
|
fills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
923
948
|
id: z.ZodUUID;
|
|
@@ -1160,6 +1185,7 @@ export declare const CreateTriggerResponse: z.ZodObject<{
|
|
|
1160
1185
|
POSITION_CLOSED: "POSITION_CLOSED";
|
|
1161
1186
|
SYSTEM: "SYSTEM";
|
|
1162
1187
|
POSITION_NETTED: "POSITION_NETTED";
|
|
1188
|
+
POSITION_REVERSED: "POSITION_REVERSED";
|
|
1163
1189
|
}>>;
|
|
1164
1190
|
fills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1165
1191
|
id: z.ZodUUID;
|