diff --git a/README.md b/README.md index a5029b2..64c7d84 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ Choose Underlying +Choose Quote Date (i.e. from which point in time are you running the analysis) Choose Strike -For each front-mont-back-month combination: +For each front-month-back-month combination: Lookup the cost to open the position - At the front month's expiration, the back-month will have a certain DTE. Determine what IV the back-month will need in order to offset this cost. + At the front month's expiration, the back-month will have a certain DTE. Determine what IV the back-month will need in order to offset this cost, for all possible underlying prices. Determine the 30-day lo-hi range for IV, normalized for distance-from-the-money and time-to-expiry. In other words, a naive 30-day-lo-hi isn't informative, because maybe it was low due to long time-to-expiry, or high due to distance-from-the-money Normalize the IV that was determined to yield a profit, and see if it's higher than the bottom of the lo-hi range. If it is, it's safe; the only way to lose is for it to end-off having a lower IV than the 30-day record. \ No newline at end of file diff --git a/src/util.ts b/src/util.ts index f96d436..22e18cc 100644 --- a/src/util.ts +++ b/src/util.ts @@ -22,7 +22,7 @@ function erf(x) { } // produced by ChatGPT -export function calculateImpliedVolatility(optionPrice, underlyingPrice, strikePrice, timeToExpiration, riskFreeRate, optionType, maxIterations = 100, tolerance = 0.0001) { +export function calculateImpliedVolatility({optionPrice, underlyingPrice, strikePrice, timeToExpiration, riskFreeRate=0.03, optionType='call', maxIterations = 100, tolerance = 0.0001}) { let iv = 0.5; // Initial guess for implied volatility let epsilon = 1e-6; // Small value to avoid division by zero @@ -76,7 +76,7 @@ const timeToExpiration = 0.25; // Example time to expiration (in years) const riskFreeRate = 0.03; // Example risk-free interest rate const optionType = 'call'; // Example option type ('call' or 'put') -const impliedVolatility = calculateImpliedVolatility(optionPrice, underlyingPrice, strikePrice, timeToExpiration, riskFreeRate, optionType); +const impliedVolatility = calculateImpliedVolatility({optionPrice, underlyingPrice, strikePrice, timeToExpiration, riskFreeRate, optionType}); console.log('Implied Volatility:', impliedVolatility); */