Class SwapTradeCalculations
- java.lang.Object
-
- com.opengamma.strata.measure.swap.SwapTradeCalculations
-
public class SwapTradeCalculations extends Object
Calculates pricing and risk measures for swap trades.This provides a high-level entry point for swap pricing and risk measures.
Each method takes a
ResolvedSwapTrade, whereas application code will typically work withSwapTrade. CallSwapTrade::resolve(ReferenceData)to convertSwapTradetoResolvedSwapTrade.
-
-
Field Summary
Fields Modifier and Type Field Description static SwapTradeCalculationsDEFAULTDefault implementation.
-
Constructor Summary
Constructors Constructor Description SwapTradeCalculations(DiscountingSwapTradePricer tradePricer)Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiCurrencyScenarioArrayaccruedInterest(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates accrued interest across one or more scenarios.MultiCurrencyAmountaccruedInterest(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates accrued interest for a single set of market data.ScenarioArray<CashFlows>cashFlows(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates cash flows across one or more scenarios.CashFlowscashFlows(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates cash flows for a single set of market data.MultiCurrencyScenarioArraycurrencyExposure(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates currency exposure across one or more scenarios.MultiCurrencyAmountcurrencyExposure(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates currency exposure for a single set of market data.MultiCurrencyScenarioArraycurrentCash(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates current cash across one or more scenarios.MultiCurrencyAmountcurrentCash(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates current cash for a single set of market data.ScenarioArray<ExplainMap>explainPresentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Explains the present value calculation across one or more scenarios.ExplainMapexplainPresentValue(ResolvedSwapTrade trade, RatesProvider ratesProvider)Explains the present value calculation for a single set of market data.LegAmountslegInitialNotional(ResolvedSwapTrade trade)Calculates the initial notional of each leg.ScenarioArray<LegAmounts>legPresentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates the present value of each leg across one or more scenarios.LegAmountslegPresentValue(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates the present value of each leg for a single set of market data.DoubleScenarioArrayparRate(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates par rate across one or more scenarios.doubleparRate(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates par rate for a single set of market data.DoubleScenarioArrayparSpread(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates par spread across one or more scenarios.doubleparSpread(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates par spread for a single set of market data.MultiCurrencyScenarioArraypresentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates present value across one or more scenarios.MultiCurrencyAmountpresentValue(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates present value for a single set of market data.ScenarioArray<CurrencyParameterSensitivities>pv01CalibratedBucketed(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates present value sensitivity across one or more scenarios.CurrencyParameterSensitivitiespv01CalibratedBucketed(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates present value sensitivity for a single set of market data.MultiCurrencyScenarioArraypv01CalibratedSum(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates present value sensitivity across one or more scenarios.MultiCurrencyAmountpv01CalibratedSum(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates present value sensitivity for a single set of market data.ScenarioArray<CurrencyParameterSensitivities>pv01MarketQuoteBucketed(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates present value sensitivity across one or more scenarios.CurrencyParameterSensitivitiespv01MarketQuoteBucketed(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates present value sensitivity for a single set of market data.MultiCurrencyScenarioArraypv01MarketQuoteSum(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)Calculates present value sensitivity across one or more scenarios.MultiCurrencyAmountpv01MarketQuoteSum(ResolvedSwapTrade trade, RatesProvider ratesProvider)Calculates present value sensitivity for a single set of market data.
-
-
-
Field Detail
-
DEFAULT
public static final SwapTradeCalculations DEFAULT
Default implementation.
-
-
Constructor Detail
-
SwapTradeCalculations
public SwapTradeCalculations(DiscountingSwapTradePricer tradePricer)
Creates an instance.In most cases, applications should use the
DEFAULTinstance.- Parameters:
tradePricer- the pricer forResolvedSwapTrade
-
-
Method Detail
-
presentValue
public MultiCurrencyScenarioArray presentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates present value across one or more scenarios.- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the present value, one entry per scenario
-
presentValue
public MultiCurrencyAmount presentValue(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates present value for a single set of market data.- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the present value
-
explainPresentValue
public ScenarioArray<ExplainMap> explainPresentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Explains the present value calculation across one or more scenarios.This provides a breakdown of how present value was calculated, typically used for debugging and validation.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the present value explanation, one entry per scenario
-
explainPresentValue
public ExplainMap explainPresentValue(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Explains the present value calculation for a single set of market data.This provides a breakdown of how present value was calculated, typically used for debugging and validation.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the present value explanation
-
pv01CalibratedSum
public MultiCurrencyScenarioArray pv01CalibratedSum(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates present value sensitivity across one or more scenarios.This is the sensitivity of present value to a one basis point shift in the calibrated curves. The result is the sum of the sensitivities of all affected curves.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the present value sensitivity, one entry per scenario
-
pv01CalibratedSum
public MultiCurrencyAmount pv01CalibratedSum(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates present value sensitivity for a single set of market data.This is the sensitivity of present value to a one basis point shift in the calibrated curves. The result is the sum of the sensitivities of all affected curves.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the present value sensitivity
-
pv01CalibratedBucketed
public ScenarioArray<CurrencyParameterSensitivities> pv01CalibratedBucketed(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates present value sensitivity across one or more scenarios.This is the sensitivity of present value to a one basis point shift in the calibrated curves. The result is provided for each affected curve and currency, bucketed by curve node.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the present value sensitivity, one entry per scenario
-
pv01CalibratedBucketed
public CurrencyParameterSensitivities pv01CalibratedBucketed(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates present value sensitivity for a single set of market data.This is the sensitivity of present value to a one basis point shift in the calibrated curves. The result is provided for each affected curve and currency, bucketed by curve node.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the present value sensitivity
-
pv01MarketQuoteSum
public MultiCurrencyScenarioArray pv01MarketQuoteSum(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates present value sensitivity across one or more scenarios.This is the sensitivity of present value to a one basis point shift in the market quotes used to calibrate the curves. The result is the sum of the sensitivities of all affected curves.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the present value sensitivity, one entry per scenario
-
pv01MarketQuoteSum
public MultiCurrencyAmount pv01MarketQuoteSum(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates present value sensitivity for a single set of market data.This is the sensitivity of present value to a one basis point shift in the market quotes used to calibrate the curves. The result is the sum of the sensitivities of all affected curves.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the present value sensitivity
-
pv01MarketQuoteBucketed
public ScenarioArray<CurrencyParameterSensitivities> pv01MarketQuoteBucketed(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates present value sensitivity across one or more scenarios.This is the sensitivity of present value to a one basis point shift in the market quotes used to calibrate the curves. The result is provided for each affected curve and currency, bucketed by curve node.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the present value sensitivity, one entry per scenario
-
pv01MarketQuoteBucketed
public CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates present value sensitivity for a single set of market data.This is the sensitivity of present value to a one basis point shift in the market quotes used to calibrate the curves. The result is provided for each affected curve and currency, bucketed by curve node.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the present value sensitivity
-
parRate
public DoubleScenarioArray parRate(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates par rate across one or more scenarios.- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the par rate, one entry per scenario
-
parRate
public double parRate(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates par rate for a single set of market data.- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the par rate
-
parSpread
public DoubleScenarioArray parSpread(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates par spread across one or more scenarios.- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the par spread, one entry per scenario
-
parSpread
public double parSpread(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates par spread for a single set of market data.- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the par spread
-
cashFlows
public ScenarioArray<CashFlows> cashFlows(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates cash flows across one or more scenarios.The cash flows provide details about the payments of the trade.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the cash flows, one entry per scenario
-
cashFlows
public CashFlows cashFlows(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates cash flows for a single set of market data.The cash flows provide details about the payments of the trade.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the cash flows
-
accruedInterest
public MultiCurrencyScenarioArray accruedInterest(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates accrued interest across one or more scenarios.The accrued interest since the last payment.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the accrued interest, one entry per scenario
-
accruedInterest
public MultiCurrencyAmount accruedInterest(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates accrued interest for a single set of market data.The accrued interest since the last payment.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the accrued interest
-
legInitialNotional
public LegAmounts legInitialNotional(ResolvedSwapTrade trade)
Calculates the initial notional of each leg.This does not require market data.
- Parameters:
trade- the trade- Returns:
- the initial notional of each leg
-
legPresentValue
public ScenarioArray<LegAmounts> legPresentValue(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates the present value of each leg across one or more scenarios.- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the present value of each leg, one entry per scenario
-
legPresentValue
public LegAmounts legPresentValue(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates the present value of each leg for a single set of market data.- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the present value of each leg
-
currencyExposure
public MultiCurrencyScenarioArray currencyExposure(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates currency exposure across one or more scenarios.The currency risk, expressed as the equivalent amount in each currency.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the currency exposure, one entry per scenario
-
currencyExposure
public MultiCurrencyAmount currencyExposure(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates currency exposure for a single set of market data.The currency risk, expressed as the equivalent amount in each currency.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the currency exposure
-
currentCash
public MultiCurrencyScenarioArray currentCash(ResolvedSwapTrade trade, RatesMarketDataLookup lookup, ScenarioMarketData marketData)
Calculates current cash across one or more scenarios.The sum of all cash flows paid on the valuation date.
- Parameters:
trade- the tradelookup- the lookup used to query the market datamarketData- the market data- Returns:
- the current cash, one entry per scenario
-
currentCash
public MultiCurrencyAmount currentCash(ResolvedSwapTrade trade, RatesProvider ratesProvider)
Calculates current cash for a single set of market data.The sum of all cash flows paid on the valuation date.
- Parameters:
trade- the traderatesProvider- the market data- Returns:
- the current cash
-
-