Pure fee and slippage math for effective fill prices, roundtrip costs, and funding-adjusted breakeven levels.
Fee and slippage rates are caller-supplied — no exchange clients or I/O.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
funding_adjusted_breakeven | 3 | Compute breakeven price after roundtrip fees and accrued funding. | entry_price: value, params: value, accrued_funding: value |
roundtrip_cost | 1 | Return total open+close fee cost for a position. | params: value |
effective_exit | 2 | Adjust a fill price for exit fees and optional slippage. | fill_price: value, params: value |
effective_entry | 2 | Adjust a fill price for entry fees and optional slippage. | fill_price: value, params: value |
Summary
Types
Inputs for funding-adjusted breakeven (extends roundtrip with size and side).
Fee and slippage inputs for effective fill prices.
Inputs for roundtrip fee cost.
Side for entry/exit price adjustments and breakeven.
Functions
Return the effective entry price after folding in fee rate and slippage.
Return the effective exit price after folding in fee rate and slippage.
Return the breakeven price accounting for open/close fee rates and accrued funding.
Return the total fee cost to open and close a position.
Types
@type breakeven_params() :: %{ :size => decimal_input(), :open_fee_rate => decimal_input(), :close_fee_rate => decimal_input(), optional(:exit_price) => decimal_input(), optional(:side) => side() }
Inputs for funding-adjusted breakeven (extends roundtrip with size and side).
@type decimal_input() :: DeltaCalc.Decimal.input()
@type fill_params() :: %{ :fee_rate => decimal_input(), optional(:slippage_bps) => decimal_input(), optional(:side) => side() }
Fee and slippage inputs for effective fill prices.
@type roundtrip_params() :: %{ optional(:notional) => decimal_input(), optional(:entry_price) => decimal_input(), optional(:size) => decimal_input(), optional(:exit_price) => decimal_input(), open_fee_rate: decimal_input(), close_fee_rate: decimal_input() }
Inputs for roundtrip fee cost.
@type side() :: :long | :short
Side for entry/exit price adjustments and breakeven.
Functions
@spec effective_entry(decimal_input(), fill_params()) :: Decimal.t()
Return the effective entry price after folding in fee rate and slippage.
Long entries (buys) increase; short entries (sells) decrease.
@spec effective_exit(decimal_input(), fill_params()) :: Decimal.t()
Return the effective exit price after folding in fee rate and slippage.
Long exits (sells) decrease; short exits (buys) increase.
@spec funding_adjusted_breakeven( decimal_input(), breakeven_params(), decimal_input() ) :: Decimal.t()
Return the breakeven price accounting for open/close fee rates and accrued funding.
Uses the exact two-leg fee model: close fees apply to the breakeven exit notional.
Returns entry_price unchanged when size is zero.
@spec roundtrip_cost(roundtrip_params()) :: Decimal.t()
Return the total fee cost to open and close a position.
Pass :notional directly, or :entry_price and :size (with optional
:exit_price for the close leg; defaults to entry price).