throw new OpenGammaRuntimeException("Can only handle interest rate notionals with the same amounts");
}
@Override
public CurrencyAmount visitFXOptionSecurity(final FXOptionSecurity security) {
final Currency currency1 = security.getPutCurrency();
final double amount1 = security.getPutAmount();
final Currency currency2 = security.getCallCurrency();
final double amount2 = security.getCallAmount();
final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
if (currencyPair.getBase().equals(currency1)) {
return CurrencyAmount.of(currency1, amount1);
}
return CurrencyAmount.of(currency2, amount2);
}
@Override
public CurrencyAmount visitFXBarrierOptionSecurity(final FXBarrierOptionSecurity security) {
final Currency currency1 = security.getPutCurrency();
final double amount1 = security.getPutAmount();
final Currency currency2 = security.getCallCurrency();
final double amount2 = security.getCallAmount();
final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
if (currencyPair.getBase().equals(currency1)) {
return CurrencyAmount.of(currency1, amount1);
}
return CurrencyAmount.of(currency2, amount2);
}
@Override
public CurrencyAmount visitNonDeliverableFXOptionSecurity(final NonDeliverableFXOptionSecurity security) {
final Currency currency = security.getDeliveryCurrency();
final double amount = security.getCallCurrency().equals(currency) ? security.getCallAmount() : security.getPutAmount();
return CurrencyAmount.of(currency, amount);
}
@Override
public CurrencyAmount visitFXDigitalOptionSecurity(final FXDigitalOptionSecurity security) {
final Currency currency1 = security.getPutCurrency();
final double amount1 = security.getPutAmount();
final Currency currency2 = security.getCallCurrency();
final double amount2 = security.getCallAmount();
final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
if (currencyPair.getBase().equals(currency1)) {
return CurrencyAmount.of(currency1, amount1);
}
return CurrencyAmount.of(currency2, amount2);
}
@Override
public CurrencyAmount visitNonDeliverableFXDigitalOptionSecurity(final NonDeliverableFXDigitalOptionSecurity security) {
final Currency currency = security.getPaymentCurrency();
final double amount = security.getCallCurrency().equals(currency) ? security.getCallAmount() : security.getPutAmount();
return CurrencyAmount.of(currency, amount);
}
@Override
public CurrencyAmount visitFXForwardSecurity(final FXForwardSecurity security) {
final Currency currency1 = security.getPayCurrency();
final double amount1 = security.getPayAmount();
final Currency currency2 = security.getReceiveCurrency();
final double amount2 = security.getReceiveAmount();
final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
if (currencyPair.getBase().equals(currency1)) {
return CurrencyAmount.of(currency1, amount1);
}
return CurrencyAmount.of(currency2, amount2);
}
@Override
public CurrencyAmount visitStandardVanillaCDSSecurity(final StandardVanillaCDSSecurity security) {
final InterestRateNotional notional = security.getNotional();
final int sign = security.isBuy() ? 1 : -1;
return CurrencyAmount.of(notional.getCurrency(), sign * notional.getAmount());
}
@Override
public CurrencyAmount visitLegacyVanillaCDSSecurity(final LegacyVanillaCDSSecurity security) {
final InterestRateNotional notional = security.getNotional();
final int sign = security.isBuy() ? 1 : -1;
return CurrencyAmount.of(notional.getCurrency(), sign * notional.getAmount());
}
@Override
public CurrencyAmount visitGovernmentBondSecurity(final GovernmentBondSecurity security) {
final Currency currency = security.getCurrency();
final double notional = security.getMinimumAmount();
return CurrencyAmount.of(currency, notional);
}
@Override
public CurrencyAmount visitCorporateBondSecurity(final CorporateBondSecurity security) {
final Currency currency = security.getCurrency();
final double notional = security.getMinimumAmount();
return CurrencyAmount.of(currency, notional);
}
@Override
public CurrencyAmount visitMunicipalBondSecurity(final MunicipalBondSecurity security) {
final Currency currency = security.getCurrency();
final double notional = security.getMinimumAmount();
return CurrencyAmount.of(currency, notional);
}
@Override
public CurrencyAmount visitSwaptionSecurity(final SwaptionSecurity security) {
final Security underlying = securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId()));
Preconditions.checkState(underlying instanceof SwapSecurity, "Failed to resolve underlying SwapSecurity. DB record potentially corrupted. '%s' returned.", underlying);
return visitSwapSecurity((SwapSecurity) underlying);
}
@Override
public CurrencyAmount visitEquityIndexOptionSecurity(final EquityIndexOptionSecurity security) {
final Currency currency = security.getCurrency();
final double notional = security.getPointValue();
return CurrencyAmount.of(currency, notional);
}
@Override
public CurrencyAmount visitInterestRateFutureSecurity(final InterestRateFutureSecurity security) {
final Currency currency = security.getCurrency();
final double notional = security.getUnitAmount();
return CurrencyAmount.of(currency, notional);
}
@Override
public CurrencyAmount visitFederalFundsFutureSecurity(final FederalFundsFutureSecurity security) {
final Currency currency = security.getCurrency();
final double notional = security.getUnitAmount();
return CurrencyAmount.of(currency, notional);
}
@Override
public CurrencyAmount visitCreditDefaultSwapIndexSecurity(final CreditDefaultSwapIndexSecurity security) {
final InterestRateNotional notional = security.getNotional();
return CurrencyAmount.of(notional.getCurrency(), notional.getAmount());
}
@Override
public CurrencyAmount visitCreditDefaultSwapOptionSecurity(final CreditDefaultSwapOptionSecurity security) {
final Currency currency = security.getCurrency();
final double notional = security.getNotional();
return CurrencyAmount.of(currency, notional);
}
});
return notional;