@pear-protocol/types 1.5.0 → 1.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/fill/entities.d.ts +1 -0
- package/dist/fill/entities.js +8 -16
- package/dist/fill/responses.d.ts +2 -0
- package/dist/ladder/entities.d.ts +3 -0
- package/dist/ladder/responses.d.ts +9 -0
- package/dist/notification/entities.d.ts +265 -0
- package/dist/notification/entities.js +52 -6
- package/dist/notification/responses.d.ts +120 -0
- package/dist/position/entities.d.ts +29 -0
- package/dist/position/entities.js +5 -7
- package/dist/position/responses.d.ts +18 -2
- package/dist/position/responses.js +4 -2
- package/dist/rebalance/entities.d.ts +64 -0
- package/dist/rebalance/entities.js +33 -0
- package/dist/rebalance/index.d.ts +2 -0
- package/dist/rebalance/index.js +2 -0
- package/dist/rebalance/payloads.d.ts +48 -2
- package/dist/rebalance/payloads.js +24 -2
- package/dist/rebalance/queries.d.ts +22 -0
- package/dist/rebalance/queries.js +20 -0
- package/dist/rebalance/responses.d.ts +82 -5
- package/dist/rebalance/responses.js +22 -4
- package/dist/schedule/entities.d.ts +5 -0
- package/dist/schedule/responses.d.ts +4 -0
- package/dist/sync/payloads.d.ts +251 -71
- package/dist/sync/payloads.js +84 -32
- package/dist/sync/responses.d.ts +7 -4
- package/dist/sync/responses.js +9 -4
- package/dist/trigger/entities/index.d.ts +10 -0
- package/dist/trigger/responses.d.ts +6 -0
- package/package.json +1 -1
|
@@ -6,6 +6,10 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
6
6
|
TAKE_PROFIT_HIT: "TAKE_PROFIT_HIT";
|
|
7
7
|
STOP_LOSS_HIT: "STOP_LOSS_HIT";
|
|
8
8
|
TRIGGER_ORDER_HIT: "TRIGGER_ORDER_HIT";
|
|
9
|
+
TAKE_PROFIT_FAILED: "TAKE_PROFIT_FAILED";
|
|
10
|
+
STOP_LOSS_FAILED: "STOP_LOSS_FAILED";
|
|
11
|
+
TRIGGER_ORDER_FAILED: "TRIGGER_ORDER_FAILED";
|
|
12
|
+
ATTACHED_TRIGGER_DISCARDED: "ATTACHED_TRIGGER_DISCARDED";
|
|
9
13
|
}>;
|
|
10
14
|
parameters: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
11
15
|
type: z.ZodLiteral<"take_profit">;
|
|
@@ -18,6 +22,25 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
18
22
|
okx: "okx";
|
|
19
23
|
lighter: "lighter";
|
|
20
24
|
}>;
|
|
25
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
price: "price";
|
|
27
|
+
notional: "notional";
|
|
28
|
+
ratio: "ratio";
|
|
29
|
+
weighted_ratio: "weighted_ratio";
|
|
30
|
+
upnl: "upnl";
|
|
31
|
+
upnl_bps: "upnl_bps";
|
|
32
|
+
funding_rate: "funding_rate";
|
|
33
|
+
prediction_market: "prediction_market";
|
|
34
|
+
btc_dominance: "btc_dominance";
|
|
35
|
+
ratio_trailing: "ratio_trailing";
|
|
36
|
+
price_trailing: "price_trailing";
|
|
37
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
38
|
+
notional_trailing: "notional_trailing";
|
|
39
|
+
upnl_trailing: "upnl_trailing";
|
|
40
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
41
|
+
}>>;
|
|
42
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
21
44
|
}, z.core.$strip>, z.ZodObject<{
|
|
22
45
|
type: z.ZodLiteral<"stop_loss">;
|
|
23
46
|
triggerId: z.ZodUUID;
|
|
@@ -29,6 +52,25 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
29
52
|
okx: "okx";
|
|
30
53
|
lighter: "lighter";
|
|
31
54
|
}>;
|
|
55
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
price: "price";
|
|
57
|
+
notional: "notional";
|
|
58
|
+
ratio: "ratio";
|
|
59
|
+
weighted_ratio: "weighted_ratio";
|
|
60
|
+
upnl: "upnl";
|
|
61
|
+
upnl_bps: "upnl_bps";
|
|
62
|
+
funding_rate: "funding_rate";
|
|
63
|
+
prediction_market: "prediction_market";
|
|
64
|
+
btc_dominance: "btc_dominance";
|
|
65
|
+
ratio_trailing: "ratio_trailing";
|
|
66
|
+
price_trailing: "price_trailing";
|
|
67
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
68
|
+
notional_trailing: "notional_trailing";
|
|
69
|
+
upnl_trailing: "upnl_trailing";
|
|
70
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
71
|
+
}>>;
|
|
72
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
32
74
|
}, z.core.$strip>, z.ZodObject<{
|
|
33
75
|
type: z.ZodLiteral<"trigger_order">;
|
|
34
76
|
triggerId: z.ZodUUID;
|
|
@@ -40,6 +82,25 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
40
82
|
okx: "okx";
|
|
41
83
|
lighter: "lighter";
|
|
42
84
|
}>;
|
|
85
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
price: "price";
|
|
87
|
+
notional: "notional";
|
|
88
|
+
ratio: "ratio";
|
|
89
|
+
weighted_ratio: "weighted_ratio";
|
|
90
|
+
upnl: "upnl";
|
|
91
|
+
upnl_bps: "upnl_bps";
|
|
92
|
+
funding_rate: "funding_rate";
|
|
93
|
+
prediction_market: "prediction_market";
|
|
94
|
+
btc_dominance: "btc_dominance";
|
|
95
|
+
ratio_trailing: "ratio_trailing";
|
|
96
|
+
price_trailing: "price_trailing";
|
|
97
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
98
|
+
notional_trailing: "notional_trailing";
|
|
99
|
+
upnl_trailing: "upnl_trailing";
|
|
100
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
101
|
+
}>>;
|
|
102
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
43
104
|
}, z.core.$strip>, z.ZodObject<{
|
|
44
105
|
type: z.ZodLiteral<"default_trigger">;
|
|
45
106
|
triggerId: z.ZodUUID;
|
|
@@ -50,6 +111,65 @@ export declare const NotificationListResponse: z.ZodObject<{
|
|
|
50
111
|
okx: "okx";
|
|
51
112
|
lighter: "lighter";
|
|
52
113
|
}>;
|
|
114
|
+
metric: z.ZodOptional<z.ZodEnum<{
|
|
115
|
+
price: "price";
|
|
116
|
+
notional: "notional";
|
|
117
|
+
ratio: "ratio";
|
|
118
|
+
weighted_ratio: "weighted_ratio";
|
|
119
|
+
upnl: "upnl";
|
|
120
|
+
upnl_bps: "upnl_bps";
|
|
121
|
+
funding_rate: "funding_rate";
|
|
122
|
+
prediction_market: "prediction_market";
|
|
123
|
+
btc_dominance: "btc_dominance";
|
|
124
|
+
ratio_trailing: "ratio_trailing";
|
|
125
|
+
price_trailing: "price_trailing";
|
|
126
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
127
|
+
notional_trailing: "notional_trailing";
|
|
128
|
+
upnl_trailing: "upnl_trailing";
|
|
129
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
130
|
+
}>>;
|
|
131
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
type: z.ZodLiteral<"attached_trigger_discarded">;
|
|
135
|
+
positionId: z.ZodUUID;
|
|
136
|
+
positionKey: z.ZodString;
|
|
137
|
+
connector: z.ZodEnum<{
|
|
138
|
+
hyperliquid: "hyperliquid";
|
|
139
|
+
binance: "binance";
|
|
140
|
+
bybit: "bybit";
|
|
141
|
+
okx: "okx";
|
|
142
|
+
lighter: "lighter";
|
|
143
|
+
}>;
|
|
144
|
+
discarded: z.ZodArray<z.ZodObject<{
|
|
145
|
+
bracketType: z.ZodEnum<{
|
|
146
|
+
STOP_LOSS: "STOP_LOSS";
|
|
147
|
+
TAKE_PROFIT: "TAKE_PROFIT";
|
|
148
|
+
}>;
|
|
149
|
+
metric: z.ZodEnum<{
|
|
150
|
+
price: "price";
|
|
151
|
+
notional: "notional";
|
|
152
|
+
ratio: "ratio";
|
|
153
|
+
weighted_ratio: "weighted_ratio";
|
|
154
|
+
upnl: "upnl";
|
|
155
|
+
upnl_bps: "upnl_bps";
|
|
156
|
+
funding_rate: "funding_rate";
|
|
157
|
+
prediction_market: "prediction_market";
|
|
158
|
+
btc_dominance: "btc_dominance";
|
|
159
|
+
ratio_trailing: "ratio_trailing";
|
|
160
|
+
price_trailing: "price_trailing";
|
|
161
|
+
weighted_ratio_trailing: "weighted_ratio_trailing";
|
|
162
|
+
notional_trailing: "notional_trailing";
|
|
163
|
+
upnl_trailing: "upnl_trailing";
|
|
164
|
+
upnl_bps_trailing: "upnl_bps_trailing";
|
|
165
|
+
}>;
|
|
166
|
+
level: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
reason: z.ZodEnum<{
|
|
168
|
+
TRIGGER_LIMIT: "TRIGGER_LIMIT";
|
|
169
|
+
TRAILING_ALREADY_EXISTS: "TRAILING_ALREADY_EXISTS";
|
|
170
|
+
}>;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
activeTriggerLimit: z.ZodNumber;
|
|
53
173
|
}, z.core.$strip>], "type">;
|
|
54
174
|
isRead: z.ZodBoolean;
|
|
55
175
|
createdAt: z.ZodString;
|
|
@@ -10,6 +10,18 @@ export declare const PositionClosedReason: z.ZodEnum<{
|
|
|
10
10
|
LIQUIDATED: "LIQUIDATED";
|
|
11
11
|
}>;
|
|
12
12
|
export type PositionClosedReason = z.infer<typeof PositionClosedReason>;
|
|
13
|
+
/**
|
|
14
|
+
* Provenance of a position, derived from the SET of fill origins on it.
|
|
15
|
+
* - PEAR: opened via Pear, only Pear fills
|
|
16
|
+
* - EXTERNAL: opened directly on the exchange, only external fills
|
|
17
|
+
* - PARTIAL: a mix of Pear and external fills
|
|
18
|
+
*/
|
|
19
|
+
export declare const PositionOrigin: z.ZodEnum<{
|
|
20
|
+
PARTIAL: "PARTIAL";
|
|
21
|
+
PEAR: "PEAR";
|
|
22
|
+
EXTERNAL: "EXTERNAL";
|
|
23
|
+
}>;
|
|
24
|
+
export type PositionOrigin = z.infer<typeof PositionOrigin>;
|
|
13
25
|
/**
|
|
14
26
|
* The exposure of a position in directional units for each asset.
|
|
15
27
|
*
|
|
@@ -26,6 +38,17 @@ export type PositionExposure = z.infer<typeof PositionExposure>;
|
|
|
26
38
|
*/
|
|
27
39
|
export declare const PositionInitialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
28
40
|
export type PositionInitialExposureUSD = z.infer<typeof PositionInitialExposureUSD>;
|
|
41
|
+
/**
|
|
42
|
+
* Cumulative funding attributed to this position per asset, in USD (signed;
|
|
43
|
+
* negative = net paid). Derived by walking the position's exposure snapshots and
|
|
44
|
+
* summing each in-window funding event as `exposure × fundingPerUnit`. Across a
|
|
45
|
+
* fully-tracked account the per-position shares sum to the account funding (up to
|
|
46
|
+
* 20-dp rounding of the coefficient).
|
|
47
|
+
*
|
|
48
|
+
* @example { '0': '-1.25' } means 1.25 USD of BTC funding paid over the position's life
|
|
49
|
+
*/
|
|
50
|
+
export declare const PositionTotalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
51
|
+
export type PositionTotalFundingPayment = z.infer<typeof PositionTotalFundingPayment>;
|
|
29
52
|
export declare const Position: z.ZodObject<{
|
|
30
53
|
id: z.ZodUUID;
|
|
31
54
|
tradeAccountId: z.ZodUUID;
|
|
@@ -45,7 +68,13 @@ export declare const Position: z.ZodObject<{
|
|
|
45
68
|
USER: "USER";
|
|
46
69
|
LIQUIDATED: "LIQUIDATED";
|
|
47
70
|
}>>>;
|
|
71
|
+
origin: z.ZodEnum<{
|
|
72
|
+
PARTIAL: "PARTIAL";
|
|
73
|
+
PEAR: "PEAR";
|
|
74
|
+
EXTERNAL: "EXTERNAL";
|
|
75
|
+
}>;
|
|
48
76
|
exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
77
|
+
totalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
49
78
|
closedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
79
|
initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
51
80
|
createdAt: z.ZodString;
|
|
@@ -5,8 +5,10 @@ import { InstrumentId } from '../instrument';
|
|
|
5
5
|
|
|
6
6
|
const PositionStatus = z.enum(["OPEN", "CLOSED"]);
|
|
7
7
|
const PositionClosedReason = z.enum(["NETTED", "USER", "LIQUIDATED"]);
|
|
8
|
+
const PositionOrigin = z.enum(["PEAR", "EXTERNAL", "PARTIAL"]);
|
|
8
9
|
const PositionExposure = z.record(InstrumentId, SignedDecimalString);
|
|
9
10
|
const PositionInitialExposureUSD = z.record(InstrumentId, SignedDecimalString);
|
|
11
|
+
const PositionTotalFundingPayment = z.record(InstrumentId, SignedDecimalString);
|
|
10
12
|
const Position = z.object({
|
|
11
13
|
/**
|
|
12
14
|
* Position UUID
|
|
@@ -28,10 +30,12 @@ const Position = z.object({
|
|
|
28
30
|
* Closed reason
|
|
29
31
|
*/
|
|
30
32
|
closedReason: PositionClosedReason.nullable().optional(),
|
|
33
|
+
origin: PositionOrigin,
|
|
31
34
|
/**
|
|
32
35
|
* Position exposure
|
|
33
36
|
*/
|
|
34
37
|
exposure: PositionExposure,
|
|
38
|
+
totalFundingPayment: PositionTotalFundingPayment,
|
|
35
39
|
/**
|
|
36
40
|
* Closed at timestamp
|
|
37
41
|
*/
|
|
@@ -42,14 +46,8 @@ const Position = z.object({
|
|
|
42
46
|
* on adjustments, and is only used for UI purposes.
|
|
43
47
|
*/
|
|
44
48
|
initialExposureUSD: PositionInitialExposureUSD,
|
|
45
|
-
/**
|
|
46
|
-
* Created at timestamp
|
|
47
|
-
*/
|
|
48
49
|
createdAt: z.string(),
|
|
49
|
-
/**
|
|
50
|
-
* Updated at timestamp
|
|
51
|
-
*/
|
|
52
50
|
updatedAt: z.string()
|
|
53
51
|
});
|
|
54
52
|
|
|
55
|
-
export { Position, PositionClosedReason, PositionExposure, PositionInitialExposureUSD, PositionStatus };
|
|
53
|
+
export { Position, PositionClosedReason, PositionExposure, PositionInitialExposureUSD, PositionOrigin, PositionStatus, PositionTotalFundingPayment };
|
|
@@ -19,7 +19,13 @@ export declare const PositionListResponse: z.ZodObject<{
|
|
|
19
19
|
USER: "USER";
|
|
20
20
|
LIQUIDATED: "LIQUIDATED";
|
|
21
21
|
}>>>;
|
|
22
|
+
origin: z.ZodEnum<{
|
|
23
|
+
PARTIAL: "PARTIAL";
|
|
24
|
+
PEAR: "PEAR";
|
|
25
|
+
EXTERNAL: "EXTERNAL";
|
|
26
|
+
}>;
|
|
22
27
|
exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
28
|
+
totalFundingPayment: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
23
29
|
closedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
30
|
initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
25
31
|
createdAt: z.ZodString;
|
|
@@ -30,8 +36,13 @@ export type PositionListResponse = z.output<typeof PositionListResponse>;
|
|
|
30
36
|
export declare const OpenPositionLite: z.ZodObject<{
|
|
31
37
|
id: z.ZodUUID;
|
|
32
38
|
createdAt: z.ZodISODateTime;
|
|
33
|
-
exposure: z.ZodRecord<z.ZodString, z.ZodString
|
|
39
|
+
exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
34
40
|
status: z.ZodLiteral<"OPEN">;
|
|
41
|
+
origin: z.ZodEnum<{
|
|
42
|
+
PARTIAL: "PARTIAL";
|
|
43
|
+
PEAR: "PEAR";
|
|
44
|
+
EXTERNAL: "EXTERNAL";
|
|
45
|
+
}>;
|
|
35
46
|
connector: z.ZodEnum<{
|
|
36
47
|
hyperliquid: "hyperliquid";
|
|
37
48
|
binance: "binance";
|
|
@@ -44,8 +55,13 @@ export declare const OpenPositionLiteListResponse: z.ZodObject<{
|
|
|
44
55
|
positions: z.ZodArray<z.ZodObject<{
|
|
45
56
|
id: z.ZodUUID;
|
|
46
57
|
createdAt: z.ZodISODateTime;
|
|
47
|
-
exposure: z.ZodRecord<z.ZodString, z.ZodString
|
|
58
|
+
exposure: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
|
|
48
59
|
status: z.ZodLiteral<"OPEN">;
|
|
60
|
+
origin: z.ZodEnum<{
|
|
61
|
+
PARTIAL: "PARTIAL";
|
|
62
|
+
PEAR: "PEAR";
|
|
63
|
+
EXTERNAL: "EXTERNAL";
|
|
64
|
+
}>;
|
|
49
65
|
connector: z.ZodEnum<{
|
|
50
66
|
hyperliquid: "hyperliquid";
|
|
51
67
|
binance: "binance";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { SignedDecimalString } from '../common/schema';
|
|
2
3
|
import { Connector } from '../connector';
|
|
3
4
|
import { InstrumentId } from '../instrument';
|
|
4
|
-
import { Position } from './entities';
|
|
5
|
+
import { Position, PositionOrigin } from './entities';
|
|
5
6
|
|
|
6
7
|
const PositionListResponse = z.object({
|
|
7
8
|
positions: z.array(Position)
|
|
@@ -9,8 +10,9 @@ const PositionListResponse = z.object({
|
|
|
9
10
|
const OpenPositionLite = z.object({
|
|
10
11
|
id: z.uuid(),
|
|
11
12
|
createdAt: z.iso.datetime(),
|
|
12
|
-
exposure: z.record(InstrumentId,
|
|
13
|
+
exposure: z.record(InstrumentId, SignedDecimalString),
|
|
13
14
|
status: z.literal("OPEN"),
|
|
15
|
+
origin: PositionOrigin,
|
|
14
16
|
connector: Connector
|
|
15
17
|
});
|
|
16
18
|
const OpenPositionLiteListResponse = z.object({
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AutoRebalanceStatus: z.ZodEnum<{
|
|
3
|
+
ACTIVE: "ACTIVE";
|
|
4
|
+
PAUSED: "PAUSED";
|
|
5
|
+
}>;
|
|
6
|
+
export type AutoRebalanceStatus = z.infer<typeof AutoRebalanceStatus>;
|
|
7
|
+
export declare const AutoRebalanceWeightSource: z.ZodEnum<{
|
|
8
|
+
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
9
|
+
LIVE_BETA: "LIVE_BETA";
|
|
10
|
+
}>;
|
|
11
|
+
export type AutoRebalanceWeightSource = z.infer<typeof AutoRebalanceWeightSource>;
|
|
12
|
+
export declare const AutoRebalanceTimeframe: z.ZodEnum<{
|
|
13
|
+
"1d": "1d";
|
|
14
|
+
"1h": "1h";
|
|
15
|
+
"4h": "4h";
|
|
16
|
+
}>;
|
|
17
|
+
export type AutoRebalanceTimeframe = z.infer<typeof AutoRebalanceTimeframe>;
|
|
18
|
+
export declare const RebalanceEventStatus: z.ZodEnum<{
|
|
19
|
+
FAILED: "FAILED";
|
|
20
|
+
SUCCESS: "SUCCESS";
|
|
21
|
+
}>;
|
|
22
|
+
export type RebalanceEventStatus = z.infer<typeof RebalanceEventStatus>;
|
|
23
|
+
export declare const WeightMap: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
24
|
+
export type WeightMap = z.output<typeof WeightMap>;
|
|
25
|
+
export declare const AutoRebalanceConfig: z.ZodObject<{
|
|
26
|
+
id: z.ZodUUID;
|
|
27
|
+
positionId: z.ZodUUID;
|
|
28
|
+
status: z.ZodEnum<{
|
|
29
|
+
ACTIVE: "ACTIVE";
|
|
30
|
+
PAUSED: "PAUSED";
|
|
31
|
+
}>;
|
|
32
|
+
weightSource: z.ZodEnum<{
|
|
33
|
+
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
34
|
+
LIVE_BETA: "LIVE_BETA";
|
|
35
|
+
}>;
|
|
36
|
+
minimumDriftPct: z.ZodString;
|
|
37
|
+
timeframe: z.ZodOptional<z.ZodEnum<{
|
|
38
|
+
"1d": "1d";
|
|
39
|
+
"1h": "1h";
|
|
40
|
+
"4h": "4h";
|
|
41
|
+
}>>;
|
|
42
|
+
createdAt: z.ZodISODateTime;
|
|
43
|
+
updatedAt: z.ZodISODateTime;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type AutoRebalanceConfig = z.output<typeof AutoRebalanceConfig>;
|
|
46
|
+
export declare const RebalanceEvent: z.ZodObject<{
|
|
47
|
+
id: z.ZodUUID;
|
|
48
|
+
autoRebalanceConfigId: z.ZodUUID;
|
|
49
|
+
positionId: z.ZodUUID;
|
|
50
|
+
weightSource: z.ZodEnum<{
|
|
51
|
+
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
52
|
+
LIVE_BETA: "LIVE_BETA";
|
|
53
|
+
}>;
|
|
54
|
+
driftPct: z.ZodString;
|
|
55
|
+
currentWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
56
|
+
targetWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
57
|
+
status: z.ZodEnum<{
|
|
58
|
+
FAILED: "FAILED";
|
|
59
|
+
SUCCESS: "SUCCESS";
|
|
60
|
+
}>;
|
|
61
|
+
error: z.ZodOptional<z.ZodString>;
|
|
62
|
+
createdAt: z.ZodISODateTime;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type RebalanceEvent = z.output<typeof RebalanceEvent>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UnsignedDecimalString } from '../common/schema';
|
|
3
|
+
import { InstrumentId } from '../instrument';
|
|
4
|
+
|
|
5
|
+
const AutoRebalanceStatus = z.enum(["ACTIVE", "PAUSED"]);
|
|
6
|
+
const AutoRebalanceWeightSource = z.enum(["INITIAL_WEIGHT", "LIVE_BETA"]);
|
|
7
|
+
const AutoRebalanceTimeframe = z.enum(["1h", "4h", "1d"]);
|
|
8
|
+
const RebalanceEventStatus = z.enum(["SUCCESS", "FAILED"]);
|
|
9
|
+
const WeightMap = z.record(InstrumentId, z.number());
|
|
10
|
+
const AutoRebalanceConfig = z.object({
|
|
11
|
+
id: z.uuid(),
|
|
12
|
+
positionId: z.uuid(),
|
|
13
|
+
status: AutoRebalanceStatus,
|
|
14
|
+
weightSource: AutoRebalanceWeightSource,
|
|
15
|
+
minimumDriftPct: UnsignedDecimalString,
|
|
16
|
+
timeframe: AutoRebalanceTimeframe.optional(),
|
|
17
|
+
createdAt: z.iso.datetime(),
|
|
18
|
+
updatedAt: z.iso.datetime()
|
|
19
|
+
});
|
|
20
|
+
const RebalanceEvent = z.object({
|
|
21
|
+
id: z.uuid(),
|
|
22
|
+
autoRebalanceConfigId: z.uuid(),
|
|
23
|
+
positionId: z.uuid(),
|
|
24
|
+
weightSource: AutoRebalanceWeightSource,
|
|
25
|
+
driftPct: UnsignedDecimalString,
|
|
26
|
+
currentWeights: WeightMap,
|
|
27
|
+
targetWeights: WeightMap,
|
|
28
|
+
status: RebalanceEventStatus,
|
|
29
|
+
error: z.string().optional(),
|
|
30
|
+
createdAt: z.iso.datetime()
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { AutoRebalanceConfig, AutoRebalanceStatus, AutoRebalanceTimeframe, AutoRebalanceWeightSource, RebalanceEvent, RebalanceEventStatus, WeightMap };
|
package/dist/rebalance/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const RebalanceManual: z.ZodObject<{
|
|
3
3
|
orderType: z.ZodEnum<{
|
|
4
4
|
MARKET: "MARKET";
|
|
5
5
|
}>;
|
|
@@ -9,4 +9,50 @@ export declare const RebalanceManually: z.ZodObject<{
|
|
|
9
9
|
}, z.core.$strip>>;
|
|
10
10
|
clientId: z.ZodOptional<z.ZodString>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
|
-
export type
|
|
12
|
+
export type RebalanceManual = z.output<typeof RebalanceManual>;
|
|
13
|
+
declare const CreateInitialWeight: z.ZodObject<{
|
|
14
|
+
weightSource: z.ZodLiteral<"INITIAL_WEIGHT">;
|
|
15
|
+
positionId: z.ZodUUID;
|
|
16
|
+
minimumDriftPct: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const CreateLiveBeta: z.ZodObject<{
|
|
19
|
+
weightSource: z.ZodLiteral<"LIVE_BETA">;
|
|
20
|
+
positionId: z.ZodUUID;
|
|
21
|
+
minimumDriftPct: z.ZodString;
|
|
22
|
+
timeframe: z.ZodEnum<{
|
|
23
|
+
"1d": "1d";
|
|
24
|
+
"1h": "1h";
|
|
25
|
+
"4h": "4h";
|
|
26
|
+
}>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export declare const CreateAutoRebalanceConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
29
|
+
weightSource: z.ZodLiteral<"INITIAL_WEIGHT">;
|
|
30
|
+
positionId: z.ZodUUID;
|
|
31
|
+
minimumDriftPct: z.ZodString;
|
|
32
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
33
|
+
weightSource: z.ZodLiteral<"LIVE_BETA">;
|
|
34
|
+
positionId: z.ZodUUID;
|
|
35
|
+
minimumDriftPct: z.ZodString;
|
|
36
|
+
timeframe: z.ZodEnum<{
|
|
37
|
+
"1d": "1d";
|
|
38
|
+
"1h": "1h";
|
|
39
|
+
"4h": "4h";
|
|
40
|
+
}>;
|
|
41
|
+
}, z.core.$strip>], "weightSource">;
|
|
42
|
+
export declare const UpdateAutoRebalanceConfig: z.ZodObject<{
|
|
43
|
+
minimumDriftPct: z.ZodOptional<z.ZodString>;
|
|
44
|
+
timeframe: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
"1d": "1d";
|
|
46
|
+
"1h": "1h";
|
|
47
|
+
"4h": "4h";
|
|
48
|
+
}>>;
|
|
49
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
ACTIVE: "ACTIVE";
|
|
51
|
+
PAUSED: "PAUSED";
|
|
52
|
+
}>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export type CreateInitialWeight = z.output<typeof CreateInitialWeight>;
|
|
55
|
+
export type CreateLiveBeta = z.output<typeof CreateLiveBeta>;
|
|
56
|
+
export type CreateAutoRebalanceConfig = z.output<typeof CreateAutoRebalanceConfig>;
|
|
57
|
+
export type UpdateAutoRebalanceConfig = z.output<typeof UpdateAutoRebalanceConfig>;
|
|
58
|
+
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ClientIdCode } from '../common/client-id';
|
|
3
3
|
import { RefineWeightingSum, RefineUniqueSymbols } from '../common/refinement';
|
|
4
|
+
import { UnsignedDecimalString } from '../common/schema';
|
|
4
5
|
import { ExecutionOrderType } from '../execution';
|
|
5
6
|
import { InstrumentId } from '../instrument';
|
|
7
|
+
import { AutoRebalanceTimeframe, AutoRebalanceStatus } from './entities';
|
|
6
8
|
|
|
7
|
-
const
|
|
9
|
+
const RebalanceManual = z.object({
|
|
8
10
|
orderType: ExecutionOrderType,
|
|
9
11
|
weightings: z.array(
|
|
10
12
|
z.object({
|
|
@@ -17,5 +19,25 @@ const RebalanceManually = z.object({
|
|
|
17
19
|
*/
|
|
18
20
|
clientId: ClientIdCode
|
|
19
21
|
});
|
|
22
|
+
const MinimumDriftPct = UnsignedDecimalString.refine((value) => Number(value) > 0 && Number(value) <= 1, {
|
|
23
|
+
message: "minimumDriftPct must be greater than 0 and at most 1"
|
|
24
|
+
});
|
|
25
|
+
const CreateInitialWeight = z.object({
|
|
26
|
+
weightSource: z.literal("INITIAL_WEIGHT"),
|
|
27
|
+
positionId: z.uuid(),
|
|
28
|
+
minimumDriftPct: MinimumDriftPct
|
|
29
|
+
});
|
|
30
|
+
const CreateLiveBeta = z.object({
|
|
31
|
+
weightSource: z.literal("LIVE_BETA"),
|
|
32
|
+
positionId: z.uuid(),
|
|
33
|
+
minimumDriftPct: MinimumDriftPct,
|
|
34
|
+
timeframe: AutoRebalanceTimeframe
|
|
35
|
+
});
|
|
36
|
+
const CreateAutoRebalanceConfig = z.discriminatedUnion("weightSource", [CreateInitialWeight, CreateLiveBeta]);
|
|
37
|
+
const UpdateAutoRebalanceConfig = z.object({
|
|
38
|
+
minimumDriftPct: MinimumDriftPct.optional(),
|
|
39
|
+
timeframe: AutoRebalanceTimeframe.optional(),
|
|
40
|
+
status: AutoRebalanceStatus.optional()
|
|
41
|
+
});
|
|
20
42
|
|
|
21
|
-
export {
|
|
43
|
+
export { CreateAutoRebalanceConfig, RebalanceManual, UpdateAutoRebalanceConfig };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AutoRebalanceListParams: z.ZodObject<{
|
|
3
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
|
|
4
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
5
|
+
status: z.ZodOptional<z.ZodPipe<z.ZodTransform<string[] | (("ACTIVE" | "PAUSED")[] & any[]) | undefined, ("ACTIVE" | "PAUSED")[]>, z.ZodArray<z.ZodEnum<{
|
|
6
|
+
ACTIVE: "ACTIVE";
|
|
7
|
+
PAUSED: "PAUSED";
|
|
8
|
+
}>>>>;
|
|
9
|
+
weightSource: z.ZodOptional<z.ZodPipe<z.ZodTransform<string[] | (("INITIAL_WEIGHT" | "LIVE_BETA")[] & any[]) | undefined, ("INITIAL_WEIGHT" | "LIVE_BETA")[]>, z.ZodArray<z.ZodEnum<{
|
|
10
|
+
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
11
|
+
LIVE_BETA: "LIVE_BETA";
|
|
12
|
+
}>>>>;
|
|
13
|
+
positionId: z.ZodOptional<z.ZodUUID>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type AutoRebalanceListParamsInput = z.input<typeof AutoRebalanceListParams>;
|
|
16
|
+
export type AutoRebalanceListParams = z.output<typeof AutoRebalanceListParams>;
|
|
17
|
+
export declare const RebalanceEventListParams: z.ZodObject<{
|
|
18
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<number>>>;
|
|
19
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type RebalanceEventListParamsInput = z.input<typeof RebalanceEventListParams>;
|
|
22
|
+
export type RebalanceEventListParams = z.output<typeof RebalanceEventListParams>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { normalizeArray, CursorFindParams } from '../common';
|
|
3
|
+
import { AutoRebalanceStatus, AutoRebalanceWeightSource } from './entities';
|
|
4
|
+
|
|
5
|
+
const StatusArray = z.preprocess(
|
|
6
|
+
(arg) => normalizeArray(arg),
|
|
7
|
+
z.array(AutoRebalanceStatus)
|
|
8
|
+
);
|
|
9
|
+
const WeightSourceArray = z.preprocess(
|
|
10
|
+
(arg) => normalizeArray(arg),
|
|
11
|
+
z.array(AutoRebalanceWeightSource)
|
|
12
|
+
);
|
|
13
|
+
const AutoRebalanceListParams = CursorFindParams.extend({
|
|
14
|
+
status: StatusArray.optional(),
|
|
15
|
+
weightSource: WeightSourceArray.optional(),
|
|
16
|
+
positionId: z.uuid().optional()
|
|
17
|
+
});
|
|
18
|
+
const RebalanceEventListParams = CursorFindParams.extend({});
|
|
19
|
+
|
|
20
|
+
export { AutoRebalanceListParams, RebalanceEventListParams };
|
|
@@ -1,10 +1,87 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const
|
|
3
|
-
plan: z.
|
|
2
|
+
export declare const RebalanceManualResponse: z.ZodObject<{
|
|
3
|
+
plan: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
4
|
outcome: z.ZodLiteral<"full_rebalance">;
|
|
5
5
|
}, z.core.$strip>, z.ZodObject<{
|
|
6
|
-
outcome: z.
|
|
6
|
+
outcome: z.ZodLiteral<"partial_rebalance">;
|
|
7
7
|
messages: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
8
|
-
}, z.core.$strip
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
outcome: z.ZodLiteral<"no_rebalance">;
|
|
10
|
+
messages: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
outcome: z.ZodLiteral<"failed">;
|
|
13
|
+
messages: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
14
|
+
}, z.core.$strip>], "outcome">;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type RebalanceManualResponse = z.output<typeof RebalanceManualResponse>;
|
|
17
|
+
export declare const AutoRebalanceListResponse: z.ZodObject<{
|
|
18
|
+
limit: z.ZodNumber;
|
|
19
|
+
nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
|
|
20
|
+
items: z.ZodArray<z.ZodObject<{
|
|
21
|
+
id: z.ZodUUID;
|
|
22
|
+
positionId: z.ZodUUID;
|
|
23
|
+
status: z.ZodEnum<{
|
|
24
|
+
ACTIVE: "ACTIVE";
|
|
25
|
+
PAUSED: "PAUSED";
|
|
26
|
+
}>;
|
|
27
|
+
weightSource: z.ZodEnum<{
|
|
28
|
+
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
29
|
+
LIVE_BETA: "LIVE_BETA";
|
|
30
|
+
}>;
|
|
31
|
+
minimumDriftPct: z.ZodString;
|
|
32
|
+
timeframe: z.ZodOptional<z.ZodEnum<{
|
|
33
|
+
"1d": "1d";
|
|
34
|
+
"1h": "1h";
|
|
35
|
+
"4h": "4h";
|
|
36
|
+
}>>;
|
|
37
|
+
createdAt: z.ZodISODateTime;
|
|
38
|
+
updatedAt: z.ZodISODateTime;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export type AutoRebalanceListResponse = z.output<typeof AutoRebalanceListResponse>;
|
|
42
|
+
export declare const CreateAutoRebalanceResponse: z.ZodObject<{
|
|
43
|
+
config: z.ZodObject<{
|
|
44
|
+
id: z.ZodUUID;
|
|
45
|
+
positionId: z.ZodUUID;
|
|
46
|
+
status: z.ZodEnum<{
|
|
47
|
+
ACTIVE: "ACTIVE";
|
|
48
|
+
PAUSED: "PAUSED";
|
|
49
|
+
}>;
|
|
50
|
+
weightSource: z.ZodEnum<{
|
|
51
|
+
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
52
|
+
LIVE_BETA: "LIVE_BETA";
|
|
53
|
+
}>;
|
|
54
|
+
minimumDriftPct: z.ZodString;
|
|
55
|
+
timeframe: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
"1d": "1d";
|
|
57
|
+
"1h": "1h";
|
|
58
|
+
"4h": "4h";
|
|
59
|
+
}>>;
|
|
60
|
+
createdAt: z.ZodISODateTime;
|
|
61
|
+
updatedAt: z.ZodISODateTime;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type CreateAutoRebalanceResponse = z.output<typeof CreateAutoRebalanceResponse>;
|
|
65
|
+
export declare const RebalanceEventListResponse: z.ZodObject<{
|
|
66
|
+
limit: z.ZodNumber;
|
|
67
|
+
nextCursor: z.ZodUnion<[z.ZodString, z.ZodUndefined]>;
|
|
68
|
+
items: z.ZodArray<z.ZodObject<{
|
|
69
|
+
id: z.ZodUUID;
|
|
70
|
+
autoRebalanceConfigId: z.ZodUUID;
|
|
71
|
+
positionId: z.ZodUUID;
|
|
72
|
+
weightSource: z.ZodEnum<{
|
|
73
|
+
INITIAL_WEIGHT: "INITIAL_WEIGHT";
|
|
74
|
+
LIVE_BETA: "LIVE_BETA";
|
|
75
|
+
}>;
|
|
76
|
+
driftPct: z.ZodString;
|
|
77
|
+
currentWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
78
|
+
targetWeights: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
79
|
+
status: z.ZodEnum<{
|
|
80
|
+
FAILED: "FAILED";
|
|
81
|
+
SUCCESS: "SUCCESS";
|
|
82
|
+
}>;
|
|
83
|
+
error: z.ZodOptional<z.ZodString>;
|
|
84
|
+
createdAt: z.ZodISODateTime;
|
|
85
|
+
}, z.core.$strip>>;
|
|
9
86
|
}, z.core.$strip>;
|
|
10
|
-
export type
|
|
87
|
+
export type RebalanceEventListResponse = z.output<typeof RebalanceEventListResponse>;
|