@pear-protocol/types 1.32.0 → 2.0.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.
@@ -1,176 +1,185 @@
1
1
  import { z } from 'zod';
2
2
  export declare const PortfolioResponse: z.ZodObject<{
3
- intervals: z.ZodNullable<z.ZodObject<{
4
- oneDay: z.ZodArray<z.ZodObject<{
5
- periodStart: z.ZodString;
6
- periodEnd: z.ZodString;
7
- volume: z.ZodNumber;
8
- openInterest: z.ZodNumber;
9
- winningTradesCount: z.ZodNumber;
10
- winningTradesUsd: z.ZodNumber;
11
- losingTradesCount: z.ZodNumber;
12
- losingTradesUsd: z.ZodNumber;
13
- }, z.core.$strip>>;
14
- oneWeek: z.ZodArray<z.ZodObject<{
15
- periodStart: z.ZodString;
16
- periodEnd: z.ZodString;
17
- volume: z.ZodNumber;
18
- openInterest: z.ZodNumber;
19
- winningTradesCount: z.ZodNumber;
20
- winningTradesUsd: z.ZodNumber;
21
- losingTradesCount: z.ZodNumber;
22
- losingTradesUsd: z.ZodNumber;
23
- }, z.core.$strip>>;
24
- oneMonth: z.ZodArray<z.ZodObject<{
25
- periodStart: z.ZodString;
26
- periodEnd: z.ZodString;
27
- volume: z.ZodNumber;
28
- openInterest: z.ZodNumber;
29
- winningTradesCount: z.ZodNumber;
30
- winningTradesUsd: z.ZodNumber;
31
- losingTradesCount: z.ZodNumber;
32
- losingTradesUsd: z.ZodNumber;
33
- }, z.core.$strip>>;
34
- oneYear: z.ZodArray<z.ZodObject<{
35
- periodStart: z.ZodString;
36
- periodEnd: z.ZodString;
37
- volume: z.ZodNumber;
38
- openInterest: z.ZodNumber;
39
- winningTradesCount: z.ZodNumber;
40
- winningTradesUsd: z.ZodNumber;
41
- losingTradesCount: z.ZodNumber;
42
- losingTradesUsd: z.ZodNumber;
43
- }, z.core.$strip>>;
44
- all: z.ZodArray<z.ZodObject<{
45
- periodStart: z.ZodString;
46
- periodEnd: z.ZodString;
47
- volume: z.ZodNumber;
48
- openInterest: z.ZodNumber;
49
- winningTradesCount: z.ZodNumber;
50
- winningTradesUsd: z.ZodNumber;
51
- losingTradesCount: z.ZodNumber;
52
- losingTradesUsd: z.ZodNumber;
3
+ realizedCashflow: z.ZodObject<{
4
+ grossPnl: z.ZodNumber;
5
+ tradeFees: z.ZodNumber;
6
+ pearFees: z.ZodNumber;
7
+ netCashflow: z.ZodNumber;
8
+ funding: z.ZodNumber;
9
+ netCashflowWithFunding: z.ZodNumber;
10
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
11
+ fundingSynced: z.ZodBoolean;
12
+ intervals: z.ZodOptional<z.ZodObject<{
13
+ oneDay: z.ZodArray<z.ZodObject<{
14
+ grossPnl: z.ZodNumber;
15
+ tradeFees: z.ZodNumber;
16
+ pearFees: z.ZodNumber;
17
+ netCashflow: z.ZodNumber;
18
+ funding: z.ZodNumber;
19
+ netCashflowWithFunding: z.ZodNumber;
20
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
21
+ periodStart: z.ZodString;
22
+ periodEnd: z.ZodString;
23
+ }, z.core.$strip>>;
24
+ oneWeek: z.ZodArray<z.ZodObject<{
25
+ grossPnl: z.ZodNumber;
26
+ tradeFees: z.ZodNumber;
27
+ pearFees: z.ZodNumber;
28
+ netCashflow: z.ZodNumber;
29
+ funding: z.ZodNumber;
30
+ netCashflowWithFunding: z.ZodNumber;
31
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
32
+ periodStart: z.ZodString;
33
+ periodEnd: z.ZodString;
34
+ }, z.core.$strip>>;
35
+ oneMonth: z.ZodArray<z.ZodObject<{
36
+ grossPnl: z.ZodNumber;
37
+ tradeFees: z.ZodNumber;
38
+ pearFees: z.ZodNumber;
39
+ netCashflow: z.ZodNumber;
40
+ funding: z.ZodNumber;
41
+ netCashflowWithFunding: z.ZodNumber;
42
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
43
+ periodStart: z.ZodString;
44
+ periodEnd: z.ZodString;
45
+ }, z.core.$strip>>;
46
+ oneYear: z.ZodArray<z.ZodObject<{
47
+ grossPnl: z.ZodNumber;
48
+ tradeFees: z.ZodNumber;
49
+ pearFees: z.ZodNumber;
50
+ netCashflow: z.ZodNumber;
51
+ funding: z.ZodNumber;
52
+ netCashflowWithFunding: z.ZodNumber;
53
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
54
+ periodStart: z.ZodString;
55
+ periodEnd: z.ZodString;
56
+ }, z.core.$strip>>;
57
+ all: z.ZodArray<z.ZodObject<{
58
+ grossPnl: z.ZodNumber;
59
+ tradeFees: z.ZodNumber;
60
+ pearFees: z.ZodNumber;
61
+ netCashflow: z.ZodNumber;
62
+ funding: z.ZodNumber;
63
+ netCashflowWithFunding: z.ZodNumber;
64
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
65
+ periodStart: z.ZodString;
66
+ periodEnd: z.ZodString;
67
+ }, z.core.$strip>>;
53
68
  }, z.core.$strip>>;
54
- }, z.core.$strip>>;
55
- overall: z.ZodObject<{
56
- totalWinningTradesCount: z.ZodNumber;
57
- totalLosingTradesCount: z.ZodNumber;
58
- totalWinningUsd: z.ZodNumber;
59
- totalLosingUsd: z.ZodNumber;
60
- currentOpenInterest: z.ZodNumber;
61
- currentTotalVolume: z.ZodNumber;
69
+ }, z.core.$strip>;
70
+ closedPositionStats: z.ZodObject<{
71
+ totalPositions: z.ZodNumber;
72
+ wins: z.ZodNumber;
73
+ losses: z.ZodNumber;
74
+ hitRate: z.ZodNullable<z.ZodNumber>;
75
+ profitFactor: z.ZodNullable<z.ZodNumber>;
76
+ avgWinSize: z.ZodNullable<z.ZodNumber>;
77
+ avgLossSize: z.ZodNullable<z.ZodNumber>;
78
+ netPnl: z.ZodNumber;
79
+ positionPnls: z.ZodArray<z.ZodNumber>;
80
+ positionReturns: z.ZodArray<z.ZodNumber>;
81
+ }, z.core.$strip>;
82
+ openSnapshot: z.ZodObject<{
83
+ openInterest: z.ZodNumber;
62
84
  unrealizedPnl: z.ZodNumber;
63
- realizedPnl: z.ZodNumber;
64
- totalFees: z.ZodNumber;
65
- totalTrades: z.ZodNumber;
85
+ }, z.core.$strip>;
86
+ volume: z.ZodObject<{
87
+ total: z.ZodNumber;
88
+ intervals: z.ZodOptional<z.ZodObject<{
89
+ oneDay: z.ZodArray<z.ZodObject<{
90
+ periodStart: z.ZodString;
91
+ periodEnd: z.ZodString;
92
+ volume: z.ZodNumber;
93
+ }, z.core.$strip>>;
94
+ oneWeek: z.ZodArray<z.ZodObject<{
95
+ periodStart: z.ZodString;
96
+ periodEnd: z.ZodString;
97
+ volume: z.ZodNumber;
98
+ }, z.core.$strip>>;
99
+ oneMonth: z.ZodArray<z.ZodObject<{
100
+ periodStart: z.ZodString;
101
+ periodEnd: z.ZodString;
102
+ volume: z.ZodNumber;
103
+ }, z.core.$strip>>;
104
+ oneYear: z.ZodArray<z.ZodObject<{
105
+ periodStart: z.ZodString;
106
+ periodEnd: z.ZodString;
107
+ volume: z.ZodNumber;
108
+ }, z.core.$strip>>;
109
+ all: z.ZodArray<z.ZodObject<{
110
+ periodStart: z.ZodString;
111
+ periodEnd: z.ZodString;
112
+ volume: z.ZodNumber;
113
+ }, z.core.$strip>>;
114
+ }, z.core.$strip>>;
66
115
  }, z.core.$strip>;
67
116
  }, z.core.$strip>;
68
117
  export type PortfolioResponse = z.output<typeof PortfolioResponse>;
69
118
  export declare const PortfolioAnalyticsResponse: z.ZodObject<{
70
119
  config: z.ZodObject<{
71
- rollingWindowDays: z.ZodNumber;
72
120
  startDate: z.ZodString;
73
121
  endDate: z.ZodString;
122
+ }, z.core.$strip>;
123
+ realizedCashflow: z.ZodObject<{
124
+ grossPnl: z.ZodNumber;
125
+ tradeFees: z.ZodNumber;
126
+ pearFees: z.ZodNumber;
127
+ netCashflow: z.ZodNumber;
128
+ funding: z.ZodNumber;
129
+ netCashflowWithFunding: z.ZodNumber;
130
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
74
131
  fundingSynced: z.ZodBoolean;
132
+ series: z.ZodOptional<z.ZodArray<z.ZodObject<{
133
+ grossPnl: z.ZodNumber;
134
+ tradeFees: z.ZodNumber;
135
+ pearFees: z.ZodNumber;
136
+ netCashflow: z.ZodNumber;
137
+ funding: z.ZodNumber;
138
+ netCashflowWithFunding: z.ZodNumber;
139
+ undeterminedQuantityByAsset: z.ZodRecord<z.ZodString, z.ZodNumber>;
140
+ periodStart: z.ZodString;
141
+ periodEnd: z.ZodString;
142
+ }, z.core.$strip>>>;
75
143
  }, z.core.$strip>;
76
- portfolio: z.ZodObject<{
77
- realizedOnly: z.ZodObject<{
78
- pnlAbsolute: z.ZodNumber;
79
- pnlPercent: z.ZodNullable<z.ZodNumber>;
80
- hitRate: z.ZodNullable<z.ZodNumber>;
81
- profitFactor: z.ZodNullable<z.ZodNumber>;
82
- avgWinSize: z.ZodNullable<z.ZodNumber>;
83
- avgLossSize: z.ZodNullable<z.ZodNumber>;
84
- avgReturnPerWin: z.ZodNullable<z.ZodNumber>;
85
- avgReturnPerLoss: z.ZodNullable<z.ZodNumber>;
86
- maxDrawdown: z.ZodNullable<z.ZodNumber>;
87
- sharpeRatio: z.ZodNullable<z.ZodNumber>;
88
- sortinoRatio: z.ZodNullable<z.ZodNumber>;
89
- }, z.core.$strip>;
90
- realizedPlusUnrealized: z.ZodObject<{
91
- pnlAbsolute: z.ZodNumber;
92
- pnlPercent: z.ZodNullable<z.ZodNumber>;
93
- hitRate: z.ZodNullable<z.ZodNumber>;
94
- profitFactor: z.ZodNullable<z.ZodNumber>;
95
- avgWinSize: z.ZodNullable<z.ZodNumber>;
96
- avgLossSize: z.ZodNullable<z.ZodNumber>;
97
- avgReturnPerWin: z.ZodNullable<z.ZodNumber>;
98
- avgReturnPerLoss: z.ZodNullable<z.ZodNumber>;
99
- maxDrawdown: z.ZodNullable<z.ZodNumber>;
100
- sharpeRatio: z.ZodNullable<z.ZodNumber>;
101
- sortinoRatio: z.ZodNullable<z.ZodNumber>;
102
- }, z.core.$strip>;
103
- realizedHitRate: z.ZodNullable<z.ZodNumber>;
144
+ closedPositionStats: z.ZodObject<{
145
+ totalPositions: z.ZodNumber;
146
+ wins: z.ZodNumber;
147
+ losses: z.ZodNumber;
148
+ hitRate: z.ZodNullable<z.ZodNumber>;
104
149
  profitFactor: z.ZodNullable<z.ZodNumber>;
105
150
  avgWinSize: z.ZodNullable<z.ZodNumber>;
106
151
  avgLossSize: z.ZodNullable<z.ZodNumber>;
107
- breakevenHitRate: z.ZodNullable<z.ZodNumber>;
108
- cushion: z.ZodNullable<z.ZodNumber>;
152
+ netPnl: z.ZodNumber;
153
+ positionPnls: z.ZodArray<z.ZodNumber>;
154
+ positionReturns: z.ZodArray<z.ZodNumber>;
109
155
  }, z.core.$strip>;
110
- assets: z.ZodArray<z.ZodObject<{
111
- asset: z.ZodString;
112
- realizedOnly: z.ZodObject<{
113
- pnlAbsolute: z.ZodNumber;
114
- pnlPercent: z.ZodNullable<z.ZodNumber>;
115
- hitRate: z.ZodNullable<z.ZodNumber>;
116
- profitFactor: z.ZodNullable<z.ZodNumber>;
117
- avgWinSize: z.ZodNullable<z.ZodNumber>;
118
- avgLossSize: z.ZodNullable<z.ZodNumber>;
119
- avgReturnPerWin: z.ZodNullable<z.ZodNumber>;
120
- avgReturnPerLoss: z.ZodNullable<z.ZodNumber>;
121
- maxDrawdown: z.ZodNullable<z.ZodNumber>;
122
- sharpeRatio: z.ZodNullable<z.ZodNumber>;
123
- sortinoRatio: z.ZodNullable<z.ZodNumber>;
124
- }, z.core.$strip>;
125
- realizedPlusUnrealized: z.ZodObject<{
126
- pnlAbsolute: z.ZodNumber;
127
- pnlPercent: z.ZodNullable<z.ZodNumber>;
128
- hitRate: z.ZodNullable<z.ZodNumber>;
129
- profitFactor: z.ZodNullable<z.ZodNumber>;
130
- avgWinSize: z.ZodNullable<z.ZodNumber>;
131
- avgLossSize: z.ZodNullable<z.ZodNumber>;
132
- avgReturnPerWin: z.ZodNullable<z.ZodNumber>;
133
- avgReturnPerLoss: z.ZodNullable<z.ZodNumber>;
134
- maxDrawdown: z.ZodNullable<z.ZodNumber>;
135
- sharpeRatio: z.ZodNullable<z.ZodNumber>;
136
- sortinoRatio: z.ZodNullable<z.ZodNumber>;
137
- }, z.core.$strip>;
138
- unrealizedReturnPerDay: z.ZodNullable<z.ZodNumber>;
139
- }, z.core.$strip>>;
140
- pairs: z.ZodArray<z.ZodObject<{
156
+ pairBreakdown: z.ZodArray<z.ZodObject<{
141
157
  key: z.ZodString;
142
158
  longAssets: z.ZodArray<z.ZodString>;
143
159
  shortAssets: z.ZodArray<z.ZodString>;
144
- trades: z.ZodNumber;
160
+ positions: z.ZodNumber;
145
161
  wins: z.ZodNumber;
146
162
  losses: z.ZodNumber;
147
163
  hitRate: z.ZodNullable<z.ZodNumber>;
148
- avgWinSize: z.ZodNullable<z.ZodNumber>;
149
- avgLossSize: z.ZodNullable<z.ZodNumber>;
150
- expectancy: z.ZodNullable<z.ZodNumber>;
151
- totalPnl: z.ZodNumber;
164
+ profitFactor: z.ZodNullable<z.ZodNumber>;
165
+ expectancy: z.ZodNumber;
166
+ grossPnl: z.ZodNumber;
167
+ tradeFees: z.ZodNumber;
168
+ pearFees: z.ZodNumber;
169
+ netPnl: z.ZodNumber;
152
170
  bookPercent: z.ZodNullable<z.ZodNumber>;
153
171
  }, z.core.$strip>>;
154
- series: z.ZodOptional<z.ZodArray<z.ZodObject<{
155
- date: z.ZodString;
156
- trades: z.ZodNumber;
157
- wins: z.ZodNumber;
158
- losses: z.ZodNumber;
159
- dayPnl: z.ZodNumber;
160
- dayVolume: z.ZodNumber;
161
- dayFunding: z.ZodNumber;
162
- dayNetPnl: z.ZodNumber;
163
- hitRate: z.ZodNullable<z.ZodNumber>;
164
- winLossRatio: z.ZodNullable<z.ZodNumber>;
165
- rollingHitRate: z.ZodNullable<z.ZodNumber>;
166
- rollingWinLossRatio: z.ZodNullable<z.ZodNumber>;
167
- dailyReturn: z.ZodNullable<z.ZodNumber>;
168
- cumulativeReturn: z.ZodNumber;
169
- equity: z.ZodNumber;
170
- drawdown: z.ZodNumber;
171
- rollingSharpe: z.ZodNullable<z.ZodNumber>;
172
- rollingSortino: z.ZodNullable<z.ZodNumber>;
173
- rollingVolatility: z.ZodNullable<z.ZodNumber>;
174
- }, z.core.$strip>>>;
172
+ openSnapshot: z.ZodObject<{
173
+ openInterest: z.ZodNumber;
174
+ unrealizedPnl: z.ZodNumber;
175
+ }, z.core.$strip>;
176
+ volume: z.ZodObject<{
177
+ total: z.ZodNumber;
178
+ series: z.ZodOptional<z.ZodArray<z.ZodObject<{
179
+ periodStart: z.ZodString;
180
+ periodEnd: z.ZodString;
181
+ volume: z.ZodNumber;
182
+ }, z.core.$strip>>>;
183
+ }, z.core.$strip>;
175
184
  }, z.core.$strip>;
176
185
  export type PortfolioAnalyticsResponse = z.output<typeof PortfolioAnalyticsResponse>;
@@ -1,16 +1,29 @@
1
1
  import { z } from 'zod';
2
- import { PortfolioOverall, PortfolioIntervals, PortfolioMetrics, PortfolioAnalyticsConfig, PortfolioSeriesPoint, PortfolioPairBreakdown, PortfolioAssetAnalytics } from './entities';
2
+ import { PortfolioOpenSnapshot, PortfolioClosedPositionStats, PortfolioVolumeAmounts, PortfolioVolumeIntervals, PortfolioCashflowAmounts, PortfolioCashflowIntervals, PortfolioAnalyticsConfig, PortfolioVolumeSeriesPoint, PortfolioPairBreakdown, PortfolioCashflowSeriesPoint } from './entities';
3
3
 
4
4
  const PortfolioResponse = z.object({
5
- intervals: PortfolioIntervals.nullable(),
6
- overall: PortfolioOverall
5
+ realizedCashflow: PortfolioCashflowAmounts.extend({
6
+ fundingSynced: z.boolean(),
7
+ intervals: PortfolioCashflowIntervals.optional()
8
+ }),
9
+ closedPositionStats: PortfolioClosedPositionStats,
10
+ openSnapshot: PortfolioOpenSnapshot,
11
+ volume: PortfolioVolumeAmounts.extend({
12
+ intervals: PortfolioVolumeIntervals.optional()
13
+ })
7
14
  });
8
15
  const PortfolioAnalyticsResponse = z.object({
9
16
  config: PortfolioAnalyticsConfig,
10
- portfolio: PortfolioMetrics,
11
- assets: z.array(PortfolioAssetAnalytics),
12
- pairs: z.array(PortfolioPairBreakdown),
13
- series: z.array(PortfolioSeriesPoint).optional()
17
+ realizedCashflow: PortfolioCashflowAmounts.extend({
18
+ fundingSynced: z.boolean(),
19
+ series: z.array(PortfolioCashflowSeriesPoint).optional()
20
+ }),
21
+ closedPositionStats: PortfolioClosedPositionStats,
22
+ pairBreakdown: z.array(PortfolioPairBreakdown),
23
+ openSnapshot: PortfolioOpenSnapshot,
24
+ volume: PortfolioVolumeAmounts.extend({
25
+ series: z.array(PortfolioVolumeSeriesPoint).optional()
26
+ })
14
27
  });
15
28
 
16
29
  export { PortfolioAnalyticsResponse, PortfolioResponse };
@@ -43,7 +43,8 @@ export type PositionInitialExposureUSD = z.infer<typeof PositionInitialExposureU
43
43
  * negative = net paid). Derived by walking the position's exposure snapshots and
44
44
  * summing each in-window funding event as `exposure × fundingPerUnit`. Across a
45
45
  * fully-tracked account the per-position shares sum to the account funding (up to
46
- * 20-dp rounding of the coefficient).
46
+ * 20-dp rounding of the coefficient); untracked or external exposure sharing the
47
+ * account under-attributes the shares, so the account-level total stays authoritative.
47
48
  *
48
49
  * @example { '0': '-1.25' } means 1.25 USD of BTC funding paid over the position's life
49
50
  */
@@ -92,11 +93,11 @@ export declare const Position: z.ZodObject<{
92
93
  }, z.core.$strip>;
93
94
  export type Position = z.output<typeof Position>;
94
95
  /** Which way a closed basket's leg was held. */
95
- export declare const ClosedTradeLegSide: z.ZodEnum<{
96
+ export declare const ClosedPositionLegSide: z.ZodEnum<{
96
97
  LONG: "LONG";
97
98
  SHORT: "SHORT";
98
99
  }>;
99
- export type ClosedTradeLegSide = z.output<typeof ClosedTradeLegSide>;
100
+ export type ClosedPositionLegSide = z.output<typeof ClosedPositionLegSide>;
100
101
  /**
101
102
  * What one asset did inside one step.
102
103
  *
@@ -107,7 +108,7 @@ export type ClosedTradeLegSide = z.output<typeof ClosedTradeLegSide>;
107
108
  * value it. Collapsing it into REDUCE would invent a basis; collapsing it into
108
109
  * INCREASE would report a close as an add.
109
110
  */
110
- export declare const ClosedTradeStepLeg: z.ZodDiscriminatedUnion<[z.ZodObject<{
111
+ export declare const PositionStepLeg: z.ZodDiscriminatedUnion<[z.ZodObject<{
111
112
  kind: z.ZodLiteral<"INCREASE">;
112
113
  asset: z.ZodString;
113
114
  side: z.ZodEnum<{
@@ -142,7 +143,7 @@ export declare const ClosedTradeStepLeg: z.ZodDiscriminatedUnion<[z.ZodObject<{
142
143
  tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
143
144
  pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
144
145
  }, z.core.$strip>], "kind">;
145
- export type ClosedTradeStepLeg = z.output<typeof ClosedTradeStepLeg>;
146
+ export type PositionStepLeg = z.output<typeof PositionStepLeg>;
146
147
  /**
147
148
  * One action taken on the position, in the order it happened: the open, each add, each
148
149
  * reduction, and the close.
@@ -153,7 +154,7 @@ export type ClosedTradeStepLeg = z.output<typeof ClosedTradeStepLeg>;
153
154
  * genuinely separate actions sharing an instant therefore merge into one step; the
154
155
  * `executionId` being absent is the signal that a step was grouped this way.
155
156
  */
156
- export declare const ClosedTradeStep: z.ZodObject<{
157
+ export declare const PositionStep: z.ZodObject<{
157
158
  executionId: z.ZodOptional<z.ZodString>;
158
159
  at: z.ZodString;
159
160
  grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
@@ -193,15 +194,15 @@ export declare const ClosedTradeStep: z.ZodObject<{
193
194
  pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
194
195
  }, z.core.$strip>], "kind">>;
195
196
  }, z.core.$strip>;
196
- export type ClosedTradeStep = z.output<typeof ClosedTradeStep>;
197
+ export type PositionStep = z.output<typeof PositionStep>;
197
198
  /**
198
- * One leg of a closed trade, with its own entry and exit economics.
199
+ * One leg of a closed position, with its own entry and exit economics.
199
200
  *
200
201
  * Both optional prices are absent rather than "0" whenever they cannot be derived:
201
202
  * "0" is a real price, and claiming one the ledger never recorded would be a lie.
202
203
  * Absence is the honest answer.
203
204
  */
204
- export declare const ClosedTradeLeg: z.ZodObject<{
205
+ export declare const ClosedPositionLeg: z.ZodObject<{
205
206
  asset: z.ZodString;
206
207
  side: z.ZodEnum<{
207
208
  LONG: "LONG";
@@ -219,12 +220,12 @@ export declare const ClosedTradeLeg: z.ZodObject<{
219
220
  exitQuantity: z.ZodString;
220
221
  undeterminedSize: z.ZodString;
221
222
  }, z.core.$strip>;
222
- export type ClosedTradeLeg = z.output<typeof ClosedTradeLeg>;
223
+ export type ClosedPositionLeg = z.output<typeof ClosedPositionLeg>;
223
224
  /**
224
- * One closed position, composed server-side into the trade a trader recognises:
225
+ * One closed position, composed server-side into the history row a trader recognises:
225
226
  * what it earned, what it cost, and what each leg did.
226
227
  */
227
- export declare const ClosedTrade: z.ZodObject<{
228
+ export declare const ClosedPosition: z.ZodObject<{
228
229
  positionId: z.ZodUUID;
229
230
  connector: z.ZodEnum<{
230
231
  hyperliquid: "hyperliquid";
@@ -233,6 +234,7 @@ export declare const ClosedTrade: z.ZodObject<{
233
234
  okx: "okx";
234
235
  lighter: "lighter";
235
236
  }>;
237
+ status: z.ZodLiteral<"CLOSED">;
236
238
  openedAt: z.ZodString;
237
239
  closedAt: z.ZodString;
238
240
  closedReason: z.ZodOptional<z.ZodEnum<{
@@ -317,4 +319,137 @@ export declare const ClosedTrade: z.ZodObject<{
317
319
  }, z.core.$strip>], "kind">>;
318
320
  }, z.core.$strip>>>;
319
321
  }, z.core.$strip>;
320
- export type ClosedTrade = z.output<typeof ClosedTrade>;
322
+ export type ClosedPosition = z.output<typeof ClosedPosition>;
323
+ /**
324
+ * What one leg of an open basket has booked, and what it still holds.
325
+ *
326
+ * Split on the only axis that exists here: `realized` describes quantity the ledger has
327
+ * already closed, `remaining` the quantity it still carries. Fees and funding stay flat
328
+ * because they are neither — both are charged across the leg's whole life, on entry fills
329
+ * as well as exit ones, so nesting them under `realized` would misreport what they cover.
330
+ *
331
+ * `remaining` holds no PnL — which is why it is not named `unrealized`. This endpoint
332
+ * reads no mark price by design, so it reports the inputs an unrealized figure is
333
+ * computed from — size and basis — and leaves the marking to a caller that has a price.
334
+ */
335
+ export declare const OpenPositionLeg: z.ZodObject<{
336
+ asset: z.ZodString;
337
+ side: z.ZodEnum<{
338
+ LONG: "LONG";
339
+ SHORT: "SHORT";
340
+ }>;
341
+ realized: z.ZodObject<{
342
+ quantity: z.ZodString;
343
+ unpricedQuantity: z.ZodString;
344
+ exitVwap: z.ZodOptional<z.ZodString>;
345
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
346
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
347
+ }, z.core.$strip>;
348
+ remaining: z.ZodObject<{
349
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
350
+ entryVwap: z.ZodOptional<z.ZodString>;
351
+ }, z.core.$strip>;
352
+ totalFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
353
+ tradeFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
354
+ pearFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
355
+ funding: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
356
+ }, z.core.$strip>;
357
+ export type OpenPositionLeg = z.output<typeof OpenPositionLeg>;
358
+ /**
359
+ * The realized view of one open position: the part of it that has already been booked,
360
+ * composed server-side from the same math /positions/closed uses.
361
+ *
362
+ * A pure ledger read — no mark price and therefore no unrealized PnL, which
363
+ * /positions and /portfolio's openSnapshot already carry.
364
+ */
365
+ export declare const OpenPosition: z.ZodObject<{
366
+ positionId: z.ZodUUID;
367
+ connector: z.ZodEnum<{
368
+ hyperliquid: "hyperliquid";
369
+ binance: "binance";
370
+ bybit: "bybit";
371
+ okx: "okx";
372
+ lighter: "lighter";
373
+ }>;
374
+ status: z.ZodLiteral<"OPEN">;
375
+ openedAt: z.ZodString;
376
+ updatedAt: z.ZodString;
377
+ origin: z.ZodEnum<{
378
+ PARTIAL: "PARTIAL";
379
+ PEAR: "PEAR";
380
+ EXTERNAL: "EXTERNAL";
381
+ }>;
382
+ realizedGrossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
383
+ netCashflow: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
384
+ totalFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
385
+ tradeFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
386
+ pearFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
387
+ totalFunding: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
388
+ initialExposureUSD: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>>;
389
+ hasSyntheticFills: z.ZodBoolean;
390
+ hasProvisionalFills: z.ZodBoolean;
391
+ unstableHistoricalData: z.ZodBoolean;
392
+ legs: z.ZodArray<z.ZodObject<{
393
+ asset: z.ZodString;
394
+ side: z.ZodEnum<{
395
+ LONG: "LONG";
396
+ SHORT: "SHORT";
397
+ }>;
398
+ realized: z.ZodObject<{
399
+ quantity: z.ZodString;
400
+ unpricedQuantity: z.ZodString;
401
+ exitVwap: z.ZodOptional<z.ZodString>;
402
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
403
+ netPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
404
+ }, z.core.$strip>;
405
+ remaining: z.ZodObject<{
406
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
407
+ entryVwap: z.ZodOptional<z.ZodString>;
408
+ }, z.core.$strip>;
409
+ totalFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
410
+ tradeFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
411
+ pearFees: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
412
+ funding: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
413
+ }, z.core.$strip>>;
414
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
415
+ executionId: z.ZodOptional<z.ZodString>;
416
+ at: z.ZodString;
417
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
418
+ legs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
419
+ kind: z.ZodLiteral<"INCREASE">;
420
+ asset: z.ZodString;
421
+ side: z.ZodEnum<{
422
+ BUY: "BUY";
423
+ SELL: "SELL";
424
+ }>;
425
+ quantity: z.ZodString;
426
+ price: z.ZodString;
427
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
428
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
429
+ }, z.core.$strip>, z.ZodObject<{
430
+ kind: z.ZodLiteral<"REDUCE">;
431
+ asset: z.ZodString;
432
+ side: z.ZodEnum<{
433
+ BUY: "BUY";
434
+ SELL: "SELL";
435
+ }>;
436
+ quantity: z.ZodString;
437
+ price: z.ZodString;
438
+ entryBasis: z.ZodString;
439
+ grossPnl: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
440
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
441
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
442
+ }, z.core.$strip>, z.ZodObject<{
443
+ kind: z.ZodLiteral<"REDUCE_UNPRICED">;
444
+ asset: z.ZodString;
445
+ side: z.ZodEnum<{
446
+ BUY: "BUY";
447
+ SELL: "SELL";
448
+ }>;
449
+ quantity: z.ZodString;
450
+ tradeFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
451
+ pearFee: z.ZodPipe<z.ZodString, z.ZodTransform<`-${string}` | `+${string}`, string>>;
452
+ }, z.core.$strip>], "kind">>;
453
+ }, z.core.$strip>>>;
454
+ }, z.core.$strip>;
455
+ export type OpenPosition = z.output<typeof OpenPosition>;