Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FxBarrierOption scenario pricing #1412

Open
elewan opened this issue Nov 9, 2016 · 3 comments
Open

FxBarrierOption scenario pricing #1412

elewan opened this issue Nov 9, 2016 · 3 comments

Comments

@elewan
Copy link

elewan commented Nov 9, 2016

In BlackBarrierPriceFormulaRepository there are some conditions on spot vs barrier level relation, namely

ArgChecker.isFalse(isDown && spot <= barrier.getBarrierLevel(), "The Data is not consistent with an alive barrier (DOWN and spot<=barrier).");
ArgChecker.isFalse(!isDown && spot >= barrier.getBarrierLevel(),"The Data is not consistent with an alive barrier (UP and spot>=barrier).");

However, when pricing using scenario framework, I'd like to shift fx spot value, which might lead to shifted spot breaching a barrier (for example resulting in zero value in case of knock out). Instead a get a Failure result, which is unexpected.

@jodastephen
Copy link
Member

For future reference, our primary channel for user questions is our forum.

Are you looking to just remove these two lines of validation?

@elewan
Copy link
Author

elewan commented Nov 15, 2016

If the barrier is Knock-Out than option value is 0, if barrier is Knock-In than option value is equals to value of vanilla option.

These validations should be replaced by following code

    if( (isDown && spot <= barrier.getBarrierLevel()) || (!isDown && spot >= barrier.getBarrierLevel())){
      if(isKnockIn){
        double df1 = Math.exp((costOfCarry-rate)*timeToExpiry);
        double df2 = Math.exp(-rate*timeToExpiry);
        double forward = spot*df1/df2;
        return BlackFormulaRepository.price(forward, strike, timeToExpiry, lognormalVol, isCall);
      }else{
        return 0d;
      }
    }

so that the following additional test in BlackBarrierPriceFormulaRepositoryTest passes

  public void barrierBreached(){
    double newSpot = 120;
    double callUpOut = BARRIER_PRICER.price(
            newSpot, STRIKE_MID, EXPIRY_TIME, COST_OF_CARRY, RATE_DOM, VOLATILITY, true, BARRIER_UP_OUT);
    assertEquals(callUpOut, 0d);

    double newForward = newSpot * DF_FOR / DF_DOM;
    double callUpIn = BARRIER_PRICER.price(
            newSpot, STRIKE_MID, EXPIRY_TIME, COST_OF_CARRY, RATE_DOM, VOLATILITY, true, BARRIER_UP_IN);
    double callVanilla = BlackFormulaRepository.price(newForward, STRIKE_MID, EXPIRY_TIME, VOLATILITY, true) ;
    assertEquals(callUpIn, callVanilla);
  }

@yukiiwashita
Copy link
Contributor

yukiiwashita commented Jan 16, 2017

The equivalent handling can be implemented in BlackFxSingleBarrierOptionProductPricer keeping the formula repositories purely mathematics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants