/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void rangeErrorstrikeForDelta4Test() { BlackScholesFormulaRepository.strikeForDelta( SPOT, -100., TIME_TO_EXPIRY, VOLS[1], NAN, COST_OF_CARRY, false); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void negativeVolErrorstrikeForDeltaTest() { BlackScholesFormulaRepository.strikeForDelta( SPOT, 0.1, TIME_TO_EXPIRY, -0.5, INTEREST_RATES[1], COST_OF_CARRY, true); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void negativeSpotErrorstrikeForDeltaTest() { BlackScholesFormulaRepository.strikeForDelta( -SPOT, 0.1, TIME_TO_EXPIRY, VOLS[1], INTEREST_RATES[1], COST_OF_CARRY, true); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void rangeErrorstrikeForDelta3Test() { BlackScholesFormulaRepository.strikeForDelta( SPOT, 100., TIME_TO_EXPIRY, VOLS[1], INTEREST_RATES[1], COST_OF_CARRY, false); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void negativeStrikeErrorstrikeForDeltaTest() { BlackScholesFormulaRepository.strikeForDelta( SPOT, 0.1, -TIME_TO_EXPIRY, VOLS[1], INTEREST_RATES[1], COST_OF_CARRY, true); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void rangeErrorstrikeForDelta1Test() { BlackScholesFormulaRepository.strikeForDelta( SPOT, 100., TIME_TO_EXPIRY, VOLS[1], INTEREST_RATES[1], COST_OF_CARRY, true); }
/** * */ @Test(expectedExceptions = IllegalArgumentException.class) public void rangeErrorstrikeForDelta2Test() { BlackScholesFormulaRepository.strikeForDelta( SPOT, -100., TIME_TO_EXPIRY, VOLS[1], NAN, COST_OF_CARRY, true); }
/** * */ public void strikeForDeltaRecoveryTest() { int nStrikes = STRIKES_INPUT.length; int nVols = VOLS.length; int nInt = INTEREST_RATES.length; for (int i = 0; i < nStrikes; ++i) { for (int j = 0; j < nVols; ++j) { for (int k = 0; k < nInt; ++k) { double deltaC = BlackScholesFormulaRepository.delta( SPOT, STRIKES_INPUT[i], TIME_TO_EXPIRY, VOLS[j], INTEREST_RATES[k], COST_OF_CARRY, true); double deltaP = BlackScholesFormulaRepository.delta( SPOT, STRIKES_INPUT[i], TIME_TO_EXPIRY, VOLS[j], INTEREST_RATES[k], COST_OF_CARRY, false); double resC = BlackScholesFormulaRepository.strikeForDelta( SPOT, deltaC, TIME_TO_EXPIRY, VOLS[j], INTEREST_RATES[k], COST_OF_CARRY, true); double resP = BlackScholesFormulaRepository.strikeForDelta( SPOT, deltaP, TIME_TO_EXPIRY, VOLS[j], INTEREST_RATES[k], COST_OF_CARRY, false); assertEquals(resC, STRIKES_INPUT[i], STRIKES_INPUT[i] * EPS); assertEquals(resP, STRIKES_INPUT[i], STRIKES_INPUT[i] * EPS); } } } }