OptionMathExternal
Functions
optionDelta
Calculate option delta
function optionDelta(
UD60x18 spot,
UD60x18 strike,
UD60x18 timeToMaturity,
UD60x18 volAnnualized,
UD60x18 riskFreeRate,
bool isCall
) public pure returns (SD59x18);
Parameters
Name | Type | Description |
---|---|---|
spot | UD60x18 | Spot price |
strike | UD60x18 | Strike price |
timeToMaturity | UD60x18 | Duration of option contract (in years) |
volAnnualized | UD60x18 | Annualized volatility |
riskFreeRate | UD60x18 | |
isCall | bool | whether to price "call" or "put" option |
Returns
Name | Type | Description |
---|---|---|
<none> | SD59x18 | price Option delta |
blackScholesPrice
Calculate the price of an option using the Black-Scholes model
this implementation assumes zero interest
function blackScholesPrice(
UD60x18 spot,
UD60x18 strike,
UD60x18 timeToMaturity,
UD60x18 volAnnualized,
UD60x18 riskFreeRate,
bool isCall
) public pure returns (UD60x18);
Parameters
Name | Type | Description |
---|---|---|
spot | UD60x18 | Spot price (18 decimals) |
strike | UD60x18 | Strike price (18 decimals) |
timeToMaturity | UD60x18 | Duration of option contract (in years) (18 decimals) |
volAnnualized | UD60x18 | Annualized volatility (18 decimals) |
riskFreeRate | UD60x18 | The risk-free rate (18 decimals) |
isCall | bool | whether to price "call" or "put" option |
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | price The Black-Scholes option price (18 decimals) |
computeCLevel
Calculates the C-level given a utilisation value and time since last trade value (duration). (https://www.desmos.com/calculator/0uzv50t7jy)
function computeCLevel(
UD60x18 utilisation,
UD60x18 duration,
UD60x18 alpha,
UD60x18 minCLevel,
UD60x18 maxCLevel,
UD60x18 decayRate
) public pure returns (UD60x18);
Parameters
Name | Type | Description |
---|---|---|
utilisation | UD60x18 | The utilisation after some collateral is utilised |
duration | UD60x18 | The time since last trade (hours) |
alpha | UD60x18 | (needs to be filled in) |
minCLevel | UD60x18 | The minimum C-level |
maxCLevel | UD60x18 | The maximum C-level |
decayRate | UD60x18 | The decay rate of the C-level back down to minimum level (decay/hour) |
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | The C-level corresponding to the post-utilisation value. |
computeCLevelGeoMean
Calculates the geo-mean C-level given a utilisation before and after collateral is utilised.
function computeCLevelGeoMean(
UD60x18 utilisationBefore,
UD60x18 utilisationAfter,
UD60x18 duration,
UD60x18 alpha,
UD60x18 minCLevel,
UD60x18 maxCLevel,
UD60x18 decayRate
) public pure returns (UD60x18 cLevel);
Parameters
Name | Type | Description |
---|---|---|
utilisationBefore | UD60x18 | The utilisation before some collateral is utilised. |
utilisationAfter | UD60x18 | The utilisation after some collateral is utilised |
duration | UD60x18 | The time since last trade (hours) |
alpha | UD60x18 | (needs to be filled in) |
minCLevel | UD60x18 | The minimum C-level |
maxCLevel | UD60x18 | The maximum C-level |
decayRate | UD60x18 | The decay rate of the C-level back down to minimum level (decay/hour) |
Returns
Name | Type | Description |
---|---|---|
cLevel | UD60x18 | The C-level corresponding to the geo-mean of the utilisation value before and after collateral is utilised. |