Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 80154x 80154x 80018x 136x | function calculateExerciseValue(option, spotPrice, time) {
const isCall = option.type === "call" ? 1 : -1;
switch (option.style) {
case "european":
return time < option.timeToMaturity
? 0
: Math.max(0, isCall * (spotPrice - option.strikePrice));
case "american":
return Math.max(0, isCall * (spotPrice - option.strikePrice));
default:
throw new Error(`invalid option style: ${option.style}`);
}
}
export { calculateExerciseValue };
|