tweaks
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
Choose Underlying
|
Choose Underlying
|
||||||
|
Choose Quote Date (i.e. from which point in time are you running the analysis)
|
||||||
Choose Strike
|
Choose Strike
|
||||||
For each front-mont-back-month combination:
|
For each front-month-back-month combination:
|
||||||
Lookup the cost to open the position
|
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.
|
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
|
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.
|
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.
|
||||||
+2
-2
@@ -22,7 +22,7 @@ function erf(x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// produced by ChatGPT
|
// 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 iv = 0.5; // Initial guess for implied volatility
|
||||||
let epsilon = 1e-6; // Small value to avoid division by zero
|
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 riskFreeRate = 0.03; // Example risk-free interest rate
|
||||||
const optionType = 'call'; // Example option type ('call' or 'put')
|
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);
|
console.log('Implied Volatility:', impliedVolatility);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user