@pear-protocol/types 1.5.0 → 1.6.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/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
package/dist/fill/entities.d.ts
CHANGED
package/dist/fill/entities.js
CHANGED
|
@@ -9,13 +9,9 @@ const Fill = z.object({
|
|
|
9
9
|
* Fill UUID
|
|
10
10
|
*/
|
|
11
11
|
id: z.uuid(),
|
|
12
|
-
/**
|
|
13
|
-
* Client order ID
|
|
14
|
-
*/
|
|
12
|
+
/** Client order ID (abbreviated as cloid) */
|
|
15
13
|
cloid: z.string().optional(),
|
|
16
|
-
/**
|
|
17
|
-
* Exchange-native fill ID (tradeId / tid / etc)
|
|
18
|
-
*/
|
|
14
|
+
/** Exchange-native fill ID (tradeId / tid / etc) */
|
|
19
15
|
exchangeFillId: z.string().optional(),
|
|
20
16
|
/**
|
|
21
17
|
* Fill lifecycle status
|
|
@@ -45,21 +41,17 @@ const Fill = z.object({
|
|
|
45
41
|
* Reduce only flag
|
|
46
42
|
*/
|
|
47
43
|
reduceOnly: z.boolean(),
|
|
48
|
-
/**
|
|
49
|
-
* True when the fill was created from external sync.
|
|
50
|
-
*/
|
|
44
|
+
/** True when the fill was created from external sync. */
|
|
51
45
|
isExternal: z.boolean(),
|
|
52
46
|
/**
|
|
53
|
-
*
|
|
47
|
+
* True when the fill is a synthetic bridge fill (gap/gone reconstruction).
|
|
48
|
+
* Unpriceable gone-close synthetics carry "0" price/usd and should be displayed distinctly.
|
|
54
49
|
*/
|
|
50
|
+
synthetic: z.boolean(),
|
|
55
51
|
quantity: z.string(),
|
|
56
|
-
/**
|
|
57
|
-
* Filled price
|
|
58
|
-
*/
|
|
52
|
+
/** Filled price — "0" on an unpriceable gone-close synthetic (no price guessing). */
|
|
59
53
|
price: z.string(),
|
|
60
|
-
/**
|
|
61
|
-
* USD value
|
|
62
|
-
*/
|
|
54
|
+
/** USD value — "0" on an unpriceable gone-close synthetic (cannot compute without price). */
|
|
63
55
|
usd: z.string(),
|
|
64
56
|
/**
|
|
65
57
|
* Trade fee paid
|
package/dist/fill/responses.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const FillListResponse: z.ZodObject<{
|
|
|
27
27
|
}>;
|
|
28
28
|
reduceOnly: z.ZodBoolean;
|
|
29
29
|
isExternal: z.ZodBoolean;
|
|
30
|
+
synthetic: z.ZodBoolean;
|
|
30
31
|
quantity: z.ZodString;
|
|
31
32
|
price: z.ZodString;
|
|
32
33
|
usd: z.ZodString;
|
|
@@ -66,6 +67,7 @@ export declare const PositionFillListResponse: z.ZodObject<{
|
|
|
66
67
|
}>;
|
|
67
68
|
reduceOnly: z.ZodBoolean;
|
|
68
69
|
isExternal: z.ZodBoolean;
|
|
70
|
+
synthetic: z.ZodBoolean;
|
|
69
71
|
quantity: z.ZodString;
|
|
70
72
|
price: z.ZodString;
|
|
71
73
|
usd: z.ZodString;
|
|
@@ -77,6 +77,7 @@ export declare const Ladder: z.ZodObject<{
|
|
|
77
77
|
}>;
|
|
78
78
|
reduceOnly: z.ZodBoolean;
|
|
79
79
|
isExternal: z.ZodBoolean;
|
|
80
|
+
synthetic: z.ZodBoolean;
|
|
80
81
|
quantity: z.ZodString;
|
|
81
82
|
price: z.ZodString;
|
|
82
83
|
usd: z.ZodString;
|
|
@@ -276,6 +277,7 @@ export declare const Ladder: z.ZodObject<{
|
|
|
276
277
|
}>;
|
|
277
278
|
reduceOnly: z.ZodBoolean;
|
|
278
279
|
isExternal: z.ZodBoolean;
|
|
280
|
+
synthetic: z.ZodBoolean;
|
|
279
281
|
quantity: z.ZodString;
|
|
280
282
|
price: z.ZodString;
|
|
281
283
|
usd: z.ZodString;
|
|
@@ -521,6 +523,7 @@ export declare const Ladder: z.ZodObject<{
|
|
|
521
523
|
}>;
|
|
522
524
|
reduceOnly: z.ZodBoolean;
|
|
523
525
|
isExternal: z.ZodBoolean;
|
|
526
|
+
synthetic: z.ZodBoolean;
|
|
524
527
|
quantity: z.ZodString;
|
|
525
528
|
price: z.ZodString;
|
|
526
529
|
usd: z.ZodString;
|
|
@@ -72,6 +72,7 @@ export declare const CreateLadderResponse: z.ZodObject<{
|
|
|
72
72
|
}>;
|
|
73
73
|
reduceOnly: z.ZodBoolean;
|
|
74
74
|
isExternal: z.ZodBoolean;
|
|
75
|
+
synthetic: z.ZodBoolean;
|
|
75
76
|
quantity: z.ZodString;
|
|
76
77
|
price: z.ZodString;
|
|
77
78
|
usd: z.ZodString;
|
|
@@ -271,6 +272,7 @@ export declare const CreateLadderResponse: z.ZodObject<{
|
|
|
271
272
|
}>;
|
|
272
273
|
reduceOnly: z.ZodBoolean;
|
|
273
274
|
isExternal: z.ZodBoolean;
|
|
275
|
+
synthetic: z.ZodBoolean;
|
|
274
276
|
quantity: z.ZodString;
|
|
275
277
|
price: z.ZodString;
|
|
276
278
|
usd: z.ZodString;
|
|
@@ -516,6 +518,7 @@ export declare const CreateLadderResponse: z.ZodObject<{
|
|
|
516
518
|
}>;
|
|
517
519
|
reduceOnly: z.ZodBoolean;
|
|
518
520
|
isExternal: z.ZodBoolean;
|
|
521
|
+
synthetic: z.ZodBoolean;
|
|
519
522
|
quantity: z.ZodString;
|
|
520
523
|
price: z.ZodString;
|
|
521
524
|
usd: z.ZodString;
|
|
@@ -823,6 +826,7 @@ export declare const LadderResponse: z.ZodObject<{
|
|
|
823
826
|
}>;
|
|
824
827
|
reduceOnly: z.ZodBoolean;
|
|
825
828
|
isExternal: z.ZodBoolean;
|
|
829
|
+
synthetic: z.ZodBoolean;
|
|
826
830
|
quantity: z.ZodString;
|
|
827
831
|
price: z.ZodString;
|
|
828
832
|
usd: z.ZodString;
|
|
@@ -1022,6 +1026,7 @@ export declare const LadderResponse: z.ZodObject<{
|
|
|
1022
1026
|
}>;
|
|
1023
1027
|
reduceOnly: z.ZodBoolean;
|
|
1024
1028
|
isExternal: z.ZodBoolean;
|
|
1029
|
+
synthetic: z.ZodBoolean;
|
|
1025
1030
|
quantity: z.ZodString;
|
|
1026
1031
|
price: z.ZodString;
|
|
1027
1032
|
usd: z.ZodString;
|
|
@@ -1267,6 +1272,7 @@ export declare const LadderResponse: z.ZodObject<{
|
|
|
1267
1272
|
}>;
|
|
1268
1273
|
reduceOnly: z.ZodBoolean;
|
|
1269
1274
|
isExternal: z.ZodBoolean;
|
|
1275
|
+
synthetic: z.ZodBoolean;
|
|
1270
1276
|
quantity: z.ZodString;
|
|
1271
1277
|
price: z.ZodString;
|
|
1272
1278
|
usd: z.ZodString;
|
|
@@ -1576,6 +1582,7 @@ export declare const LadderListResponse: z.ZodObject<{
|
|
|
1576
1582
|
}>;
|
|
1577
1583
|
reduceOnly: z.ZodBoolean;
|
|
1578
1584
|
isExternal: z.ZodBoolean;
|
|
1585
|
+
synthetic: z.ZodBoolean;
|
|
1579
1586
|
quantity: z.ZodString;
|
|
1580
1587
|
price: z.ZodString;
|
|
1581
1588
|
usd: z.ZodString;
|
|
@@ -1775,6 +1782,7 @@ export declare const LadderListResponse: z.ZodObject<{
|
|
|
1775
1782
|
}>;
|
|
1776
1783
|
reduceOnly: z.ZodBoolean;
|
|
1777
1784
|
isExternal: z.ZodBoolean;
|
|
1785
|
+
synthetic: z.ZodBoolean;
|
|
1778
1786
|
quantity: z.ZodString;
|
|
1779
1787
|
price: z.ZodString;
|
|
1780
1788
|
usd: z.ZodString;
|
|
@@ -2020,6 +2028,7 @@ export declare const LadderListResponse: z.ZodObject<{
|
|
|
2020
2028
|
}>;
|
|
2021
2029
|
reduceOnly: z.ZodBoolean;
|
|
2022
2030
|
isExternal: z.ZodBoolean;
|
|
2031
|
+
synthetic: z.ZodBoolean;
|
|
2023
2032
|
quantity: z.ZodString;
|
|
2024
2033
|
price: z.ZodString;
|
|
2025
2034
|
usd: 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>;
|