Expand description
Pure settlement arithmetic for Hypercall options.
This crate computes option settlement payouts at expiry. It has no IO,
no state, and no async – just deterministic arithmetic over [Decimal]
values. This makes it auditable, formally verifiable, and safe to call
from any context.
§Invariants (verified by Kani bounded model checking)
- Non-negative intrinsic value:
intrinsic_value() >= 0for all inputs. - Call-put parity:
call_iv - put_iv = spot - strike. - Zero-sum: for any matched long/short pair with the same parameters,
long.net_pnl + short.net_pnl = 0. Settlement cannot create or destroy value. - No panics:
settle_positiondoes not panic on any validDecimalinput.
§Usage
use hypercall_settlement::{OptionType, SettlementInput, settle_position};
use rust_decimal_macros::dec;
let output = settle_position(&SettlementInput {
option_type: OptionType::Call,
strike: dec!(80000),
reference_price: dec!(85000),
position_size: dec!(1),
entry_price: dec!(3000),
});
assert_eq!(output.intrinsic_value, dec!(5000));
assert_eq!(output.settlement_value, dec!(5000));
assert_eq!(output.cost_basis, dec!(3000));
assert_eq!(output.net_pnl, dec!(2000));§Settlement math
For a position with size s, strike K, spot at expiry S, and entry price e:
intrinsic_value = max(S - K, 0) for calls
max(K - S, 0) for puts
settlement_value = intrinsic_value * s
cost_basis = s * e
net_pnl = settlement_value - cost_basisAll intermediate results are quantized to 8 decimal places (MidpointAwayFromZero rounding).
Modules§
Structs§
- Parsed
Settlement Symbol - Parsed components of an option symbol used by settlement.
- Position
Expired Message - Canonical position-expired event payload.
- Settlement
Economics - Optional economics fields that must be all present or all absent.
- Settlement
Error - Settlement validation failure.
- Settlement
Input - Inputs required to settle a single option position at expiry.
- Settlement
Instrument - Instrument metadata needed to settle a symbol.
- Settlement
Output - Settlement result for a single position.
- Settlement
Payout View - Settlement payout view used by API adapters.
- Settlement
Persistence Intent - Database-neutral settlement persistence intent.
- Settlement
Position - Engine position selected for settlement.
Enums§
- Option
Type - Option type: European-style call or put.
Constants§
- SCALE_
DP 🔒
Functions§
- build_
position_ expired_ message - Build the canonical position-expired event for a settlement output.
- intrinsic_
value - Compute the intrinsic value of an option at expiry.
- normalize_
payout_ ids - Normalize settlement payout IDs supplied to the seen-payout API.
- plan_
position_ settlements - Build settlement outputs for all non-zero positions in one instrument.
- quantize 🔒
- settle_
batch - Settle a batch of positions and return per-position outputs plus total PnL.
- settle_
position - Settle a single option position at expiry.
- settlement_
cash_ delta_ for_ margin_ mode - Calculate the cash delta that settlement should apply for a margin mode.
- validate_
settlement_ economics - Validate that optional settlement economics are either complete or absent.
- validate_
settlement_ value - Validate that settlement cashflow matches size times intrinsic settlement price.