ledger_models/fintekkers.models.position.rs
1#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
2#[repr(i32)]
3pub enum PositionStatusProto {
4 Unknown = 0,
5 /// Hypothetical status means a transaction, tax lot or position that may never occur. This can be used to understand how potential actions could impact a portfolio
6 Hypothetical = 1,
7 /// Intended status means a transaction, tax lot or position that is expected to occur if nothing changes. For example a fixed income bond that is expected to pay a coupon, or a security that is expected to mature in a specific point in the future
8 Intended = 2,
9 /// Executed status means a transaction, tax lot or position that is the result of a legally binding transaction
10 Executed = 3,
11}
12impl PositionStatusProto {
13 /// String value of the enum field names used in the ProtoBuf definition.
14 ///
15 /// The values are not transformed in any way and thus are considered stable
16 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
17 pub fn as_str_name(&self) -> &'static str {
18 match self {
19 PositionStatusProto::Unknown => "UNKNOWN",
20 PositionStatusProto::Hypothetical => "HYPOTHETICAL",
21 PositionStatusProto::Intended => "INTENDED",
22 PositionStatusProto::Executed => "EXECUTED",
23 }
24 }
25 /// Creates an enum from field names used in the ProtoBuf definition.
26 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
27 match value {
28 "UNKNOWN" => Some(Self::Unknown),
29 "HYPOTHETICAL" => Some(Self::Hypothetical),
30 "INTENDED" => Some(Self::Intended),
31 "EXECUTED" => Some(Self::Executed),
32 _ => None,
33 }
34 }
35}
36#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
37#[repr(i32)]
38pub enum MeasureProto {
39 /// Placeholder for unset or unrecognized measure values.
40 /// Should never be requested in a valuation call.
41 UnknownMeasure = 0,
42 /// The signed quantity of a position (e.g. number of shares, or total face value of bonds held).
43 /// This is an input measure provided on the PositionProto, not a computed output.
44 ///
45 /// Formula: N/A — user-supplied input.
46 /// Applicability: All security types (Bond, TIPS, FRN, Equity, Cash).
47 /// Units: Units of the security (shares for equity, face-value dollars for bonds).
48 DirectedQuantity = 1,
49 /// The current dollar value of a position at the given market price.
50 ///
51 /// Formula:
52 /// MarketValue = (price * face_value / 100) * (directed_quantity / face_value)
53 /// = price / 100 * directed_quantity
54 /// Where price is quoted as a percentage of par (e.g. 95 means 95% of face).
55 ///
56 /// Example: face=1000, price=95, qty=20000 → MV = 95/100 * 20000 = 19,000.
57 ///
58 /// Model assumptions: None — this is a direct mark-to-market calculation.
59 /// Applicability: Bond, TIPS, FRN, Equity (price=share price, face_value=1), Cash.
60 /// Units: Dollars (or settlement currency).
61 MarketValue = 2,
62 /// The original purchase price of the security, before any adjustments for
63 /// amortization, accretion, or corporate actions.
64 ///
65 /// Formula: Returns the price_input as-is (quoted as % of par for bonds).
66 /// Over time this may incorporate adjustments such as stock splits.
67 ///
68 /// Model assumptions: None — pass-through of the input price.
69 /// Applicability: Bond, TIPS, FRN, Equity, Cash.
70 /// Units: Quoted price (% of par for bonds; dollar price for equities).
71 UnadjustedCostBasis = 3,
72 /// Reserved for future use. The cost basis adjusted for amortization of premium,
73 /// accretion of discount, or corporate actions (e.g. stock splits, return of capital).
74 ///
75 /// Not currently implemented.
76 /// Applicability: Bond, TIPS, FRN, Equity.
77 /// Units: Quoted price (% of par for bonds; dollar price for equities).
78 AdjustedCostBasis = 4,
79 /// Annual coupon income as a percentage of the current market price.
80 ///
81 /// Formula (coupon-bearing bonds):
82 /// CurrentYield = (coupon_rate * principal) / (price * face_value / 100)
83 /// Where principal = face_value for nominal bonds, or inflation-adjusted principal for TIPS.
84 ///
85 /// Formula (zero-coupon bonds):
86 /// CurrentYield = (face_value / dollar_price)^(1 / years_to_maturity) - 1
87 /// This is the annualized investment yield from discount to par.
88 ///
89 /// Model assumptions: Assumes coupon income is constant (no reinvestment assumption).
90 /// For TIPS, uses the inflation-adjusted principal for the annual coupon calculation.
91 /// Day count: Actual/365 for years-to-maturity calculation.
92 /// Applicability: Bond, TIPS. (Equity dividend yield not yet supported.)
93 /// Units: Decimal (0-1 scale; e.g. 0.0526 = 5.26%).
94 CurrentYield = 5,
95 /// The annualized rate of return assuming the bond is held to maturity and all
96 /// coupons are reinvested at the same rate. This is the internal rate of return
97 /// that equates the present value of all future cashflows to the current price.
98 ///
99 /// Formula:
100 /// Solve for r (annual) such that:
101 /// price * (face / 100) = Sum_{t=1}^{N} [C / (1 + r/m)^t] + F / (1 + r/m)^N
102 /// Where C = periodic coupon, F = principal (face or inflation-adjusted),
103 /// m = coupon frequency, N = number of periods.
104 ///
105 /// Solver: Newton-Raphson iteration (ytm_solver.rs) with the linear approximation
106 /// YTM ≈ (annual_coupon + (F - P) / years) / ((F + P) / 2)
107 /// as the initial guess. Converges to the exact YTM where PV = price.
108 ///
109 /// Model assumptions:
110 /// - Coupon reinvestment at the YTM rate (standard bond math assumption).
111 /// - For TIPS: uses inflation-adjusted principal for cashflows, but the input
112 /// price is real — yielding a "mixed" rate, not the true real yield. Use
113 /// REAL_YIELD for the economically correct TIPS yield.
114 /// - Settlement on a coupon date (no accrued interest adjustment currently).
115 /// - Day count: Actual/365 for years-to-maturity.
116 ///
117 /// Applicability: Bond, TIPS. Not meaningful for FRN (use DISCOUNT_MARGIN) or Equity.
118 /// Units: Decimal (0-1 scale; e.g. 0.06 = 6.00% annual).
119 YieldToMaturity = 7,
120 /// The weighted average time (in years) to receive all cashflows from a bond,
121 /// where each cashflow's weight is its proportion of the bond's total present value.
122 ///
123 /// Formula:
124 /// D = Sum_{t=1}^{N} [(t / m) * PV_t / TotalPV]
125 /// Where PV_t = cashflow_t / (1 + r/m)^t, TotalPV = Sum(PV_t),
126 /// m = coupon frequency, r = YTM.
127 ///
128 /// Model assumptions:
129 /// - Uses the bond's YTM (from Newton-Raphson solver) as the discount rate.
130 /// - Flat yield curve (single rate for all maturities).
131 /// - Settlement on a coupon date (integer period exponents).
132 ///
133 /// Applicability: Bond, TIPS. Not typically used for FRN (spread duration is the
134 /// relevant risk measure). Not applicable to Equity or Cash.
135 /// Units: Years (e.g. 4.41 = 4.41 years).
136 MacaulayDuration = 8,
137 /// The theoretical price of a bond computed as the sum of all future cashflows
138 /// (coupons + principal) discounted at the bond's yield to maturity.
139 ///
140 /// Formula:
141 /// PV = Sum_{t=1}^{N} [C / (1 + r/m)^t] + F / (1 + r/m)^N
142 /// Returned as: PV_dollar / (face_value / 100) (quoted price, % of par).
143 ///
144 /// The YTM used for discounting is computed via Newton-Raphson from the input price,
145 /// which guarantees the three-way invariant:
146 /// price == present_value == sum(cashflow_pvs)
147 ///
148 /// Model assumptions:
149 /// - Same as YIELD_TO_MATURITY (the discount rate is derived from the input price).
150 /// - For TIPS: cashflows use inflation-adjusted principal; discount rate is the
151 /// Newton-Raphson-solved rate equating nominal cashflows to the real price.
152 ///
153 /// Applicability: Bond, TIPS. For FRN, PV uses the discount margin framework instead.
154 /// Units: Quoted price (% of par; e.g. 95.00 = $95 per $100 face).
155 PresentValue = 9,
156 /// The yield of a TIPS bond in real (inflation-adjusted) terms. This is the return
157 /// an investor earns above the rate of inflation.
158 ///
159 /// Formula: Currently delegates to the YTM calculator, which uses inflation-adjusted
160 /// principal for cashflows. For a par TIPS (real coupon = real yield), the solver
161 /// finds a "mixed" rate rather than the true real yield (see YIELD_TO_MATURITY notes).
162 ///
163 /// Model assumptions:
164 /// - Same as YIELD_TO_MATURITY but applied to TIPS securities.
165 /// - Known limitation: the current implementation mixes real price with nominal
166 /// (inflation-adjusted) cashflows in the solver, which produces a rate that is
167 /// not the true real yield for non-par TIPS.
168 ///
169 /// Applicability: TIPS only. For nominal bonds, returns the same value as YTM.
170 /// Units: Decimal (0-1 scale; e.g. 0.02 = 2.00% real annual yield).
171 RealYield = 10,
172 /// The inflation-adjusted principal of a TIPS bond, reflecting the cumulative
173 /// change in the Consumer Price Index (CPI) since the bond's issuance.
174 ///
175 /// Formula:
176 /// index_ratio = current_cpi / base_cpi
177 /// adjusted_principal = max(face_value * index_ratio, face_value)
178 /// The max() enforces the deflation floor: at maturity, TIPS redeem at no less
179 /// than the original face value, even if CPI has fallen.
180 ///
181 /// Model assumptions:
182 /// - Uses the CPI values provided in the request (base_cpi on the security,
183 /// current_cpi on the cpi_price_input).
184 /// - Deflation floor applies only to the principal at maturity; interim coupons
185 /// use the raw (potentially deflated) adjusted principal.
186 ///
187 /// Applicability: TIPS only.
188 /// Units: Dollars (e.g. 103.36 for face=100 with 3.36% cumulative inflation).
189 InflationAdjustedPrincipal = 11,
190 /// Requests the full schedule of future cashflows for a bond or TIPS.
191 /// When this measure is included in the request, the ValuationResponseProto will
192 /// populate the `cashflows` repeated field with one CashflowProto per payment period.
193 ///
194 /// Each CashflowProto contains:
195 /// - cashflow_date: the payment date
196 /// - fv_amount: the undiscounted (future) value of the cashflow
197 /// - pv_amount: the cashflow discounted to settlement at the bond's YTM
198 /// - coupon_rate: the annualized coupon rate for this period (constant for
199 /// fixed-rate bonds; reference_rate + spread for FRNs)
200 ///
201 /// The sum of all pv_amounts equals the PRESENT_VALUE measure (three-way invariant).
202 ///
203 /// Model assumptions: Same as PRESENT_VALUE.
204 /// Applicability: Bond, TIPS, FRN.
205 /// Units: fv_amount and pv_amount in dollars; coupon_rate as percentage.
206 PresentValueCashflows = 12,
207 /// The discount margin of a Floating Rate Note (FRN) — the spread over the
208 /// reference rate at which the market discounts the FRN's projected cashflows
209 /// to arrive at its current price. This is the FRN analogue of YTM.
210 ///
211 /// Formula:
212 /// Solve for DM such that:
213 /// price = Sum_{t=1}^{N} [(R + QM)/m * FV / (1 + (R + DM)/m)^t]
214 /// + FV / (1 + (R + DM)/m)^N
215 /// Where R = reference rate, QM = quoted margin (fixed spread), FV = face value,
216 /// m = payment frequency, N = number of remaining periods.
217 ///
218 /// Solver: Newton-Raphson — same solver as YTM (ytm_solver.rs). Solve for the
219 /// periodic discount rate, then extract DM = (solved_rate * m) - R.
220 ///
221 /// Model assumptions:
222 /// - Flat forward rates: all future reference rate fixings are assumed equal to
223 /// the current observation of R. This is the standard FRN simplification.
224 /// - When DM = QM, price = par (100) on a reset date.
225 /// - When DM > QM, price < par (discount); when DM < QM, price > par (premium).
226 ///
227 /// Applicability: FRN only. For fixed-rate bonds, use YIELD_TO_MATURITY.
228 /// Units: Decimal (0-1 scale; e.g. 0.0075 = 75 basis points).
229 DiscountMargin = 13,
230 /// The sensitivity of an FRN's price to a 1 basis point change in the discount
231 /// margin. This is the primary risk measure for FRNs, analogous to modified
232 /// duration for fixed-rate bonds but measuring spread risk rather than rate risk.
233 ///
234 /// Formula (numerical differentiation):
235 /// SpreadDuration = -(1/P) * dP/dDM
236 /// ≈ (P_down - P_up) / (2 * 0.0001 * P_base)
237 /// Where P_down and P_up are the FRN prices when DM is bumped down and up by 1bp.
238 ///
239 /// For a 2-year quarterly FRN at par, spread duration ≈ 1.90 years.
240 /// This is approximately equal to the weighted average time to maturity.
241 ///
242 /// Model assumptions:
243 /// - Same flat-forward assumption as DISCOUNT_MARGIN.
244 /// - Uses a symmetric 1bp bump for numerical differentiation.
245 /// - Interest rate duration of an FRN is near-zero (≈ time to next reset);
246 /// spread duration captures the economically significant risk.
247 ///
248 /// Applicability: FRN only. For fixed-rate bonds, use MACAULAY_DURATION.
249 /// Units: Years (e.g. 1.90 = a 1bp spread widening causes ~1.90bp price decline).
250 SpreadDuration = 14,
251 /// The par yield at a given maturity point on the yield curve. The par yield is
252 /// the coupon rate at which a bond would trade at par (price = 100) for a given
253 /// maturity. This is the most commonly quoted yield curve.
254 ///
255 /// Formula:
256 /// For each maturity point, the par yield is the coupon rate c such that:
257 /// 100 = Sum_{t=1}^{N} [c/m / (1 + r_t)^t] + 100 / (1 + r_N)^N
258 /// Where r_t are spot rates, m = coupon frequency, N = number of periods.
259 ///
260 /// In practice, for on-the-run bonds, par yield ≈ YTM when the bond trades
261 /// near par. The par yield curve is bootstrapped from observed bond prices.
262 ///
263 /// Model assumptions:
264 /// - Coupon frequency matches the market convention (semiannual for US Treasuries).
265 /// - Interpolation between observed maturities uses the method specified in
266 /// the CurveRequestProto (linear by default).
267 ///
268 /// Applicability: Bond, TIPS (real par yield curve).
269 /// Not applicable to FRN, Equity, or Cash.
270 /// Units: Decimal (0-1 scale; e.g. 0.045 = 4.50% annual).
271 ParYield = 15,
272 /// The spot (zero-coupon) yield at a given maturity. The spot rate is the yield
273 /// on a zero-coupon bond maturing at that point — it represents the pure time
274 /// value of money with no reinvestment assumption.
275 ///
276 /// Formula:
277 /// Bootstrapped from the par yield curve:
278 /// P = 100 / (1 + s_N)^N → s_N = (100 / P)^(1/N) - 1
279 /// Where s_N is the N-period spot rate, P is the zero-coupon bond price
280 /// implied by stripping coupons from the par curve.
281 ///
282 /// For the first period, spot rate = par yield. For subsequent periods,
283 /// the bootstrap solves:
284 /// 100 = Sum_{t=1}^{N-1} [c/m / (1 + s_t)^t] + (100 + c/m) / (1 + s_N)^N
285 /// for s_N, using previously computed spot rates s_1..s_{N-1}.
286 ///
287 /// Model assumptions:
288 /// - Requires a complete par yield curve as input (no gaps).
289 /// - Bootstrap assumes exact coupon dates (no day-count adjustments).
290 ///
291 /// Applicability: Derived from Bond par curve. Used for discounting cashflows
292 /// and computing forward rates.
293 /// Units: Decimal (0-1 scale; e.g. 0.046 = 4.60% annual).
294 SpotYield = 16,
295 /// The forward yield between two future dates, implied by the spot curve.
296 /// The forward rate f(t1, t2) is the rate agreed today for borrowing/lending
297 /// between future times t1 and t2.
298 ///
299 /// Formula:
300 /// f(t1, t2) = [(1 + s_{t2})^{t2} / (1 + s_{t1})^{t1}]^{1/(t2 - t1)} - 1
301 /// Where s_t are spot rates for maturities t1 and t2.
302 ///
303 /// For example, the 1-year forward rate 1 year from now (1y1y) is:
304 /// f(1,2) = [(1 + s_2)^2 / (1 + s_1)]^1 - 1
305 ///
306 /// Model assumptions:
307 /// - Derived from the spot curve (which is bootstrapped from par).
308 /// - Assumes no arbitrage between spot and forward rates.
309 /// - The forward period is defined by adjacent tenor points in the
310 /// CurveRequestProto.
311 ///
312 /// Applicability: Derived from Bond spot curve. Used for rate expectations
313 /// and forward-starting instrument pricing.
314 /// Units: Decimal (0-1 scale; e.g. 0.048 = 4.80% annual forward rate).
315 ForwardYield = 17,
316 /// The profit or loss on a position relative to its cost basis.
317 ///
318 /// Formula:
319 /// ProfitLoss = MarketValue - (UnadjustedCostBasis / 100 * DirectedQuantity)
320 ///
321 /// Applicability: All security types.
322 /// Units: Dollars (or settlement currency).
323 ProfitLoss = 18,
324 /// The profit or loss as a percentage of the original cost basis.
325 ///
326 /// Formula:
327 /// ProfitLossPercent = ProfitLoss / (UnadjustedCostBasis / 100 * DirectedQuantity)
328 ///
329 /// Applicability: All security types.
330 /// Units: Decimal (0-1 scale; e.g. 0.05 = 5.00% gain).
331 ProfitLossPercent = 19,
332 /// The accrued interest on a bond position — the pro-rated coupon income earned
333 /// since the last coupon payment date but not yet received.
334 ///
335 /// Formula (coupon-bearing bonds):
336 /// AccruedInterest = (coupon_rate / coupon_frequency) * (days_since_last_coupon / days_in_period)
337 /// * directed_quantity
338 /// Day count: Actual/Actual (ICMA) for US Treasuries.
339 ///
340 /// Accrued interest on settlement date T is the interest accumulated from the
341 /// last coupon date up to but not including T.
342 ///
343 /// Applicability: Bond, TIPS, FRN (coupon-bearing securities).
344 /// Returns null/zero for Equity, Cash, and zero-coupon bonds.
345 /// Units: Dollars (absolute dollar amount for the position).
346 AccruedInterest = 20,
347 /// The second derivative of a bond's price with respect to yield, normalised by price.
348 /// Convexity measures how the duration of a bond changes as yield changes — a bond
349 /// with higher convexity gains more in price when yields fall and loses less when
350 /// yields rise, compared to a bond with lower convexity of equal duration.
351 ///
352 /// Formula:
353 /// Convexity = (1/P) × Σ_{t=1}^{N} [CF_t × t × (t+1) / (1+y/n)^(t+2)] / n²
354 ///
355 /// Equivalently, in terms of periodic-discount PVs:
356 /// Convexity = Σ_{t=1}^{N} [t(t+1) × PV_t] / (P_dollar × n² × (1+r)²)
357 /// Where r = y/n (periodic yield), P_dollar = dollar price,
358 /// PV_t = CF_t / (1+r)^t, n = coupon frequency (periods per year).
359 ///
360 /// Model assumptions:
361 /// - Same as MACAULAY_DURATION (flat yield curve, YTM-based discounting).
362 /// - For FRN: uses flat-forwards effective YTM (same model as PRESENT_VALUE).
363 /// - Settlement on a coupon date (integer period exponents).
364 ///
365 /// Applicability: Bond, TIPS, FRN. UNIMPLEMENTED for Equity and Cash.
366 /// Units: Years² (e.g. 20.5 = 20.5 years²).
367 Convexity = 21,
368 /// The full (invoice) price of a bond including accrued interest, expressed as a
369 /// percentage of face value.
370 ///
371 /// Formula:
372 /// DirtyPrice = market_value / (num_bonds * face_value) * 100
373 /// where num_bonds = directed_quantity / face_value
374 /// Equivalently: market_value / directed_quantity * 100
375 ///
376 /// Applicability: Bond, TIPS. UNIMPLEMENTED for Equity and Cash.
377 /// Units: Percentage of par (e.g. 99.5 = 99.5% of par).
378 DirtyPrice = 22,
379 /// The quoted price of a bond excluding accrued interest, expressed as a
380 /// percentage of face value. This is the price conventionally quoted in bond markets.
381 ///
382 /// Formula:
383 /// CleanPrice = DirtyPrice - (accrued_interest / directed_quantity * 100)
384 ///
385 /// Applicability: Bond, TIPS. UNIMPLEMENTED for Equity and Cash.
386 /// Units: Percentage of par (e.g. 98.75 = 98.75% of par).
387 CleanPrice = 23,
388 /// Modified Duration = MacaulayDuration / (1 + ytm/coupon_frequency).
389 ///
390 /// Measures the percentage price change of a bond for a 1% (100bp) change in yield.
391 /// Unlike Macaulay Duration (which is expressed in years), Modified Duration is a
392 /// direct measure of price sensitivity: a bond with ModifiedDuration=5 will move
393 /// approximately 5% in price for a 100bp parallel shift in yield.
394 ///
395 /// Formula:
396 /// ModifiedDuration = MacaulayDuration / (1 + ytm/n)
397 /// where ytm = yield to maturity (annual), n = coupon periods per year.
398 ///
399 /// Applicability: Bond, TIPS, FRN. UNIMPLEMENTED for Equity and Cash.
400 /// Units: Years (dimensionally equivalent to years, interpreted as % per 100bp).
401 ModifiedDuration = 24,
402 /// DV01 (Dollar Value of 01) = the dollar P&L impact of a 1bp (0.01%) yield increase.
403 ///
404 /// Formula:
405 /// DV01 = ModifiedDuration × MarketValue × 0.0001
406 ///
407 /// For a $1M market value position with ModifiedDuration=5:
408 /// DV01 = 5 × 1,000,000 × 0.0001 = $500 per bp
409 ///
410 /// Applicability: Bond, TIPS, FRN. UNIMPLEMENTED for Equity and Cash.
411 /// Units: Dollars per basis point.
412 Dv01 = 25,
413}
414impl MeasureProto {
415 /// String value of the enum field names used in the ProtoBuf definition.
416 ///
417 /// The values are not transformed in any way and thus are considered stable
418 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
419 pub fn as_str_name(&self) -> &'static str {
420 match self {
421 MeasureProto::UnknownMeasure => "UNKNOWN_MEASURE",
422 MeasureProto::DirectedQuantity => "DIRECTED_QUANTITY",
423 MeasureProto::MarketValue => "MARKET_VALUE",
424 MeasureProto::UnadjustedCostBasis => "UNADJUSTED_COST_BASIS",
425 MeasureProto::AdjustedCostBasis => "ADJUSTED_COST_BASIS",
426 MeasureProto::CurrentYield => "CURRENT_YIELD",
427 MeasureProto::YieldToMaturity => "YIELD_TO_MATURITY",
428 MeasureProto::MacaulayDuration => "MACAULAY_DURATION",
429 MeasureProto::PresentValue => "PRESENT_VALUE",
430 MeasureProto::RealYield => "REAL_YIELD",
431 MeasureProto::InflationAdjustedPrincipal => "INFLATION_ADJUSTED_PRINCIPAL",
432 MeasureProto::PresentValueCashflows => "PRESENT_VALUE_CASHFLOWS",
433 MeasureProto::DiscountMargin => "DISCOUNT_MARGIN",
434 MeasureProto::SpreadDuration => "SPREAD_DURATION",
435 MeasureProto::ParYield => "PAR_YIELD",
436 MeasureProto::SpotYield => "SPOT_YIELD",
437 MeasureProto::ForwardYield => "FORWARD_YIELD",
438 MeasureProto::ProfitLoss => "PROFIT_LOSS",
439 MeasureProto::ProfitLossPercent => "PROFIT_LOSS_PERCENT",
440 MeasureProto::AccruedInterest => "ACCRUED_INTEREST",
441 MeasureProto::Convexity => "CONVEXITY",
442 MeasureProto::DirtyPrice => "DIRTY_PRICE",
443 MeasureProto::CleanPrice => "CLEAN_PRICE",
444 MeasureProto::ModifiedDuration => "MODIFIED_DURATION",
445 MeasureProto::Dv01 => "DV01",
446 }
447 }
448 /// Creates an enum from field names used in the ProtoBuf definition.
449 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
450 match value {
451 "UNKNOWN_MEASURE" => Some(Self::UnknownMeasure),
452 "DIRECTED_QUANTITY" => Some(Self::DirectedQuantity),
453 "MARKET_VALUE" => Some(Self::MarketValue),
454 "UNADJUSTED_COST_BASIS" => Some(Self::UnadjustedCostBasis),
455 "ADJUSTED_COST_BASIS" => Some(Self::AdjustedCostBasis),
456 "CURRENT_YIELD" => Some(Self::CurrentYield),
457 "YIELD_TO_MATURITY" => Some(Self::YieldToMaturity),
458 "MACAULAY_DURATION" => Some(Self::MacaulayDuration),
459 "PRESENT_VALUE" => Some(Self::PresentValue),
460 "REAL_YIELD" => Some(Self::RealYield),
461 "INFLATION_ADJUSTED_PRINCIPAL" => Some(Self::InflationAdjustedPrincipal),
462 "PRESENT_VALUE_CASHFLOWS" => Some(Self::PresentValueCashflows),
463 "DISCOUNT_MARGIN" => Some(Self::DiscountMargin),
464 "SPREAD_DURATION" => Some(Self::SpreadDuration),
465 "PAR_YIELD" => Some(Self::ParYield),
466 "SPOT_YIELD" => Some(Self::SpotYield),
467 "FORWARD_YIELD" => Some(Self::ForwardYield),
468 "PROFIT_LOSS" => Some(Self::ProfitLoss),
469 "PROFIT_LOSS_PERCENT" => Some(Self::ProfitLossPercent),
470 "ACCRUED_INTEREST" => Some(Self::AccruedInterest),
471 "CONVEXITY" => Some(Self::Convexity),
472 "DIRTY_PRICE" => Some(Self::DirtyPrice),
473 "CLEAN_PRICE" => Some(Self::CleanPrice),
474 "MODIFIED_DURATION" => Some(Self::ModifiedDuration),
475 "DV01" => Some(Self::Dv01),
476 _ => None,
477 }
478 }
479}
480#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
481#[repr(i32)]
482pub enum FieldProto {
483 UnknownField = 0,
484 /// (UUID.class)
485 Id = 1,
486 /// ZonedDateTime
487 AsOf = 2,
488 /// Attribute fields. Likely to be fields that one would pivot on.
489 ///
490 /// LocalDate.class
491 EffectiveDate = 10,
492 /// common.model.strategy.Strategy.class
493 Strategy = 11,
494 /// common.model.security.Security.class
495 Security = 12,
496 SecurityDescription = 61,
497 SecurityIssuerName = 62,
498 /// common.model.security.Security.class
499 CashImpactSecurity = 13,
500 /// Security Fields
501 ///
502 /// AssetClass(String.class), //FixedIncome, Equity, etc
503 AssetClass = 50,
504 /// ProductClass(String.class), //Bond, CashEquity, etc
505 ProductClass = 51,
506 /// ProductType (String.class), //TBILL, BOND, etc
507 ProductType = 52,
508 SecurityId = 53,
509 Identifier = 54,
510 /// 1M
511 Tenor = 55,
512 IssueDate = 58,
513 MaturityDate = 56,
514 AdjustedTenor = 57,
515 /// Portfolio fields
516 ///
517 /// common.model.portfolio.Portfolio.class
518 Portfolio = 14,
519 /// UUID
520 PortfolioId = 15,
521 PortfolioName = 60,
522 /// Miscellaneous
523 ///
524 /// common.model.price.Price.class
525 Price = 16,
526 /// UUID
527 PriceId = 17,
528 /// Boolean.class
529 IsCancelled = 18,
530 /// PositionStatus.class
531 PositionStatus = 19,
532 /// Transaction only
533 ///
534 /// TradeDate(LocalDate.class),
535 TradeDate = 30,
536 /// SettlementDate(LocalDate.class),
537 SettlementDate = 31,
538 /// BUY, SELL, MATURATION, etc (TransactionType.class)
539 TransactionType = 32,
540 /// Tax Lot only
541 ///
542 /// TaxLotOpenDate(LocalDate.class),
543 TaxLotOpenDate = 40,
544 /// TaxLotCloseDate(LocalDate.class),
545 TaxLotCloseDate = 41,
546}
547impl FieldProto {
548 /// String value of the enum field names used in the ProtoBuf definition.
549 ///
550 /// The values are not transformed in any way and thus are considered stable
551 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
552 pub fn as_str_name(&self) -> &'static str {
553 match self {
554 FieldProto::UnknownField => "UNKNOWN_FIELD",
555 FieldProto::Id => "ID",
556 FieldProto::AsOf => "AS_OF",
557 FieldProto::EffectiveDate => "EFFECTIVE_DATE",
558 FieldProto::Strategy => "STRATEGY",
559 FieldProto::Security => "SECURITY",
560 FieldProto::SecurityDescription => "SECURITY_DESCRIPTION",
561 FieldProto::SecurityIssuerName => "SECURITY_ISSUER_NAME",
562 FieldProto::CashImpactSecurity => "CASH_IMPACT_SECURITY",
563 FieldProto::AssetClass => "ASSET_CLASS",
564 FieldProto::ProductClass => "PRODUCT_CLASS",
565 FieldProto::ProductType => "PRODUCT_TYPE",
566 FieldProto::SecurityId => "SECURITY_ID",
567 FieldProto::Identifier => "IDENTIFIER",
568 FieldProto::Tenor => "TENOR",
569 FieldProto::IssueDate => "ISSUE_DATE",
570 FieldProto::MaturityDate => "MATURITY_DATE",
571 FieldProto::AdjustedTenor => "ADJUSTED_TENOR",
572 FieldProto::Portfolio => "PORTFOLIO",
573 FieldProto::PortfolioId => "PORTFOLIO_ID",
574 FieldProto::PortfolioName => "PORTFOLIO_NAME",
575 FieldProto::Price => "PRICE",
576 FieldProto::PriceId => "PRICE_ID",
577 FieldProto::IsCancelled => "IS_CANCELLED",
578 FieldProto::PositionStatus => "POSITION_STATUS",
579 FieldProto::TradeDate => "TRADE_DATE",
580 FieldProto::SettlementDate => "SETTLEMENT_DATE",
581 FieldProto::TransactionType => "TRANSACTION_TYPE",
582 FieldProto::TaxLotOpenDate => "TAX_LOT_OPEN_DATE",
583 FieldProto::TaxLotCloseDate => "TAX_LOT_CLOSE_DATE",
584 }
585 }
586 /// Creates an enum from field names used in the ProtoBuf definition.
587 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
588 match value {
589 "UNKNOWN_FIELD" => Some(Self::UnknownField),
590 "ID" => Some(Self::Id),
591 "AS_OF" => Some(Self::AsOf),
592 "EFFECTIVE_DATE" => Some(Self::EffectiveDate),
593 "STRATEGY" => Some(Self::Strategy),
594 "SECURITY" => Some(Self::Security),
595 "SECURITY_DESCRIPTION" => Some(Self::SecurityDescription),
596 "SECURITY_ISSUER_NAME" => Some(Self::SecurityIssuerName),
597 "CASH_IMPACT_SECURITY" => Some(Self::CashImpactSecurity),
598 "ASSET_CLASS" => Some(Self::AssetClass),
599 "PRODUCT_CLASS" => Some(Self::ProductClass),
600 "PRODUCT_TYPE" => Some(Self::ProductType),
601 "SECURITY_ID" => Some(Self::SecurityId),
602 "IDENTIFIER" => Some(Self::Identifier),
603 "TENOR" => Some(Self::Tenor),
604 "ISSUE_DATE" => Some(Self::IssueDate),
605 "MATURITY_DATE" => Some(Self::MaturityDate),
606 "ADJUSTED_TENOR" => Some(Self::AdjustedTenor),
607 "PORTFOLIO" => Some(Self::Portfolio),
608 "PORTFOLIO_ID" => Some(Self::PortfolioId),
609 "PORTFOLIO_NAME" => Some(Self::PortfolioName),
610 "PRICE" => Some(Self::Price),
611 "PRICE_ID" => Some(Self::PriceId),
612 "IS_CANCELLED" => Some(Self::IsCancelled),
613 "POSITION_STATUS" => Some(Self::PositionStatus),
614 "TRADE_DATE" => Some(Self::TradeDate),
615 "SETTLEMENT_DATE" => Some(Self::SettlementDate),
616 "TRANSACTION_TYPE" => Some(Self::TransactionType),
617 "TAX_LOT_OPEN_DATE" => Some(Self::TaxLotOpenDate),
618 "TAX_LOT_CLOSE_DATE" => Some(Self::TaxLotCloseDate),
619 _ => None,
620 }
621 }
622}
623#[allow(clippy::derive_partial_eq_without_eq)]
624#[derive(Clone, PartialEq, ::prost::Message)]
625pub struct MeasureMapEntry {
626 #[prost(enumeration = "MeasureProto", tag = "1")]
627 pub measure: i32,
628 #[prost(message, optional, tag = "2")]
629 pub measure_decimal_value: ::core::option::Option<super::util::DecimalValueProto>,
630}
631#[allow(clippy::derive_partial_eq_without_eq)]
632#[derive(Clone, PartialEq, ::prost::Message)]
633pub struct FieldMapEntry {
634 #[prost(enumeration = "FieldProto", tag = "1")]
635 pub field: i32,
636 /// Used for position filters, but not for responses
637 #[prost(enumeration = "PositionFilterOperator", tag = "20")]
638 pub operator: i32,
639 #[prost(oneof = "field_map_entry::FieldMapValueOneOf", tags = "4, 5, 6")]
640 pub field_map_value_one_of: ::core::option::Option<
641 field_map_entry::FieldMapValueOneOf,
642 >,
643}
644/// Nested message and enum types in `FieldMapEntry`.
645pub mod field_map_entry {
646 #[allow(clippy::derive_partial_eq_without_eq)]
647 #[derive(Clone, PartialEq, ::prost::Oneof)]
648 pub enum FieldMapValueOneOf {
649 /// If the field is a 'complex' proto type (e.g. a full enum) we serialize the enum and wrap it in an Any. You can think of the Any as a string describing the type, and a binary of the proto itself
650 #[prost(message, tag = "4")]
651 FieldValuePacked(::prost_types::Any),
652 /// If the field is an enum type, then we use the number to denote which value it is
653 #[prost(int32, tag = "5")]
654 EnumValue(i32),
655 /// If the field is a string type, we just serialize the string (packing has an overhead)
656 #[prost(string, tag = "6")]
657 StringValue(::prost::alloc::string::String),
658 }
659}
660#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
661#[repr(i32)]
662pub enum PositionFilterOperator {
663 UnknownOperator = 0,
664 Equals = 1,
665 NotEquals = 2,
666 LessThan = 3,
667 LessThanOrEquals = 4,
668 MoreThan = 5,
669 MoreThanOrEquals = 6,
670}
671impl PositionFilterOperator {
672 /// String value of the enum field names used in the ProtoBuf definition.
673 ///
674 /// The values are not transformed in any way and thus are considered stable
675 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
676 pub fn as_str_name(&self) -> &'static str {
677 match self {
678 PositionFilterOperator::UnknownOperator => "UNKNOWN_OPERATOR",
679 PositionFilterOperator::Equals => "EQUALS",
680 PositionFilterOperator::NotEquals => "NOT_EQUALS",
681 PositionFilterOperator::LessThan => "LESS_THAN",
682 PositionFilterOperator::LessThanOrEquals => "LESS_THAN_OR_EQUALS",
683 PositionFilterOperator::MoreThan => "MORE_THAN",
684 PositionFilterOperator::MoreThanOrEquals => "MORE_THAN_OR_EQUALS",
685 }
686 }
687 /// Creates an enum from field names used in the ProtoBuf definition.
688 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
689 match value {
690 "UNKNOWN_OPERATOR" => Some(Self::UnknownOperator),
691 "EQUALS" => Some(Self::Equals),
692 "NOT_EQUALS" => Some(Self::NotEquals),
693 "LESS_THAN" => Some(Self::LessThan),
694 "LESS_THAN_OR_EQUALS" => Some(Self::LessThanOrEquals),
695 "MORE_THAN" => Some(Self::MoreThan),
696 "MORE_THAN_OR_EQUALS" => Some(Self::MoreThanOrEquals),
697 _ => None,
698 }
699 }
700}
701#[allow(clippy::derive_partial_eq_without_eq)]
702#[derive(Clone, PartialEq, ::prost::Message)]
703pub struct PositionProto {
704 #[prost(string, tag = "1")]
705 pub object_class: ::prost::alloc::string::String,
706 #[prost(string, tag = "2")]
707 pub version: ::prost::alloc::string::String,
708 #[prost(enumeration = "PositionViewProto", tag = "10")]
709 pub position_view: i32,
710 #[prost(enumeration = "PositionTypeProto", tag = "11")]
711 pub position_type: i32,
712 #[prost(message, repeated, tag = "20")]
713 pub measures: ::prost::alloc::vec::Vec<MeasureMapEntry>,
714 #[prost(message, repeated, tag = "21")]
715 pub fields: ::prost::alloc::vec::Vec<FieldMapEntry>,
716 /// The base/reporting currency for monetary measures in this position.
717 /// Set to the portfolio's base currency (e.g. USD cash security).
718 /// Allows the UI to display the currency alongside MARKET_VALUE and other measures.
719 #[prost(message, optional, tag = "22")]
720 pub reporting_currency: ::core::option::Option<super::security::SecurityProto>,
721}
722#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
723#[repr(i32)]
724pub enum PositionViewProto {
725 UnknownPositionView = 0,
726 DefaultView = 1,
727 StrategyView = 2,
728}
729impl PositionViewProto {
730 /// String value of the enum field names used in the ProtoBuf definition.
731 ///
732 /// The values are not transformed in any way and thus are considered stable
733 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
734 pub fn as_str_name(&self) -> &'static str {
735 match self {
736 PositionViewProto::UnknownPositionView => "UNKNOWN_POSITION_VIEW",
737 PositionViewProto::DefaultView => "DEFAULT_VIEW",
738 PositionViewProto::StrategyView => "STRATEGY_VIEW",
739 }
740 }
741 /// Creates an enum from field names used in the ProtoBuf definition.
742 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
743 match value {
744 "UNKNOWN_POSITION_VIEW" => Some(Self::UnknownPositionView),
745 "DEFAULT_VIEW" => Some(Self::DefaultView),
746 "STRATEGY_VIEW" => Some(Self::StrategyView),
747 _ => None,
748 }
749 }
750}
751#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
752#[repr(i32)]
753pub enum PositionTypeProto {
754 UnknownPositionType = 0,
755 Transaction = 1,
756 TaxLot = 2,
757}
758impl PositionTypeProto {
759 /// String value of the enum field names used in the ProtoBuf definition.
760 ///
761 /// The values are not transformed in any way and thus are considered stable
762 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
763 pub fn as_str_name(&self) -> &'static str {
764 match self {
765 PositionTypeProto::UnknownPositionType => "UNKNOWN_POSITION_TYPE",
766 PositionTypeProto::Transaction => "TRANSACTION",
767 PositionTypeProto::TaxLot => "TAX_LOT",
768 }
769 }
770 /// Creates an enum from field names used in the ProtoBuf definition.
771 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
772 match value {
773 "UNKNOWN_POSITION_TYPE" => Some(Self::UnknownPositionType),
774 "TRANSACTION" => Some(Self::Transaction),
775 "TAX_LOT" => Some(Self::TaxLot),
776 _ => None,
777 }
778 }
779}
780#[allow(clippy::derive_partial_eq_without_eq)]
781#[derive(Clone, PartialEq, ::prost::Message)]
782pub struct PositionFilterProto {
783 #[prost(string, tag = "1")]
784 pub object_class: ::prost::alloc::string::String,
785 #[prost(string, tag = "2")]
786 pub version: ::prost::alloc::string::String,
787 #[prost(message, repeated, tag = "21")]
788 pub filters: ::prost::alloc::vec::Vec<FieldMapEntry>,
789}