Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
ore::data Namespace Reference

Namespaces

namespace  os
 

Classes

class  AbsoluteStrike
 
class  AbstractReferenceDatumBuilder
 
class  AbstractTradeBuilder
 TradeBuilder base class. More...
 
class  AccrualBondRepoEngineBuilder
 Accrual Bond Repo Engine Builder. More...
 
class  Accumulator
 
class  AdjustedInMemoryLoader
 An Adjusted In Memory Loader,. More...
 
class  AdjustmentFactors
 Class to hold market data adjustment factors - for example equity stock splits. More...
 
class  AmcModel
 
class  AmericanOptionBAWEngineBuilder
 Abstract Engine Builder for American Vanilla Options using Barone Adesi Whaley Approximation. More...
 
class  AmericanOptionEngineBuilder
 Abstract Engine Builder for American Vanilla Options. More...
 
class  AmericanOptionFDEngineBuilder
 Abstract Engine Builder for American Vanilla Options using Finite Difference Method. More...
 
class  AmericanOptionWrapper
 American Option Wrapper. More...
 
class  AmortizationData
 Serializable object holding amortization rules. More...
 
class  AnalyticBlackRiskParticipationAgreementEngine
 
class  AnalyticHaganCmsCouponPricerBuilder
 
class  AnalyticXCcyBlackRiskParticipationAgreementEngine
 
class  Ascot
 Serializable Convertible Bond. More...
 
class  AscotEngineBuilder
 
class  AscotIntrinsicEngineBuilder
 
class  AsianOption
 Serializable Asian Option. More...
 
class  AsianOptionEngineBuilder
 Abstract Engine Builder for Asian Options. More...
 
class  AsianOptionScriptedEngineBuilder
 
struct  AssetPositionTrsUnderlyingBuilder
 
struct  AssignmentNode
 
struct  ASTNode
 
struct  ASTNodeAnnotation
 
class  AtmStrike
 
class  Autocallable_01
 
class  AverageOisConvention
 Container for storing Average OIS conventions. More...
 
class  AverageOISYieldCurveSegment
 Average OIS yield curve segment. More...
 
class  BalanceGuaranteedSwap
 Serializable Balance Guaranteed Swap. More...
 
class  BalanceGuaranteedSwapDiscountingEngineBuilder
 Balance Guaranteed Swap Discounting Engine Builder. More...
 
class  BalanceGuaranteedSwapFlexiSwapLGMGridEngineBuilder
 Balance Guaranteed Swap Flexi Swap LGM Grid Engine Builder. More...
 
class  BarrierData
 Serializable obejct holding barrier data. More...
 
class  BarrierOption
 Serializable FX Barrier Option. More...
 
class  BarrierOptionWrapper
 Barrier Option Wrapper. More...
 
class  BaseCorrelationCurve
 
class  BaseCorrelationCurveConfig
 Base Correlation term structure configuration. More...
 
class  BaseCorrelationCurveSpec
 Base Correlation surface description. More...
 
class  BaseCorrelationQuote
 Base correlation data class. More...
 
class  BaseStrike
 
class  BasicReferenceDataManager
 Basic Concrete impl that loads an big XML and keeps data in memory. More...
 
class  BasicUnderlying
 
class  BasisSwapQuote
 Basis Swap data class. More...
 
class  BasketConstituent
 
class  BasketData
 
class  BasketOption
 
class  BasketVarianceSwap
 
class  BermudanOptionWrapper
 Bermudan Option Wrapper. More...
 
class  BestEntryOption
 
class  BGSTrancheData
 Serializable Tranche for use in Balance Guaranteed Swaps. More...
 
class  BlackCdsOptionEngineBuilder
 Black CDS option engine builder for CDS options. More...
 
class  BlackIndexCdsOptionEngineBuilder
 Black CDS option engine builder for index CDS options. More...
 
class  BlackScholes
 
class  BlackScholesBase
 
class  BlackScholesCG
 
class  BlackScholesCGBase
 
class  BlackScholesModelBuilder
 
class  BlackScholesModelBuilderBase
 
class  BMABasisSwapConvention
 Container for storing Libor-BMA Basis Swap conventions. More...
 
class  BMASwapQuote
 BMA Swap data class. More...
 
class  Bond
 Serializable Bond. More...
 
class  BondBasket
 Serializable Bond-Basket Data. More...
 
class  BondBasketReferenceDatum
 Bond Basket Reference Data. More...
 
struct  BondBuilder
 Bond Factory that builds bonds from reference data. More...
 
class  BondData
 
class  BondDiscountingEngineBuilder
 Discounting Engine Builder class for Bonds. More...
 
class  BondEngineBuilder
 Engine Builder base class for Bonds. More...
 
class  BondFactory
 
class  BondIndexBuilder
 
class  BondMultiStateDiscountingEngineBuilder
 Multi State Engine Builder class for Bonds. More...
 
class  BondOption
 Serializable Bond Option. More...
 
class  BondOptionEngineBuilder
 Engine builder for bond option. More...
 
class  BondOptionQuote
 Bond option data class. More...
 
class  BondOptionShiftQuote
 Shift data class (for SLN bond option volatilities) More...
 
class  BondPosition
 
class  BondPositionData
 
class  BondPositionInstrumentWrapper
 Equity Position instrument wrapper. More...
 
struct  BondPositionTrsUnderlyingBuilder
 
class  BondPriceQuote
 Bond Price Quote. More...
 
class  BondReferenceDatum
 
class  BondRepo
 
class  BondRepoEngineBuilderBase
 Bond Repo engine builder base class. More...
 
class  BondSpreadImply
 
class  BondSpreadImplyMarket
 
class  BondTRS
 
class  BondTRSEngineBuilder
 
struct  BondTrsUnderlyingBuilder
 
class  BondUnderlying
 
class  BondYieldConvention
 
class  BondYieldShiftedYieldCurveSegment
 Bond yield shifted yield curve segment. More...
 
class  BootstrapConfig
 
class  BufferLogger
 BufferLogger. More...
 
class  CachingEngineBuilder
 Abstract template EngineBuilder class that can cache engines and coupon pricers. More...
 
class  CachingOptionEngineBuilder
 
class  CalendarAdjustmentConfig
 
class  CalendarParser
 
class  CalibrationBasket
 
class  CalibrationConfiguration
 
class  CalibrationInstrument
 
class  CalibrationInstrumentFactory
 
class  CalibrationPointCache
 
class  CallableSwap
 Serializable Swaption. More...
 
class  CamAmcCurrencySwapEngineBuilder
 Multileg option engine builder for external cam, with additional simulation dates (AMC) More...
 
class  CamAmcFxForwardEngineBuilder
 FX forward engine builder for external cam, with additional simulation dates (AMC) More...
 
class  CamAmcFxOptionEngineBuilder
 FX option engine builder for external cam, with additional simulation dates (AMC) More...
 
class  CamAmcMultiLegOptionEngineBuilder
 Multileg option engine builder for external cam, with additional simulation dates (AMC) More...
 
class  CamAmcSwapEngineBuilder
 Implementation of SwapEngineBuilderBase using MC pricer for external cam / AMC. More...
 
class  CamMcMultiLegOptionEngineBuilder
 MultiLeg option engine builder for MC pricer. More...
 
class  CapFloor
 Serializable cap, floor, collar. More...
 
class  CapFlooredAverageBMACouponLegEngineBuilder
 CouponPricer Builder for CapFlooredAVerageBMACouponLeg. More...
 
class  CapFlooredAverageONIndexedCouponLegEngineBuilder
 CouponPricer Builder for CapFlooredOvernightIndexedCouponLeg. More...
 
class  CapFlooredCpiLegCashFlowEngineBuilder
 
class  CapFlooredCpiLegCouponEngineBuilder
 CouponPricer Builder for Capped/Floored CPI Inflation Leg. More...
 
class  CapFlooredIborLegEngineBuilder
 CouponPricer Builder for CapFlooredIborLeg. More...
 
class  CapFlooredNonStandardYoYLegEngineBuilder
 CouponPricer Builder for Capped/Floored YoY Inflation Leg. More...
 
class  CapFlooredOvernightIndexedCouponLegEngineBuilder
 CouponPricer Builder for CapFlooredOvernightIndexedCouponLeg. More...
 
class  CapFlooredYoYLegEngineBuilder
 CouponPricer Builder for Capped/Floored YoY Inflation Leg. More...
 
class  CapFloorEngineBuilder
 Engine Builder for Caps, Floors and Collars on an IborIndex. More...
 
class  CapFloorQuote
 Cap/Floor data class. More...
 
class  CapFloorShiftQuote
 Shift data class (for SLN cap/floor volatilities) More...
 
class  CapFloorVolatilityCurveConfig
 
class  CapFloorVolatilityCurveSpec
 Cap/Floor Volatility curve description. More...
 
class  CapFloorVolCurve
 
class  CashflowData
 Serializable Cashflow Leg Data. More...
 
class  CashflowLegBuilder
 
class  CBO
 
class  CboMCEngineBuilder
 
class  CboReferenceDatum
 
struct  CBOTrsUnderlyingBuilder
 
class  CdoEngineBuilder
 
class  CdsConvention
 Container for storing Credit Default Swap quote conventions. More...
 
class  CDSEngineKey
 
class  CDSProxyVolatilityConfig
 
class  CdsQuote
 
class  CdsReferenceInformation
 
class  CDSVolatilityCurveConfig
 
class  CDSVolatilityCurveSpec
 CDS Volatility curve description. More...
 
class  CDSVolCurve
 
class  CFD
 
class  CliquetOption
 Serializable Equity Cliquet Option. More...
 
class  CliquetOptionEngineBuilder
 Engine builder for Cliquet Options. More...
 
class  CliquetOptionMcScriptEngine
 
class  ClonedLoader
 
class  CMBLegBuilder
 
class  CMBLegData
 Serializable Constant Maturity Bond Yield Leg Data. More...
 
class  CmsCouponPricerBuilder
 CouponPricer Builder for CmsLeg. More...
 
class  CMSLegBuilder
 
class  CMSLegData
 Serializable CMS Leg Data. More...
 
class  CmsSpreadCouponPricerBuilder
 CouponPricer Builder for CmsSpreadLeg. More...
 
class  CMSSpreadLegBuilder
 
class  CMSSpreadLegData
 Serializable CMS Spread Leg Data. More...
 
class  CmsSpreadOptionConvention
 Container for storing CMS Spread Option conventions. More...
 
class  CollateralBalance
 
class  CollateralBalances
 Collateral Balances. More...
 
class  CommodityAccumulator
 
class  CommodityAmericanOptionBAWEngineBuilder
 
class  CommodityAmericanOptionFDEngineBuilder
 
class  CommodityApoAnalyticalEngineBuilder
 Analytical Engine builder for Commodity Average Price Options. More...
 
class  CommodityApoBaseEngineBuilder
 Engine builder base class for Commodity Average Price Options. More...
 
class  CommodityApoModelBuilder
 
class  CommodityApoMonteCarloEngineBuilder
 Monte Carlo Engine builder for Commodity Average Price Options. More...
 
class  CommodityAsianOption
 
class  CommodityAveragePriceOption
 
class  CommodityBasketOption
 
class  CommodityBasketVarianceSwap
 
class  CommodityBestEntryOption
 
class  CommodityCurve
 
struct  CommodityCurveCalibrationInfo
 
class  CommodityCurveConfig
 Commodity curve configuration. More...
 
class  CommodityCurveSpec
 Commodity curve description. More...
 
class  CommodityDigitalAveragePriceOption
 
class  CommodityDigitalOption
 Commodity digital option trade representation as call spread. More...
 
class  CommodityEuropeanAsianOptionACGAPEngineBuilder
 Continuous Analytic Engine Builder for European Asian Commodity Geometric Average Price Options. More...
 
class  CommodityEuropeanAsianOptionADGAPEngineBuilder
 Discrete Analytic Engine Builder for European Asian Commodity Geometric Average Price Options. More...
 
class  CommodityEuropeanAsianOptionADGASEngineBuilder
 Discrete Analytic Engine Builder for European Asian Commodity Geometric Average Strike Options. More...
 
class  CommodityEuropeanAsianOptionMCDAAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Commodity Arithmetic Average Price Options. More...
 
class  CommodityEuropeanAsianOptionMCDAASEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Commodity Arithmetic Average Strike Options. More...
 
class  CommodityEuropeanAsianOptionMCDGAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Commodity Geometric Average Price Options. More...
 
class  CommodityEuropeanAsianOptionTWEngineBuilder
 Discrete Analytic TW Engine Builder for European Asian Commodity Arithmetic Average Price Options. More...
 
class  CommodityEuropeanCSOptionEngineBuilder
 
class  CommodityEuropeanForwardOptionEngineBuilder
 
class  CommodityEuropeanOptionEngineBuilder
 
class  CommodityFixedLegBuilder
 
class  CommodityFixedLegData
 
class  CommodityFloatingLegBuilder
 
class  CommodityFloatingLegData
 
class  CommodityForward
 
class  CommodityForwardConvention
 
class  CommodityForwardEngineBuilder
 Engine builder for commodity forward. More...
 
class  CommodityForwardQuote
 Commodity forward quote class. More...
 
class  CommodityFutureConvention
 
class  CommodityGenericBarrierOption
 
class  CommodityIndexReferenceDatum
 EquityIndex Reference data, contains the names and weights of an equity index. More...
 
class  CommodityOption
 Commodity option trade representation. More...
 
class  CommodityOptionQuote
 Commodity option data class. More...
 
class  CommodityOptionStrip
 
class  CommodityPosition
 Serializable Commodity Position. More...
 
class  CommodityPositionData
 Serializable Commodity Position Data. More...
 
class  CommodityPositionInstrumentWrapper
 Commodity Position instrument wrapper. More...
 
class  CommodityPositionInstrumentWrapperEngine
 
class  CommodityRainbowOption
 
class  CommoditySchwartzData
 COM Schwartz Model Parameters. More...
 
class  CommoditySchwartzModelBuilder
 Builder for a COM model component. More...
 
class  CommoditySpotQuote
 Commodity spot quote class. More...
 
class  CommoditySpreadOption
 
class  CommoditySpreadOptionBaseEngineBuilder
 Base Engine builder for Commodity Spread Options. More...
 
class  CommoditySpreadOptionData
 
class  CommoditySpreadOptionEngineBuilder
 Analytical Engine builder for Commodity Spread Options. More...
 
class  CommoditySwap
 
class  CommoditySwapEngineBuilder
 Engine builder for Commodity Swaps. More...
 
class  CommoditySwaption
 
class  CommoditySwaptionAnalyticalEngineBuilder
 Analytical Approximation Engine builder for Commodity Swaptions. More...
 
class  CommoditySwaptionEngineBuilder
 Engine builder for Commodity Swaptions. More...
 
class  CommoditySwaptionMonteCarloEngineBuilder
 Monte Carlo Engine builder for Commodity Swaptions. More...
 
class  CommodityTaRF
 
class  CommodityUnderlying
 
class  CommodityVolatilityConfig
 Commodity volatility configuration. More...
 
class  CommodityVolatilityCurveSpec
 Commodity volatility description. More...
 
class  CommodityVolCurve
 Wrapper class for building commodity volatility structures. More...
 
class  CommodityWindowBarrierOption
 
class  CommodityWorstOfBasketSwap
 
class  CompositeInstrumentWrapper
 Composite Instrument Wrapper. More...
 
class  CompositeLoader
 
class  CompositeTrade
 Composite Trade class. More...
 
class  ComputationGraphBuilder
 
class  ComVarSwap
 
struct  ConditionAndNode
 
struct  ConditionEqNode
 
struct  ConditionGeqNode
 
struct  ConditionGtNode
 
struct  ConditionLeqNode
 
struct  ConditionLtNode
 
struct  ConditionNeqNode
 
struct  ConditionNotNode
 
struct  ConditionOrNode
 
class  ConsoleLog
 Singleton to control console logging. More...
 
struct  ConstantNumberNode
 
class  ConstantVolatilityConfig
 
struct  Context
 
class  Convention
 Abstract base class for convention objects. More...
 
class  Conventions
 Repository for currency dependent market conventions. More...
 
class  ConventionsBasedFutureExpiry
 Perform date calculations for future contracts based on conventions. More...
 
class  ConvertibleBond
 Serializable Convertible Bond. More...
 
struct  ConvertibleBondBuilder
 
class  ConvertibleBondData
 
class  ConvertibleBondEngineBuilder
 
class  ConvertibleBondFDDefaultableEquityJumpDiffusionEngineBuilder
 
class  ConvertibleBondReferenceDatum
 Convertible Bond Reference data. More...
 
struct  ConvertibleBondTrsUnderlyingBuilder
 
class  CorrelationCurve
 Wrapper class for building correlation structures. More...
 
class  CorrelationCurveConfig
 Correlation curve configuration. More...
 
class  CorrelationCurveSpec
 Correlation curve description. More...
 
struct  CorrelationFactor
 
class  CorrelationMatrixBuilder
 
class  CorrelationQuote
 Spread data class. More...
 
class  CpiCapFloor
 
class  CpiCapFloorEngineBuilder
 Engine Builder for CPI Caps, Floors and Collars. More...
 
class  CPILegBuilder
 
class  CPILegData
 Serializable CPI Leg Data. More...
 
class  CPRQuote
 CPR data class. More...
 
class  CrCirBuilder
 Builder for a cir model component. More...
 
class  CrCirData
 
class  CreditDefaultSwap
 
class  CreditDefaultSwapData
 
class  CreditDefaultSwapEngineBuilder
 Engine builder base class for credit default swaps. More...
 
class  CreditDefaultSwapOption
 
class  CreditDefaultSwapOptionEngineBuilder
 Engine Builder base class for Credit Default Swap Options. More...
 
class  CreditIndexConstituent
 
class  CreditIndexReferenceDatum
 Credit index reference data, contains a set of index constituents. More...
 
class  CreditLinkedSwap
 
class  CreditLinkedSwapEngineBuilder
 
class  CreditReferenceDatum
 CreditIndex Reference data, contains the names and weights of a credit index. More...
 
class  CreditUnderlying
 
class  CrLgmBuilder
 
class  CrLgmData
 CR LGM Model Parameters. More...
 
class  CrossAssetModelBuilder
 Cross Asset Model Builder. More...
 
class  CrossAssetModelData
 Cross Asset Model Parameters. More...
 
class  CrossCcyBasisSwapConvention
 Container for storing Cross Currency Basis Swap quote conventions. More...
 
class  CrossCcyBasisSwapQuote
 Cross Currency Basis Swap data class. More...
 
class  CrossCcyFixFloatSwapConvention
 
class  CrossCcyFixFloatSwapQuote
 Cross Currency Fix Float Swap quote holder. More...
 
class  CrossCcyYieldCurveSegment
 Cross Currency yield curve segment. More...
 
class  CrossCurrencySwap
 Serializable Cross Currency Swap contract. More...
 
class  CrossCurrencySwapEngineBuilder
 Discounted Cashflows Engine Builder for Cross Currency Swaps. More...
 
class  CrossCurrencySwapEngineBuilderBase
 Engine Builder base class for Cross Currency Swaps. More...
 
class  CSA
 
class  CSVBufferReader
 
class  CSVFileReader
 
class  CSVFileReport
 
class  CSVLoader
 Utility class for loading market quotes and fixings from a file. More...
 
class  CSVReader
 
class  CurrencyConfig
 Currency configuration. More...
 
class  CurrencyHedgedEquityIndexDecomposition
 
class  CurrencyHedgedEquityIndexReferenceDatum
 
class  CurrencyParser
 
class  CurrencySwapEngineBuilderDeltaGamma
 Engine Builder for Cross Currency Swaps. More...
 
struct  CurrencyVec
 
class  CurveConfig
 Base curve configuration. More...
 
class  CurveConfigurations
 Container class for all Curve Configurations. More...
 
class  CurveConfigurationsManager
 
class  CurveSpec
 Curve Specification. More...
 
class  DateGrid
 Simulation Date Grid. More...
 
struct  DaycounterVec
 
struct  DeclarationNumberNode
 
class  DefaultCurve
 Wrapper class for building Swaption volatility structures. More...
 
class  DefaultCurveConfig
 Default curve configuration. More...
 
class  DefaultCurveSpec
 Default curve description. More...
 
class  DelegatingEngineBuilder
 Delegating Engine Builder. More...
 
class  DeltaStrike
 
class  DeltaString
 Utility class for handling delta strings ATM, 10P, 25C, ... used e.g. for FX Surfaces. More...
 
class  DependencyGraph
 
class  DepositConvention
 Container for storing Deposit conventions. More...
 
struct  DerivativeTrsUnderlyingBuilder
 
class  DigitalCMSLegBuilder
 
class  DigitalCMSLegData
 Serializable Digital CMS Leg Data. More...
 
class  DigitalCMSSpreadLegBuilder
 
class  DigitalCMSSpreadLegData
 Serializable Digital CMS Spread Leg Data. More...
 
class  DirectYieldCurveSegment
 Direct yield curve segment. More...
 
class  DiscountingBondRepoEngineBuilder
 Discounting Bond Repo Engine Builder. More...
 
class  DiscountingBondTRSEngineBuilder
 
class  DiscountingForwardBondEngineBuilder
 
class  DiscountQuote
 Discount market data class. More...
 
class  DiscountRatioYieldCurveSegment
 Discount ratio yield curve segment. More...
 
class  DoubleBarrierOptionWrapper
 
class  DoubleDigitalOption
 
class  DummyModel
 
class  DurationAdjustedCmsCouponPricerBuilder
 
class  DurationAdjustedCmsLegBuilder
 
class  DurationAdjustedCmsLegData
 
class  EngineBuilder
 Base PricingEngine Builder class for a specific model and engine. More...
 
class  EngineBuilderFactory
 Engine/ Leg Builder Factory - notice that both engine and leg builders are allowed to maintain a state. More...
 
class  EngineData
 Pricing engine description. More...
 
class  EngineFactory
 Pricing Engine Factory class. More...
 
class  Envelope
 Serializable object holding generic trade data, reporting dimensions. More...
 
class  EqBsBuilder
 Builder for a Lognormal EQ model component. More...
 
class  EqBsData
 EQ Model Parameters. More...
 
class  EqPairwiseVarSwap
 
class  EquityAccumulator
 
class  EquityAmericanOptionBAWEngineBuilder
 Engine Builder for American Equity Options using Barone Adesi Whaley Approximation. More...
 
class  EquityAmericanOptionFDEngineBuilder
 Engine Builder for American Equity Options using Finite Difference Method. More...
 
class  EquityAsianOption
 
class  EquityBarrierOption
 Serializable EQ Barrier Option. More...
 
class  EquityBarrierOptionAnalyticEngineBuilder
 
class  EquityBarrierOptionEngineBuilder
 Engine Builder for Equity Barrier Options. More...
 
class  EquityBarrierOptionFDEngineBuilder
 
class  EquityBasketOption
 
class  EquityBasketVarianceSwap
 
class  EquityBestEntryOption
 
class  EquityCliquetOption
 
class  EquityCliquetOptionEngineBuilder
 Engine Builder for Equity Cliquet Options. More...
 
class  EquityCliquetOptionMcScriptEngineBuilder
 
class  EquityCurve
 Wrapper class for building Equity curves (spot quote, yield term structure, risk free IR term structure) More...
 
class  EquityCurveConfig
 Equity curve configuration. More...
 
class  EquityCurveSpec
 Equity curve description. More...
 
class  EquityDerivative
 Base class for all Equity Derivaties. More...
 
class  EquityDigitalOption
 Serializable EQ Digital Option. More...
 
class  EquityDigitalOptionEngineBuilder
 Engine Builder for European EQ Digital Options. More...
 
class  EquityDividendYieldQuote
 Equity/Index Dividend yield data class. More...
 
class  EquityDoubleBarrierOption
 Serializable Equity Double Barrier Option. More...
 
class  EquityDoubleBarrierOptionAnalyticEngineBuilder
 
class  EquityDoubleBarrierOptionEngineBuilder
 Engine Builder for Equity Double Barrier Options. More...
 
class  EquityDoubleTouchOption
 SerializableEQ Double One-Touch/No-Touch Option. More...
 
class  EquityDoubleTouchOptionAnalyticEngineBuilder
 Analytical Engine Builder for EQ Double Touch Options. More...
 
class  EquityDoubleTouchOptionEngineBuilder
 Abstract Engine Builder for EQ Double Touch Options. More...
 
class  EquityEuropeanAsianOptionACGAPEngineBuilder
 Continuous Analytic Engine Builder for European Asian Equity Geometric Average Price Options. More...
 
class  EquityEuropeanAsianOptionADGAPEngineBuilder
 Discrete Analytic Engine Builder for European Asian Equity Geometric Average Price Options. More...
 
class  EquityEuropeanAsianOptionADGASEngineBuilder
 Discrete Analytic Engine Builder for European Asian Equity Geometric Average Strike Options. More...
 
class  EquityEuropeanAsianOptionMCDAAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Equity Arithmetic Average Price Options. More...
 
class  EquityEuropeanAsianOptionMCDAASEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Equity Arithmetic Average Strike Options. More...
 
class  EquityEuropeanAsianOptionMCDGAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Equity Geometric Average Price Options. More...
 
class  EquityEuropeanAsianOptionTWEngineBuilder
 Discrete Analytic TW Engine Builder for European Asian Equity Arithmetic Average Price Options. More...
 
class  EquityEuropeanBarrierOption
 Serializable EQ European Barrier Option. More...
 
class  EquityEuropeanCompositeEngineBuilder
 Engine Builder for Composite European Equity Options. More...
 
class  EquityEuropeanCSOptionEngineBuilder
 
class  EquityEuropeanOptionEngineBuilder
 Engine Builder for European Equity Option Options. More...
 
class  EquityEuropeanOptionEngineBuilderDeltaGamma
 Engine Builder for European Equity Options with analytical sensitivities. More...
 
class  EquityForward
 Serializable Equity Forward contract. More...
 
class  EquityForwardEngineBuilder
 Engine Builder for European Equity Forwards. More...
 
class  EquityForwardQuote
 Equity forward data class. More...
 
class  EquityFutureEuropeanOptionEngineBuilder
 
class  EquityFutureOption
 Serializable EQ Futures Option. More...
 
class  EquityGenericBarrierOption
 
class  EquityIndexReferenceDatum
 EquityIndex Reference data, contains the names and weights of an equity index. More...
 
class  EquityLegBuilder
 
class  EquityLegData
 Serializable Fixed Leg Data. More...
 
class  EquityMarginLegBuilder
 
class  EquityMarginLegData
 Serializable Equity Margin Leg Data. More...
 
class  EquityOption
 Serializable Equity Option. More...
 
class  EquityOptionPosition
 Serializable Equity Option Position. More...
 
class  EquityOptionPositionData
 Serializable Equity Option Position Data. More...
 
class  EquityOptionPositionInstrumentWrapper
 Equity Option Position instrument wrapper. More...
 
class  EquityOptionPositionInstrumentWrapperEngine
 
struct  EquityOptionPositionTrsUnderlyingBuilder
 
class  EquityOptionQuote
 Equity/Index Option data class. More...
 
class  EquityOptionUnderlyingData
 Serializable Equity Option Underlying Data, this represents one underlying in EquityOptionPositionData. More...
 
class  EquityOptionWithBarrier
 
class  EquityOutperformanceOption
 Serializable EQ Outperformance Option. More...
 
class  EquityOutperformanceOptionEngineBuilder
 Engine Builder for EQ Outperformance Option. More...
 
class  EquityPosition
 Serializable Equity Position. More...
 
class  EquityPositionData
 Serializable Equity Position Data. More...
 
class  EquityPositionInstrumentWrapper
 Equity Position instrument wrapper. More...
 
class  EquityPositionInstrumentWrapperEngine
 
class  EquityRainbowOption
 
class  EquityReferenceDatum
 Equity Reference data. More...
 
class  EquitySingleAssetDerivative
 Base class for all single asset Equity Derivaties. More...
 
class  EquitySpotQuote
 Equity/Index spot price data class. More...
 
class  EquitySwap
 Serializable Equity Swap contract. More...
 
class  EquityTaRF
 
class  EquityTouchOption
 Serializable EQ One-Touch/No-Touch Option. More...
 
class  EquityTouchOptionEngineBuilder
 Engine Builder for EQ Touch Options. More...
 
class  EquityUnderlying
 
class  EquityVolatilityCurveConfig
 Equity volatility structure configuration. More...
 
class  EquityVolatilityCurveSpec
 Equity Volatility curve description. More...
 
class  EquityVolCurve
 Wrapper class for building Equity volatility structures. More...
 
class  EquityWindowBarrierOption
 
class  EquityWorstOfBasketSwap
 
class  EqVarSwap
 
class  EuropeanAsianOptionACGAPEngineBuilder
 Continuous Analytic Engine Builder for European Asian Geometric Average Price Options. More...
 
class  EuropeanAsianOptionADGAPEngineBuilder
 Discrete Analytic Engine Builder for European Asian Geometric Average Price Options. More...
 
class  EuropeanAsianOptionADGASEngineBuilder
 Discrete Analytic Engine Builder for European Asian Geometric Average Strike Options. More...
 
class  EuropeanAsianOptionMCDAAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Arithmetic Average Price Options. More...
 
class  EuropeanAsianOptionMCDAASEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Arithmetic Average Strike Options. More...
 
class  EuropeanAsianOptionMCDGAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Geometric Average Price Options. More...
 
class  EuropeanAsianOptionTWEngineBuilder
 Discrete Analytic TW Engine Builder for European Asian Arithmetic Average Price Options. More...
 
class  EuropeanCSOptionEngineBuilder
 
class  EuropeanForwardOptionEngineBuilder
 Abstract Engine Builder for European Vanilla Forward Options. More...
 
class  EuropeanOptionBarrier
 
class  EuropeanOptionEngineBuilder
 Abstract Engine Builder for European Vanilla Options. More...
 
class  EuropeanOptionEngineBuilderDeltaGamma
 Engine Builder for European Options with delta/gamma extension. More...
 
class  EuropeanOptionWrapper
 European Option Wrapper. More...
 
class  EuropeanSwaptionEngineBuilder
 European Swaption Engine Builder. More...
 
class  EventLogger
 EventLogger. More...
 
class  EventMessage
 
struct  EventVec
 
class  ExerciseBuilder
 
class  Expiry
 
class  ExpiryDate
 
class  ExpiryPeriod
 
class  FailedTrade
 
class  FdBlackScholesBase
 
class  FdGaussianCam
 
class  FileIO
 
class  FileLogger
 FileLogger. More...
 
struct  FittedBondCurveCalibrationInfo
 
class  FittedBondCurveHelperMarket
 
class  FittedBondYieldCurveSegment
 FittedBond yield curve segment. More...
 
class  FixedLegBuilder
 
class  FixedLegData
 Serializable Fixed Leg Data. More...
 
struct  Fixing
 Fixing data structure. More...
 
class  FixingDateGetter
 
class  FlexiSwap
 Serializable Flexi-Swap. More...
 
class  FlexiSwapBGSDiscountingEngineBuilderBase
 Flexi Swap / BGS Discounting Engine Builder. More...
 
class  FlexiSwapBGSEngineBuilderBase
 Flexi Swap / BGS Engine Builder Base Class (id2 is used for BGS only) More...
 
class  FlexiSwapBGSLGMGridEngineBuilderBase
 Flexi Swap / BGS Numeric LGM Grid Engine Builder Base Class. More...
 
class  FlexiSwapDiscountingEngineBuilder
 Flexi Swap Discounting Engine Builder. More...
 
class  FlexiSwapLGMGridEngineBuilder
 Flexi Swap LGM Grid Engine Builder. More...
 
class  FloatingLegBuilder
 
class  FloatingLegData
 Serializable Floating Leg Data. More...
 
class  FormulaBasedCouponPricerBuilder
 
class  FormulaBasedLegBuilder
 
class  FormulaBasedLegData
 
class  ForwardBond
 
struct  ForwardBondTrsUnderlyingBuilder
 
class  ForwardRateAgreement
 Serializable ForwardRateAgreement. More...
 
class  FraConvention
 Container for storing Forward rate Agreement conventions. More...
 
class  FRAQuote
 FRA market data class. More...
 
struct  FunctionAboveProbNode
 
struct  FunctionAbsNode
 
struct  FunctionBelowProbNode
 
struct  FunctionBlackNode
 
struct  FunctionDateIndexNode
 
struct  FunctionDaysNode
 
struct  FunctionDcfNode
 
struct  FunctionDiscountNode
 
struct  FunctionExpNode
 
struct  FunctionFwdAvgNode
 
struct  FunctionFwdCompNode
 
struct  FunctionLogNode
 
struct  FunctionLogPayNode
 
struct  FunctionMaxNode
 
struct  FunctionMinNode
 
struct  FunctionNormalCdfNode
 
struct  FunctionNormalPdfNode
 
struct  FunctionNpvMemNode
 
struct  FunctionNpvNode
 
struct  FunctionPayNode
 
struct  FunctionPowNode
 
struct  FunctionSqrtNode
 
class  FutureContinuationExpiry
 
class  FutureConvention
 Container for storing Money Market Futures conventions. More...
 
class  fwdBondEngineBuilder
 
class  FxAccumulator
 
class  FxAmericanOptionBAWEngineBuilder
 Engine Builder for American Fx Options using Barone Adesi Whaley Approximation. More...
 
class  FxAmericanOptionFDEngineBuilder
 Engine Builder for American Fx Options using Finite Difference Method. More...
 
class  FxAsianOption
 
class  FxAverageForward
 Serializable Fx Average Forward. More...
 
class  FxBarrierOption
 Serializable FX Barrier Option. More...
 
class  FxBarrierOptionAnalyticEngineBuilder
 
class  FxBarrierOptionEngineBuilder
 Engine Builder for European FX Barrier Options. More...
 
class  FxBarrierOptionFDEngineBuilder
 
class  FxBasketOption
 
class  FxBasketVarianceSwap
 
class  FxBestEntryOption
 
class  FxBsBuilder
 Builder for a Lognormal FX model component. More...
 
class  FxBsData
 FX Model Parameters. More...
 
class  FXConvention
 Container for storing FX Spot quote conventions. More...
 
class  FxDerivative
 Base class for all FX Derivaties. More...
 
class  FxDigitalBarrierOption
 Serializable FX Digital Barrier Option. More...
 
class  FxDigitalBarrierOptionEngineBuilder
 Engine Builder for European FX Digital Barrier Options. More...
 
class  FxDigitalCSOptionEngineBuilder
 Engine Builder for European cash-settled FX Digital Options. More...
 
class  FxDigitalOption
 Serializable FX Digital Option. More...
 
class  FxDigitalOptionEngineBuilder
 Engine Builder for European FX Digital Options. More...
 
class  FxDoubleBarrierOption
 Serializable FX Double Barrier Option. More...
 
class  FxDoubleBarrierOptionAnalyticEngineBuilder
 Analytical Engine Builder for FX Double Barrier Options. More...
 
class  FxDoubleBarrierOptionEngineBuilder
 Engine Builder for European FX Double Barrier Options. More...
 
class  FxDoubleTouchOption
 Serializable FX Double One-Touch/No-Touch Option. More...
 
class  FxDoubleTouchOptionAnalyticEngineBuilder
 Analytical Engine Builder for FX Double Touch Options. More...
 
class  FxDoubleTouchOptionEngineBuilder
 Abstract Engine Builder for FX Double Touch Options. More...
 
struct  FxEqCommVolCalibrationInfo
 
class  FxEuropeanAsianOptionACGAPEngineBuilder
 Continuous Analytic Engine Builder for European Asian Fx Geometric Average Price Options. More...
 
class  FxEuropeanAsianOptionADGAPEngineBuilder
 Discrete Analytic Engine Builder for European Asian Fx Geometric Average Price Options. More...
 
class  FxEuropeanAsianOptionADGASEngineBuilder
 Discrete Analytic Engine Builder for European Asian Fx Geometric Average Strike Options. More...
 
class  FxEuropeanAsianOptionMCDAAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Fx Arithmetic Average Price Options. More...
 
class  FxEuropeanAsianOptionMCDAASEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Fx Arithmetic Average Strike Options. More...
 
class  FxEuropeanAsianOptionMCDGAPEngineBuilder
 Discrete Monte Carlo Engine Builder for European Asian Fx Geometric Average Price Options. More...
 
class  FxEuropeanAsianOptionTWEngineBuilder
 Discrete Analytic TW Engine Builder for European Asian Fx Arithmetic Average Price Options. More...
 
class  FxEuropeanBarrierOption
 Serializable FX European Barrier Option. More...
 
class  FxEuropeanCSOptionEngineBuilder
 
class  FxEuropeanOptionEngineBuilder
 Engine Builder for European Fx Option Options. More...
 
class  FxEuropeanOptionEngineBuilderDeltaGamma
 Engine Builder for European FX Options with analytical sensitivities. More...
 
class  FxForward
 Serializable FX Forward. More...
 
class  FxForwardEngineBuilder
 Engine Builder for FX Forwards. More...
 
class  FxForwardEngineBuilderBase
 Engine Builder base class for FX Forwards. More...
 
class  FxForwardEngineBuilderDeltaGamma
 Engine Builder for FX Forwards. More...
 
class  FXForwardQuote
 Foreign exchange rate data class. More...
 
class  FxGenericBarrierOption
 
class  FxKIKOBarrierOption
 Serializable FX KIKO Barrier Option. More...
 
class  FxOption
 Serializable FX Option. More...
 
class  FxOptionConvention
 Container for storing FX Option conventions. More...
 
class  FXOptionQuote
 FX Option data class. More...
 
class  FxOptionWithBarrier
 
class  FxPairwiseVarSwap
 
class  FxRainbowOption
 
class  FxSingleAssetDerivative
 Base class for all single asset FX Derivaties. More...
 
class  FXSpotConfig
 FXSpot configuration. More...
 
class  FXSpotQuote
 Foreign exchange rate data class. More...
 
class  FXSpotSpec
 FX Spot description. More...
 
class  FxSwap
 Serializable FX Swap. More...
 
class  FxTaRF
 
class  FxTouchOption
 Serializable FX One-Touch/No-Touch Option. More...
 
class  FxTouchOptionEngineBuilder
 Engine Builder for FX Touch Options. More...
 
class  FXTriangulation
 
class  FXUnderlying
 
class  FxVarSwap
 
class  FXVolatilityCurveConfig
 FX volatility structure configuration. More...
 
class  FXVolatilityCurveSpec
 FX Volatility curve description. More...
 
class  FXVolCurve
 Wrapper class for building FX volatility structures. More...
 
class  FxWindowBarrierOption
 
class  FxWorstOfBasketSwap
 
class  GaussCopulaBucketingCdoEngineBuilder
 
class  GaussianCam
 
class  GaussianCamCG
 
class  GenericBarrierOption
 
class  GenericYieldVolatilityCurveConfig
 Generic yield volatility curve configuration class. More...
 
class  GenericYieldVolCurve
 Wrapper class for building Generic yield volatility structures. More...
 
class  GlobalPseudoCurrencyMarketParameters
 Singleton to store Global parameters, this should be initialised at some point with PEGP. More...
 
class  HazardRateQuote
 Hazard rate data class. More...
 
struct  HistFixingNode
 
class  HwBuilder
 Builder for a Hull White model or a HW component for the CAM. More...
 
class  HwCG
 
class  HwModelData
 Hull White Model Parameters. More...
 
class  IborFallbackConfig
 
class  IborFallbackCurveSegment
 Ibor Fallback yield curve segment. More...
 
class  IborIndexConvention
 Container for storing Ibor Index conventions. More...
 
struct  IfThenElseNode
 
class  ImmFraQuote
 IMM FRA market data class. More...
 
class  IndependentLogger
 Base Log handler class that utilises Boost logging to create log sinks. More...
 
class  IndexCDSOptionQuote
 CDS Index Option data class. More...
 
class  IndexCreditDefaultSwap
 
class  IndexCreditDefaultSwapData
 
class  IndexCreditDefaultSwapEngineBuilder
 Engine Builder base class for Index Credit Default Swaps. More...
 
class  IndexCreditDefaultSwapOption
 
class  IndexCreditDefaultSwapOptionEngineBuilder
 Engine Builder base class for Index Credit Default Swap Options. More...
 
class  IndexInfo
 
class  Indexing
 Serializable object holding indexing data. More...
 
class  IndexNameTranslator
 IndexNameTranslator. More...
 
class  IndexReferenceDatum
 Base class for indices - lets see if we can keep this, they might diverge too much... More...
 
struct  IndexVec
 
class  InfDkBuilder
 
class  InfDkData
 
class  InfJyBuilder
 
class  InfJyData
 
class  InflationCapFloorQuote
 Inflation Cap Floor data class. More...
 
class  InflationCapFloorVolatilityCurveConfig
 Inflation CapFloor volatility curve configuration class. More...
 
class  InflationCapFloorVolatilityCurveSpec
 Inflation cap floor volatility description. More...
 
class  InflationCapFloorVolCurve
 
class  InflationCurve
 Wrapper class for building inflation curves. More...
 
struct  InflationCurveCalibrationInfo
 
class  InflationCurveConfig
 
class  InflationCurveSpec
 Inflation curve description. More...
 
class  InflationModelData
 
class  InflationSwap
 Serializable Cross Currency Swap contract. More...
 
class  InflationSwapConvention
 
class  InflationUnderlying
 
class  InMemoryLoader
 
class  InMemoryReport
 
class  InstantaneousCorrelations
 InstantaneousCorrelations. More...
 
class  InstrumentConventions
 Singleton to hold conventions. More...
 
class  InstrumentWrapper
 Instrument Wrapper. More...
 
class  InterestRateUnderlying
 
class  IrLgmData
 INF Model Parameters. More...
 
class  IrModelData
 Linear Gauss Markov Model Parameters. More...
 
class  IRSwapConvention
 Container for storing Interest Rate Swap conventions. More...
 
struct  IrVolCalibrationInfo
 
class  JSONMessage
 
class  KnockOutSwap
 
class  LegAdditionalData
 Serializable Additional Leg Data. More...
 
class  LegBuilder
 
class  LegData
 Serializable object holding leg data. More...
 
class  LegDataFactory
 
class  LGMAmcSwaptionEngineBuilder
 
class  LgmBuilder
 Builder for a Linear Gauss Markov model component. More...
 
class  LgmCG
 
class  LgmData
 Linear Gauss Markov Model Parameters. More...
 
class  LGMFDSwaptionEngineBuilder
 Implementation of BermudanAmericanSwaptionEngineBuilder using LGM FD pricer. More...
 
class  LGMGridSwaptionEngineBuilder
 Implementation of BermudanAmericanSwaptionEngineBuilder using LGM Grid pricer. More...
 
class  LGMMCSwaptionEngineBuilder
 Implementation of LGMBermudanAmericanSwaptionEngineBuilder using MC pricer. More...
 
class  LgmReversionTransformation
 
class  LGMSwaptionEngineBuilder
 Abstract LGMSwaptionEngineBuilder class. More...
 
class  LinearTSRCmsCouponPricerBuilder
 
class  LinearTsrDurationAdjustedCmsCouponPricerBuilder
 
class  Loader
 Market data loader base class. More...
 
class  LocalVol
 
class  LocalVolModelBuilder
 
struct  LocationInfo
 
class  Log
 Global static Log class. More...
 
class  Logger
 The Base Custom Log Handler class. More...
 
class  LoggerStream
 LoggerStream class that is a std::ostream replacement that will log each line. More...
 
struct  LoopNode
 
class  Market
 Market. More...
 
class  MarketConfiguration
 
class  MarketDatum
 Base market data class. More...
 
class  MarketImpl
 Market Implementation. More...
 
class  MidPointCdsEngineBuilder
 Midpoint engine builder class for credit default swaps. More...
 
class  MidPointCdsMultiStateEngineBuilder
 Multi State Engine Builder class for CDS. More...
 
class  MidPointIndexCdsEngineBuilder
 Midpoint Engine Builder class for IndexCreditDefaultSwaps. More...
 
class  MMFutureQuote
 Money Market Future data class. More...
 
class  Model
 
class  ModelCG
 
class  ModelCGImpl
 
class  ModelData
 
class  ModelImpl
 
class  ModelParameter
 
class  MoneyMarketQuote
 Money market data class. More...
 
class  MoneynessStrike
 
class  MultiLegOption
 
class  MultiLegOptionEngineBuilderBase
 MultiLeg option engine builder base class. More...
 
class  MultiThreadedProgressIndicator
 
struct  NegateNode
 
class  NettingSetDefinition
 Netting Set Definition. More...
 
class  NettingSetDetails
 Serializable object holding netting set identification data. More...
 
class  NettingSetManager
 Netting Set Manager. More...
 
class  NoProgressBar
 
class  NumericalHaganCmsCouponPricerBuilder
 
class  NumericalIntegrationIndexCdsOptionEngineBuilder
 Numerical Integration index CDS option engine. More...
 
class  NumericLgmRiskParticipationAgreementEngine
 
class  NumericLgmRiskParticipationAgreementEngineTLock
 
class  OIFutureQuote
 Overnight index future data class. More...
 
class  OisConvention
 Container for storing Overnight Index Swap conventions. More...
 
class  OneDimSolverConfig
 
struct  OperatorDivideNode
 
struct  OperatorMinusNode
 
struct  OperatorMultiplyNode
 
struct  OperatorPlusNode
 
class  OptionData
 Serializable object holding option data. More...
 
class  OptionExerciseData
 
class  OptionPaymentData
 
class  OptionWrapper
 Option Wrapper. More...
 
class  OvernightIndexConvention
 Container for storing Overnight Index conventions. More...
 
class  PairwiseVarSwap
 
class  PairwiseVarSwapEngineBuilder
 Engine Builder for Pairwise Variance Swaps. More...
 
class  ParametricSmileConfiguration
 
struct  ParserError
 
class  PayLog
 
struct  PaymentLagInteger
 
struct  PaymentLagPeriod
 
class  PerformanceOption_01
 
struct  PermuteNode
 
struct  PiecewiseYieldCurveCalibrationInfo
 
class  PlainInMemoryReport
 InMemoryReport with access to plain types instead of boost::variant<>, to facilitate language bindings. More...
 
class  Portfolio
 Serializable portfolio. More...
 
class  PortfolioBasketReferenceDatum
 
class  PremiumData
 Serializable object holding premium data. More...
 
class  PriceSegment
 
class  ProgressIndicator
 Abstract Base class for a Progress Indicator. More...
 
class  ProgressLog
 Progress Logger that writes the progress using the LOG macro. More...
 
class  ProgressLogger
 
class  ProgressMessage
 
class  ProgressReporter
 Base class for a Progress Reporter. More...
 
class  ProxyVolatilityConfig
 
struct  PseudoCurrencyMarketParameters
 Struct to store parameters for commodities to be treatred as pseudo currencies. More...
 
class  QuantoEquityEuropeanOptionEngineBuilder
 Engine Builder for Quanto European Equity Option Options. More...
 
class  QuantoEuropeanOptionEngineBuilder
 Abstract Engine Builder for Quanto European Vanilla Options. More...
 
class  QuantoVanillaOptionEngineBuilder
 Abstract Engine Builder for Quanto Vanilla Options. More...
 
class  QuoteBasedVolatilityConfig
 
class  RainbowOption
 
class  RangeBound
 Serializable obejct holding range bound data. More...
 
class  RecoveryRateQuote
 Recovery rate data class. More...
 
class  ReferenceDataManager
 Interface for Reference Data lookups. More...
 
class  ReferenceDatum
 Base class for reference data. More...
 
class  ReferenceDatumBuilder
 Template TradeBuilder class. More...
 
class  ReferenceDatumFactory
 
class  Report
 
class  ReportConfig
 
class  RequiredFixings
 
struct  RequireNode
 
class  ReversionParameter
 
class  RiskParticipationAgreement
 Serializable risk participation agreement. More...
 
class  RiskParticipationAgreementBaseEngine
 
class  RiskParticipationAgreementBlackEngineBuilder
 RPA Black engine builder. More...
 
class  RiskParticipationAgreementEngineBuilderBase
 RPA base engine builder. More...
 
class  RiskParticipationAgreementLGMGridEngineBuilder
 RPA Numeric LGM base builder. More...
 
class  RiskParticipationAgreementSwapLGMGridEngineBuilder
 RPA Numeric LGM engine builder for swap underlyings. More...
 
class  RiskParticipationAgreementTLockLGMGridEngineBuilder
 RPA Numeric LGM engine builder for tlock underlyings. More...
 
class  RiskParticipationAgreementXCcyBlackEngineBuilder
 RPA XCcy Black engine builder. More...
 
class  SafeStack
 
class  ScheduleBuilder
 
class  ScheduleData
 Serializable schedule data. More...
 
class  ScheduleDates
 Serializable object holding schedule Dates data. More...
 
class  ScheduleDerived
 Serializable object holding Derived schedule data. More...
 
class  ScheduleRules
 Serializable object holding schedule Rules data. More...
 
class  ScriptedInstrumentAmcCalculator
 
class  ScriptedInstrumentPricingEngine
 
class  ScriptedInstrumentPricingEngineCG
 
class  ScriptedTrade
 
class  ScriptedTradeEngineBuilder
 
class  ScriptedTradeEventData
 
class  ScriptedTradeScriptData
 
class  ScriptedTradeValueTypeData
 
class  ScriptEngine
 
struct  ScriptGrammar
 
class  ScriptLibraryData
 
class  ScriptLibraryStorage
 
class  ScriptParser
 
class  SeasonalityQuote
 Inflation seasonality data class. More...
 
class  Security
 Wrapper class for holding Bond Spread and recovery rate quotes. More...
 
class  SecurityConfig
 Security configuration. More...
 
class  SecuritySpec
 Security description. More...
 
class  SecuritySpreadConvention
 Container for storing Bond Spread Rate conventions. More...
 
class  SecuritySpreadQuote
 Bond spread data class. More...
 
struct  SequenceNode
 
struct  SharedPtrMarketDatumComparator
 
struct  SimmCreditQualifierMapping
 
class  SimpleProgressBar
 Simple Progress Bar. More...
 
class  SimpleYieldCurveSegment
 Simple yield curve segment. More...
 
class  SingleBarrierOptionWrapper
 
struct  SizeOpNode
 
struct  SortNode
 
class  StaticAnalyser
 
class  StderrLogger
 Stderr Logger. More...
 
struct  Strike
 
class  StructuredConfigurationErrorMessage
 Utility classes for Structured configuration errors, contains the configuration type and ID (NettingSetId, CounterParty, etc.) More...
 
class  StructuredConfigurationWarningMessage
 Utility classes for Structured warnings, contains the configuration type and ID (NettingSetId, CounterParty, etc.) More...
 
class  StructuredCurveErrorMessage
 Utility class for Structured Curve errors, contains the curve ID. More...
 
class  StructuredCurveWarningMessage
 
class  StructuredLogger
 
class  StructuredLoggingErrorMessage
 
class  StructuredMessage
 
class  StructuredModelErrorMessage
 Utility class for Structured Model errors. More...
 
class  StructuredModelWarningMessage
 Utility class for Structured Model errors. More...
 
class  StructuredTradeErrorMessage
 Utility class for Structured Trade errors, contains the Trade ID and Type. More...
 
class  StructuredTradeWarningMessage
 Utility classes for Structured warnings, contains the Trade ID and Type. More...
 
class  Swap
 Serializable Swap, Single and Cross Currency. More...
 
class  SwapEngineBuilder
 Engine Builder for Single Currency Swaps. More...
 
class  SwapEngineBuilderBase
 Engine Builder base class for Single Currency Swaps. More...
 
class  SwapEngineBuilderDeltaGamma
 Engine Builder for Single Currency Swaps. More...
 
class  SwapEngineBuilderOptimised
 Engine Builder for Single Currency Swaps. More...
 
class  SwapIndexConvention
 Container for storing Swap Index conventions. More...
 
class  SwapQuote
 Swap market data class. More...
 
class  Swaption
 Serializable Swaption. More...
 
class  SwaptionEngineBuilder
 Swaption engine builder base class. More...
 
class  SwaptionQuote
 Swaption data class. More...
 
class  SwaptionShiftQuote
 Shift data class (for SLN swaption volatilities) More...
 
class  SwaptionVolatilityCurveConfig
 Swaption volatility curve configuration class. More...
 
class  SwaptionVolatilityCurveSpec
 Swaption Volatility curve description. More...
 
class  SwaptionVolCurve
 Wrapper class for building Swaption volatility structures. More...
 
class  SyntheticCDO
 Serializable CDS Index Tranche (Synthetic CDO) More...
 
class  TaRF
 
class  TenorBasisSwapConvention
 Container for storing Tenor Basis Swap conventions. More...
 
class  TenorBasisTwoSwapConvention
 Container for storing conventions for Tenor Basis Swaps quoted as a spread of two interest rate swaps. More...
 
class  TenorBasisYieldCurveSegment
 Tenor Basis yield curve segment. More...
 
class  TimePeriod
 Handles non-contiguous time period. More...
 
class  TodaysMarket
 Today's Market. More...
 
struct  TodaysMarketCalibrationInfo
 
class  TodaysMarketParameters
 Today's Market Parameters. More...
 
class  Trade
 Trade base class. More...
 
class  TradeAction
 Serializable object holding a trade action. More...
 
class  TradeActions
 Serializable object holding generic trade actions. More...
 
class  TradeBarrier
 
class  TradeBuilder
 Template TradeBuilder class. More...
 
class  TradeFactory
 TradeFactory. More...
 
class  TradeMonetary
 
class  TradeStrike
 
class  TrancheData
 Serializable Bond-Basket Data. More...
 
class  TransitionProbabilityQuote
 Transition Probability data class. More...
 
class  TreasuryLockData
 
class  TRS
 
struct  TrsUnderlyingBuilder
 
class  TrsUnderlyingBuilderFactory
 
class  TRSWrapper
 TRS Instrument Wrapper. More...
 
class  TRSWrapperAccrualEngine
 
class  Underlying
 Class to hold Underlyings. More...
 
class  UnderlyingBuilder
 
struct  ValueTypeWhich
 
struct  VanillaBondBuilder
 
class  VanillaInstrument
 Vanilla Instrument Wrapper. More...
 
class  VanillaOptionEngineBuilder
 Abstract Engine Builder for Vanilla Options. More...
 
class  VanillaOptionTrade
 Serializable Vanilla Option. More...
 
struct  VarEvaluationNode
 
struct  VariableNode
 
class  VarSwap
 
class  VarSwapEngineBuilder
 Engine Builder for Variance Swaps. More...
 
class  VolatilityApoFutureSurfaceConfig
 
class  VolatilityConfig
 
class  VolatilityConfigBuilder
 
class  VolatilityCurveConfig
 
class  VolatilityDeltaSurfaceConfig
 
class  VolatilityMoneynessSurfaceConfig
 
class  VolatilityParameter
 
class  VolatilityStrikeSurfaceConfig
 
class  VolatilitySurfaceConfig
 
class  WeightedAverageYieldCurveSegment
 Weighted average yield curve segment. More...
 
class  Wildcard
 
class  WindowBarrierOption
 
class  WorstOfBasketSwap
 
class  WrappedMarket
 Wrapped Market. More...
 
class  XMLDocument
 Small XML Document wrapper class. More...
 
class  XMLSerializable
 Base class for all serializable classes. More...
 
class  XMLUtils
 XML Utilities Class. More...
 
class  YieldCurve
 Wrapper class for building yield term structures. More...
 
struct  YieldCurveCalibrationInfo
 
class  YieldCurveConfig
 Yield Curve configuration. More...
 
class  YieldCurveSegment
 Base class for yield curve segments. More...
 
class  YieldCurveSpec
 Yield curve description. More...
 
class  YieldPlusDefaultYieldCurveSegment
 Yield plus default curves segment. More...
 
class  YieldVolatilityCurveConfig
 Yield volatility curve configuration. More...
 
class  YieldVolatilityCurveSpec
 Yield volatility curve description. More...
 
class  YieldVolCurve
 Wrapper class for building Yield volatility structures. More...
 
class  YoYCapFloor
 
class  YoYCapFloorEngineBuilder
 Engine Builder for Year on Year Caps, Floors and Collars on an IborIndex. More...
 
struct  YoYInflationCurveCalibrationInfo
 
class  YoYInflationSwapQuote
 YoY Inflation swap data class. More...
 
class  YoYLegData
 Serializable YoY Leg Data. More...
 
class  YoYSwap
 
class  YyInflationCapFloorQuote
 YY Cap Floor data class. More...
 
class  YYLegBuilder
 
class  ZcInflationCapFloorQuote
 ZC Cap Floor data class. More...
 
class  ZcInflationSwapQuote
 ZC Inflation swap data class. More...
 
class  ZeroCouponFixedLegBuilder
 
class  ZeroCouponFixedLegData
 Serializable Fixed Leg Data. More...
 
struct  ZeroInflationCurveCalibrationInfo
 
class  ZeroInflationIndexConvention
 
class  ZeroQuote
 
class  ZeroRateConvention
 Container for storing Zero Rate conventions. More...
 
class  ZeroSpreadedYieldCurveSegment
 Zero Spreaded yield curve segment. More...
 

Typedefs

typedef boost::bimap< string, CapFloorVolatilityCurveConfig::VolatilityTypeBmType
 
using YieldCurveConfigMap = std::map< string, QuantLib::ext::shared_ptr< YieldCurveConfig > >
 
template<class I >
using Crv = QuantExt::PiecewisePriceCurve< I, QuantExt::IterativeBootstrap >
 
template<class C >
using BS = QuantExt::IterativeBootstrap< C >
 
using Helpers = InfJyBuilder::Helpers
 
template<class T , typename... Args>
using CachingPricingEngineBuilder = CachingEngineBuilder< T, PricingEngine, Args... >
 
template<class T , typename... Args>
using CachingCouponPricerBuilder = CachingEngineBuilder< T, FloatingRateCouponPricer, Args... >
 
template<class T , typename... Args>
using CachingInflationCouponPricerBuilder = CachingEngineBuilder< T, InflationCouponPricer, Args... >
 
template<class T , typename... Args>
using CachingInflationCashFlowPricerBuilder = CachingEngineBuilder< T, QuantExt::InflationCashFlowPricer, Args... >
 
using ASI = CreditDefaultSwapOption::AuctionSettlementInformation
 
typedef AssetPositionTrsUnderlyingBuilder< ore::data::EquityPositionEquityPositionTrsUnderlyingBuilder
 
typedef AssetPositionTrsUnderlyingBuilder< ore::data::CommodityPositionCommodityPositionTrsUnderlyingBuilder
 
typedef boost::variant< QuantLib::Period, QuantLib::Natural > PaymentLag
 
using ASTNodePtr = QuantLib::ext::shared_ptr< ASTNode >
 
using ScriptGrammarIterator = boost::spirit::line_pos_iterator< std::string::const_iterator >
 
using ValueType = boost::variant< RandomVariable, EventVec, CurrencyVec, IndexVec, DaycounterVec, Filter >
 
typedef boost::log::sinks::synchronous_sink< boost::log::sinks::text_file_backend > file_sink
 
typedef boost::log::sinks::synchronous_sink< boost::log::sinks::text_ostream_backend > text_sink
 
using ADCP = CommodityFutureConvention::AveragingData::CalculationPeriod
 
using PST = PriceSegment::Type
 
using CQF = CommodityQuantityFrequency
 
typedef rapidxml::xml_node< char > XMLNode
 

Enumerations

enum class  YieldCurveType { Discount = 0 , Yield = 1 , EquityDividend = 2 }
 
enum class  MarketObject {
  DiscountCurve = 0 , YieldCurve = 1 , IndexCurve = 2 , SwapIndexCurve = 3 ,
  FXSpot = 4 , FXVol = 5 , SwaptionVol = 6 , DefaultCurve = 7 ,
  CDSVol = 8 , BaseCorrelation = 9 , CapFloorVol = 10 , ZeroInflationCurve = 11 ,
  YoYInflationCurve = 12 , ZeroInflationCapFloorVol = 13 , YoYInflationCapFloorVol = 14 , EquityCurve = 15 ,
  EquityVol = 16 , Security = 17 , CommodityCurve = 18 , CommodityVolatility = 19 ,
  Correlation = 20 , YieldVol = 21
}
 
enum class  ParamType { Constant , Piecewise }
 Supported calibration parameter type. More...
 
enum class  CalibrationType { Bootstrap , BestFit , None }
 Supported calibration types. More...
 
enum class  CalibrationStrategy {
  CoterminalATM , CoterminalDealStrike , UnderlyingATM , UnderlyingDealStrike ,
  None
}
 Supported calibration strategies. More...
 
enum class  CommodityPayRelativeTo { CalculationPeriodEndDate , CalculationPeriodStartDate , TerminationDate , FutureExpiryDate }
 
enum class  CommodityPriceType { Spot , FutureSettlement }
 
enum class  CommodityPricingDateRule { FutureExpiryDate , None }
 
enum class  CdsTier {
  SNRFOR , SUBLT2 , SNRLAC , SECDOM ,
  JRSUBUT2 , PREFT1 , LIEN1 , LIEN2 ,
  LIEN3
}
 CDS debt tier enumeration. More...
 
enum class  CdsDocClause {
  CR , MM , MR , XR ,
  CR14 , MM14 , MR14 , XR14
}
 CDS documentation clause enumeration. More...
 
enum class  IsdaRulesDefinitions { y2003 = 2003 , y2014 = 2014 }
 ISDA CDS documentation rules set enumeration. More...
 
enum class  CreditEventType {
  BANKRUPTCY , FAILURE_TO_PAY , RESTRUCTURING , OBLIGATION_ACCELERATION ,
  OBLIGATION_DEFAULT , REPUDIATION_MORATORIUM , GOVERNMENTAL_INTERVENTION
}
 ISDA credit event types enumeration. More...
 
enum class  CreditEventTiers {
  SNR , SUB , SNRLAC , SNR_SUB ,
  SNR_SNRLAC , SUB_SNRLAC , SNR_SUB_SNRLAC
}
 ISDA credit event seniority sets enumeration. More...
 
enum class  MarketContext { irCalibration , fxCalibration , eqCalibration , pricing }
 
enum class  AmortizationType {
  None , FixedAmount , RelativeToInitialNotional , RelativeToPreviousNotional ,
  Annuity , LinearToMaturity
}
 
enum class  AssetClass {
  EQ , FX , COM , IR ,
  INF , CR , BOND , BOND_INDEX
}
 
enum class  Extrapolation { None , UseInterpolator , Flat }
 Enumeration for holding various extrapolation settings. More...
 
enum class  MomentType { Variance , Volatility }
 
enum class  CreditPortfolioSensitivityDecomposition { Underlying , NotionalWeighted , LossWeighted , DeltaWeighted }
 Enumeration CreditPortfolioSensitivityDecomposition. More...
 
enum  MporCashFlowMode {
  Unspecified , NonePay , BothPay , WePay ,
  TheyPay
}
 

Functions

VolatilityType volatilityType (CapFloorVolatilityCurveConfig::VolatilityType type)
 Imply QuantLib::VolatilityType from CapFloorVolatilityCurveConfig::VolatilityType. More...
 
bool operator< (const CommodityFutureConvention::ProhibitedExpiry &lhs, const CommodityFutureConvention::ProhibitedExpiry &rhs)
 Compare two prohibited expiries. More...
 
std::ostream & operator<< (std::ostream &out, Convention::Type type)
 
std::ostream & operator<< (std::ostream &out, CorrelationCurveConfig::CorrelationType t)
 
std::ostream & operator<< (std::ostream &out, CorrelationCurveConfig::Dimension t)
 
bool indexNameLessThan (const std::string &index1, const std::string &index2)
 
template<class T >
void addMinimalCurves (const char *nodeName, const map< string, QuantLib::ext::shared_ptr< T > > &m, map< string, QuantLib::ext::shared_ptr< T > > &n, CurveSpec::CurveType curveType, const map< CurveSpec::CurveType, set< string > > configIds)
 
std::ostream & operator<< (std::ostream &out, EquityCurveConfig::Type t)
 
EquityCurveConfig::Type parseEquityCurveConfigType (const std::string &str)
 
std::ostream & operator<< (std::ostream &out, GenericYieldVolatilityCurveConfig::VolatilityType t)
 
std::ostream & operator<< (std::ostream &out, InflationCapFloorVolatilityCurveConfig::VolatilityType t)
 
std::ostream & operator<< (std::ostream &out, InflationCapFloorVolatilityCurveConfig::QuoteType t)
 
ReportConfig effectiveReportConfig (const ReportConfig &globalConfig, const ReportConfig &localConfig)
 
bool operator< (const VolatilityConfig &vc1, const VolatilityConfig &vc2)
 
YieldCurveSegment::Type parseYieldCurveSegment (const string &s)
 
bool interpOnOpt (CapFloorVolatilityCurveConfig &config)
 
QuantLib::ext::shared_ptr< MarketDatummakeDummyMarketDatum (const Date &d, const std::string &name)
 
bool operator< (const CurveSpec &lhs, const CurveSpec &rhs)
 Relational operators for CurveSpecs. More...
 
bool operator== (const CurveSpec &lhs, const CurveSpec &rhs)
 
bool operator< (const QuantLib::ext::shared_ptr< CurveSpec > &lhs, const QuantLib::ext::shared_ptr< CurveSpec > &rhs)
 
bool operator== (const QuantLib::ext::shared_ptr< CurveSpec > &lhs, const QuantLib::ext::shared_ptr< CurveSpec > &rhs)
 
std::ostream & operator<< (std::ostream &os, const CurveSpec &spec)
 Stream operator for CurveSpec. More...
 
std::ostream & operator<< (std::ostream &os, const CurveSpec::CurveType &t)
 Stream operator for CurveType. More...
 
QuantLib::ext::shared_ptr< CurveSpecparseCurveSpec (const string &s)
 function to convert a string into a curve spec More...
 
CurveSpec::CurveType parseCurveConfigurationType (const std::string &)
 function to convert a curve configuration node string into a curve spec type More...
 
bool operator== (const Expiry &lhs, const Expiry &rhs)
 
ostream & operator<< (std::ostream &os, const Expiry &expiry)
 Write strike to stream. More...
 
QuantLib::ext::shared_ptr< ExpiryparseExpiry (const std::string &strExpiry)
 Parse an Expiry from its string representation, strExpiry. More...
 
void applyFixings (const std::set< Fixing > &fixings)
 Utility to write a vector of fixings in the QuantLib index manager's fixing history. More...
 
bool operator< (const Fixing &f1, const Fixing &f2)
 Compare fixings. More...
 
Handle< QuantExt::CorrelationTermStructuregetCorrelationCurve (const std::string &index1, const std::string &index2, const map< string, QuantLib::ext::shared_ptr< CorrelationCurve > > &correlationCurves)
 
QuantLib::Date getInflationSwapStart (const Date &asof, const InflationSwapConvention &convention)
 
void load (InMemoryLoader &loader, const vector< string > &data, bool isMarket, bool implyTodaysFixings)
 
void loadDataFromBuffers ( InMemoryLoader &loader, const std::vector< std::string > &marketData, const std::vector< std::string > &fixingData, bool implyTodaysFixings=false)
 Utility function for loading market quotes and fixings from an in memory csv buffer. More...
 
PseudoCurrencyMarketParameters buildPseudoCurrencyMarketParameters (const std::map< string, string > &pricingEngineGlobalParameters=std::map< string, string >())
 Function to build parameters from PricingEngine GlobalParametrs. More...
 
std::ostream & operator<< (std::ostream &os, const struct PseudoCurrencyMarketParameters &p)
 
bool operator< (const MarketDatum &a, const MarketDatum &b)
 
std::ostream & operator<< (std::ostream &out, const MarketDatum::QuoteType &type)
 
std::ostream & operator<< (std::ostream &out, const MarketDatum::InstrumentType &type)
 
Date getDateFromDateOrPeriod (const string &token, Date asof, QuantLib::Calendar cal=QuantLib::WeekendsOnly(), QuantLib::BusinessDayConvention bdc=QuantLib::BusinessDayConvention::Following)
 Get a date from a date string or period. More...
 
boost::variant< QuantLib::Period, FXForwardQuote::FxFwdStringparseFxPeriod (const string &s)
 Convert text to QuantLib::Period of Fx forward string. More...
 
QuantLib::Period fxFwdQuoteTenor (const boost::variant< QuantLib::Period, FXForwardQuote::FxFwdString > &term)
 
QuantLib::Period fxFwdQuoteStartTenor (const boost::variant< QuantLib::Period, FXForwardQuote::FxFwdString > &term, const QuantLib::ext::shared_ptr< FXConvention > &fxConvention)
 
bool matchFxFwdStringTerm (const boost::variant< QuantLib::Period, FXForwardQuote::FxFwdString > &term, const FXForwardQuote::FxFwdString &fxfwdString)
 
QuantLib::ext::shared_ptr< MarketDatumparseMarketDatum (const Date &asof, const string &datumName, const Real &value)
 Function to parse a market datum. More...
 
bool operator== (const BaseStrike &lhs, const BaseStrike &rhs)
 
ostream & operator<< (std::ostream &os, const BaseStrike &strike)
 Write strike to stream. More...
 
ostream & operator<< (ostream &os, DeltaVolQuote::DeltaType type)
 
ostream & operator<< (ostream &os, DeltaVolQuote::AtmType type)
 
ostream & operator<< (std::ostream &os, MoneynessStrike::Type type)
 Write MoneynessStrike::Type, type, to stream. More...
 
MoneynessStrike::Type parseMoneynessType (const std::string &type)
 Parse MoneynessStrike::Type from type. More...
 
QuantLib::ext::shared_ptr< BaseStrikeparseBaseStrike (const std::string &strStrike)
 Parse a Strike from its string representation, strStrike. More...
 
std::ostream & operator<< (std::ostream &os, QuantLib::DeltaVolQuote::DeltaType type)
 Write deltaType to stream. Not provided in QuantLib so add it here. More...
 
std::ostream & operator<< (std::ostream &os, QuantLib::DeltaVolQuote::AtmType type)
 Write atmType to stream. Not provided in QuantLib so add it here. More...
 
template<class Archive >
void registerBaseStrike (Archive &ar)
 
std::ostream & operator<< (std::ostream &o, const DependencyGraph::Node &n)
 
std::ostream & operator<< (std::ostream &out, const MarketObject &o)
 Market Configuration structure. More...
 
std::set< MarketObjectgetMarketObjectTypes ()
 
template<template< class > class CurveType>
QuantLib::ext::shared_ptr< YieldTermStructure > buildYieldCurve (const vector< Date > &dates, const vector< QuantLib::Real > &rates, const DayCounter &dayCounter, YieldCurve::InterpolationMethod interpolationMethod, Size n=0)
 Templated function to build a YieldTermStructure and apply interpolation methods to it. More...
 
QuantLib::ext::shared_ptr< YieldTermStructure > zerocurve (const vector< Date > &dates, const vector< Rate > &yields, const DayCounter &dayCounter, YieldCurve::InterpolationMethod interpolationMethod, Size n=0)
 Create a Interpolated Zero Curve and apply interpolators. More...
 
QuantLib::ext::shared_ptr< YieldTermStructure > discountcurve (const vector< Date > &dates, const vector< DiscountFactor > &dfs, const DayCounter &dayCounter, YieldCurve::InterpolationMethod interpolationMethod, Size n=0)
 Create a Interpolated Discount Curve and apply interpolators. More...
 
QuantLib::ext::shared_ptr< YieldTermStructure > forwardcurve (const vector< Date > &dates, const vector< Rate > &forwards, const DayCounter &dayCounter, YieldCurve::InterpolationMethod interpolationMethod, Size n=0)
 Create a Interpolated Forward Curve and apply interpolators. More...
 
YieldCurve::InterpolationMethod parseYieldCurveInterpolationMethod (const string &s)
 Helper function for parsing interpolation method. More...
 
YieldCurve::InterpolationVariable parseYieldCurveInterpolationVariable (const string &s)
 Helper function for parsing interpolation variable. More...
 
std::ostream & operator<< (std::ostream &out, const YieldCurve::InterpolationMethod m)
 Output operator for interpolation method. More...
 
template<class T >
QuantLib::ext::shared_ptr< CalibrationInstrumentcreateCalibrationInstrument ()
 
CrCirData::CalibrationStrategy parseCirCalibrationStrategy (const string &s)
 
std::ostream & operator<< (std::ostream &oss, const CrCirData::CalibrationStrategy &s)
 
std::vector< std::string > pairToStrings (std::pair< std::string, std::string > p)
 
QuantExt::CrossAssetModel::Discretization parseDiscretization (const string &s)
 
std::ostream & operator<< (std::ostream &oss, const ParamType &type)
 Convert enumerated class value into a string. More...
 
ParamType parseParamType (const string &s)
 Convert parameter type string into enumerated class value. More...
 
CalibrationType parseCalibrationType (const string &s)
 Convert calibration type string into enumerated class value. More...
 
std::ostream & operator<< (std::ostream &oss, const CalibrationType &type)
 Convert enumerated class value into a string. More...
 
CalibrationStrategy parseCalibrationStrategy (const string &s)
 Convert calibration strategy string into enumerated class value. More...
 
std::ostream & operator<< (std::ostream &oss, const CalibrationStrategy &type)
 Convert enumerated class value into a string. More...
 
LgmData::ReversionType parseReversionType (const string &s)
 Enum parsers. More...
 
std::ostream & operator<< (std::ostream &oss, const LgmData::ReversionType &type)
 Enum to string. More...
 
LgmData::VolatilityType parseVolatilityType (const string &s)
 
std::ostream & operator<< (std::ostream &oss, const LgmData::VolatilityType &type)
 
QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping parseFloatSpreadMapping (const string &s)
 
std::ostream & operator<< (std::ostream &oss, const QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping &m)
 
std::string getCalibrationDetails (LgmCalibrationInfo &info, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &parametrization)
 
std::string getCalibrationDetails (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< FxBsParametrization > &parametrization, const QuantLib::ext::shared_ptr< Parametrization > &domesticIrModel)
 
std::string getCalibrationDetails (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< FxBsParametrization > &parametrization, const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &domesticLgm)
 
std::string getCalibrationDetails (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< EqBsParametrization > &parametrization, const QuantLib::ext::shared_ptr< Parametrization > &domesticIrModel)
 
std::string getCalibrationDetails (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< EqBsParametrization > &parametrization, const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &domesticLgm)
 
std::string getCalibrationDetails (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > &parametrization)
 
std::string getCalibrationDetails (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< InfDkParametrization > &parametrization, bool indexIsInterpolated)
 
string getCalibrationDetails (const vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &rrBasket, const vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &idxBasket, const QuantLib::ext::shared_ptr< InfJyParameterization > &p, bool calibrateRealRateVol)
 
string getCalibrationDetails (const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &parametrization)
 
Date optionMaturity (const boost::variant< Date, Period > &maturity, const QuantLib::Calendar &calendar, const QuantLib::Date &referenceDate)
 
Real cpiCapFloorStrikeValue (const QuantLib::ext::shared_ptr< BaseStrike > &strike, const QuantLib::ext::shared_ptr< ZeroInflationTermStructure > &curve, const QuantLib::Date &optionMaturityDate)
 Return a cpi cap/floor strike value, the input strike can be of type absolute or atm forward. More...
 
Real yoyCapFloorStrikeValue (const QuantLib::ext::shared_ptr< BaseStrike > &strike, const QuantLib::ext::shared_ptr< YoYInflationTermStructure > &curve, const QuantLib::Date &optionMaturityDate)
 Return a yoy cap/floor strike value, the input strike can be of type absolute or atm forward. More...
 
Real atmForward (const Real s0, const Handle< YieldTermStructure > &r, const Handle< YieldTermStructure > &q, const Real t)
 helper function that computes the atm forward More...
 
template<typename Helper >
Real getCalibrationError (const std::vector< QuantLib::ext::shared_ptr< Helper > > &basket)
 
QuantLib::Date optionMaturity (const boost::variant< QuantLib::Date, QuantLib::Period > &maturity, const QuantLib::Calendar &calendar, const QuantLib::Date &referenceDate=Settings::instance().evaluationDate())
 Return an option's maturity date, given an explicit date or a period. More...
 
bool operator< (const BasketConstituent &lhs, const BasketConstituent &rhs)
 
void populateFromBondReferenceData (std::string &subType, std::string &issuerId, std::string &settlementDays, std::string &calendar, std::string &issueDate, std::string &priceQuoteMethod, std::string &priceQuoteBaseValue, std::string &creditCurveId, std::string &creditGroup, std::string &referenceCurveId, std::string &incomeCurveId, std::string &volatilityCurveId, std::vector< LegData > &coupons, const std::string &name, const QuantLib::ext::shared_ptr< BondReferenceDatum > &bondRefData, const std::string &startDate="", const std::string &endDate="")
 Populate bond data from name and ReferenceDataManager. More...
 
Date getOpenEndDateReplacement (const std::string &replacementPeriodStr, const Calendar &calendar)
 
std::vector< Handle< DefaultProbabilityTermStructure > > buildPerformanceOptimizedDefaultCurves (const std::vector< Handle< DefaultProbabilityTermStructure > > &curves)
 
std::vector< QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > > buildPerformanceOptimizedDefaultCurves (const std::vector< QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > > &curves)
 Engine Builder base class for CDOs. More...
 
GFunctionFactory::YieldCurveModel ycmFromString (const string &s)
 
bool operator== (const CDSEngineKey &lhs, const CDSEngineKey &rhs)
 
bool operator< (const CDSEngineKey &lhs, const CDSEngineKey &rhs)
 
bool operator!= (const CDSEngineKey &lhs, const CDSEngineKey &rhs)
 
bool operator> (const CDSEngineKey &lhs, const CDSEngineKey &rhs)
 
bool operator<= (const CDSEngineKey &lhs, const CDSEngineKey &rhs)
 
bool operator>= (const CDSEngineKey &lhs, const CDSEngineKey &rhs)
 
CommodityPayRelativeTo parseCommodityPayRelativeTo (const string &s)
 
ostream & operator<< (ostream &out, const CommodityPayRelativeTo &cprt)
 
CommodityPriceType parseCommodityPriceType (const string &s)
 
ostream & operator<< (ostream &out, const CommodityPriceType &cpt)
 
CommodityPricingDateRule parseCommodityPricingDateRule (const string &s)
 
ostream & operator<< (std::ostream &out, const CommodityPricingDateRule &cpdr)
 
QuantLib::ext::shared_ptr< OptionPaymentDateAdjuster > makeOptionPaymentDateAdjuster (CommoditySpreadOptionData &optionData, const std::vector< Date > &expiryDates)
 
CdsTier parseCdsTier (const string &s)
 
ostream & operator<< (ostream &out, const CdsTier &cdsTier)
 
CdsDocClause parseCdsDocClause (const string &s)
 
ostream & operator<< (ostream &out, const CdsDocClause &cdsDocClause)
 
IsdaRulesDefinitions parseIsdaRulesDefinitions (const string &s)
 
ostream & operator<< (ostream &out, const IsdaRulesDefinitions &isdaRulesDefinitions)
 
IsdaRulesDefinitions isdaRulesDefinitionsFromDocClause (const CdsDocClause &cdsDocClause)
 
CreditEventType parseCreditEventType (const string &s)
 
ostream & operator<< (ostream &out, const CreditEventType &creditEventType)
 
bool isTriggeredDocClause (CdsDocClause contractDocClause, CreditEventType creditEventType)
 
CreditEventTiers parseCreditEventTiers (const string &s)
 
ostream & operator<< (ostream &out, const CreditEventTiers &creditEventTiers)
 
bool isAuctionedSeniority (CdsTier contractTier, CreditEventTiers creditEventTiers)
 
bool tryParseCdsInformation (string strInfo, CdsReferenceInformation &cdsInfo)
 
std::pair< std::string, std::string > getLowerAndUpperBound (const std::string &type, const std::string &binaryLevelA, const std::string &binaryLevelB)
 
bool operator== (const EngineData &lhs, const EngineData &rhs)
 
bool operator!= (const EngineData &lhs, const EngineData &rhs)
 
QuantExt::Leg makeEquityMarginLeg (const LegData &data, const QuantLib::ext::shared_ptr< EquityIndex2 > &equityCurve, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex, const QuantLib::Date &openEndDateReplacement)
 
bool operator< (const RequiredFixings::FixingEntry &lhs, const RequiredFixings::FixingEntry &rhs)
 
bool operator< (const RequiredFixings::InflationFixingEntry &lhs, const RequiredFixings::InflationFixingEntry &rhs)
 
bool operator< (const RequiredFixings::ZeroInflationFixingEntry &lhs, const RequiredFixings::ZeroInflationFixingEntry &rhs)
 
std::ostream & operator<< (std::ostream &out, const ore::data::RequiredFixings::FixingEntry &f)
 
std::ostream & operator<< (std::ostream &out, const std::set< ore::data::RequiredFixings::FixingEntry > &entries)
 
std::ostream & operator<< (std::ostream &out, const std::set< ore::data::RequiredFixings::InflationFixingEntry > &entries)
 
std::ostream & operator<< (std::ostream &out, const std::set< ore::data::RequiredFixings::ZeroInflationFixingEntry > &entries)
 
std::ostream & operator<< (std::ostream &out, const RequiredFixings &requiredFixings)
 
void addToRequiredFixings (const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
 
void amendInflationFixingDates (std::map< std::string, RequiredFixings::FixingDates > &fixings)
 
void addMarketFixingDates (const Date &asof, map< string, RequiredFixings::FixingDates > &fixings, const TodaysMarketParameters &mktParams, const Period &iborLookback, const Period &oisLookback, const Period &bmaLookback, const Period &inflationLookback)
 
void addMarketFixingDates (const QuantLib::Date &asof, std::map< std::string, RequiredFixings::FixingDates > &fixings, const TodaysMarketParameters &mktParams, const QuantLib::Period &iborLookback=5 *QuantLib::Days, const QuantLib::Period &oisLookback=4 *QuantLib::Months, const QuantLib::Period &bmaLookback=2 *QuantLib::Weeks, const QuantLib::Period &inflationLookback=1 *QuantLib::Years)
 
QuantLib::ext::shared_ptr< QuantExt::FormulaBasedIndex > makeFormulaBasedIndex (const std::string &formula, const QuantLib::ext::shared_ptr< ore::data::Market > market, const std::string &configuration, std::map< std::string, QuantLib::ext::shared_ptr< QuantLib::InterestRateIndex > > &indexMaps, const Calendar &fixingCalendar)
 
Leg makeFormulaBasedLeg (const LegData &data, const QuantLib::ext::shared_ptr< QuantExt::FormulaBasedIndex > &formulaBasedIndex, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const std::map< std::string, QuantLib::ext::shared_ptr< QuantLib::InterestRateIndex > > &indexMaps, const QuantLib::Date &openEndDateReplacement)
 
bool checkBarrier (Real spot, Barrier::Type type, Real barrier)
 
bool lessThan (const string &s1, const string &s2)
 
Leg makeNotionalLeg (const Leg &refLeg, const bool initNomFlow, const bool finalNomFlow, const bool amortNomFlow, const Natural notionalPaymentLag, const BusinessDayConvention paymentConvention, const Calendar paymentCalendar, const bool excludeIndexing)
 
Leg makeEquityLeg (const LegData &data, const QuantLib::ext::shared_ptr< EquityIndex2 > &equityCurve, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex, const QuantLib::Date &openEndDateReplacement)
 
vector< double > buildAmortizationScheduleLinearToMaturity (const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
 
template<class T >
QuantLib::ext::shared_ptr< LegAdditionalDatacreateLegData ()
 
Leg makeNonStandardIborLeg (const QuantLib::ext::shared_ptr< IborIndex > &index, const std::vector< Date > &calcDates, const std::vector< Date > &payDatesInput, const std::vector< Date > &fixingDatesInput, const std::vector< Date > &resetDatesInput, const Size fixingDays, const std::vector< Real > &notionals, const std::vector< Date > &notionalDatesInput, const std::vector< Real > &spreadsInput, const std::vector< Date > &spreadDatesInput, const std::vector< Real > &gearingsInput, const std::vector< Date > &gearingDatesInput, const bool strictNotionalDates, const DayCounter &dayCounter, const Calendar &payCalendar, const BusinessDayConvention payConv, const Period &payLag, const bool isInArrears)
 
Leg makeNonStandardFixedLeg (const std::vector< Date > &calcDates, const std::vector< Date > &payDatesInput, const std::vector< Real > &notionals, const std::vector< Date > &notionalDatesInput, const std::vector< Real > &rates, const std::vector< Date > &rateDatesInput, const bool strictNotionalDates, const DayCounter &dayCounter, const Calendar &payCalendar, const BusinessDayConvention payConv, const Period &payLag)
 
QuantLib::Leg makeNonStandardIborLeg (const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &index, const std::vector< QuantLib::Date > &calcDates, const std::vector< QuantLib::Date > &payDates, const std::vector< QuantLib::Date > &fixingDates, const std::vector< QuantLib::Date > &resetDates, const QuantLib::Size fixingDays, const std::vector< QuantLib::Real > &notionals, const std::vector< QuantLib::Date > &notionalDates, const std::vector< QuantLib::Real > &spreads, const std::vector< QuantLib::Date > &spreadDates, const std::vector< QuantLib::Real > &gearings, const std::vector< QuantLib::Date > &gearingDates, const bool strictNotionalDates, const QuantLib::DayCounter &dayCounter, const QuantLib::Calendar &payCalendar, const QuantLib::BusinessDayConvention payConv, const QuantLib::Period &payLag, const bool isInArrears)
 
QuantLib::Leg makeNonStandardFixedLeg (const std::vector< QuantLib::Date > &calcDates, const std::vector< QuantLib::Date > &payDates, const std::vector< QuantLib::Real > &notionals, const std::vector< QuantLib::Date > &notionalDates, const std::vector< QuantLib::Real > &rates, const std::vector< QuantLib::Date > &rateDates, const bool strictNotionalDates, const QuantLib::DayCounter &dayCounter, const QuantLib::Calendar &payCalendar, const QuantLib::BusinessDayConvention payConv, const QuantLib::Period &payLag)
 
CSA::Type parseCsaType (const string &s)
 
std::ostream & operator<< (std::ostream &out, CSA::Type t)
 
bool operator< (const NettingSetDetails &lhs, const NettingSetDetails &rhs)
 Comparison operators. More...
 
bool operator== (const NettingSetDetails &lhs, const NettingSetDetails &rhs)
 
bool operator!= (const NettingSetDetails &lhs, const NettingSetDetails &rhs)
 
std::ostream & operator<< (std::ostream &out, const NettingSetDetails &nettingSetDetails)
 Enable writing of netting set details. More...
 
ostream & operator<< (std::ostream &out, const OptionPaymentData::RelativeTo &relativeTo)
 Print RelativeTo enum values. More...
 
std::pair< QuantLib::ext::shared_ptr< Trade >, boolbuildTrade (QuantLib::ext::shared_ptr< Trade > &trade, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const std::string &context, const bool ignoreTradeBuildFail, const bool buildFailedTrades, const bool emitStructuredError)
 
bool operator== (const RangeBound &a, const RangeBound &b)
 
std::ostream & operator<< (std::ostream &out, const RangeBound &t)
 
std::ostream & operator<< (std::ostream &out, const std::vector< RangeBound > &t)
 
bool operator< (const CreditIndexConstituent &lhs, const CreditIndexConstituent &rhs)
 Compare CreditIndexConstituent instances using their name. More...
 
template<class T >
QuantLib::ext::shared_ptr< AbstractReferenceDatumBuildercreateReferenceDatumBuilder ()
 
Schedule makeSchedule (const ScheduleDates &data)
 
Schedule makeSchedule (const ScheduleDerived &data, const Schedule &baseSchedule)
 
Schedule makeSchedule (const ScheduleRules &data, const Date &openEndDateReplacement)
 
Schedule makeSchedule (const ScheduleData &data, const Date &openEndDateReplacement, const map< string, QuantLib::Schedule > &baseSchedules)
 
QuantLib::Schedule makeSchedule (const ScheduleData &data, const QuantLib::Date &openEndDateReplacement=QuantLib::Null< QuantLib::Date >(), const map< string, QuantLib::Schedule > &baseSchedules=map< string, QuantLib::Schedule >())
 Functions. More...
 
QuantLib::Schedule makeSchedule (const ScheduleRules &rules, const QuantLib::Date &openEndDateReplacement=QuantLib::Null< QuantLib::Date >())
 
QuantLib::Schedule makeSchedule (const ScheduleDerived &derived, const QuantLib::Schedule &baseSchedule)
 
std::string isdaSubProductSwap (const std::string &tradeId, const vector< LegData > &legData)
 
void addTRSRequiredFixings (RequiredFixings &fixings, const std::vector< Leg > &returnLegs, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &ind=nullptr)
 
TRS::FundingData::NotionalType parseTrsFundingNotionalType (const std::string &s)
 
std::ostream & operator<< (std::ostream &os, const TRS::FundingData::NotionalType t)
 
void modifyBondTRSLeg (QuantLib::Leg &leg, QuantLib::Date issueDate)
 
Leg makeBondTRSLeg (const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const BondIndexBuilder &bondIndexBuilder, Real initialPrice, QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex)
 
Leg makeBondTRSLeg (const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const BondIndexBuilder &bondIndexBuilder, QuantLib::Real initialPrice=QuantLib::Null< QuantLib::Real >(), QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex=nullptr)
 
ScriptedTradeEventData readEventData (XMLNode *node)
 
XMLNodewriteEventData (XMLDocument &doc, ScriptedTradeEventData &eventData)
 
QuantLib::ext::shared_ptr< ore::data::InMemoryReportaddColumnToExisitingReport (const std::string &columnName, const std::string &value, const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &report)
 
QuantLib::ext::shared_ptr< ore::data::InMemoryReportaddColumnsToExisitingReport (const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &newColsReport, const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &report)
 
QuantLib::ext::shared_ptr< ore::data::InMemoryReportconcatenateReports (const std::vector< QuantLib::ext::shared_ptr< ore::data::InMemoryReport > > &reports)
 
std::string to_string (const LocationInfo &l)
 
std::string to_string (const ASTNodePtr root, const bool printLocationInfo)
 
void reset (const ASTNodePtr root)
 
std::string to_script (const ASTNodePtr root)
 
std::ostream & operator<< (std::ostream &out, const Context &context)
 
std::size_t addModelParameter (ComputationGraph &g, std::vector< std::pair< std::size_t, std::function< double(void)> > > &m, const std::string &id, std::function< double(void)> f)
 
Date getSloppyDate (const Date &d, const bool sloppyDates, const std::set< Date > &dates)
 
ASTNodePtr generateRandomAST (const Size maxSequenceLength, const Size maxDepth, const Size seed)
 
std::ostream & operator<< (std::ostream &out, const ParserError &error)
 
std::string printCodeContext (std::string script, const ASTNode *loc, bool compact)
 
std::vector< Date > coarsenDateGrid (const std::vector< Date > &dates, const std::string &rule, const Date &referenceDate)
 
std::pair< std::string, ScriptedTradeScriptDatagetScript (const ScriptedTrade &scriptedTrade, const ScriptLibraryData &scriptLibrary, const std::string &purpose, const bool fallBackOnEmptyPurpose)
 
ASTNodePtr parseScript (const std::string &code)
 
std::pair< std::string, Period > convertIndexToCamCorrelationEntry (const std::string &i)
 
void checkDuplicateName (const QuantLib::ext::shared_ptr< Context > context, const std::string &name)
 
QuantLib::ext::shared_ptr< ContextmakeContext (Size nPaths, const std::string &gridCoarsening, const std::vector< std::string > &schedulesEligibleForCoarsening, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceData, const std::vector< ScriptedTradeEventData > &events, const std::vector< ScriptedTradeValueTypeData > &numbers, const std::vector< ScriptedTradeValueTypeData > &indices, const std::vector< ScriptedTradeValueTypeData > &currencies, const std::vector< ScriptedTradeValueTypeData > &daycounters)
 
void addNewSchedulesToContext (QuantLib::ext::shared_ptr< Context > context, const std::vector< ScriptedTradeScriptData::NewScheduleData > &newSchedules)
 
void amendContextVariablesSizes (QuantLib::ext::shared_ptr< Context > context, const Size newSize)
 
std::ostream & operator<< (std::ostream &o, const IndexInfo &i)
 
QuantLib::ext::shared_ptr< QuantExt::CommodityIndexparseScriptedCommodityIndex (const std::string &indexName, const QuantLib::Date &obsDate)
 
QL_DEPRECATED_DISABLE_WARNING std::pair< QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex >, std::string > parseScriptedInflationIndex (const std::string &indexName)
 
QL_DEPRECATED_ENABLE_WARNING std::string scriptedIndexName (const QuantLib::ext::shared_ptr< Underlying > &underlying)
 
Size getInflationSimulationLag (const QuantLib::ext::shared_ptr< ZeroInflationIndex > &index)
 
std::map< std::string, std::vector< Real > > getCalibrationStrikes (const std::vector< ScriptedTradeScriptData::CalibrationData > &calibrationSpec, const QuantLib::ext::shared_ptr< Context > &context)
 
std::ostream & operator<< (std::ostream &out, const EventVec &a)
 
std::ostream & operator<< (std::ostream &out, const CurrencyVec &a)
 
std::ostream & operator<< (std::ostream &out, const IndexVec &a)
 
std::ostream & operator<< (std::ostream &out, const DaycounterVec &a)
 
bool deterministic (const ValueType &v)
 
Size size (const ValueType &v)
 
bool operator== (const EventVec &a, const EventVec &b)
 
bool operator== (const CurrencyVec &a, const CurrencyVec &b)
 
bool operator== (const IndexVec &a, const IndexVec &b)
 
bool operator== (const DaycounterVec &a, const DaycounterVec &b)
 
ValueType operator+ (const ValueType &x, const ValueType &y)
 
ValueType operator- (const ValueType &x, const ValueType &y)
 
ValueType operator* (const ValueType &x, const ValueType &y)
 
ValueType operator/ (const ValueType &x, const ValueType &y)
 
ValueType min (const ValueType &x, const ValueType &y)
 
ValueType max (const ValueType &x, const ValueType &y)
 
ValueType pow (const ValueType &x, const ValueType &y)
 
ValueType operator- (const ValueType &x)
 
ValueType abs (const ValueType &x)
 
ValueType exp (const ValueType &x)
 
ValueType log (const ValueType &x)
 
ValueType sqrt (const ValueType &x)
 
ValueType normalCdf (const ValueType &x)
 
ValueType normalPdf (const ValueType &x)
 
ValueType typeSafeAssign (ValueType &x, const ValueType &y)
 
Filter equal (const ValueType &x, const ValueType &y)
 
Filter notequal (const ValueType &x, const ValueType &y)
 
Filter lt (const ValueType &x, const ValueType &y)
 
Filter gt (const ValueType &x, const ValueType &y)
 
Filter leq (const ValueType &x, const ValueType &y)
 
Filter geq (const ValueType &x, const ValueType &y)
 
Filter logicalNot (const ValueType &x)
 
Filter logicalAnd (const ValueType &x, const ValueType &y)
 
Filter logicalOr (const ValueType &x, const ValueType &y)
 
QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexDecompositionloadCurrencyHedgedIndexDecomposition (const std::string &name, const QuantLib::ext::shared_ptr< ReferenceDataManager > &refDataMgr, const QuantLib::ext::shared_ptr< CurveConfigurations > &curveConfigs)
 
QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexDecompositionloadCurrencyHedgedIndexDecomposition (const std::string &name, const QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > &refDataMgr, const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &curveConfigs)
 
void dataBuilders ()
 
QuantLib::ext::shared_ptr< DateGridgenerateShiftedDateGrid (const QuantLib::ext::shared_ptr< DateGrid > &dg, const QuantLib::Period &shift)
 
QuantLib::ext::shared_ptr< DateGridcombineDateGrids (const QuantLib::ext::shared_ptr< DateGrid > &dg1, const QuantLib::ext::shared_ptr< DateGrid > &dg2)
 
vector< vector< string > > flowAnalysis (const QuantLib::Leg &)
 Flow Analysis. More...
 
QuantExt::CompiledFormula parseFormula (const std::string &text, std::vector< std::string > &variables)
 
template<class T >
parseFormula (const std::string &text, const std::function< T(std::string)> &variableMapping={})
 
double gtZero (const double x)
 
double geqZero (const double x)
 
double max (const double x, const double y)
 
double min (const double x, const double y)
 
void checkOneToOne (const map< string, QuantLib::ext::shared_ptr< OvernightIndex > > &onIndices, const map< string, QuantLib::ext::shared_ptr< IborIndexParser > > &iborIndices)
 
QuantLib::ext::shared_ptr< FxIndexparseFxIndex (const string &s, const Handle< Quote > &fxSpot=Handle< Quote >(), const Handle< YieldTermStructure > &sourceYts=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &targetYts=Handle< YieldTermStructure >(), const bool useConventions=false)
 Convert std::string to QuantExt::FxIndex. More...
 
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2parseEquityIndex (const string &s)
 Convert std::string (e.g SP5) to QuantExt::EquityIndex. More...
 
QuantLib::ext::shared_ptr< QuantLib::Index > parseGenericIndex (const string &s)
 Convert std::string (GENERIC-...) to QuantExt::Index. More...
 
bool tryParseIborIndex (const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
 Try to convert std::string to QuantLib::IborIndex. More...
 
QuantLib::ext::shared_ptr< IborIndexparseIborIndex (const string &s, const Handle< YieldTermStructure > &h=Handle< YieldTermStructure >())
 Convert std::string to QuantLib::IborIndex. More...
 
QuantLib::ext::shared_ptr< IborIndexparseIborIndex (const string &s, string &tenor, const Handle< YieldTermStructure > &h)
 
bool isGenericIborIndex (const string &indexName)
 Return true if the indexName is that of a generic ibor index, otherwise false. More...
 
pair< bool, QuantLib::ext::shared_ptr< ZeroInflationIndex > > isInflationIndex (const string &indexName)
 
bool isEquityIndex (const std::string &indexName)
 Return true if the indexName is that of an EquityIndex, otherwise false. More...
 
bool isCommodityIndex (const std::string &indexName)
 Return true if the indexName is that of an CommodityIndex, otherwise false. More...
 
bool isGenericIndex (const string &indexName)
 
QuantLib::ext::shared_ptr< SwapIndex > parseSwapIndex (const string &s, const Handle< YieldTermStructure > &forwarding=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &discounting=Handle< YieldTermStructure >())
 Convert std::string to QuantLib::SwapIndex. More...
 
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex (const string &s, const Handle< ZeroInflationTermStructure > &h=Handle< ZeroInflationTermStructure >())
 Convert std::string to QuantLib::ZeroInflationIndex. More...
 
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex (const string &s, bool isInterpolated, const Handle< ZeroInflationTermStructure > &h)
 
QuantLib::ext::shared_ptr< BondIndexparseBondIndex (const string &s)
 Convert std::string to QuantExt::BondIndex. More...
 
QuantLib::ext::shared_ptr< ConstantMaturityBondIndexparseConstantMaturityBondIndex (const string &s)
 Convert std::string to QuantExt::ConstantMaturityBondIndex. More...
 
QuantLib::ext::shared_ptr< QuantExt::CommodityIndexparseCommodityIndex (const string &name, bool hasPrefix, const Handle< PriceTermStructure > &ts, const Calendar &cal, const bool enforceFutureIndex)
 
QuantLib::ext::shared_ptr< Index > parseIndex (const string &s)
 Convert std::string to QuantLib::Index. More...
 
bool isOvernightIndex (const std::string &indexName)
 Return true if the indexName is that of an overnight index, otherwise false. More...
 
bool isBmaIndex (const std::string &indexName)
 Return true if the indexName is that of an bma/sifma index, otherwise false. More...
 
string internalIndexName (const string &indexName)
 
bool isFxIndex (const std::string &indexName)
 
std::string inverseFxIndex (const std::string &indexName)
 
QuantLib::ext::shared_ptr< IborIndexparseIborIndex (const std::string &strIndex, std::string &outTenor, const QuantLib::Handle< QuantLib::YieldTermStructure > &h=QuantLib::Handle< QuantLib::YieldTermStructure >())
 Convert std::string to QuantLib::IborIndex and return the tenor string component of the index. More...
 
QuantLib::ext::shared_ptr< QuantExt::CommodityIndexparseCommodityIndex (const std::string &name, bool hasPrefix=true, const QuantLib::Handle< QuantExt::PriceTermStructure > &ts=QuantLib::Handle< QuantExt::PriceTermStructure >(), const QuantLib::Calendar &cal=QuantLib::NullCalendar(), const bool enforceFutureIndex=true)
 
std::pair< QuantLib::Date, QuantLib::Period > getStartAndLag (const QuantLib::Date &asof, const InflationSwapConvention &conv)
 
QuantLib::Date getInflationSwapStart (const QuantLib::Date &asof, const InflationSwapConvention &conv)
 
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Category &category)
 
std::ostream & operator<< (std::ostream &out, const StructuredMessage::Group &group)
 
string xccyCurveName (const string &ccyCode)
 
Handle< YieldTermStructure > xccyYieldCurve (const QuantLib::ext::shared_ptr< Market > &market, const string &ccyCode, const string &configuration)
 
Handle< YieldTermStructure > xccyYieldCurve (const QuantLib::ext::shared_ptr< Market > &market, const string &ccyCode, bool &outXccyExists, const string &configuration)
 
Handle< YieldTermStructure > indexOrYieldCurve (const QuantLib::ext::shared_ptr< Market > &market, const std::string &name, const std::string &configuration)
 
std::string securitySpecificCreditCurveName (const std::string &securityId, const std::string &creditCurveId)
 
std::string creditCurveNameFromSecuritySpecificCreditCurveName (const std::string &name)
 
QuantLib::Handle< QuantExt::CreditCurvesecuritySpecificCreditCurve (const QuantLib::ext::shared_ptr< Market > &market, const std::string &securityId, const std::string &creditCurveId, const std::string &configuration)
 
std::string prettyPrintInternalCurveName (std::string name)
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexbuildFxIndex (const string &fxIndex, const string &domestic, const string &foreign, const QuantLib::ext::shared_ptr< Market > &market, const string &configuration, bool useXbsCurves)
 
std::tuple< Natural, Calendar, BusinessDayConvention > getFxIndexConventions (const string &index)
 
std::pair< std::string, QuantLib::Period > splitCurveIdWithTenor (const std::string &creditCurveId)
 
QuantLib::Handle< QuantExt::CreditCurveindexCdsDefaultCurve (const QuantLib::ext::shared_ptr< Market > &market, const std::string &creditCurveId, const std::string &config)
 
Date parseDate (const string &s)
 Convert std::string to QuantLib::Date. More...
 
Real parseReal (const string &s)
 Convert text to Real. More...
 
Real parseRealOrNull (const string &s)
 Convert text to Real, empty string to Null<Real>() More...
 
bool tryParseReal (const string &s, QuantLib::Real &result)
 Attempt to convert text to Real. More...
 
Integer parseInteger (const string &s)
 Convert text to QuantLib::Integer. More...
 
bool parseBool (const string &s)
 Convert text to bool. More...
 
Calendar parseCalendar (const string &s)
 Convert text to QuantLib::Calendar. More...
 
bool isOnePeriod (const string &s)
 return true if s represents a period of the form [0-9][D|W|M|Y] (i.e. 1Y6M would return false) More...
 
Period parsePeriod (const string &s)
 Convert text to QuantLib::Period. More...
 
BusinessDayConvention parseBusinessDayConvention (const string &s)
 Convert text to QuantLib::BusinessDayConvention. More...
 
DayCounter parseDayCounter (const string &s)
 Convert text to QuantLib::DayCounter. More...
 
Currency parseCurrency (const string &s)
 Convert text to QuantLib::Currency. More...
 
QuantExt::ConfigurableCurrency::Type parseCurrencyType (const string &s)
 Convert text to QuantExt::ConfigurableCurrency::Type (Major, Minor, Metal, Crypto) More...
 
Currency parseMinorCurrency (const string &s)
 Convert text to QuantLib::Currency for minor currencies e.g GBp -> GBPCurrency() More...
 
Currency parseCurrencyWithMinors (const string &s)
 Convert text to QuantLib::Currency. More...
 
pair< Currency, Currency > parseCurrencyPair (const string &s, const string &delimiters)
 Convert text to std::pair<QuantLib::Currency, QuantLib::Currency> More...
 
bool checkCurrency (const string &code)
 check for vaid currency code, including minors and pseudo currencies More...
 
bool isPseudoCurrency (const string &code)
 check for pseudo currency = precious metal or crypto currency *‍/ More...
 
bool isPreciousMetal (const string &code)
 check for precious metal *‍/ More...
 
bool isCryptoCurrency (const string &code)
 check for crypto currency *‍/ More...
 
QuantLib::Real convertMinorToMajorCurrency (const std::string &s, QuantLib::Real value)
 Convert a value from a minor ccy to major. More...
 
DateGeneration::Rule parseDateGenerationRule (const string &s)
 Convert text to QuantLib::DateGeneration::Rule. More...
 
Frequency parseFrequency (const string &s)
 Convert text to QuantLib::Frequency. More...
 
Compounding parseCompounding (const string &s)
 Convert text to QuantLib::Compounding;. More...
 
QuantLib::Bond::Price::Type parseBondPriceType (const string &s)
 Convert text to QuantLib::Bond::Price::Type. More...
 
Position::Type parsePositionType (const string &s)
 Convert text to QuantLib::Position::Type. More...
 
Protection::Side parseProtectionSide (const string &s)
 Convert text to QuantLib::Protection::Side. More...
 
Settlement::Type parseSettlementType (const string &s)
 Convert text to QuantLib::Settlement::Type. More...
 
Settlement::Method parseSettlementMethod (const string &s)
 Convert text to QuantLib::Settlement::Method. More...
 
Exercise::Type parseExerciseType (const string &s)
 Convert text to QuantLib::Exercise::Type. More...
 
Option::Type parseOptionType (const string &s)
 Convert text to QuantLib::Option::Type. More...
 
boost::variant< QuantLib::Date, QuantLib::Period > parseDateOrPeriod (const string &s)
 Convert text to QuantLib::Period or QuantLib::Date. More...
 
void parseDateOrPeriod (const string &s, Date &d, Period &p, bool &isDate)
 
QuantLib::LsmBasisSystem::PolynomialType parsePolynomType (const std::string &s)
 Convert text to QuantLib::LsmBasisSystem::PolynomialType. More...
 
std::ostream & operator<< (std::ostream &os, QuantLib::LsmBasisSystem::PolynomialType a)
 Write QuantLib::LsmBasisSystem::PolynomialType to stream. More...
 
SobolBrownianGenerator::Ordering parseSobolBrownianGeneratorOrdering (const std::string &s)
 Convert text to QuantLib::SobolBrownianGenerator::Ordering. More...
 
SobolRsg::DirectionIntegers parseSobolRsgDirectionIntegers (const std::string &s)
 Convert text to QuantLib::SobolRsg::DirectionIntegers. More...
 
Weekday parseWeekday (const string &s)
 
Month parseMonth (const string &s)
 
PaymentLag parsePaymentLag (const string &s)
 Convert text to PaymentLag. More...
 
std::vector< string > parseListOfValues (string s, const char escape, const char delim, const char quote)
 
AmortizationType parseAmortizationType (const std::string &s)
 
SequenceType parseSequenceType (const std::string &s)
 Convert string to sequence type. More...
 
QuantLib::CPI::InterpolationType parseObservationInterpolation (const std::string &s)
 Convert string to observation interpolation. More...
 
FdmSchemeDesc parseFdmSchemeDesc (const std::string &s)
 Convert string to fdm scheme desc. More...
 
AssetClass parseAssetClass (const std::string &s)
 Convert text to ore::data::AssetClass. More...
 
std::ostream & operator<< (std::ostream &os, AssetClass a)
 Write ore::data::AssetClass to stream. More...
 
DeltaVolQuote::AtmType parseAtmType (const std::string &s)
 Convert text to QuantLib::DeltaVolQuote::AtmType. More...
 
DeltaVolQuote::DeltaType parseDeltaType (const std::string &s)
 Convert text to QuantLib::DeltaVolQuote::DeltaType. More...
 
Extrapolation parseExtrapolation (const string &s)
 Parse Extrapolation from string. More...
 
std::ostream & operator<< (std::ostream &os, Extrapolation extrap)
 Write Extrapolation, extrap, to stream. More...
 
VolatilityType parseVolatilityQuoteType (const string &s)
 
CapFloor::Type parseCapFloorType (const string &s)
 
YoYInflationCapFloor::Type parseYoYInflationCapFloorType (const string &s)
 
QuantExt::CrossAssetModel::AssetType parseCamAssetType (const string &s)
 
pair< string, string > parseBoostAny (const boost::any &anyType, Size precision)
 
QuantLib::RateAveraging::Type parseOvernightIndexFutureNettingType (const std::string &s)
 Convert text to QuantLib::RateAveraging::Type. More...
 
std::ostream & operator<< (std::ostream &os, QuantLib::RateAveraging::Type t)
 Write QuantLib::RateAveraging::Type to stream. More...
 
FutureConvention::DateGenerationRule parseFutureDateGenerationRule (const std::string &s)
 Convert text to FutureConvention::DateGeneration. More...
 
std::ostream & operator<< (std::ostream &os, FutureConvention::DateGenerationRule t)
 Write QuantLib::RateAveraging::Type to stream. More...
 
InflationSwapConvention::PublicationRoll parseInflationSwapPublicationRoll (const std::string &s)
 Convert text to InflationSwapConvention::PublicationRoll. More...
 
QuantLib::Rounding::Type parseRoundingType (const std::string &s)
 Convert text to QuantLib::Rounding. More...
 
Barrier::Type parseBarrierType (const string &s)
 Convert std::string to QuantLib::BarrierType. More...
 
DoubleBarrier::Type parseDoubleBarrierType (const string &s)
 Convert std::string to QuantLib::DoubleBarrierType. More...
 
ostream & operator<< (std::ostream &os, InflationSwapConvention::PublicationRoll pr)
 Write InflationSwapConvention::PublicationRoll to stream. More...
 
std::ostream & operator<< (std::ostream &os, SobolBrownianGenerator::Ordering t)
 Write QuantLib::SobolBrownianGenerator::Ordering to stream. More...
 
std::ostream & operator<< (std::ostream &os, SobolRsg::DirectionIntegers t)
 Write QuantLib::SobolRsg::DirectionIntegers to stream. More...
 
std::ostream & operator<< (std::ostream &os, QuantExt::CrossAssetModel::Discretization type)
 Enum to string used in ScenarioGeneratorData's toXML. More...
 
ADCP parseAveragingDataPeriod (const std::string &s)
 Convert text to CommodityFutureConvention::AveragingData::CalculationPeriod. More...
 
ostream & operator<< (std::ostream &os, CommodityFutureConvention::AveragingData::CalculationPeriod cp)
 Write CommodityFutureConvention::AveragingData::CalculationPeriod to stream. More...
 
PriceSegment::Type parsePriceSegmentType (const std::string &s)
 Convert text to PriceSegment::Type. More...
 
ostream & operator<< (std::ostream &os, PriceSegment::Type pst)
 Write PriceSegment::Type to stream. More...
 
CommodityQuantityFrequency parseCommodityQuantityFrequency (const std::string &s)
 Convert text to QuantExt::CommodityQuantityFrequency. More...
 
ostream & operator<< (std::ostream &os, QuantExt::CommodityQuantityFrequency cqf)
 Write QuantExt::CommodityQuantityFrequency to stream. More...
 
ostream & operator<< (ostream &os, Rounding::Type t)
 
CdsOption::StrikeType parseCdsOptionStrikeType (const string &s)
 
Average::Type parseAverageType (const std::string &s)
 
QuantExt::BondIndex::PriceQuoteMethod parsePriceQuoteMethod (const std::string &s)
 
std::ostream & operator<< (std::ostream &os, QuantExt::BondIndex::PriceQuoteMethod)
 Write PriceQuoteMethod to stream. More...
 
std::vector< std::string > getCorrelationTokens (const std::string &name)
 Helper function to get the two tokens in a correlation name Index2:Index1. More...
 
string fxDominance (const string &s1, const string &s2)
 Convert FX pair to market standard dominance. More...
 
string normaliseFxIndex (const std::string &indexName)
 Convert FX index name to market standard dominance. More...
 
MomentType parseMomentType (const std::string &s)
 Convert text to ore::data::MomentType. More...
 
CreditPortfolioSensitivityDecomposition parseCreditPortfolioSensitivityDecomposition (const std::string &s)
 Convert text to CreditPortfolioSensitivitiyDecomposition. More...
 
std::ostream & operator<< (std::ostream &os, const CreditPortfolioSensitivityDecomposition d)
 Output operator for CreditPortfolioSensitivityDecomposition. More...
 
QuantLib::Pillar::Choice parsePillarChoice (const std::string &s)
 Convert text to QuantLib::Pillar::Choice. More...
 
QuantExt::McMultiLegBaseEngine::RegressorModel parseRegressorModel (const std::string &s)
 Convert text to QuantExt::McMultiLegBaseEngine::RegressorModel. More...
 
MporCashFlowMode parseMporCashFlowMode (const std::string &s)
 Convert text to MporCashFlowMode. More...
 
std::ostream & operator<< (std::ostream &os, MporCashFlowMode t)
 Write MporCashFlowMode to stream. More...
 
SabrParametricVolatility::ModelVariant parseSabrParametricVolatilityModelVariant (const std::string &s)
 Parse SabrParametricVolatility::ModelVariant. More...
 
std::ostream & operator<< (std::ostream &out, SabrParametricVolatility::ModelVariant m)
 
std::ostream & operator<< (std::ostream &os, Exercise::Type type)
 
void parseDateOrPeriod (const string &s, QuantLib::Date &d, QuantLib::Period &p, bool &isDate)
 Convert text to QuantLib::Period or QuantLib::Date (deprecated version) More...
 
template<class T >
std::vector< T > parseListOfValues (string s, std::function< T(string)> parser)
 Convert comma separated list of values to vector of values. More...
 
template<class T >
std::vector< T > parseVectorOfValues (std::vector< std::string > str, std::function< T(string)> parser)
 
template<class T >
bool tryParse (const std::string &str, T &obj, std::function< T(const std::string &)> parser)
 
bool tryParseCurrency (const std::string &str, Currency &obj)
 
std::ostream & operator<< (std::ostream &out, QuantExt::SabrParametricVolatility::ModelVariant m)
 Write SabrParametricVolatility::ModelVariant. More...
 
std::ostream & operator<< (std::ostream &os, QuantLib::Exercise::Type type)
 Write QuantLib::Exercise::Type. More...
 
Strike parseStrike (const std::string &s)
 Convert text to Strike. More...
 
std::ostream & operator<< (std::ostream &out, const Strike &s)
 Convert Strike to text. More...
 
bool operator== (const Strike &s1, const Strike &s2)
 Logical comparison of strikes. More...
 
QuantLib::Real computeAbsoluteStrike (const Strike &s, const QuantLib::Real atm, const QuantLib::Real atmf)
 Convenience function that computes an absolute strike. More...
 
std::ostream & operator<< (std::ostream &out, const TimePeriod &t)
 
TimePeriod totalTimePeriod (std::vector< std::string > timePeriods, Size mporDays, const QuantLib::Calendar &calendar)
 
std::string to_string (const Date &date)
 
string to_string (bool aBool)
 Convert bool to std::string. More...
 
std::string to_string (const Period &period)
 
std::string to_string (const QuantLib::Date &date)
 Convert QuantLib::Date to std::string. More...
 
std::string to_string (const QuantLib::Period &period)
 Convert QuantLib::Period to std::string. More...
 
template<class T >
std::string to_string (const std::vector< T > &vec, const std::string &sep=",")
 Convert vector to std::string. More...
 
template<class T >
std::string to_string (const std::set< T > &set, const std::string &sep=",")
 Convert set to std::string. More...
 
template<class T >
std::string to_string (const T &t)
 Convert type to std::string. More...
 
template<typename T , typename Compare >
std::vector< std::size_t > sort_permutation (const std::vector< T > &vec, Compare &compare)
 
template<typename T >
std::vector< T > apply_permutation (const std::vector< T > &vec, const std::vector< std::size_t > &p)
 
template<typename T >
void apply_permutation_in_place (std::vector< T > &vec, const std::vector< std::size_t > &p)
 
void partitionQuotes (const set< string > &quoteNames, set< string > &names, set< string > &regexes)
 
void partitionQuotes (const set< string > &quoteNames, set< string > &names, set< string > &regexes, std::set< std::string > &prefixes, const bool aggressivePrefixes)
 
template<class C >
boost::optional< WildcardgetUniqueWildcard (const C &c)
 checks if at most one element in C has a wild card and returns it in this case More...
 
Utilities for building QuantLib Legs
QuantExt::Leg makeEquityMarginLeg (const ore::data::LegData &data, const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &equityCurve, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex=nullptr, const QuantLib::Date &openEndDateReplacement=QuantLib::Null< QuantLib::Date >())
 
Leg makeSimpleLeg (const LegData &data)
 
Leg makeFixedLeg (const LegData &data, const QuantLib::Date &openEndDateReplacement)
 
Leg makeZCFixedLeg (const LegData &data, const QuantLib::Date &openEndDateReplacement)
 
Leg makeIborLeg (const LegData &data, const QuantLib::ext::shared_ptr< IborIndex > &index, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
 
Leg makeOISLeg (const LegData &data, const QuantLib::ext::shared_ptr< OvernightIndex > &index, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
 
Leg makeBMALeg (const LegData &data, const QuantLib::ext::shared_ptr< QuantExt::BMAIndexWrapper > &indexWrapper, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::Date &openEndDateReplacement)
 
Leg makeCPILeg (const LegData &data, const QuantLib::ext::shared_ptr< ZeroInflationIndex > &index, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::Date &openEndDateReplacement)
 
Leg makeYoYLeg (const LegData &data, const QuantLib::ext::shared_ptr< InflationIndex > &index, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::Date &openEndDateReplacement)
 
Leg makeCMSLeg (const LegData &data, const QuantLib::ext::shared_ptr< QuantLib::SwapIndex > &swapIndex, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
 
Leg makeCMBLeg (const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
 
Leg makeDigitalCMSLeg (const LegData &data, const QuantLib::ext::shared_ptr< QuantLib::SwapIndex > &swapIndex, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
 
Leg makeCMSSpreadLeg (const LegData &data, const QuantLib::ext::shared_ptr< QuantLib::SwapSpreadIndex > &swapSpreadIndex, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
 
Leg makeDigitalCMSSpreadLeg (const LegData &data, const QuantLib::ext::shared_ptr< QuantLib::SwapSpreadIndex > &swapSpreadIndex, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::Date &openEndDateReplacement)
 
Real currentNotional (const Leg &leg)
 
Real originalNotional (const Leg &leg)
 
vector< double > buildAmortizationScheduleFixedAmount (const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
 
vector< double > buildAmortizationScheduleRelativeToInitialNotional (const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
 
vector< double > buildAmortizationScheduleRelativeToPreviousNotional (const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
 
vector< double > buildAmortizationScheduleFixedAnnuity (const vector< double > &notionals, const vector< double > &rates, const Schedule &schedule, const AmortizationData &data, const DayCounter &dc)
 
void applyAmortization (std::vector< Real > &notionals, const LegData &data, const Schedule &schedule, const bool annuityAllowed, const std::vector< Real > &rates)
 
void applyIndexing (Leg &leg, const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, RequiredFixings &requiredFixings, const QuantLib::Date &openEndDateReplacement, const bool useXbsCurves)
 
Leg joinLegs (const std::vector< Leg > &legs)
 
Leg buildNotionalLeg (const LegData &data, const Leg &leg, RequiredFixings &requiredFixings, const QuantLib::ext::shared_ptr< Market > &market, const std::string &configuration)
 
std::string getCmbLegCreditRiskCurrency (const CMBLegData &ld, const QuantLib::ext::shared_ptr< ReferenceDataManager > &refData)
 
std::pair< std::string, SimmCreditQualifierMappinggetCmbLegCreditQualifierMapping (const CMBLegData &ld, const QuantLib::ext::shared_ptr< ReferenceDataManager > &refData, const std::string &tradeId, const std::string &tradeType)
 
Leg makeNotionalLeg (const Leg &refLeg, const bool initNomFlow, const bool finalNomFlow, const bool amortNomFlow, const QuantLib::Natural notionalPaymentLag, const BusinessDayConvention paymentConvention, const Calendar paymentCalendar, const bool excludeIndexing=true)
 
Leg makeEquityLeg (const LegData &data, const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &equityCurve, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex=nullptr, const QuantLib::Date &openEndDateReplacement=Null< Date >())
 
template<typename T >
vector< T > buildScheduledVector (const vector< T > &values, const vector< string > &dates, const Schedule &schedule, const bool checkAllValuesAppearInResult=false)
 
template<typename T >
vector< T > normaliseToSchedule (const vector< T > &values, const Schedule &schedule, const T &defaultValue)
 
template<typename T >
vector< T > buildScheduledVectorNormalised (const vector< T > &values, const vector< string > &dates, const Schedule &schedule, const T &defaultValue, const bool checkAllValuesAppearInResult=false)
 
template<typename T >
vector< T >::const_iterator checkAllValuesAppearInScheduledVector (const vector< T > &scheduledVecotr, const vector< T > &inputValues)
 

Variables

const BmType volatilityTypeMap
 
const set< string > validInterps = {"Linear", "LinearFlat", "BackwardFlat", "Cubic", "CubicFlat"}
 
boost::bimap< std::string, TRS::FundingData::NotionalTypetypes
 
const string xccyCurveNamePrefix = "__XCCY__"
 

Compare <code>CorrelationFactor</code>s.

typedef std::pair< CorrelationFactor, CorrelationFactorCorrelationKey
 
bool operator< (const CorrelationFactor &lhs, const CorrelationFactor &rhs)
 
bool operator== (const CorrelationFactor &lhs, const CorrelationFactor &rhs)
 
bool operator!= (const CorrelationFactor &lhs, const CorrelationFactor &rhs)
 
ostream & operator<< (std::ostream &out, const CorrelationFactor &f)
 Allow CorrelationFactors to be written. More...
 
CorrelationFactor parseCorrelationFactor (const string &name, const char separator)
 

Detailed Description

Data Checks namespace

Typedef Documentation

◆ BmType

Definition at line 44 of file capfloorvolcurveconfig.cpp.

◆ YieldCurveConfigMap

using YieldCurveConfigMap = std::map<string, QuantLib::ext::shared_ptr<YieldCurveConfig> >

Definition at line 714 of file yieldcurveconfig.hpp.

◆ Crv

Definition at line 444 of file commoditycurve.cpp.

◆ BS

Definition at line 445 of file commoditycurve.cpp.

◆ Helpers

Definition at line 75 of file infjybuilder.cpp.

◆ CachingPricingEngineBuilder

using CachingPricingEngineBuilder = CachingEngineBuilder<T, PricingEngine, Args...>

Definition at line 83 of file cachingenginebuilder.hpp.

◆ CachingCouponPricerBuilder

Definition at line 86 of file cachingenginebuilder.hpp.

◆ CachingInflationCouponPricerBuilder

using CachingInflationCouponPricerBuilder = CachingEngineBuilder<T, InflationCouponPricer, Args...>

Definition at line 89 of file cachingenginebuilder.hpp.

◆ CachingInflationCashFlowPricerBuilder

Definition at line 92 of file cachingenginebuilder.hpp.

◆ ASI

Definition at line 141 of file creditdefaultswapoption.cpp.

◆ EquityPositionTrsUnderlyingBuilder

Definition at line 121 of file trsunderlyingbuilder.hpp.

◆ CommodityPositionTrsUnderlyingBuilder

Definition at line 122 of file trsunderlyingbuilder.hpp.

◆ PaymentLag

typedef boost::variant<QuantLib::Period, QuantLib::Natural> PaymentLag

Definition at line 32 of file types.hpp.

◆ ASTNodePtr

using ASTNodePtr = QuantLib::ext::shared_ptr<ASTNode>

Definition at line 46 of file ast.hpp.

◆ ScriptGrammarIterator

using ScriptGrammarIterator = boost::spirit::line_pos_iterator<std::string::const_iterator>

Definition at line 46 of file grammar.hpp.

◆ ValueType

Definition at line 60 of file value.hpp.

◆ CorrelationKey

The key for storing the correlation data is the pair of factors.

Definition at line 61 of file correlationmatrix.hpp.

◆ file_sink

typedef boost::log::sinks::synchronous_sink<boost::log::sinks::text_file_backend> file_sink

Definition at line 120 of file log.hpp.

◆ text_sink

typedef boost::log::sinks::synchronous_sink<boost::log::sinks::text_ostream_backend> text_sink

Definition at line 121 of file log.hpp.

◆ ADCP

Definition at line 1135 of file parsers.cpp.

◆ PST

Definition at line 1157 of file parsers.cpp.

◆ CQF

Definition at line 1191 of file parsers.cpp.

◆ XMLNode

typedef rapidxml::xml_node<char> XMLNode

Definition at line 60 of file xmlutils.hpp.

Enumeration Type Documentation

◆ YieldCurveType

enum class YieldCurveType
strong
Enumerator
Discount 
Yield 
EquityDividend 

Definition at line 59 of file market.hpp.

59 {
60 Discount = 0, // Chosen to match MarketObject::DiscountCurve
61 Yield = 1, // Chosen to match MarketObject::YieldCurve
63};

◆ MarketObject

enum class MarketObject
strong
Enumerator
DiscountCurve 
YieldCurve 
IndexCurve 
SwapIndexCurve 
FXSpot 
FXVol 
SwaptionVol 
DefaultCurve 
CDSVol 
BaseCorrelation 
CapFloorVol 
ZeroInflationCurve 
YoYInflationCurve 
ZeroInflationCapFloorVol 
YoYInflationCapFloorVol 
EquityCurve 
EquityVol 
Security 
CommodityCurve 
CommodityVolatility 
Correlation 
YieldVol 

Definition at line 65 of file market.hpp.

65 {
66 DiscountCurve = 0,
67 YieldCurve = 1,
68 IndexCurve = 2,
70 FXSpot = 4,
71 FXVol = 5,
72 SwaptionVol = 6,
73 DefaultCurve = 7,
74 CDSVol = 8,
76 CapFloorVol = 10,
81 EquityCurve = 15,
82 EquityVol = 16,
83 Security = 17,
84 CommodityCurve = 18,
86 Correlation = 20,
87 YieldVol = 21
88};
Wrapper class for building Swaption volatility structures.
Wrapper class for building Equity curves (spot quote, yield term structure, risk free IR term structu...
Definition: equitycurve.hpp:44
Wrapper class for holding Bond Spread and recovery rate quotes.
Definition: security.hpp:39
Wrapper class for building yield term structures.
Definition: yieldcurve.hpp:61

◆ ParamType

enum class ParamType
strong

Supported calibration parameter type.

Enumerator
Constant 
Piecewise 

Definition at line 35 of file irmodeldata.hpp.

35 {
37 Piecewise // i.e. time-dependent, but piecewise constant
38};

◆ CalibrationType

enum class CalibrationType
strong

Supported calibration types.

Enumerator
Bootstrap 

Choose this option if the component's calibration strategy is expected to yield a perfect match of model to market prices. For example, this can be achieved when calibrating an IR component to a series of co-terminal swaptions with given mean reversion speed and piecewise volatility function (alpha) where jump times coincide with expiry dates in the swaption basket. Similarly, when calibrating an FX component to a series of FX Options. The calibration routine will throw an exception if no perfect match is achieved.

BestFit 

Choose this if no perfect match like above can be expected, for example when an IR component with constant parameters is calibrated to a basket of swaptions. The calibration routine will consequently not throw an exception when the match is imperfect.

None 

No calibration

Definition at line 46 of file irmodeldata.hpp.

46 {
47 /*! Choose this option if the component's calibration strategy is expected to
48 yield a perfect match of model to market prices. For example, this can be
49 achieved when calibrating an IR component to a series of co-terminal
50 swaptions with given mean reversion speed and piecewise volatility
51 function (alpha) where jump times coincide with expiry dates in the swaption
52 basket. Similarly, when calibrating an FX component to a series of FX Options.
53 The calibration routine will throw an exception if no perfect match is
54 achieved.
55 */
57 /*! Choose this if no perfect match like above can be expected, for example when
58 an IR component with constant parameters is calibrated to a basket of swaptions.
59 The calibration routine will consequently not throw an exception when the match
60 is imperfect.
61 */
62 BestFit,
63 /*! No calibration
64 */
65 None
66};

◆ CalibrationStrategy

enum class CalibrationStrategy
strong

Supported calibration strategies.

Enumerator
CoterminalATM 
CoterminalDealStrike 
UnderlyingATM 
UnderlyingDealStrike 
None 

Definition at line 69 of file irmodeldata.hpp.

◆ CommodityPayRelativeTo

enum class CommodityPayRelativeTo
strong
Enumerator
CalculationPeriodEndDate 
CalculationPeriodStartDate 
TerminationDate 
FutureExpiryDate 

Definition at line 33 of file commoditylegdata.hpp.

◆ CommodityPriceType

enum class CommodityPriceType
strong
Enumerator
Spot 
FutureSettlement 

Definition at line 42 of file commoditylegdata.hpp.

◆ CommodityPricingDateRule

enum class CommodityPricingDateRule
strong
Enumerator
FutureExpiryDate 
None 

Definition at line 46 of file commoditylegdata.hpp.

◆ CdsTier

enum class CdsTier
strong

CDS debt tier enumeration.

Enumerator
SNRFOR 
SUBLT2 
SNRLAC 
SECDOM 
JRSUBUT2 
PREFT1 
LIEN1 
LIEN2 
LIEN3 

Definition at line 36 of file creditdefaultswapdata.hpp.

◆ CdsDocClause

enum class CdsDocClause
strong

CDS documentation clause enumeration.

Enumerator
CR 
MM 
MR 
XR 
CR14 
MM14 
MR14 
XR14 

Definition at line 41 of file creditdefaultswapdata.hpp.

◆ IsdaRulesDefinitions

enum class IsdaRulesDefinitions
strong

ISDA CDS documentation rules set enumeration.

Enumerator
y2003 
y2014 

Definition at line 47 of file creditdefaultswapdata.hpp.

◆ CreditEventType

enum class CreditEventType
strong

ISDA credit event types enumeration.

Enumerator
BANKRUPTCY 
FAILURE_TO_PAY 
RESTRUCTURING 
OBLIGATION_ACCELERATION 
OBLIGATION_DEFAULT 
REPUDIATION_MORATORIUM 
GOVERNMENTAL_INTERVENTION 

Definition at line 53 of file creditdefaultswapdata.hpp.

◆ CreditEventTiers

enum class CreditEventTiers
strong

ISDA credit event seniority sets enumeration.

Enumerator
SNR 
SUB 
SNRLAC 
SNR_SUB 
SNR_SNRLAC 
SUB_SNRLAC 
SNR_SUB_SNRLAC 

Definition at line 67 of file creditdefaultswapdata.hpp.

◆ MarketContext

enum class MarketContext
strong

Market configuration contexts. Note that there is only one pricing context. If several are needed (for different trade types, different collateral currencies etc.), several engine factories should be set up for each such portfolio subset.

Enumerator
irCalibration 
fxCalibration 
eqCalibration 
pricing 

Definition at line 60 of file enginefactory.hpp.

◆ AmortizationType

enum class AmortizationType
strong
Enumerator
None 
FixedAmount 
RelativeToInitialNotional 
RelativeToPreviousNotional 
Annuity 
LinearToMaturity 

Definition at line 346 of file parsers.hpp.

◆ AssetClass

enum class AssetClass
strong
Enumerator
EQ 
FX 
COM 
IR 
INF 
CR 
BOND 
BOND_INDEX 

Definition at line 374 of file parsers.hpp.

◆ Extrapolation

enum class Extrapolation
strong

Enumeration for holding various extrapolation settings.

Enumerator
None 
UseInterpolator 
Flat 

Definition at line 450 of file parsers.hpp.

◆ MomentType

enum class MomentType
strong
Enumerator
Variance 
Volatility 

Definition at line 559 of file parsers.hpp.

◆ CreditPortfolioSensitivityDecomposition

Enumeration CreditPortfolioSensitivityDecomposition.

Enumerator
Underlying 
NotionalWeighted 
LossWeighted 
DeltaWeighted 

Definition at line 568 of file parsers.hpp.

◆ MporCashFlowMode

Enumerator
Unspecified 
NonePay 
BothPay 
WePay 
TheyPay 

Definition at line 588 of file parsers.hpp.

Function Documentation

◆ volatilityType()

QuantLib::VolatilityType volatilityType ( CapFloorVolatilityCurveConfig::VolatilityType  type)

Imply QuantLib::VolatilityType from CapFloorVolatilityCurveConfig::VolatilityType.

Definition at line 433 of file capfloorvolcurveconfig.cpp.

433 {
434 switch (type) {
435 case CapFloorVolatilityCurveConfig::VolatilityType::Lognormal:
436 case CapFloorVolatilityCurveConfig::VolatilityType::ShiftedLognormal:
437 return ShiftedLognormal;
438 case CapFloorVolatilityCurveConfig::VolatilityType::Normal:
439 return Normal;
440 default:
441 QL_FAIL("Unknown VolatilityType (" << static_cast<int>(type) << ")");
442 }
443}
+ Here is the caller graph for this function:

◆ operator<() [1/14]

Compare two prohibited expiries.

Definition at line 1707 of file conventions.cpp.

1708 {
1709 return lhs.expiry() < rhs.expiry();
1710}
+ Here is the call graph for this function:

◆ operator<<() [1/73]

std::ostream & operator<< ( std::ostream &  out,
Convention::Type  type 
)

Definition at line 2748 of file conventions.cpp.

2748 {
2749 switch (type) {
2750 case Convention::Type::Zero:
2751 return out << "Zero";
2752 case Convention::Type::Deposit:
2753 return out << "Deposit";
2754 case Convention::Type::Future:
2755 return out << "Future";
2756 case Convention::Type::FRA:
2757 return out << "FRA";
2758 case Convention::Type::OIS:
2759 return out << "OIS";
2760 case Convention::Type::Swap:
2761 return out << "Swap";
2762 case Convention::Type::AverageOIS:
2763 return out << "AverageOIS";
2764 case Convention::Type::TenorBasisSwap:
2765 return out << "TenorBasisSwap";
2766 case Convention::Type::TenorBasisTwoSwap:
2767 return out << "TenorBasisTwoSwap";
2768 case Convention::Type::BMABasisSwap:
2769 return out << "BMABasisSwap";
2770 case Convention::Type::FX:
2771 return out << "FX";
2772 case Convention::Type::CrossCcyBasis:
2773 return out << "CrossCcyBasis";
2774 case Convention::Type::CrossCcyFixFloat:
2775 return out << "CrossCcyFixFloat";
2776 case Convention::Type::CDS:
2777 return out << "CDS";
2778 case Convention::Type::IborIndex:
2779 return out << "IborIndex";
2780 case Convention::Type::OvernightIndex:
2781 return out << "OvernightIndex";
2782 case Convention::Type::SwapIndex:
2783 return out << "SwapIndex";
2784 case Convention::Type::ZeroInflationIndex:
2785 return out << "ZeroInflationIndex";
2786 case Convention::Type::InflationSwap:
2787 return out << "InflationSwap";
2788 case Convention::Type::SecuritySpread:
2789 return out << "SecuritySpread";
2790 case Convention::Type::CMSSpreadOption:
2791 return out << "CMSSpreadOption";
2792 case Convention::Type::CommodityForward:
2793 return out << "CommodityForward";
2794 case Convention::Type::CommodityFuture:
2795 return out << "CommodityFuture";
2796 case Convention::Type::FxOption:
2797 return out << "FxOption";
2798 case Convention::Type::BondYield:
2799 return out << "BondYield";
2800 default:
2801 return out << "unknown convention type (" << static_cast<int>(type) << ")";
2802 }
2803}

◆ operator<<() [2/73]

std::ostream & operator<< ( std::ostream &  out,
CorrelationCurveConfig::CorrelationType  t 
)

Definition at line 30 of file correlationcurveconfig.cpp.

30 {
31 switch (t) {
32 case CorrelationCurveConfig::CorrelationType::CMSSpread:
33 return out << "CMSSpread";
34 case CorrelationCurveConfig::CorrelationType::Generic:
35 return out << "Generic";
36 default:
37 QL_FAIL("unknown QuoteType(" << Integer(t) << ")");
38 }
39}

◆ operator<<() [3/73]

std::ostream & operator<< ( std::ostream &  out,
CorrelationCurveConfig::Dimension  t 
)

Definition at line 40 of file correlationcurveconfig.cpp.

40 {
41 switch (t) {
42 case CorrelationCurveConfig::Dimension::ATM:
43 return out << "ATM";
44 case CorrelationCurveConfig::Dimension::Constant:
45 return out << "Constant";
46 default:
47 QL_FAIL("unknown Dimension(" << Integer(t) << ")");
48 }
49}

◆ indexNameLessThan()

bool indexNameLessThan ( const std::string &  index1,
const std::string &  index2 
)

Definition at line 224 of file correlationcurveconfig.cpp.

224 {
225 vector<string> tokens1;
226 boost::split(tokens1, index1, boost::is_any_of("-"));
227 vector<string> tokens2;
228 boost::split(tokens2, index2, boost::is_any_of("-"));
229
230 QL_REQUIRE(tokens1.size() >= 2, "at least two tokens expected in " << index1);
231 QL_REQUIRE(tokens2.size() >= 2, "at least two tokens expected in " << index2);
232
233 Size s1, s2;
234
235 if (tokens1[1] == "CMS")
236 s1 = 4;
237 else if (tokens1[0] == "FX")
238 s1 = 2;
239 else if (tokens1[0] == "EQ")
240 s1 = 1;
241 else if (tokens1[0] == "COMM")
242 s1 = 0;
243 else
244 s1 = 3; // assume Ibor
245
246 if (tokens2[1] == "CMS")
247 s2 = 4;
248 else if (tokens2[0] == "FX")
249 s2 = 2;
250 else if (tokens2[0] == "EQ")
251 s2 = 1;
252 else if (tokens2[0] == "COMM")
253 s2 = 0;
254 else
255 s2 = 3; // assume Ibor
256
257 if (s1 < s2)
258 return true;
259 else if (s2 < s1)
260 return false;
261
262 // both EQ or both COM
263 if (s1 == 0 || s1 == 1)
264 return tokens1[1] < tokens2[1];
265
266 QL_REQUIRE(tokens1.size() >= 3, "at least three tokens expected in " << index1);
267 QL_REQUIRE(tokens2.size() >= 3, "at least three tokens expected in " << index2);
268
269 // both CMS or both Ibor, tenor is the last token (3rd or even 4th for customised CMS indices)
270 if (s1 == 3 || s1 == 4)
271 return parsePeriod(tokens1.back()) < parsePeriod(tokens2.back());
272
273 QL_REQUIRE(tokens1.size() >= 4, "at least four tokens expected in " << index1);
274 QL_REQUIRE(tokens2.size() >= 4, "at least four tokens expected in " << index2);
275
276 // both FX, compare CCY1 then CCY2 alphabetical
277 if (s1 == 2) {
278 return (tokens1[2] + "-" + tokens1[3]) < (tokens2[2] + "-" + tokens2[3]);
279 }
280
281 QL_FAIL("indexNameLessThan(): internal error");
282}
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
+ Here is the call graph for this function:

◆ addMinimalCurves()

void addMinimalCurves ( const char *  nodeName,
const map< string, QuantLib::ext::shared_ptr< T > > &  m,
map< string, QuantLib::ext::shared_ptr< T > > &  n,
CurveSpec::CurveType  curveType,
const map< CurveSpec::CurveType, set< string > >  configIds 
)

Definition at line 33 of file curveconfigurations.cpp.

35 {
36 for (auto it : m) {
37 if ((configIds.count(curveType) && configIds.at(curveType).count(it.first))) {
38 const string& id = it.second->curveID();
39 n[id] = it.second;
40 }
41 }
42}

◆ operator<<() [4/73]

std::ostream & operator<< ( std::ostream &  out,
EquityCurveConfig::Type  t 
)

Definition at line 115 of file equitycurveconfig.cpp.

115 {
116 switch (t) {
117 case EquityCurveConfig::Type::DividendYield:
118 return out << "DividendYield";
119 case EquityCurveConfig::Type::ForwardPrice:
120 return out << "ForwardPrice";
121 case EquityCurveConfig::Type::ForwardDividendPrice:
122 return out << "ForwardDividendPrice";
123 case EquityCurveConfig::Type::OptionPremium:
124 return out << "OptionPremium";
125 case EquityCurveConfig::Type::NoDividends:
126 return out << "NoDividends";
127 default:
128 QL_FAIL("unknown EquityCurveConfig::Type(" << int(t) << ")");
129 }
130}

◆ parseEquityCurveConfigType()

EquityCurveConfig::Type parseEquityCurveConfigType ( const std::string &  str)

Definition at line 132 of file equitycurveconfig.cpp.

132 {
133 if (str == "DividendYield")
134 return EquityCurveConfig::Type::DividendYield;
135 else if (str == "ForwardPrice")
136 return EquityCurveConfig::Type::ForwardPrice;
137 else if (str == "ForwardDividendPrice")
138 return EquityCurveConfig::Type::ForwardDividendPrice;
139 else if (str == "OptionPremium")
140 return EquityCurveConfig::Type::OptionPremium;
141 else if (str == "NoDividends")
142 return EquityCurveConfig::Type::NoDividends;
143 QL_FAIL("Invalid EquityCurveConfig::Type " << str);
144}
+ Here is the caller graph for this function:

◆ operator<<() [5/73]

std::ostream & operator<< ( std::ostream &  out,
GenericYieldVolatilityCurveConfig::VolatilityType  t 
)

Definition at line 31 of file genericyieldvolcurveconfig.cpp.

31 {
32 switch (t) {
33 case GenericYieldVolatilityCurveConfig::VolatilityType::Lognormal:
34 return out << "RATE_LNVOL";
35 case GenericYieldVolatilityCurveConfig::VolatilityType::Normal:
36 return out << "RATE_NVOL";
37 case GenericYieldVolatilityCurveConfig::VolatilityType::ShiftedLognormal:
38 return out << "RATE_SLNVOL";
39 default:
40 QL_FAIL("unknown VolatilityType(" << Integer(t) << ")");
41 }
42}

◆ operator<<() [6/73]

std::ostream & operator<< ( std::ostream &  out,
InflationCapFloorVolatilityCurveConfig::VolatilityType  t 
)

Definition at line 32 of file inflationcapfloorvolcurveconfig.cpp.

32 {
33 switch (t) {
34 case InflationCapFloorVolatilityCurveConfig::VolatilityType::Lognormal:
35 return out << "RATE_LNVOL";
36 case InflationCapFloorVolatilityCurveConfig::VolatilityType::Normal:
37 return out << "RATE_NVOL";
38 case InflationCapFloorVolatilityCurveConfig::VolatilityType::ShiftedLognormal:
39 return out << "RATE_SLNVOL";
40 default:
41 QL_FAIL("unknown VolatilityType(" << Integer(t) << ")");
42 }
43}

◆ operator<<() [7/73]

std::ostream & operator<< ( std::ostream &  out,
InflationCapFloorVolatilityCurveConfig::QuoteType  t 
)

Definition at line 45 of file inflationcapfloorvolcurveconfig.cpp.

45 {
46 switch (t) {
47 case InflationCapFloorVolatilityCurveConfig::QuoteType::Price:
48 return out << "PRICE";
49 case InflationCapFloorVolatilityCurveConfig::QuoteType::Volatility:
50 return out << "VOLATILITY";
51 default:
52 QL_FAIL("unknown QuoteType(" << Integer(t) << ")");
53 }
54}

◆ effectiveReportConfig()

ReportConfig effectiveReportConfig ( const ReportConfig globalConfig,
const ReportConfig localConfig 
)

Definition at line 109 of file reportconfig.cpp.

109 {
110 bool reportOnDeltaGrid = false;
111 bool reportOnMoneynessGrid = false;
112 bool reportOnStrikeGrid = false;
113 bool reportOnStrikeSpreadGrid = false;
114 std::vector<Real> moneyness;
115 std::vector<std::string> deltas;
116 std::vector<Real> strikes;
117 std::vector<Real> strikeSpreads;
118 std::vector<Period> expiries;
119 std::vector<Period> underlyingTenors;
120
121 if (localConfig.reportOnDeltaGrid())
122 reportOnDeltaGrid = *localConfig.reportOnDeltaGrid();
123 else if (globalConfig.reportOnDeltaGrid())
124 reportOnDeltaGrid = *globalConfig.reportOnDeltaGrid();
125
126 if (localConfig.reportOnMoneynessGrid())
127 reportOnMoneynessGrid = *localConfig.reportOnMoneynessGrid();
128 else if (globalConfig.reportOnMoneynessGrid())
129 reportOnMoneynessGrid = *globalConfig.reportOnMoneynessGrid();
130
131 if (localConfig.reportOnStrikeGrid())
132 reportOnStrikeGrid = *localConfig.reportOnStrikeGrid();
133 else if (globalConfig.reportOnStrikeGrid())
134 reportOnStrikeGrid = *globalConfig.reportOnStrikeGrid();
135
136 if (localConfig.reportOnStrikeSpreadGrid())
137 reportOnStrikeSpreadGrid = *localConfig.reportOnStrikeSpreadGrid();
138 else if (globalConfig.reportOnStrikeSpreadGrid())
139 reportOnStrikeSpreadGrid = *globalConfig.reportOnStrikeSpreadGrid();
140
141 if (localConfig.moneyness())
142 moneyness = *localConfig.moneyness();
143 else if (globalConfig.moneyness())
144 moneyness = *globalConfig.moneyness();
145
146 if (localConfig.deltas())
147 deltas = *localConfig.deltas();
148 else if (globalConfig.deltas())
149 deltas = *globalConfig.deltas();
150
151 if (localConfig.strikes())
152 strikes = *localConfig.strikes();
153 else if (globalConfig.strikes())
154 strikes = *globalConfig.strikes();
155
156 if (localConfig.strikeSpreads())
157 strikeSpreads = *localConfig.strikeSpreads();
158 else if (globalConfig.strikeSpreads())
159 strikeSpreads = *globalConfig.strikeSpreads();
160
161 if (localConfig.expiries())
162 expiries = *localConfig.expiries();
163 else if (globalConfig.expiries())
164 expiries = *globalConfig.expiries();
165
166 if (localConfig.underlyingTenors())
167 underlyingTenors = *localConfig.underlyingTenors();
168 else if (globalConfig.underlyingTenors())
169 underlyingTenors = *globalConfig.underlyingTenors();
170
171 return ReportConfig(reportOnDeltaGrid, reportOnMoneynessGrid, reportOnStrikeGrid, reportOnStrikeSpreadGrid, deltas,
172 moneyness, strikes, strikeSpreads, expiries, underlyingTenors);
173}
const boost::optional< bool > reportOnDeltaGrid() const
const boost::optional< std::vector< Period > > & underlyingTenors() const
const boost::optional< std::vector< Real > > & strikes() const
const boost::optional< std::vector< std::string > > & deltas() const
const boost::optional< bool > reportOnStrikeSpreadGrid() const
const boost::optional< bool > reportOnMoneynessGrid() const
const boost::optional< bool > reportOnStrikeGrid() const
const boost::optional< std::vector< Period > > & expiries() const
const boost::optional< std::vector< Real > > & moneyness() const
const boost::optional< std::vector< Real > > & strikeSpreads() const
vector< Real > strikes
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<() [2/14]

bool operator< ( const VolatilityConfig vc1,
const VolatilityConfig vc2 
)

Definition at line 31 of file volatilityconfig.cpp.

31 {
32 return vc1.priority() < vc2.priority();
33}
QuantLib::Natural priority() const
+ Here is the call graph for this function:

◆ parseYieldCurveSegment()

YieldCurveSegment::Type parseYieldCurveSegment ( const string &  s)

Definition at line 40 of file yieldcurveconfig.cpp.

40 {
41 if (iequals(s, "Zero"))
42 return YieldCurveSegment::Type::Zero;
43 else if (iequals(s, "Zero Spread"))
44 return YieldCurveSegment::Type::ZeroSpread;
45 else if (iequals(s, "Discount"))
46 return YieldCurveSegment::Type::Discount;
47 else if (iequals(s, "Deposit"))
48 return YieldCurveSegment::Type::Deposit;
49 else if (iequals(s, "FRA"))
50 return YieldCurveSegment::Type::FRA;
51 else if (iequals(s, "Future"))
52 return YieldCurveSegment::Type::Future;
53 else if (iequals(s, "OIS"))
54 return YieldCurveSegment::Type::OIS;
55 else if (iequals(s, "Swap"))
56 return YieldCurveSegment::Type::Swap;
57 else if (iequals(s, "Average OIS"))
58 return YieldCurveSegment::Type::AverageOIS;
59 else if (iequals(s, "Tenor Basis Swap"))
60 return YieldCurveSegment::Type::TenorBasis;
61 else if (iequals(s, "Tenor Basis Two Swaps"))
62 return YieldCurveSegment::Type::TenorBasisTwo;
63 else if (iequals(s, "BMA Basis Swap"))
64 return YieldCurveSegment::Type::BMABasis;
65 else if (iequals(s, "FX Forward"))
66 return YieldCurveSegment::Type::FXForward;
67 else if (iequals(s, "Cross Currency Basis Swap"))
68 return YieldCurveSegment::Type::CrossCcyBasis;
69 else if (iequals(s, "Cross Currency Fix Float Swap"))
70 return YieldCurveSegment::Type::CrossCcyFixFloat;
71 else if (iequals(s, "Discount Ratio"))
72 return YieldCurveSegment::Type::DiscountRatio;
73 else if (iequals(s, "FittedBond"))
74 return YieldCurveSegment::Type::FittedBond;
75 else if (iequals(s, "Yield Plus Default"))
76 return YieldCurveSegment::Type::YieldPlusDefault;
77 else if (iequals(s, "Weighted Average"))
78 return YieldCurveSegment::Type::WeightedAverage;
79 else if (iequals(s, "Ibor Fallback"))
80 return YieldCurveSegment::Type::IborFallback;
81 else if (iequals(s, "Bond Yield Shifted"))
82 return YieldCurveSegment::Type::BondYieldShifted;
83 QL_FAIL("Yield curve segment type " << s << " not recognized");
84}
+ Here is the caller graph for this function:

◆ interpOnOpt()

bool interpOnOpt ( CapFloorVolatilityCurveConfig config)

Definition at line 63 of file capfloorvolcurve.cpp.

63 {
64 QL_REQUIRE(config.interpolateOn() == "TermVolatilities" || config.interpolateOn() == "OptionletVolatilities",
65 "Expected InterpolateOn to be one of TermVolatilities or OptionletVolatilities");
66 return config.interpolateOn() == "OptionletVolatilities";
67}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeDummyMarketDatum()

QuantLib::ext::shared_ptr< MarketDatum > makeDummyMarketDatum ( const Date &  d,
const std::string &  name 
)

Definition at line 95 of file csvloader.cpp.

95 {
96 return QuantLib::ext::make_shared<MarketDatum>(0.0, d, name, MarketDatum::QuoteType::NONE,
97 MarketDatum::InstrumentType::NONE);
98}
string name
+ Here is the caller graph for this function:

◆ operator<() [3/14]

bool operator< ( const CurveSpec lhs,
const CurveSpec rhs 
)

Relational operators for CurveSpecs.

Definition at line 27 of file curvespec.cpp.

27 {
28 if (lhs == rhs) {
29 /* If CurveSpecs are equal (i.e. have same name), return false. */
30 return false;
31 } else if (lhs.baseType() != rhs.baseType()) {
32 /* If types are not the same, use the enum value for ordering along type.
33 * The enum order in the header file is deliberate, it ensures that FX comes before FXVol
34 * this property is used in data::order() (see curveloader.hpp)
35 */
36 return lhs.baseType() < rhs.baseType();
37 } else {
38 /* If types are the same and CurveSpecs are different, use default < for string */
39 return lhs.name() < rhs.name();
40 }
41}
virtual CurveType baseType() const =0
string name() const
returns the unique curve name
Definition: curvespec.hpp:78
+ Here is the call graph for this function:

◆ operator==() [1/13]

bool operator== ( const CurveSpec lhs,
const CurveSpec rhs 
)

Definition at line 43 of file curvespec.cpp.

43 {
44 /* We consider two CurveSpecs equal if they have the same name. */
45 return lhs.name() == rhs.name();
46}
+ Here is the call graph for this function:

◆ operator<() [4/14]

bool operator< ( const QuantLib::ext::shared_ptr< CurveSpec > &  lhs,
const QuantLib::ext::shared_ptr< CurveSpec > &  rhs 
)

Definition at line 48 of file curvespec.cpp.

48{ return *lhs < *rhs; }

◆ operator==() [2/13]

bool operator== ( const QuantLib::ext::shared_ptr< CurveSpec > &  lhs,
const QuantLib::ext::shared_ptr< CurveSpec > &  rhs 
)

Definition at line 50 of file curvespec.cpp.

50 {
51 return *lhs == *rhs;
52}

◆ operator<<() [8/73]

std::ostream & operator<< ( std::ostream &  os,
const CurveSpec spec 
)

Stream operator for CurveSpec.

Definition at line 54 of file curvespec.cpp.

54{ return os << spec.name(); }
+ Here is the call graph for this function:

◆ operator<<() [9/73]

std::ostream & operator<< ( std::ostream &  os,
const CurveSpec::CurveType t 
)

Stream operator for CurveType.

Definition at line 56 of file curvespec.cpp.

56 {
57 switch (t) {
58 case CurveSpec::CurveType::Yield:
59 return os << "Yield";
60 case CurveSpec::CurveType::CapFloorVolatility:
61 return os << "CapFloorVolatility";
62 case CurveSpec::CurveType::SwaptionVolatility:
63 return os << "SwaptionVolatility";
64 case CurveSpec::CurveType::YieldVolatility:
65 return os << "YieldVolatility";
66 case CurveSpec::CurveType::FX:
67 return os << "FX";
68 case CurveSpec::CurveType::FXVolatility:
69 return os << "FXVolatility";
70 case CurveSpec::CurveType::Security:
71 return os << "Security";
72 case CurveSpec::CurveType::Default:
73 return os << "Default";
74 case CurveSpec::CurveType::CDSVolatility:
75 return os << "CDSVolatility";
76 case CurveSpec::CurveType::Inflation:
77 return os << "Inflation";
78 case CurveSpec::CurveType::InflationCapFloorVolatility:
79 return os << "InflationCapFloorVolatility";
80 case CurveSpec::CurveType::Equity:
81 return os << "Equity";
82 case CurveSpec::CurveType::EquityVolatility:
83 return os << "EquityVolatility";
84 case CurveSpec::CurveType::BaseCorrelation:
85 return os << "BaseCorrelation";
86 case CurveSpec::CurveType::Commodity:
87 return os << "Commodity";
88 case CurveSpec::CurveType::CommodityVolatility:
89 return os << "CommodityVolatility";
90 case CurveSpec::CurveType::Correlation:
91 return os << "Correlation";
92 default:
93 return os << "N/A";
94 }
95}

◆ operator==() [3/13]

bool operator== ( const Expiry lhs,
const Expiry rhs 
)

Definition at line 33 of file expiry.cpp.

33{ return lhs.equal_to(rhs); }
virtual bool equal_to(const Expiry &other) const =0
Override in derived classes to compare specific expiries.

◆ operator<<() [10/73]

std::ostream & operator<< ( ostream &  os,
const Expiry expiry 
)

Write strike to stream.

Definition at line 108 of file expiry.cpp.

108{ return os << expiry.toString(); }
virtual std::string toString() const =0
Write the Expiry object to string.
+ Here is the call graph for this function:

◆ parseExpiry()

QuantLib::ext::shared_ptr< Expiry > parseExpiry ( const string &  strExpiry)

Parse an Expiry from its string representation, strExpiry.

Definition at line 110 of file expiry.cpp.

110 {
111
112 QL_REQUIRE(strExpiry.size() > 1, "Expiry string must have at least 2 characters");
113
114 if (strExpiry.at(0) == 'c') {
115 auto expiry = QuantLib::ext::make_shared<FutureContinuationExpiry>();
116 expiry->fromString(strExpiry);
117 return expiry;
118 } else {
119 Date date;
120 Period period;
121 bool isDate;
122 parseDateOrPeriod(strExpiry, date, period, isDate);
123 if (isDate) {
124 return QuantLib::ext::make_shared<ExpiryDate>(date);
125 } else {
126 return QuantLib::ext::make_shared<ExpiryPeriod>(period);
127 }
128 }
129}
boost::variant< QuantLib::Date, QuantLib::Period > parseDateOrPeriod(const string &s)
Convert text to QuantLib::Period or QuantLib::Date.
Definition: parsers.cpp:493
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyFixings()

void applyFixings ( const set< Fixing > &  fixings)

Utility to write a vector of fixings in the QuantLib index manager's fixing history.

Definition at line 41 of file fixings.cpp.

41 {
42
43 QuantExt::SavedObservableSettings savedObservableSettings;
44 ObservableSettings::instance().disableUpdates(true);
45
46 Size count = 0;
47 cpu_timer timer;
48 QuantLib::ext::shared_ptr<Index> index;
49 std::string lastIndexName;
50 for (auto& f : fixings) {
51 if(f.name.empty()) {
52 WLOG("Skipping fixing with empty name, value " << f.fixing << ", date " << f.date);
53 }
54 try {
55 if (lastIndexName != f.name) {
56 index = parseIndex(f.name);
57 lastIndexName = f.name;
58 }
59 index->addFixing(f.date, f.fixing, true);
60 TLOG("Added fixing for " << f.name << " (" << io::iso_date(f.date) << ") value:" << f.fixing);
61 ++count;
62 } catch (const std::exception& e) {
63 WLOG("Error during adding fixing for " << f.name << ": " << e.what());
64 }
65 }
66 timer.stop();
67 LOG("Added " << count << " of " << fixings.size() << " fixings in " << timer.format(default_places, "%w")
68 << " seconds");
69}
QuantLib::ext::shared_ptr< Index > parseIndex(const string &s)
Convert std::string to QuantLib::Index.
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
#define TLOG(text)
Logging Macro (Level = Data)
Definition: log.hpp:556
std::size_t count
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<() [5/14]

bool operator< ( const Fixing f1,
const Fixing f2 
)

Compare fixings.

Definition at line 71 of file fixings.cpp.

71 {
72 if (f1.name != f2.name)
73 return f1.name < f2.name;
74 return f1.date < f2.date;
75}
std::string name
Index name.
Definition: fixings.hpp:48
QuantLib::Date date
Fixing date.
Definition: fixings.hpp:46

◆ getCorrelationCurve()

Handle< QuantExt::CorrelationTermStructure > getCorrelationCurve ( const std::string &  index1,
const std::string &  index2,
const map< string, QuantLib::ext::shared_ptr< CorrelationCurve > > &  correlationCurves 
)

Definition at line 665 of file fxvolcurve.cpp.

666 {
667 // straight pair
668 auto tmpCorr = correlationCurves.find("Correlation/" + index1 + "&" + index2);
669 if (tmpCorr != correlationCurves.end()) {
670 return Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
671 }
672 // inverse pair
673 tmpCorr = correlationCurves.find("Correlation/" + index2 + "&" + index1);
674 if (tmpCorr != correlationCurves.end()) {
675 return Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
676 }
677 // inverse fx index1
678 tmpCorr = correlationCurves.find("Correlation/" + inverseFxIndex(index1) + "&" + index2);
679 if (tmpCorr != correlationCurves.end()) {
680 Handle<QuantExt::CorrelationTermStructure> h =
681 Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
682 return Handle<QuantExt::CorrelationTermStructure>(
683 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(h));
684 }
685 tmpCorr = correlationCurves.find("Correlation/" + index2 + "&" + inverseFxIndex(index1));
686 if (tmpCorr != correlationCurves.end()) {
687 Handle<QuantExt::CorrelationTermStructure> h =
688 Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
689 return Handle<QuantExt::CorrelationTermStructure>(
690 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(h));
691 }
692 // inverse fx index2
693 tmpCorr = correlationCurves.find("Correlation/" + index1 + "&" + inverseFxIndex(index2));
694 if (tmpCorr != correlationCurves.end()) {
695 Handle<QuantExt::CorrelationTermStructure> h =
696 Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
697 return Handle<QuantExt::CorrelationTermStructure>(
698 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(h));
699 }
700 tmpCorr = correlationCurves.find("Correlation/" + inverseFxIndex(index2) + "&" + index1);
701 if (tmpCorr != correlationCurves.end()) {
702 Handle<QuantExt::CorrelationTermStructure> h =
703 Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
704 return Handle<QuantExt::CorrelationTermStructure>(
705 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(h));
706 }
707 // both fx indices inverted
708 tmpCorr = correlationCurves.find("Correlation/" + inverseFxIndex(index1) + "&" + inverseFxIndex(index2));
709 if (tmpCorr != correlationCurves.end()) {
710 return Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
711 }
712 tmpCorr = correlationCurves.find("Correlation/" + inverseFxIndex(index2) + "&" + inverseFxIndex(index1));
713 if (tmpCorr != correlationCurves.end()) {
714 return Handle<QuantExt::CorrelationTermStructure>(tmpCorr->second->corrTermStructure());
715 }
716
717 QL_FAIL("no correlation curve found for " << index1 << ":" << index2);
718}
std::string inverseFxIndex(const std::string &indexName)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInflationSwapStart() [1/2]

QuantLib::Date getInflationSwapStart ( const Date &  asof,
const InflationSwapConvention convention 
)

Given an asof and inflation swap convention, determine the start date of an inflation swap.

In general, this just returns the asof. If the convention has a publication roll and a publication schedule, the swap start date will be generated according to this schedule.

+ Here is the caller graph for this function:

◆ load()

void load ( InMemoryLoader loader,
const vector< string > &  data,
bool  isMarket,
bool  implyTodaysFixings 
)

Definition at line 152 of file inmemoryloader.cpp.

152 {
153 LOG("MemoryLoader started");
154
155 Date today = QuantLib::Settings::instance().evaluationDate();
156
157 for (Size i = 0; i < data.size(); ++i) {
158 string line = data[i];
159 // skip blank and comment lines
160 if (line.size() > 0 && line[0] != '#') {
161 vector<string> tokens;
162 boost::trim(line);
163 boost::split(tokens, line, boost::is_any_of(",;\t "), boost::token_compress_on);
164
165 // TODO: should we try, catch and log any invalid lines?
166 QL_REQUIRE(tokens.size() == 3, "Invalid MemoryLoader line, 3 tokens expected " << line);
167 Date date = parseDate(tokens[0]);
168 const string& key = tokens[1];
169 Real value = parseReal(tokens[2]);
170
171 if (isMarket) {
172 // process market
173 // build market datum and add to map
174 try {
175 loader.add(date, key, value);
176 TLOG("Added MarketDatum " << key);
177 } catch (std::exception& e) {
178 WLOG("Failed to parse MarketDatum " << key << ": " << e.what());
179 }
180 } else {
181 // process fixings
182 if (date < today || (date == today && !implyTodaysFixings))
183 loader.addFixing(date, key, value);
184 }
185 }
186 }
187 LOG("MemoryLoader completed");
188}
virtual void addFixing(QuantLib::Date date, const string &name, QuantLib::Real value)
virtual void add(QuantLib::Date date, const string &name, QuantLib::Real value)
SafeStack< ValueType > value
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
@ data
Definition: log.hpp:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadDataFromBuffers()

void loadDataFromBuffers ( InMemoryLoader loader,
const std::vector< std::string > &  marketData,
const std::vector< std::string > &  fixingData,
bool  implyTodaysFixings 
)

Utility function for loading market quotes and fixings from an in memory csv buffer.

Parameters
loaderThe loader that will be populated
marketDataQuantLib::Date Key Value in a single std::string, separated by blanks, tabs, colons or commas
fixingDataQuantLib::Date Index Fixing in a single std::string, separated by blanks, tabs, colons or commas
implyTodaysFixingsEnable/disable implying today's fixings

Definition at line 190 of file inmemoryloader.cpp.

191 {
192 load(loader, marketData, true, implyTodaysFixings);
193 load(loader, fixingData, false, implyTodaysFixings);
194}
void load(InMemoryLoader &loader, const vector< string > &data, bool isMarket, bool implyTodaysFixings)
+ Here is the call graph for this function:

◆ buildPseudoCurrencyMarketParameters()

struct PseudoCurrencyMarketParameters buildPseudoCurrencyMarketParameters ( const std::map< string, string > &  pricingEngineGlobalParameters = std::map< string, string >())

Function to build parameters from PricingEngine GlobalParametrs.

If no PricingEngine Global Parameters (PEGP) are provided the default params are returned which have treatAsFX = true. If PEGP are present, we look for the following fields

name="PseudoCurrency.TreatAsFX" value = true or false name="PseudoCurrency.BaseCurrency" value = currency code name="PseudoCurrency.FXIndexTag" value = Tag name for FX indices, e.g. GENERIC means we request correlation for "FX-GENERIC-USD-EUR" name="PseudeoCurrency.Curves.XXX" value = curve name, here XXX should be a 3 letter Precious metal or Crypto currency code name="PseudoCurrency.DefaultCorrelation" value = correlation. This is optional, if present we use this when the market has no correlation

A typical configuration is <pre> <GlobalParameters> <Parameter name="PseudoCurrency.TreatAsFX">false</Parameter> <Parameter name="PseudoCurrency.BaseCurrency">USD</Parameter> <Parameter name="PseudoCurrency.FXIndexTag">GENERIC</Parameter> <Parameter name="PseudoCurrency.Curve.XAU">PM:XAUUSD</Parameter> <Parameter name="PseudoCurrency.Curve.XBT">CRYPTO:XBTUSD</Parameter> </GlobalParameters> </pre>

Definition at line 54 of file market.cpp.

54 {
56
57 // default
58 params.treatAsFX = true;
59
60 auto it = pegp.find("PseudoCurrency.TreatAsFX");
61 if (it != pegp.end()) {
62 DLOG("Building PseudoCurrencyMarketParameters from PricingEngine GlobalParameters");
63 try {
64 // Build the params
65 params.treatAsFX = parseBool(it->second);
66 it = pegp.find("PseudoCurrency.BaseCurrency");
67 QL_REQUIRE(it != pegp.end(), "No BaseCurrency field");
68 params.baseCurrency = it->second;
69 parseCurrency(params.baseCurrency); // to check it is valid
70
71 // Now just search for the 4 precious metals and 7 crypto currencies
72 for (const string& pm : CurrencyParser::instance().pseudoCurrencyCodes()) {
73 it = pegp.find("PseudoCurrency.Curve." + pm);
74 if (it != pegp.end())
75 params.curves[pm] = it->second;
76 }
77 QL_REQUIRE(!params.curves.empty(), "At least one PM Curve required");
78
79 // Look for fxIndexTag
80 it = pegp.find("PseudoCurrency.FXIndexTag");
81 QL_REQUIRE(it != pegp.end(), "No FXIndexTag field");
82 params.fxIndexTag = it->second;
83
84 // Look for Optional default correlation
85 it = pegp.find("PseudoCurrency.DefaultCorrelation");
86 if (it == pegp.end()) {
87 LOG("No Default Correlation present");
88 params.defaultCorrelation = Null<Real>();
89 } else {
90 LOG("Default Correlation is \"" << it->second << "\"");
91 params.defaultCorrelation = parseReal(it->second);
92 QL_REQUIRE(-1.0 <= params.defaultCorrelation && params.defaultCorrelation <= 1.0,
93 "Invalid DefaultCorrelation value " << it->second);
94 }
95 } catch (std::exception& e) {
96 QL_FAIL("Failed to build PseudoCurrencyMarketParameters : " << e.what());
97 }
98 } else {
99 DLOG("Building default PseudoCurrencyMarketParameters");
100 }
101 DLOG(params);
102
103 return params;
104}
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
Struct to store parameters for commodities to be treatred as pseudo currencies.
Definition: market.hpp:91
std::map< string, string > curves
Definition: market.hpp:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [11/73]

std::ostream & operator<< ( std::ostream &  os,
const struct PseudoCurrencyMarketParameters p 
)

Definition at line 106 of file market.cpp.

106 {
107 // we don't need to write everything out, this is enough for debugging most things
108 return os << "PseudoCurrencyMarketParameters { "
109 << "TreatAsFX:" << (p.treatAsFX ? "True" : "False") << ", BaseCurrency:" << p.baseCurrency << "}";
110}

◆ operator<() [6/14]

bool operator< ( const MarketDatum a,
const MarketDatum b 
)

Definition at line 32 of file marketdatum.cpp.

32 {
33 if (a.asofDate() != b.asofDate())
34 return a.asofDate() < b.asofDate();
35 // the name determines the instrument and quote type uniquely by construction
36 return a.name() < b.name();
37}
const string & name() const
+ Here is the call graph for this function:

◆ operator<<() [12/73]

std::ostream & operator<< ( std::ostream &  out,
const MarketDatum::QuoteType type 
)

Definition at line 39 of file marketdatum.cpp.

39 {
40 switch (type) {
41 case MarketDatum::QuoteType::BASIS_SPREAD:
42 return out << "BASIS_SPREAD";
43 case MarketDatum::QuoteType::CREDIT_SPREAD:
44 return out << "CREDIT_SPREAD";
45 case MarketDatum::QuoteType::CONV_CREDIT_SPREAD:
46 return out << "CONV_CREDIT_SPREAD";
47 case MarketDatum::QuoteType::YIELD_SPREAD:
48 return out << "YIELD_SPREAD";
49 case MarketDatum::QuoteType::RATE:
50 return out << "RATE";
51 case MarketDatum::QuoteType::RATIO:
52 return out << "RATIO";
53 case MarketDatum::QuoteType::PRICE:
54 return out << "PRICE";
55 case MarketDatum::QuoteType::RATE_LNVOL:
56 return out << "RATE_LNVOL";
57 case MarketDatum::QuoteType::RATE_NVOL:
58 return out << "RATE_NVOL";
59 case MarketDatum::QuoteType::RATE_SLNVOL:
60 return out << "RATE_SLNVOL";
61 case MarketDatum::QuoteType::BASE_CORRELATION:
62 return out << "BASE_CORRELATION";
63 case MarketDatum::QuoteType::SHIFT:
64 return out << "SHIFT";
65 case MarketDatum::QuoteType::TRANSITION_PROBABILITY:
66 return out << "TRANSITION_PROBABILITY";
67 case MarketDatum::QuoteType::NONE:
68 return out << "NULL";
69 default:
70 return out << "?";
71 }
72}

◆ operator<<() [13/73]

std::ostream & operator<< ( std::ostream &  out,
const MarketDatum::InstrumentType type 
)

Definition at line 74 of file marketdatum.cpp.

74 {
75 switch (type) {
76 case MarketDatum::InstrumentType::ZERO:
77 return out << "ZERO";
78 case MarketDatum::InstrumentType::DISCOUNT:
79 return out << "DISCOUNT";
80 case MarketDatum::InstrumentType::MM:
81 return out << "MM";
82 case MarketDatum::InstrumentType::MM_FUTURE:
83 return out << "MM_FUTURE";
84 case MarketDatum::InstrumentType::OI_FUTURE:
85 return out << "OI_FUTURE";
86 case MarketDatum::InstrumentType::FRA:
87 return out << "FRA";
88 case MarketDatum::InstrumentType::IMM_FRA:
89 return out << "IMM_FRA";
90 case MarketDatum::InstrumentType::IR_SWAP:
91 return out << "IR_SWAP";
92 case MarketDatum::InstrumentType::BASIS_SWAP:
93 return out << "BASIS_SWAP";
94 case MarketDatum::InstrumentType::BMA_SWAP:
95 return out << "BMA_SWAP";
96 case MarketDatum::InstrumentType::CC_BASIS_SWAP:
97 return out << "CC_BASIS_SWAP";
98 case MarketDatum::InstrumentType::CC_FIX_FLOAT_SWAP:
99 return out << "CC_FIX_FLOAT_SWAP";
100 case MarketDatum::InstrumentType::CDS:
101 return out << "CDS";
102 case MarketDatum::InstrumentType::CDS_INDEX:
103 return out << "CDS_INDEX";
104 case MarketDatum::InstrumentType::FX_SPOT:
105 return out << "FX_SPOT";
106 case MarketDatum::InstrumentType::FX_FWD:
107 return out << "FX_FWD";
108 case MarketDatum::InstrumentType::HAZARD_RATE:
109 return out << "HAZARD_RATE";
110 case MarketDatum::InstrumentType::RECOVERY_RATE:
111 return out << "RECOVERY_RATE";
112 case MarketDatum::InstrumentType::SWAPTION:
113 return out << "SWAPTION";
114 case MarketDatum::InstrumentType::CAPFLOOR:
115 return out << "CAPFLOOR";
116 case MarketDatum::InstrumentType::FX_OPTION:
117 return out << "FX_OPTION";
118 case MarketDatum::InstrumentType::ZC_INFLATIONSWAP:
119 return out << "ZC_INFLATIONSWAP";
120 case MarketDatum::InstrumentType::ZC_INFLATIONCAPFLOOR:
121 return out << "ZC_INFLATIONCAPFLOOR";
122 case MarketDatum::InstrumentType::YY_INFLATIONSWAP:
123 return out << "YY_INFLATIONSWAP";
124 case MarketDatum::InstrumentType::YY_INFLATIONCAPFLOOR:
125 return out << "YY_INFLATIONCAPFLOOR";
126 case MarketDatum::InstrumentType::SEASONALITY:
127 return out << "SEASONALITY";
128 case MarketDatum::InstrumentType::EQUITY_SPOT:
129 return out << "EQUITY_SPOT";
130 case MarketDatum::InstrumentType::EQUITY_FWD:
131 return out << "EQUITY_FWD";
132 case MarketDatum::InstrumentType::EQUITY_DIVIDEND:
133 return out << "EQUITY_DIVIDEND";
134 case MarketDatum::InstrumentType::EQUITY_OPTION:
135 return out << "EQUITY_OPTION";
136 case MarketDatum::InstrumentType::BOND:
137 return out << "BOND";
138 case MarketDatum::InstrumentType::BOND_OPTION:
139 return out << "BOND_OPTION";
140 case MarketDatum::InstrumentType::INDEX_CDS_OPTION:
141 return out << "INDEX_CDS_OPTION";
142 case MarketDatum::InstrumentType::COMMODITY_SPOT:
143 return out << "COMMODITY_SPOT";
144 case MarketDatum::InstrumentType::COMMODITY_FWD:
145 return out << "COMMODITY_FWD";
146 case MarketDatum::InstrumentType::CORRELATION:
147 return out << "CORRELATION";
148 case MarketDatum::InstrumentType::COMMODITY_OPTION:
149 return out << "COMMODITY_OPTION";
150 case MarketDatum::InstrumentType::CPR:
151 return out << "CPR";
152 case MarketDatum::InstrumentType::RATING:
153 return out << "RATING";
154 case MarketDatum::InstrumentType::NONE:
155 return out << "NONE";
156 default:
157 return out << "?";
158 }
159}

◆ fxFwdQuoteTenor()

QuantLib::Period fxFwdQuoteTenor ( const boost::variant< QuantLib::Period, FXForwardQuote::FxFwdString > &  term)

Definition at line 206 of file marketdatumparser.cpp.

206 {
207 return boost::apply_visitor(FxTenorGetter(), term);
208}
+ Here is the caller graph for this function:

◆ fxFwdQuoteStartTenor()

QuantLib::Period fxFwdQuoteStartTenor ( const boost::variant< QuantLib::Period, FXForwardQuote::FxFwdString > &  term,
const QuantLib::ext::shared_ptr< FXConvention > &  fxConvention 
)

Definition at line 210 of file marketdatumparser.cpp.

211 {
212 return boost::apply_visitor(FxStartTenorGetter(fxConvention), term);
213}
QuantLib::ext::shared_ptr< FXConvention > fxConvention
+ Here is the caller graph for this function:

◆ matchFxFwdStringTerm()

bool matchFxFwdStringTerm ( const boost::variant< QuantLib::Period, FXForwardQuote::FxFwdString > &  term,
const FXForwardQuote::FxFwdString fxfwdString 
)

Definition at line 215 of file marketdatumparser.cpp.

216 {
217 return boost::apply_visitor(FxFwdStringCompare(fxfwdString), term);
218}
+ Here is the caller graph for this function:

◆ operator==() [4/13]

bool operator== ( const BaseStrike lhs,
const BaseStrike rhs 
)

Definition at line 38 of file strike.cpp.

38{ return lhs.equal_to(rhs); }
virtual bool equal_to(const BaseStrike &other) const =0
Override in derived classes to compare specific Strikes.

◆ operator<<() [14/73]

std::ostream & operator<< ( ostream &  os,
const BaseStrike strike 
)

Write strike to stream.

Definition at line 203 of file strike.cpp.

203{ return os << strike.toString(); }
virtual std::string toString() const =0
Write the Strike object to string.
+ Here is the call graph for this function:

◆ operator<<() [15/73]

ostream & operator<< ( ostream &  os,
DeltaVolQuote::DeltaType  type 
)

Definition at line 205 of file strike.cpp.

205 {
206 switch (type) {
207 case DeltaVolQuote::Spot:
208 return os << "Spot";
209 case DeltaVolQuote::Fwd:
210 return os << "Fwd";
211 case DeltaVolQuote::PaSpot:
212 return os << "PaSpot";
213 case DeltaVolQuote::PaFwd:
214 return os << "PaFwd";
215 default:
216 QL_FAIL("Unknown delta type");
217 }
218}

◆ operator<<() [16/73]

ostream & operator<< ( ostream &  os,
DeltaVolQuote::AtmType  type 
)

Definition at line 220 of file strike.cpp.

220 {
221 switch (type) {
222 case DeltaVolQuote::AtmNull:
223 return os << "AtmNull";
224 case DeltaVolQuote::AtmSpot:
225 return os << "AtmSpot";
226 case DeltaVolQuote::AtmFwd:
227 return os << "AtmFwd";
228 case DeltaVolQuote::AtmDeltaNeutral:
229 return os << "AtmDeltaNeutral";
230 case DeltaVolQuote::AtmVegaMax:
231 return os << "AtmVegaMax";
232 case DeltaVolQuote::AtmGammaMax:
233 return os << "AtmGammaMax";
234 case DeltaVolQuote::AtmPutCall50:
235 return os << "AtmPutCall50";
236 default:
237 QL_FAIL("Unknown atm type");
238 }
239}

◆ operator<<() [17/73]

std::ostream & operator<< ( ostream &  os,
MoneynessStrike::Type  type 
)

Write MoneynessStrike::Type, type, to stream.

Definition at line 241 of file strike.cpp.

241 {
242 switch (type) {
243 case MoneynessStrike::Type::Spot:
244 return os << "Spot";
245 case MoneynessStrike::Type::Forward:
246 return os << "Fwd";
247 default:
248 QL_FAIL("Unknown moneyness type");
249 }
250}

◆ parseMoneynessType()

MoneynessStrike::Type parseMoneynessType ( const string &  type)

Parse MoneynessStrike::Type from type.

Definition at line 252 of file strike.cpp.

252 {
253 if (type == "Spot") {
254 return MoneynessStrike::Type::Spot;
255 } else if (type == "Fwd") {
256 return MoneynessStrike::Type::Forward;
257 } else {
258 QL_FAIL("Moneyness type '" << type << "' not recognized");
259 }
260}
+ Here is the caller graph for this function:

◆ parseBaseStrike()

QuantLib::ext::shared_ptr< BaseStrike > parseBaseStrike ( const string &  strStrike)

Parse a Strike from its string representation, strStrike.

Definition at line 262 of file strike.cpp.

262 {
263
264 QuantLib::ext::shared_ptr<BaseStrike> strike;
265
266 // Expect strStrike to either:
267 // 1. have a single token which means that we have an absolute strike, or
268 // 2. have multiple tokens beginning with one of DEL, ATM or MNY
269 vector<string> tokens;
270 boost::split(tokens, strStrike, boost::is_any_of("/"));
271
272 if (tokens.size() == 1) {
273 strike = QuantLib::ext::make_shared<AbsoluteStrike>();
274 } else if (tokens[0] == "DEL") {
275 strike = QuantLib::ext::make_shared<DeltaStrike>();
276 } else if (tokens[0] == "ATM") {
277 strike = QuantLib::ext::make_shared<AtmStrike>();
278 } else if (tokens[0] == "MNY") {
279 strike = QuantLib::ext::make_shared<MoneynessStrike>();
280 } else {
281 QL_FAIL("Could not parse strike string '" << strStrike << "'.");
282 }
283
284 strike->fromString(strStrike);
285
286 return strike;
287}
+ Here is the caller graph for this function:

◆ operator<<() [18/73]

std::ostream & operator<< ( std::ostream &  os,
QuantLib::DeltaVolQuote::DeltaType  type 
)

Write deltaType to stream. Not provided in QuantLib so add it here.

◆ operator<<() [19/73]

std::ostream & operator<< ( std::ostream &  os,
QuantLib::DeltaVolQuote::AtmType  type 
)

Write atmType to stream. Not provided in QuantLib so add it here.

◆ registerBaseStrike()

void registerBaseStrike ( Archive &  ar)

Definition at line 273 of file strike.hpp.

273 {
274 ar.template register_type<AbsoluteStrike>();
275 ar.template register_type<DeltaStrike>();
276 ar.template register_type<AtmStrike>();
277 ar.template register_type<MoneynessStrike>();
278}

◆ operator<<() [20/73]

std::ostream & operator<< ( std::ostream &  o,
const DependencyGraph::Node n 
)

Definition at line 949 of file todaysmarket.cpp.

949 {
950 return o << n.obj << "(" << n.name << "," << n.mapping << ")";
951}

◆ getMarketObjectTypes()

std::set< MarketObject > getMarketObjectTypes ( )

Definition at line 84 of file todaysmarketparameters.cpp.

84 {
85 thread_local static std::set<MarketObject> result;
86 if (result.empty()) {
87 for (auto const& o : marketObjectData) {
88 result.insert(o.obj);
89 }
90 }
91 return result;
92}
+ Here is the caller graph for this function:

◆ buildYieldCurve()

QuantLib::ext::shared_ptr< YieldTermStructure > buildYieldCurve ( const vector< Date > &  dates,
const vector< QuantLib::Real > &  rates,
const DayCounter &  dayCounter,
YieldCurve::InterpolationMethod  interpolationMethod,
Size  n 
)

Templated function to build a YieldTermStructure and apply interpolation methods to it.

Definition at line 92 of file yieldcurve.cpp.

94 {
95
96 QuantLib::ext::shared_ptr<YieldTermStructure> yieldts;
97 switch (interpolationMethod) {
98 case YieldCurve::InterpolationMethod::Linear:
99 yieldts.reset(new CurveType<QuantLib::Linear>(dates, rates, dayCounter, QuantLib::Linear()));
100 break;
101 case YieldCurve::InterpolationMethod::LogLinear:
102 yieldts.reset(new CurveType<QuantLib::LogLinear>(dates, rates, dayCounter, QuantLib::LogLinear()));
103 break;
104 case YieldCurve::InterpolationMethod::NaturalCubic:
105 yieldts.reset(new CurveType<QuantLib::Cubic>(dates, rates, dayCounter,
106 QuantLib::Cubic(CubicInterpolation::Kruger, true)));
107 break;
108 case YieldCurve::InterpolationMethod::FinancialCubic:
109 yieldts.reset(new CurveType<QuantLib::Cubic>(dates, rates, dayCounter,
110 QuantLib::Cubic(CubicInterpolation::Kruger, true,
111 CubicInterpolation::SecondDerivative, 0.0,
112 CubicInterpolation::FirstDerivative)));
113 break;
114 case YieldCurve::InterpolationMethod::ConvexMonotone:
115 yieldts.reset(
116 new CurveType<QuantLib::ConvexMonotone>(dates, rates, dayCounter, Calendar(), {}, {}, QuantLib::ConvexMonotone()));
117 break;
118 case YieldCurve::InterpolationMethod::Quadratic:
119 yieldts.reset(new CurveType<QuantExt::Quadratic>(dates, rates, dayCounter, QuantExt::Quadratic(1, 0, 1, 0, 1)));
120 break;
121 case YieldCurve::InterpolationMethod::LogQuadratic:
122 yieldts.reset(
123 new CurveType<QuantExt::LogQuadratic>(dates, rates, dayCounter, QuantExt::LogQuadratic(1, 0, -1, 0, 1)));
124 break;
125 case YieldCurve::InterpolationMethod::Hermite:
126 yieldts.reset(new CurveType<QuantLib::Cubic>(dates, rates, dayCounter, Cubic(CubicInterpolation::Parabolic)));
127 break;
128 case YieldCurve::InterpolationMethod::CubicSpline:
129 yieldts.reset(new CurveType<QuantLib::Cubic>(dates, rates, dayCounter,
130 Cubic(CubicInterpolation::Spline, false,
131 CubicInterpolation::SecondDerivative, 0.0,
132 CubicInterpolation::SecondDerivative, 0.0)));
133 break;
134 case YieldCurve::InterpolationMethod::DefaultLogMixedLinearCubic:
135 yieldts.reset(
136 new CurveType<DefaultLogMixedLinearCubic>(dates, rates, dayCounter, DefaultLogMixedLinearCubic(n)));
137 break;
138 case YieldCurve::InterpolationMethod::MonotonicLogMixedLinearCubic:
139 yieldts.reset(
140 new CurveType<MonotonicLogMixedLinearCubic>(dates, rates, dayCounter, MonotonicLogMixedLinearCubic(n)));
141 break;
142 case YieldCurve::InterpolationMethod::KrugerLogMixedLinearCubic:
143 yieldts.reset(
144 new CurveType<KrugerLogMixedLinearCubic>(dates, rates, dayCounter, KrugerLogMixedLinearCubic(n)));
145 break;
146 case YieldCurve::InterpolationMethod::LogMixedLinearCubicNaturalSpline:
147 yieldts.reset(new CurveType<LogMixedLinearCubic>(
148 dates, rates, dayCounter,
149 LogMixedLinearCubic(n, MixedInterpolation::ShareRanges, CubicInterpolation::Spline, false,
150 CubicInterpolation::SecondDerivative, 0.0, CubicInterpolation::SecondDerivative,
151 0.0)));
152 break;
153
154 default:
155 QL_FAIL("Interpolation method '" << interpolationMethod << "' not recognised.");
156 }
157 return yieldts;
158}

◆ zerocurve()

QuantLib::ext::shared_ptr< YieldTermStructure > zerocurve ( const vector< Date > &  dates,
const vector< Rate > &  yields,
const DayCounter &  dayCounter,
YieldCurve::InterpolationMethod  interpolationMethod,
Size  n 
)

Create a Interpolated Zero Curve and apply interpolators.

Definition at line 160 of file yieldcurve.cpp.

162 {
163 return buildYieldCurve<InterpolatedZeroCurve>(dates, yields, dayCounter, interpolationMethod, n);
164}
+ Here is the caller graph for this function:

◆ discountcurve()

QuantLib::ext::shared_ptr< YieldTermStructure > discountcurve ( const vector< Date > &  dates,
const vector< DiscountFactor > &  dfs,
const DayCounter &  dayCounter,
YieldCurve::InterpolationMethod  interpolationMethod,
Size  n 
)

Create a Interpolated Discount Curve and apply interpolators.

Definition at line 166 of file yieldcurve.cpp.

168 {
169 return buildYieldCurve<InterpolatedDiscountCurve>(dates, dfs, dayCounter, interpolationMethod, n);
170}
+ Here is the caller graph for this function:

◆ forwardcurve()

QuantLib::ext::shared_ptr< YieldTermStructure > forwardcurve ( const vector< Date > &  dates,
const vector< Rate > &  forwards,
const DayCounter &  dayCounter,
YieldCurve::InterpolationMethod  interpolationMethod,
Size  n 
)

Create a Interpolated Forward Curve and apply interpolators.

Definition at line 172 of file yieldcurve.cpp.

174 {
175 return buildYieldCurve<InterpolatedForwardCurve>(dates, forwards, dayCounter, interpolationMethod, n);
176}
+ Here is the caller graph for this function:

◆ parseYieldCurveInterpolationMethod()

YieldCurve::InterpolationMethod parseYieldCurveInterpolationMethod ( const string &  s)

Helper function for parsing interpolation method.

Definition at line 180 of file yieldcurve.cpp.

180 {
181 if (s == "Linear")
182 return YieldCurve::InterpolationMethod::Linear;
183 else if (s == "LogLinear")
184 return YieldCurve::InterpolationMethod::LogLinear;
185 else if (s == "NaturalCubic")
186 return YieldCurve::InterpolationMethod::NaturalCubic;
187 else if (s == "FinancialCubic")
188 return YieldCurve::InterpolationMethod::FinancialCubic;
189 else if (s == "ConvexMonotone")
190 return YieldCurve::InterpolationMethod::ConvexMonotone;
191 else if (s == "ExponentialSplines")
192 return YieldCurve::InterpolationMethod::ExponentialSplines;
193 else if (s == "Quadratic")
194 return YieldCurve::InterpolationMethod::Quadratic;
195 else if (s == "LogQuadratic")
196 return YieldCurve::InterpolationMethod::LogQuadratic;
197 else if (s == "LogNaturalCubic")
198 return YieldCurve::InterpolationMethod::LogNaturalCubic;
199 else if (s == "LogFinancialCubic")
200 return YieldCurve::InterpolationMethod::LogFinancialCubic;
201 else if (s == "LogCubicSpline")
202 return YieldCurve::InterpolationMethod::LogCubicSpline;
203 else if (s == "Hermite")
204 return YieldCurve::InterpolationMethod::Hermite;
205 else if (s == "CubicSpline")
206 return YieldCurve::InterpolationMethod::CubicSpline;
207 else if (s == "DefaultLogMixedLinearCubic")
208 return YieldCurve::InterpolationMethod::DefaultLogMixedLinearCubic;
209 else if (s == "MonotonicLogMixedLinearCubic")
210 return YieldCurve::InterpolationMethod::MonotonicLogMixedLinearCubic;
211 else if (s == "KrugerLogMixedLinearCubic")
212 return YieldCurve::InterpolationMethod::KrugerLogMixedLinearCubic;
213 else if (s == "LogMixedLinearCubicNaturalSpline")
214 return YieldCurve::InterpolationMethod::LogMixedLinearCubicNaturalSpline;
215 else if (s == "NelsonSiegel")
216 return YieldCurve::InterpolationMethod::NelsonSiegel;
217 else if (s == "Svensson")
218 return YieldCurve::InterpolationMethod::Svensson;
219 else
220 QL_FAIL("Yield curve interpolation method " << s << " not recognized");
221};
+ Here is the caller graph for this function:

◆ parseYieldCurveInterpolationVariable()

YieldCurve::InterpolationVariable parseYieldCurveInterpolationVariable ( const string &  s)

Helper function for parsing interpolation variable.

Definition at line 223 of file yieldcurve.cpp.

223 {
224 if (s == "Zero")
225 return YieldCurve::InterpolationVariable::Zero;
226 else if (s == "Discount")
227 return YieldCurve::InterpolationVariable::Discount;
228 else if (s == "Forward")
229 return YieldCurve::InterpolationVariable::Forward;
230 else
231 QL_FAIL("Yield curve interpolation variable " << s << " not recognized");
232};
+ Here is the caller graph for this function:

◆ operator<<() [21/73]

std::ostream & operator<< ( std::ostream &  out,
const YieldCurve::InterpolationMethod  m 
)

Output operator for interpolation method.

Definition at line 234 of file yieldcurve.cpp.

234 {
235 if (m == YieldCurve::InterpolationMethod::Linear)
236 return out << "Linear";
237 else if (m == YieldCurve::InterpolationMethod::LogLinear)
238 return out << "LogLinear";
239 else if (m == YieldCurve::InterpolationMethod::NaturalCubic)
240 return out << "NaturalCubic";
241 else if (m == YieldCurve::InterpolationMethod::FinancialCubic)
242 return out << "FinancialCubic";
243 else if (m == YieldCurve::InterpolationMethod::ConvexMonotone)
244 return out << "ConvexMonotone";
245 else if (m == YieldCurve::InterpolationMethod::ExponentialSplines)
246 return out << "ExponentialSplines";
247 else if (m == YieldCurve::InterpolationMethod::Quadratic)
248 return out << "Quadratic";
249 else if (m == YieldCurve::InterpolationMethod::LogQuadratic)
250 return out << "LogQuadratic";
251 else if (m == YieldCurve::InterpolationMethod::LogNaturalCubic)
252 return out << "LogNaturalCubic";
253 else if (m == YieldCurve::InterpolationMethod::LogFinancialCubic)
254 return out << "LogFinancialCubic";
255 else if (m == YieldCurve::InterpolationMethod::LogCubicSpline)
256 return out << "LogCubicSpline";
257 else if (m == YieldCurve::InterpolationMethod::Hermite)
258 return out << "Hermite";
259 else if (m == YieldCurve::InterpolationMethod::CubicSpline)
260 return out << "CubicSpline";
261 else if (m == YieldCurve::InterpolationMethod::DefaultLogMixedLinearCubic)
262 return out << "DefaultLogMixedLinearCubic";
263 else if (m == YieldCurve::InterpolationMethod::MonotonicLogMixedLinearCubic)
264 return out << "MonotonicLogMixedLinearCubic";
265 else if (m == YieldCurve::InterpolationMethod::KrugerLogMixedLinearCubic)
266 return out << "KrugerLogMixedLinearCubic";
267 else if (m == YieldCurve::InterpolationMethod::LogMixedLinearCubicNaturalSpline)
268 return out << "LogMixedLinearCubicNaturalSpline";
269 else if (m == YieldCurve::InterpolationMethod::NelsonSiegel)
270 return out << "NelsonSiegel";
271 else if (m == YieldCurve::InterpolationMethod::Svensson)
272 return out << "Svensson";
273 else
274 QL_FAIL("Yield curve interpolation method " << static_cast<int>(m) << " not recognized");
275}

◆ parseCirCalibrationStrategy()

CrCirData::CalibrationStrategy parseCirCalibrationStrategy ( const string &  s)

Definition at line 42 of file crcirdata.cpp.

42 {
43 if (s == "None")
44 return CrCirData::CalibrationStrategy::None;
45 else if (s == "CurveAndFlatVol")
46 return CrCirData::CalibrationStrategy::CurveAndFlatVol;
47 else {
48 QL_FAIL("CrCirData::CalibrationStrategy " << s << " not recognised.");
49 }
50}
+ Here is the caller graph for this function:

◆ operator<<() [22/73]

std::ostream & operator<< ( std::ostream &  oss,
const CrCirData::CalibrationStrategy s 
)

Definition at line 52 of file crcirdata.cpp.

52 {
53 if (s == CrCirData::CalibrationStrategy::None)
54 oss << "None";
55 else if (s == CrCirData::CalibrationStrategy::CurveAndFlatVol)
56 oss << "CurveAndFlatVol";
57 else
58 QL_FAIL("CIR Calibration strategy(" << ((int)s) << ") not covered");
59 return oss;
60}

◆ pairToStrings()

std::vector< std::string > pairToStrings ( std::pair< std::string, std::string >  p)

Definition at line 248 of file crossassetmodeldata.cpp.

248 {
249 std::vector<std::string> pair = {p.first, p.second};
250 return pair;
251}

◆ parseDiscretization()

CrossAssetModel::Discretization parseDiscretization ( const string &  s)

Definition at line 840 of file crossassetmodeldata.cpp.

840 {
841 static std::map<string, QuantExt::CrossAssetModel::Discretization> m = {
842 {"Exact", QuantExt::CrossAssetModel::Discretization::Exact},
843 {"Euler", QuantExt::CrossAssetModel::Discretization::Euler}};
844
845 auto it = m.find(s);
846 if (it != m.end()) {
847 return it->second;
848 } else {
849 QL_FAIL("Cannot convert \"" << s << "\" to QuantExt::CrossAssetStateProcess::discretization");
850 }
851}
+ Here is the caller graph for this function:

◆ operator<<() [23/73]

std::ostream & operator<< ( std::ostream &  oss,
const ParamType type 
)

Convert enumerated class value into a string.

Definition at line 28 of file irmodeldata.cpp.

28 {
29 if (type == ParamType::Constant)
30 oss << "CONSTANT";
31 else if (type == ParamType::Piecewise)
32 oss << "PIECEWISE";
33 else
34 QL_FAIL("Parameter type not covered by <<");
35 return oss;
36}

◆ parseParamType()

ParamType parseParamType ( const string &  s)

Convert parameter type string into enumerated class value.

Definition at line 38 of file irmodeldata.cpp.

38 {
39 if (boost::algorithm::to_upper_copy(s) == "CONSTANT")
40 return ParamType::Constant;
41 else if (boost::algorithm::to_upper_copy(s) == "PIECEWISE")
42 return ParamType::Piecewise;
43 else
44 QL_FAIL("Parameter type " << s << " not recognized");
45}
+ Here is the caller graph for this function:

◆ parseCalibrationType()

CalibrationType parseCalibrationType ( const string &  s)

Convert calibration type string into enumerated class value.

Definition at line 47 of file irmodeldata.cpp.

47 {
48 if (boost::algorithm::to_upper_copy(s) == "BOOTSTRAP")
49 return CalibrationType::Bootstrap;
50 else if (boost::algorithm::to_upper_copy(s) == "BESTFIT")
51 return CalibrationType::BestFit;
52 else if (boost::algorithm::to_upper_copy(s) == "NONE")
53 return CalibrationType::None;
54 else
55 QL_FAIL("Calibration type " << s << " not recognized");
56}
+ Here is the caller graph for this function:

◆ operator<<() [24/73]

std::ostream & operator<< ( std::ostream &  oss,
const CalibrationType type 
)

Convert enumerated class value into a string.

Definition at line 58 of file irmodeldata.cpp.

58 {
59 if (type == CalibrationType::Bootstrap)
60 oss << "BOOTSTRAP";
61 else if (type == CalibrationType::BestFit)
62 oss << "BESTFIT";
63 else if (type == CalibrationType::None)
64 oss << "NONE";
65 else
66 QL_FAIL("Calibration type not covered");
67 return oss;
68}

◆ parseCalibrationStrategy()

CalibrationStrategy parseCalibrationStrategy ( const string &  s)

Convert calibration strategy string into enumerated class value.

Definition at line 70 of file irmodeldata.cpp.

70 {
71 if (boost::algorithm::to_upper_copy(s) == "COTERMINALATM")
72 return CalibrationStrategy::CoterminalATM;
73 else if (boost::algorithm::to_upper_copy(s) == "COTERMINALDEALSTRIKE")
74 return CalibrationStrategy::CoterminalDealStrike;
75 else if (boost::algorithm::to_upper_copy(s) == "UNDERLYINGATM")
76 return CalibrationStrategy::UnderlyingATM;
77 else if (boost::algorithm::to_upper_copy(s) == "UNDERLYINGDEALSTRIKE")
78 return CalibrationStrategy::UnderlyingDealStrike;
79 else if (boost::algorithm::to_upper_copy(s) == "NONE")
80 return CalibrationStrategy::None;
81 else
82 QL_FAIL("Calibration strategy " << s << " not recognized");
83}
+ Here is the caller graph for this function:

◆ operator<<() [25/73]

std::ostream & operator<< ( std::ostream &  oss,
const CalibrationStrategy type 
)

Convert enumerated class value into a string.

Definition at line 85 of file irmodeldata.cpp.

85 {
86 if (type == CalibrationStrategy::CoterminalATM)
87 oss << "COTERMINALATM";
88 else if (type == CalibrationStrategy::CoterminalDealStrike)
89 oss << "COTERMINALDEALSTRIKE";
90 else if (type == CalibrationStrategy::UnderlyingATM)
91 oss << "UNDERLYINGATM";
92 else if (type == CalibrationStrategy::UnderlyingDealStrike)
93 oss << "UNDERLYINGDEALSTRIKE";
94 else if (type == CalibrationStrategy::None)
95 oss << "NONE";
96 else
97 QL_FAIL("Calibration strategy not covered");
98 return oss;
99}

◆ parseReversionType()

LgmData::ReversionType parseReversionType ( const string &  s)

Enum parsers.

Definition at line 62 of file lgmdata.cpp.

62 {
63 if (boost::algorithm::to_upper_copy(s) == "HULLWHITE")
64 return LgmData::ReversionType::HullWhite;
65 else if (boost::algorithm::to_upper_copy(s) == "HAGAN")
66 return LgmData::ReversionType::Hagan;
67 else
68 QL_FAIL("Reversion type " << s << " not recognized");
69}
+ Here is the caller graph for this function:

◆ operator<<() [26/73]

std::ostream & operator<< ( std::ostream &  oss,
const LgmData::ReversionType type 
)

Enum to string.

Definition at line 71 of file lgmdata.cpp.

71 {
72 if (type == LgmData::ReversionType::HullWhite)
73 oss << "HULLWHITE";
74 else if (type == LgmData::ReversionType::Hagan)
75 oss << "HAGAN";
76 else
77 QL_FAIL("Reversion type not covered");
78 return oss;
79}

◆ parseVolatilityType()

LgmData::VolatilityType parseVolatilityType ( const string &  s)

Definition at line 81 of file lgmdata.cpp.

81 {
82 if (boost::algorithm::to_upper_copy(s) == "HULLWHITE")
83 return LgmData::VolatilityType::HullWhite;
84 else if (boost::algorithm::to_upper_copy(s) == "HAGAN")
85 return LgmData::VolatilityType::Hagan;
86 else
87 QL_FAIL("Volatility type " << s << " not recognized");
88}
+ Here is the caller graph for this function:

◆ operator<<() [27/73]

std::ostream & operator<< ( std::ostream &  oss,
const LgmData::VolatilityType type 
)

Definition at line 90 of file lgmdata.cpp.

90 {
91 if (type == LgmData::VolatilityType::HullWhite)
92 oss << "HULLWHITE";
93 else if (type == LgmData::VolatilityType::Hagan)
94 oss << "HAGAN";
95 else
96 QL_FAIL("Volatility type not covered");
97 return oss;
98}

◆ parseFloatSpreadMapping()

QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping parseFloatSpreadMapping ( const string &  s)

Definition at line 100 of file lgmdata.cpp.

100 {
101 if (boost::algorithm::to_upper_copy(s) == "NEXTCOUPON")
103 else if (boost::algorithm::to_upper_copy(s) == "PRORATA")
105 else if (boost::algorithm::to_upper_copy(s) == "SIMPLE")
106 return QuantExt::AnalyticLgmSwaptionEngine::simple;
107 else
108 QL_FAIL("FloatSpreadMapping '" << s << "' not recognized");
109}
+ Here is the caller graph for this function:

◆ operator<<() [28/73]

std::ostream & operator<< ( std::ostream &  oss,
const QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping m 
)

Definition at line 111 of file lgmdata.cpp.

111 {
113 oss << "NEXTCOUPON";
115 oss << "PRORATA";
116 else if (m == QuantExt::AnalyticLgmSwaptionEngine::simple)
117 oss << "SIMPLE";
118 else
119 QL_FAIL("FloatSpreadMapping type not covered");
120 return oss;
121}

◆ getCalibrationDetails() [1/9]

std::string getCalibrationDetails ( LgmCalibrationInfo info,
const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  basket,
const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &  parametrization 
)

Definition at line 125 of file utilities.cpp.

127 {
128 std::ostringstream log;
129 log << std::right << std::setw(3) << "#" << std::setw(14) << "time" << std::setw(14) << "modelVol" << std::setw(14)
130 << "marketVol" << std::setw(14) << "(diff)" << std::setw(14) << "modelValue" << std::setw(14) << "marketValue"
131 << std::setw(14) << "(diff)" << std::setw(14) << "irlgm1fAlpha" << std::setw(14) << "irlgm1fKappa"
132 << std::setw(16) << "irlgm1fHwSigma\n";
133 Real t = 0.0, modelAlpha = 0.0, modelKappa = 0.0, modelHwSigma = 0.0;
134 info.lgmCalibrationData.clear();
135 for (Size j = 0; j < basket.size(); j++) {
136 Real modelValue = basket[j]->modelValue();
137 Real marketValue = basket[j]->marketValue();
138 Real valueDiff = modelValue - marketValue;
139 Volatility modelVol = 0, marketVol = 0, volDiff = 0;
140 QuantLib::ext::shared_ptr<SwaptionHelper> swaption = QuantLib::ext::dynamic_pointer_cast<SwaptionHelper>(basket[j]);
141 if (swaption != nullptr && parametrization != nullptr) {
142 // report alpha, kappa at t_expiry^-
143 t = parametrization->termStructure()->timeFromReference(swaption->swaption()->exercise()->date(0));
144 modelAlpha = parametrization->alpha(t - 1E-4);
145 modelKappa = parametrization->kappa(t - 1E-4);
146 modelHwSigma = parametrization->hullWhiteSigma(t - 1E-4);
147 }
148 // TODO handle other calibration helpers, too (capfloor)
149 marketVol = basket[j]->volatility()->value();
150 modelVol = impliedVolatility(basket[j]);
151 volDiff = modelVol - marketVol;
152 log << std::setw(3) << j << std::setprecision(6) << std::setw(14) << t << std::setw(14) << modelVol
153 << std::setw(14) << marketVol << std::setw(14) << volDiff << std::setw(14) << modelValue << std::setw(14)
154 << marketValue << std::setw(14) << valueDiff << std::setw(14) << modelAlpha << std::setw(14) << modelKappa
155 << std::setw(16) << modelHwSigma << "\n";
156 info.lgmCalibrationData.push_back(
157 LgmCalibrationData{t, modelVol, marketVol, modelValue, marketValue, modelAlpha, modelKappa, modelHwSigma});
158 }
159 if (parametrization != nullptr) {
160 // report alpha, kappa at t_expiry^+ for last expiry
161 modelAlpha = parametrization->alpha(t + 1E-4);
162 modelKappa = parametrization->kappa(t + 1E-4);
163 modelHwSigma = parametrization->hullWhiteSigma(t + 1E-4);
164 }
165 log << "t >= " << t << ": irlgm1fAlpha = " << modelAlpha << " irlgm1fKappa = " << modelKappa
166 << " irlgm1fHwSigma = " << modelHwSigma << "\n";
167 return log.str();
168}
Real marketValue
Definition: utilities.cpp:64
Real modelValue
Definition: utilities.cpp:63
RandomVariable log(RandomVariable x)
std::vector< LgmCalibrationData > lgmCalibrationData
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCalibrationDetails() [2/9]

std::string getCalibrationDetails ( const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  basket,
const QuantLib::ext::shared_ptr< FxBsParametrization > &  parametrization,
const QuantLib::ext::shared_ptr< Parametrization > &  domesticIrModel 
)

Definition at line 170 of file utilities.cpp.

172 {
173 auto lgmParametrization = QuantLib::ext::dynamic_pointer_cast<IrLgm1fParametrization>(domesticIrModel);
174 if (lgmParametrization) {
175 return getCalibrationDetails(basket, parametrization, lgmParametrization);
176 } else {
177 return std::string();
178 }
179}
std::string getCalibrationDetails(LgmCalibrationInfo &info, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &parametrization)
Definition: utilities.cpp:125
+ Here is the call graph for this function:

◆ getCalibrationDetails() [3/9]

std::string getCalibrationDetails ( const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  basket,
const QuantLib::ext::shared_ptr< FxBsParametrization > &  parametrization,
const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &  domesticLgm 
)

Definition at line 181 of file utilities.cpp.

183 {
184 std::ostringstream log;
185 log << std::right << std::setw(3) << "#" << std::setw(14) << "time" << std::setw(14) << "modelVol" << std::setw(14)
186 << "marketVol" << std::setw(14) << "(diff)" << std::setw(14) << "modelValue" << std::setw(14) << "marketValue"
187 << std::setw(14) << "(diff)" << std::setw(14) << "fxbsSigma\n";
188 Real t = 0.0, modelSigma = 0.0;
189 for (Size j = 0; j < basket.size(); j++) {
190 Real modelValue = basket[j]->modelValue();
191 Real marketValue = basket[j]->marketValue();
192 Real valueDiff = modelValue - marketValue;
193 Volatility modelVol = 0, marketVol = 0, volDiff = 0;
194 QuantLib::ext::shared_ptr<FxEqOptionHelper> fxoption = QuantLib::ext::dynamic_pointer_cast<FxEqOptionHelper>(basket[j]);
195 if (fxoption != nullptr && parametrization != nullptr && domesticLgm != nullptr) {
196 // report alpha, kappa at t_expiry^-
197 t = domesticLgm->termStructure()->timeFromReference(fxoption->option()->exercise()->date(0));
198 modelSigma = parametrization->sigma(t - 1E-4);
199 }
200 marketVol = basket[j]->volatility()->value();
201 modelVol = impliedVolatility(basket[j]);
202 volDiff = modelVol - marketVol;
203 log << std::setw(3) << j << std::setprecision(6) << std::setw(14) << t << std::setw(14) << modelVol
204 << std::setw(14) << marketVol << std::setw(14) << volDiff << std::setw(14) << modelValue << std::setw(14)
205 << marketValue << std::setw(14) << valueDiff << std::setw(14) << modelSigma << "\n";
206 }
207 if (parametrization != nullptr) {
208 // report alpha, kappa at t_expiry^+ for last expiry
209 modelSigma = parametrization->sigma(t + 1E-4);
210 }
211 log << "t >= " << t << ": fxbsSigma = " << modelSigma << "\n";
212 return log.str();
213}
+ Here is the call graph for this function:

◆ getCalibrationDetails() [4/9]

std::string getCalibrationDetails ( const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  basket,
const QuantLib::ext::shared_ptr< EqBsParametrization > &  parametrization,
const QuantLib::ext::shared_ptr< Parametrization > &  domesticIrModel 
)

Definition at line 215 of file utilities.cpp.

217 {
218 auto lgmParametrization = QuantLib::ext::dynamic_pointer_cast<IrLgm1fParametrization>(parametrization);
219 if (lgmParametrization) {
220 return getCalibrationDetails(basket, parametrization, lgmParametrization);
221 } else {
222 return std::string();
223 }
224}
+ Here is the call graph for this function:

◆ getCalibrationDetails() [5/9]

std::string getCalibrationDetails ( const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  basket,
const QuantLib::ext::shared_ptr< EqBsParametrization > &  parametrization,
const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &  domesticLgm 
)

Definition at line 226 of file utilities.cpp.

228 {
229 std::ostringstream log;
230 log << std::right << std::setw(3) << "#" << std::setw(14) << "time" << std::setw(14) << "modelVol" << std::setw(14)
231 << "marketVol" << std::setw(14) << "(diff)" << std::setw(14) << "modelValue" << std::setw(14) << "marketValue"
232 << std::setw(14) << "(diff)" << std::setw(14) << "eqbsSigma\n";
233 Real t = 0.0, modelSigma = 0.0;
234 for (Size j = 0; j < basket.size(); j++) {
235 Real modelValue = basket[j]->modelValue();
236 Real marketValue = basket[j]->marketValue();
237 Real valueDiff = modelValue - marketValue;
238 Volatility modelVol = 0, marketVol = 0, volDiff = 0;
239 QuantLib::ext::shared_ptr<FxEqOptionHelper> eqoption = QuantLib::ext::dynamic_pointer_cast<FxEqOptionHelper>(basket[j]);
240 if (eqoption != nullptr && parametrization != nullptr && domesticLgm != nullptr) {
241 t = domesticLgm->termStructure()->timeFromReference(eqoption->option()->exercise()->date(0));
242 modelSigma = parametrization->sigma(t - 1E-4);
243 }
244 marketVol = basket[j]->volatility()->value();
245 modelVol = impliedVolatility(basket[j]);
246 volDiff = modelVol - marketVol;
247 log << std::setw(3) << j << std::setprecision(6) << std::setw(14) << t << std::setw(14) << modelVol
248 << std::setw(14) << marketVol << std::setw(14) << volDiff << std::setw(14) << modelValue << std::setw(14)
249 << marketValue << std::setw(14) << valueDiff << std::setw(14) << modelSigma << "\n";
250 }
251 if (parametrization != nullptr) {
252 modelSigma = parametrization->sigma(t + 1E-4);
253 }
254 log << "t >= " << t << ": eqbsSigma = " << modelSigma << "\n";
255 return log.str();
256}
+ Here is the call graph for this function:

◆ getCalibrationDetails() [6/9]

std::string getCalibrationDetails ( const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  basket,
const QuantLib::ext::shared_ptr< CommoditySchwartzParametrization > &  parametrization 
)

Definition at line 258 of file utilities.cpp.

259 {
260 std::ostringstream log;
261 log << std::right << std::setw(3) << "#" << std::setw(14) << "time" << std::setw(14) << "modelVol" << std::setw(14)
262 << "marketVol" << std::setw(14) << "(diff)" << std::setw(14) << "modelValue" << std::setw(14) << "marketValue"
263 << std::setw(14) << "(diff)" << std::setw(14) << "Sigma" << setw(14) << "Kappa\n";
264 Real t = 0.0;
265 Real modelSigma = parametrization->sigmaParameter();
266 Real modelKappa = parametrization->kappaParameter();
267 for (Size j = 0; j < basket.size(); j++) {
268 Real modelValue = basket[j]->modelValue();
269 Real marketValue = basket[j]->marketValue();
270 Real valueDiff = modelValue - marketValue;
271 Volatility modelVol = 0, marketVol = 0, volDiff = 0;
272 QuantLib::ext::shared_ptr<FutureOptionHelper> option = QuantLib::ext::dynamic_pointer_cast<FutureOptionHelper>(basket[j]);
273 if (option != nullptr && parametrization != nullptr) {
274 t = option->priceCurve()->timeFromReference(option->option()->exercise()->date(0));
275 //modelSigma = parametrization->sigma(t - 1E-4);
276 }
277 marketVol = basket[j]->volatility()->value();
278 modelVol = impliedVolatility(basket[j]);
279 volDiff = modelVol - marketVol;
280 log << std::setw(3) << j << std::setprecision(6) << std::setw(14) << t << std::setw(14) << modelVol
281 << std::setw(14) << marketVol << std::setw(14) << volDiff << std::setw(14) << modelValue << std::setw(14)
282 << marketValue << std::setw(14) << valueDiff << std::setw(14) << modelSigma << " " << modelKappa << "\n";
283 }
284 if (parametrization != nullptr) {
285 modelSigma = parametrization->sigma(t + 1E-4);
286 }
287 log << "t >= " << t << ": Sigma = " << modelSigma << ", Kappa = " << modelKappa << "\n";
288 return log.str();
289}
+ Here is the call graph for this function:

◆ getCalibrationDetails() [7/9]

std::string getCalibrationDetails ( const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &  basket,
const QuantLib::ext::shared_ptr< InfDkParametrization > &  parametrization,
bool  indexIsInterpolated 
)

Definition at line 291 of file utilities.cpp.

293 {
294 std::ostringstream log;
295 log << std::right << std::setw(3) << "#" << std::setw(14) << "time" << std::setw(14) << "modelValue"
296 << std::setw(14) << "marketValue" << std::setw(14) << "(diff)" << std::setw(14) << "infdkAlpha" << std::setw(14)
297 << "infdkH\n";
298 Real t = 0.0, modelAlpha = 0.0, modelH = 0.0;
299 for (Size j = 0; j < basket.size(); j++) {
300 Real modelValue = basket[j]->modelValue();
301 Real marketValue = basket[j]->marketValue();
302 Real valueDiff = (modelValue - marketValue);
303 QuantLib::ext::shared_ptr<CpiCapFloorHelper> instr = QuantLib::ext::dynamic_pointer_cast<CpiCapFloorHelper>(basket[j]);
304 if (instr != nullptr && parametrization != nullptr) {
305 // report alpha, H at t_expiry^-
306 t = inflationYearFraction(
307 parametrization->termStructure()->frequency(), indexIsInterpolated,
308 parametrization->termStructure()->dayCounter(), parametrization->termStructure()->baseDate(),
309 instr->instrument()->payDate() - parametrization->termStructure()->observationLag());
310 modelAlpha = parametrization->alpha(t - 1.0 / 250.0);
311 modelH = parametrization->H(t - 1.0 / 250.0);
312 }
313 // TODO handle other calibration helpers, too (capfloor)
314 log << std::setw(3) << j << std::setprecision(6) << std::setw(14) << t << std::setw(14) << modelValue
315 << std::setw(14) << marketValue << std::setw(14) << valueDiff << std::setw(14) << modelAlpha
316 << std::setw(14) << modelH << "\n";
317 }
318 if (parametrization != nullptr) {
319 // report alpha, kappa at t_expiry^+ for last expiry
320 modelAlpha = parametrization->alpha(t + 1.0 / 250.0);
321 modelH = parametrization->H(t + 1.0 / 2500.0);
322 }
323 log << "t >= " << t << ": infDkAlpha = " << modelAlpha << " infDkH = " << modelH << "\n";
324 return log.str();
325}
+ Here is the call graph for this function:

◆ getCalibrationDetails() [8/9]

std::string getCalibrationDetails ( const vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &  rrBasket,
const vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &  idxBasket,
const QuantLib::ext::shared_ptr< InfJyParameterization > &  p,
bool  calibrateRealRateVol 
)

Definition at line 327 of file utilities.cpp.

329 {
330
331 ostringstream log;
332 Real epsTime = 0.0001;
333
334 // Real rate basket: if it has instruments, the real rate was calibrated.
335 if (!rrBasket.empty()) {
336
337 // Header rows
338 log << "Real rate calibration:\n";
339 log << right << setw(3) << "#" << setw(5) << "](-" << setw(12) << "inst_date" << setw(12) << "time" << setw(14)
340 << "modelValue" << setw(14) << "marketValue" << setw(14) << "(diff)" << setw(14) << "infJyAlpha" << setw(14)
341 << "infJyH\n";
342
343 // Parameter values for corresponding to maturity of each instrument
344 Array times = calibrateRealRateVol ? p->realRate()->parameterTimes(0) : p->realRate()->parameterTimes(1);
345 auto helperValues = jyHelperValues(rrBasket, times);
346 Size ctr = 0;
347 Time t = 0.0;
348 for (const auto& kv : helperValues) {
349 auto hv = kv.second;
350 t = hv.maturity - epsTime;
351 string bound = "<=";
352 if (helperValues.size() == 1) {
353 bound = " -";
354 } else if (ctr == helperValues.size() - 1) {
355 t += 2 * epsTime;
356 bound = " >";
357 }
358 auto alpha = p->realRate()->alpha(t);
359 auto h = p->realRate()->H(t);
360 log << setw(3) << ctr++ << setw(5) << bound << setw(6) << io::iso_date(kv.first) << setprecision(6)
361 << setw(12) << hv.maturity << setw(14) << hv.modelValue << setw(14) << hv.marketValue << setw(14)
362 << hv.error << setw(14) << alpha << setw(14) << h << "\n";
363 }
364 }
365
366 // Inflation index basket: if it has instruments, the inflation index was calibrated.
367 if (!idxBasket.empty()) {
368
369 // Header rows
370 log << "Inflation index calibration:\n";
371 log << right << setw(3) << "#" << setw(5) << "](-" << setw(12) << "inst_date" << setw(12) << "time" << setw(14)
372 << "modelValue" << setw(14) << "marketValue" << setw(14) << "(diff)" << setw(14) << "infJySigma\n";
373
374 // Parameter values for corresponding to maturity of each instrument
375 Array times = p->index()->parameterTimes(0);
376 auto helperValues = jyHelperValues(idxBasket, times);
377 Size ctr = 0;
378 Time t = 0.0;
379 for (const auto& kv : helperValues) {
380 auto hv = kv.second;
381 t = hv.maturity - epsTime;
382 string bound = "<=";
383 if (helperValues.size() == 1) {
384 bound = " -";
385 } else if (ctr == helperValues.size() - 1) {
386 t += 2 * epsTime;
387 bound = " >";
388 }
389 auto sigma = p->index()->sigma(t);
390 log << setw(3) << ctr++ << setw(5) << bound << setw(6) << io::iso_date(kv.first) << setprecision(6)
391 << setw(12) << hv.maturity << setw(14) << hv.modelValue << setw(14) << hv.marketValue << setw(14)
392 << hv.error << setw(14) << sigma << "\n";
393 }
394 }
395
396 return log.str();
397}
+ Here is the call graph for this function:

◆ getCalibrationDetails() [9/9]

std::string getCalibrationDetails ( const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &  parametrization)

Definition at line 399 of file utilities.cpp.

399 {
400 std::ostringstream log;
401
402 log << right << setw(3) << "#" << setw(14) << "time" << setw(14) << "irlgm1fAlpha" << setw(14)
403 << "irlgm1fHwSigma\n";
404 Real t = 0.0;
405 Size j = 0;
406 for (; j < parametrization->parameterTimes(0).size(); ++j) {
407 t = parametrization->parameterTimes(0)[j];
408 Real alpha = parametrization->alpha(t - 1E-4);
409 Real sigma = parametrization->hullWhiteSigma(t - 1E-4);
410 log << setw(3) << j << setprecision(6) << setw(14) << t << setw(14) << alpha << setw(14) << sigma << "\n";
411 }
412 log << setw(3) << j << setprecision(6) << setw(14) << (std::to_string(t) + "+") << setw(14)
413 << parametrization->alpha(t + 1E-4) << setw(14) << parametrization->hullWhiteSigma(t + 1E-4) << "\n";
414
415 log << right << setw(3) << "#" << setw(14) << "time" << setw(14) << "irlgm1fKappa" << setw(14) << "irlgm1fH\n";
416 t = 0.0;
417 j = 0;
418 for (; j < parametrization->parameterTimes(1).size(); ++j) {
419 t = parametrization->parameterTimes(0)[j];
420 Real kappa = parametrization->kappa(t - 1E-4);
421 Real H = parametrization->H(t - 1E-4);
422 log << setw(3) << j << setprecision(6) << setw(14) << t << setw(14) << kappa << setw(14) << H << "\n";
423 }
424 log << setw(3) << j << setprecision(6) << setw(14) << (std::to_string(t) + "+") << setw(14)
425 << parametrization->kappa(t + 1E-4) << setw(14) << parametrization->H(t + 1E-4) << "\n";
426
427 return log.str();
428}
Size size(const ValueType &v)
Definition: value.cpp:145
+ Here is the call graph for this function:

◆ optionMaturity() [1/2]

Date optionMaturity ( const boost::variant< Date, Period > &  maturity,
const QuantLib::Calendar &  calendar,
const QuantLib::Date &  referenceDate 
)

Definition at line 447 of file utilities.cpp.

448 {
449
450 return boost::apply_visitor(MaturityGetter(calendar, referenceDate), maturity);
451}
Time maturity
Definition: utilities.cpp:66
Date referenceDate
Definition: utilities.cpp:442
Calendar calendar
Definition: utilities.cpp:441
+ Here is the caller graph for this function:

◆ cpiCapFloorStrikeValue()

Real cpiCapFloorStrikeValue ( const QuantLib::ext::shared_ptr< BaseStrike > &  strike,
const QuantLib::ext::shared_ptr< ZeroInflationTermStructure > &  curve,
const QuantLib::Date &  optionMaturityDate 
)

Return a cpi cap/floor strike value, the input strike can be of type absolute or atm forward.

Definition at line 453 of file utilities.cpp.

455 {
456 if (auto abs = QuantLib::ext::dynamic_pointer_cast<AbsoluteStrike>(strike)) {
457 return abs->strike();
458 } else if (auto atm = QuantLib::ext::dynamic_pointer_cast<AtmStrike>(strike)) {
459 QL_REQUIRE(atm->atmType() == DeltaVolQuote::AtmFwd,
460 "only atm forward allowed as atm strike for cpi cap floors");
461 return curve->zeroRate(optionMaturityDate);
462 } else {
463 QL_FAIL("cpi cap floor strike type not supported, expected absolute strike or atm fwd strike, got '"
464 << strike->toString());
465 }
466}
RandomVariable abs(RandomVariable x)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ yoyCapFloorStrikeValue()

Real yoyCapFloorStrikeValue ( const QuantLib::ext::shared_ptr< BaseStrike > &  strike,
const QuantLib::ext::shared_ptr< YoYInflationTermStructure > &  curve,
const QuantLib::Date &  optionMaturityDate 
)

Return a yoy cap/floor strike value, the input strike can be of type absolute or atm forward.

Definition at line 468 of file utilities.cpp.

470 {
471 if (auto abs = QuantLib::ext::dynamic_pointer_cast<AbsoluteStrike>(strike)) {
472 return abs->strike();
473 } else if (auto atm = QuantLib::ext::dynamic_pointer_cast<AtmStrike>(strike)) {
474 QL_REQUIRE(atm->atmType() == DeltaVolQuote::AtmFwd,
475 "only atm forward allowed as atm strike for cpi cap floors");
476 return curve->yoyRate(optionMaturityDate);
477 } else {
478 QL_FAIL("yoy cap floor strike type not supported, expected absolute strike or atm fwd strike, got '"
479 << strike->toString());
480 }
481}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ atmForward()

Real atmForward ( const Real  s0,
const Handle< YieldTermStructure > &  r,
const Handle< YieldTermStructure > &  q,
const Real  t 
)

helper function that computes the atm forward

Definition at line 483 of file utilities.cpp.

483 {
484 return s0 * q->discount(t) / r->discount(t);
485}
+ Here is the caller graph for this function:

◆ getCalibrationError()

Real getCalibrationError ( const std::vector< QuantLib::ext::shared_ptr< Helper > > &  basket)

Definition at line 47 of file utilities.hpp.

47 {
48 Real rmse = 0.0;
49 for (auto const& h : basket) {
50 Real tmp = h->calibrationError();
51 rmse += tmp * tmp;
52 }
53 return std::sqrt(rmse / static_cast<Real>(basket.size()));
54}
+ Here is the caller graph for this function:

◆ optionMaturity() [2/2]

QuantLib::Date optionMaturity ( const boost::variant< QuantLib::Date, QuantLib::Period > &  maturity,
const QuantLib::Calendar &  calendar,
const QuantLib::Date &  referenceDate = Settings::instance().evaluationDate() 
)

Return an option's maturity date, given an explicit date or a period.

◆ operator<() [7/14]

bool operator< ( const BasketConstituent lhs,
const BasketConstituent rhs 
)

Compare BasketConstituent instances using their credit curve ID.

If credit curve ID is not enough here, we should construct a private key member variable in BasketConstituent and make this operator a friend that uses the key.

Definition at line 255 of file basketdata.cpp.

255 {
256 return lhs.creditCurveId() < rhs.creditCurveId();
257}
const std::string & creditCurveId() const
Definition: basketdata.cpp:204
+ Here is the call graph for this function:

◆ populateFromBondReferenceData()

void populateFromBondReferenceData ( std::string &  subType,
std::string &  issuerId,
std::string &  settlementDays,
std::string &  calendar,
std::string &  issueDate,
std::string &  priceQuoteMethod,
std::string &  priceQuoteBaseValue,
std::string &  creditCurveId,
std::string &  creditGroup,
std::string &  referenceCurveId,
std::string &  incomeCurveId,
std::string &  volatilityCurveId,
std::vector< LegData > &  coupons,
const std::string &  name,
const QuantLib::ext::shared_ptr< BondReferenceDatum > &  bondRefData,
const std::string &  startDate = "",
const std::string &  endDate = "" 
)

Populate bond data from name and ReferenceDataManager.

The following elements are references and updated, if empty: issuerId settlementDays calendar issueDate creditCurveId creditGroup referenceCurveId incomeCurveId volatilityCurveId coupons

Definition at line 26 of file bondutils.cpp.

33 {
34 DLOG("populating data bond from reference data");
35 QL_REQUIRE(bondRefData, "populateFromBondReferenceData(): empty bond reference datum given");
36 if (subType.empty()) {
37 subType = bondRefData->bondData().subType;
38 TLOG("overwrite subType with '" << subType << "'");
39 }
40 if (issuerId.empty()) {
41 issuerId = bondRefData->bondData().issuerId;
42 TLOG("overwrite issuerId with '" << issuerId << "'");
43 }
44 if (settlementDays.empty()) {
45 settlementDays = bondRefData->bondData().settlementDays;
46 TLOG("overwrite settlementDays with '" << settlementDays << "'");
47 }
48 if (calendar.empty()) {
49 calendar = bondRefData->bondData().calendar;
50 TLOG("overwrite calendar with '" << calendar << "'");
51 }
52 if (issueDate.empty()) {
53 issueDate = bondRefData->bondData().issueDate;
54 TLOG("overwrite issueDate with '" << issueDate << "'");
55 }
56 if (priceQuoteMethod.empty()) {
57 priceQuoteMethod = bondRefData->bondData().priceQuoteMethod;
58 TLOG("overwrite priceQuoteMethod with '" << priceQuoteMethod << "'");
59 }
60 if (priceQuoteBaseValue.empty()) {
61 priceQuoteBaseValue = bondRefData->bondData().priceQuoteBaseValue;
62 TLOG("overwrite priceQuoteBaseValue with '" << priceQuoteBaseValue << "'");
63 }
64 if (creditCurveId.empty()) {
65 creditCurveId = bondRefData->bondData().creditCurveId;
66 TLOG("overwrite creditCurveId with '" << creditCurveId << "'");
67 }
68 if (creditGroup.empty()) {
69 creditGroup = bondRefData->bondData().creditGroup;
70 TLOG("overwrite creditGroup with '" << creditGroup << "'");
71 }
72 if (referenceCurveId.empty()) {
73 referenceCurveId = bondRefData->bondData().referenceCurveId;
74 TLOG("overwrite referenceCurveId with '" << referenceCurveId << "'");
75 }
76 if (incomeCurveId.empty()) {
77 incomeCurveId = bondRefData->bondData().incomeCurveId;
78 TLOG("overwrite incomeCurveId with '" << incomeCurveId << "'");
79 }
80 if (volatilityCurveId.empty()) {
81 volatilityCurveId = bondRefData->bondData().volatilityCurveId;
82 TLOG("overwrite volatilityCurveId with '" << volatilityCurveId << "'");
83 }
84 if (coupons.empty()) {
85 coupons = bondRefData->bondData().legData;
86 TLOG("overwrite coupons with " << coupons.size() << " LegData nodes");
87 }
88 if (!startDate.empty()) {
89 if (coupons.size() == 1 && coupons.front().schedule().rules().size() == 1 && coupons.front().schedule().dates().size() == 0) {
90 string oldStart = coupons.front().schedule().rules().front().startDate();
91 coupons.front().schedule().modifyRules().front().modifyStartDate() = startDate;
92 string newStart = coupons.front().schedule().rules().front().startDate();
93 DLOG("Modified start date " << oldStart << " -> " << newStart);
94 }
95 else {
96 StructuredTradeErrorMessage(bondRefData->bondData().issuerId, "Bond-linked", "update reference data",
97 "modifified start date cannot be applied to multiple legs/schedules")
98 .log();
99 }
100 }
101 if (!endDate.empty()) {
102 if (coupons.size() == 1 && coupons.front().schedule().rules().size() == 1 && coupons.front().schedule().dates().size() == 0) {
103 string oldEnd = coupons.front().schedule().rules().front().endDate();
104 coupons.front().schedule().modifyRules().front().modifyEndDate() = endDate;
105 string newEnd = coupons.front().schedule().rules().front().endDate();
106 DLOG("Modified end date " << oldEnd << " -> " << newEnd);
107 }
108 else {
109 StructuredTradeErrorMessage(bondRefData->bondData().issuerId, "Bond-linked", "update reference data",
110 "modifified end date cannot be applied to multiple legs/schedules")
111 .log();
112 }
113 }
114
115 DLOG("populating bond data from reference data done.");
116}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOpenEndDateReplacement()

Date getOpenEndDateReplacement ( const std::string &  replacementPeriodStr,
const Calendar &  calendar 
)

Definition at line 118 of file bondutils.cpp.

118 {
119 if (replacementPeriodStr.empty())
120 return QuantLib::Null<QuantLib::Date>();
121 Date today = Settings::instance().evaluationDate();
122 Date result = Date::maxDate() - 365;
123 try {
124 // might throw because we are beyond the last allowed date
125 result = (calendar.empty() ? NullCalendar() : calendar).advance(today, parsePeriod(replacementPeriodStr));
126 } catch (...) {
127 }
128 DLOG("Compute open end date replacement as "
129 << QuantLib::io::iso_date(result) << " (today = " << QuantLib::io::iso_date(today)
130 << ", OpenEndDateReplacement from pricing engine config = " << replacementPeriodStr << ")");
131 return result;
132}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildPerformanceOptimizedDefaultCurves()

std::vector< Handle< DefaultProbabilityTermStructure > > buildPerformanceOptimizedDefaultCurves ( const std::vector< Handle< DefaultProbabilityTermStructure > > &  curves)

Disable sensitivites for the all but the first default probability curve Shift all other curves parallel with the first curve, reduce the numbers of calculations

Definition at line 40 of file cdo.cpp.

40 {
41 std::vector<Handle<DefaultProbabilityTermStructure>> dpts;
42 Handle<DefaultProbabilityTermStructure> clientCurve;
43 Handle<DefaultProbabilityTermStructure> baseCurve;
44 vector<Time> baseCurveTimes;
45
46 for (const auto& targetCurve : curves) {
47 //For all but the first curve use a spreaded curve, with the first curve as reference and
48 //the inital spread between the curve and the first curve, keep the spread constant
49 //in case of a spreaded curve we need to use the underlying reference curve to retrieve the
50 //correct pillar times, otherwise the interpolation grid is to coarse and we wouldnt match
51 //today's market prices
52 vector<Time> targetCurveTimes = ore::data::SyntheticCDO::extractTimeGridDefaultCurve(targetCurve);
53 // Sort times we need to interpolate an all pillars of the base and target curve
54 std::sort(targetCurveTimes.begin(), targetCurveTimes.end());
55 // Use the first curve as basis curve and update times
56 if (targetCurve == curves.front()) {
57 baseCurve = targetCurve;
58 clientCurve = baseCurve;
59 baseCurveTimes = targetCurveTimes;
60 } else {
61 std::vector<Time> times;
62 std::set_union(baseCurveTimes.begin(), baseCurveTimes.end(), targetCurveTimes.begin(),
63 targetCurveTimes.end(), std::back_inserter(times));
64 vector<Handle<Quote>> spreads(times.size());
65 std::transform(times.begin(), times.end(), spreads.begin(), [&baseCurve, &targetCurve](Time t) {
66 Probability spread =
67 targetCurve->survivalProbability(t, true) / baseCurve->survivalProbability(t, true);
68 if (close_enough(spread, 0.0)) {
69 spread = 1e-18;
70 }
71 return Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(spread));
72 });
73 clientCurve = Handle<DefaultProbabilityTermStructure>(
74 QuantLib::ext::make_shared<SpreadedSurvivalProbabilityTermStructure>(baseCurve, times, spreads));
75 if (baseCurve->allowsExtrapolation())
76 clientCurve->enableExtrapolation();
77 }
78 dpts.push_back(clientCurve);
79 }
80 return dpts;
81}
static vector< Time > extractTimeGridDefaultCurve(const QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > &dpts)
Definition: cdo.cpp:739
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ycmFromString()

GFunctionFactory::YieldCurveModel ycmFromString ( const string &  s)

Definition at line 30 of file cms.cpp.

30 {
31 if (s == "Standard")
32 return GFunctionFactory::Standard;
33 else if (s == "ExactYield")
34 return GFunctionFactory::ExactYield;
35 else if (s == "ParallelShifts")
36 return GFunctionFactory::ParallelShifts;
37 else if (s == "NonParallelShifts")
38 return GFunctionFactory::NonParallelShifts;
39 else
40 QL_FAIL("unknown string for YieldCurveModel");
41}
+ Here is the caller graph for this function:

◆ operator==() [5/13]

bool operator== ( const CDSEngineKey lhs,
const CDSEngineKey rhs 
)

Definition at line 75 of file creditdefaultswap.hpp.

75 {
76
77 // Check the credit curve IDs first
78 if (lhs.creditCurveId() != rhs.creditCurveId())
79 return false;
80
81 // Check the currencies
82 if (lhs.currency() != rhs.currency())
83 return false;
84
85 // Now check recovery rates.
86 if (lhs.recoveryRate() == QuantLib::Null<QuantLib::Real>() &&
87 rhs.recoveryRate() == QuantLib::Null<QuantLib::Real>()) {
88 // Most usual case is both are Null<Real> and using the recovery rate from the market.
89 return true;
90 } else if ((lhs.recoveryRate() != QuantLib::Null<QuantLib::Real>() &&
91 rhs.recoveryRate() == QuantLib::Null<QuantLib::Real>()) ||
92 (lhs.recoveryRate() == QuantLib::Null<QuantLib::Real>() &&
93 rhs.recoveryRate() != QuantLib::Null<QuantLib::Real>())) {
94 return false;
95 } else {
96 return QuantLib::close(lhs.recoveryRate(), rhs.recoveryRate());
97 }
98}
QuantLib::Real recoveryRate() const
Return the recovery rate if it is set, otherwise Null<Real>()
const std::string & creditCurveId() const
Return the credit curve Id.
const QuantLib::Currency & currency() const
Return the currency.
+ Here is the call graph for this function:

◆ operator<() [8/14]

bool operator< ( const CDSEngineKey lhs,
const CDSEngineKey rhs 
)

Definition at line 100 of file creditdefaultswap.hpp.

100 {
101
102 // Check equality first
103 if (lhs == rhs)
104 return false;
105
106 // Now check credit curve Ids.
107 if (lhs.creditCurveId() != rhs.creditCurveId())
108 return lhs.creditCurveId() < rhs.creditCurveId();
109
110 // Now check currencies.
111 if (lhs.currency() != rhs.currency())
112 return lhs.currency().name() < rhs.currency().name();
113
114 // Now use the recovery rates
115 return lhs.recoveryRate() < rhs.recoveryRate();
116}
+ Here is the call graph for this function:

◆ operator!=() [1/4]

bool operator!= ( const CDSEngineKey lhs,
const CDSEngineKey rhs 
)

Definition at line 118 of file creditdefaultswap.hpp.

118{ return !(lhs == rhs); }

◆ operator>()

bool operator> ( const CDSEngineKey lhs,
const CDSEngineKey rhs 
)

Definition at line 119 of file creditdefaultswap.hpp.

119{ return rhs < lhs; }

◆ operator<=()

bool operator<= ( const CDSEngineKey lhs,
const CDSEngineKey rhs 
)

Definition at line 120 of file creditdefaultswap.hpp.

120{ return !(lhs > rhs); }

◆ operator>=()

bool operator>= ( const CDSEngineKey lhs,
const CDSEngineKey rhs 
)

Definition at line 121 of file creditdefaultswap.hpp.

121{ return !(lhs < rhs); }

◆ parseCommodityPayRelativeTo()

CommodityPayRelativeTo parseCommodityPayRelativeTo ( const string &  s)

Definition at line 52 of file commoditylegdata.cpp.

52 {
53 if (iequals(s, "CalculationPeriodEndDate")) {
54 return CommodityPayRelativeTo::CalculationPeriodEndDate;
55 } else if (iequals(s, "CalculationPeriodStartDate")) {
56 return CommodityPayRelativeTo::CalculationPeriodStartDate;
57 } else if (iequals(s, "TerminationDate")) {
58 return CommodityPayRelativeTo::TerminationDate;
59 } else if (iequals(s, "FutureExpiryDate")) {
60 return CommodityPayRelativeTo::FutureExpiryDate;
61 } else {
62 QL_FAIL("Could not parse " << s << " to CommodityPayRelativeTo");
63 }
64}
+ Here is the caller graph for this function:

◆ operator<<() [29/73]

std::ostream & operator<< ( ostream &  out,
const CommodityPayRelativeTo cprt 
)

Definition at line 66 of file commoditylegdata.cpp.

66 {
67 if (cprt == CommodityPayRelativeTo::CalculationPeriodEndDate) {
68 return out << "CalculationPeriodEndDate";
69 } else if (cprt == CommodityPayRelativeTo::CalculationPeriodStartDate) {
70 return out << "CalculationPeriodStartDate";
71 } else if (cprt == CommodityPayRelativeTo::TerminationDate) {
72 return out << "TerminationDate";
73 } else if (cprt == CommodityPayRelativeTo::FutureExpiryDate) {
74 return out << "FutureExpiryDate";
75 } else {
76 QL_FAIL("Do not recognise CommodityPayRelativeTo " << static_cast<int>(cprt));
77 }
78}

◆ parseCommodityPriceType()

CommodityPriceType parseCommodityPriceType ( const string &  s)

Definition at line 80 of file commoditylegdata.cpp.

80 {
81 if (iequals(s, "Spot")) {
82 return CommodityPriceType::Spot;
83 } else if (iequals(s, "FutureSettlement")) {
84 return CommodityPriceType::FutureSettlement;
85 } else {
86 QL_FAIL("Could not parse " << s << " to CommodityPriceType");
87 }
88}
+ Here is the caller graph for this function:

◆ operator<<() [30/73]

std::ostream & operator<< ( ostream &  out,
const CommodityPriceType cpt 
)

Definition at line 90 of file commoditylegdata.cpp.

90 {
91 if (cpt == CommodityPriceType::Spot) {
92 return out << "Spot";
93 } else if (cpt == CommodityPriceType::FutureSettlement) {
94 return out << "FutureSettlement";
95 } else {
96 QL_FAIL("Do not recognise CommodityPriceType " << static_cast<int>(cpt));
97 }
98}

◆ parseCommodityPricingDateRule()

CommodityPricingDateRule parseCommodityPricingDateRule ( const string &  s)

Definition at line 100 of file commoditylegdata.cpp.

100 {
101 if (iequals(s, "FutureExpiryDate")) {
102 return CommodityPricingDateRule::FutureExpiryDate;
103 } else if (iequals(s, "None")) {
104 return CommodityPricingDateRule::None;
105 } else {
106 QL_FAIL("Could not parse " << s << " to CommodityPricingDateRule");
107 }
108}
+ Here is the caller graph for this function:

◆ operator<<() [31/73]

std::ostream & operator<< ( std::ostream &  out,
const CommodityPricingDateRule cpdr 
)

Definition at line 110 of file commoditylegdata.cpp.

110 {
111 if (cpdr == CommodityPricingDateRule::FutureExpiryDate) {
112 return out << "FutureExpiryDate";
113 } else if (cpdr == CommodityPricingDateRule::None) {
114 return out << "None";
115 } else {
116 QL_FAIL("Do not recognise CommodityPricingDateRule " << static_cast<int>(cpdr));
117 }
118}

◆ makeOptionPaymentDateAdjuster()

QuantLib::ext::shared_ptr< OptionPaymentDateAdjuster > makeOptionPaymentDateAdjuster ( CommoditySpreadOptionData optionData,
const std::vector< Date > &  expiryDates 
)

Definition at line 112 of file commodityspreadoption.cpp.

113 {
114
115 if (optionData.optionStrip().has_value()) {
116 return QuantLib::ext::make_shared<OptionStripPaymentDateAdjuster>(expiryDates, optionData.optionStrip().get());
117 } else if (optionData.optionData().paymentData().has_value()) {
118 return QuantLib::ext::make_shared<OptionPaymentDataAdjuster>(optionData.optionData().paymentData().get());
119 } else {
120 return QuantLib::ext::make_shared<OptionPaymentDateAdjuster>();
121 }
122}
const ore::data::OptionData & optionData() const
boost::optional< OptionStripData > optionStrip()
const boost::optional< OptionPaymentData > & paymentData() const
Definition: optiondata.hpp:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseCdsTier()

CdsTier parseCdsTier ( const string &  s)

Definition at line 33 of file creditdefaultswapdata.cpp.

33 {
34 if (s == "SNRFOR") {
35 return CdsTier::SNRFOR;
36 } else if (s == "SUBLT2") {
37 return CdsTier::SUBLT2;
38 } else if (s == "SNRLAC") {
39 return CdsTier::SNRLAC;
40 } else if (s == "SECDOM") {
41 return CdsTier::SECDOM;
42 } else if (s == "JRSUBUT2") {
43 return CdsTier::JRSUBUT2;
44 } else if (s == "PREFT1") {
45 return CdsTier::PREFT1;
46 } else if (s == "LIEN1") {
47 return CdsTier::LIEN1;
48 } else if (s == "LIEN2") {
49 return CdsTier::LIEN2;
50 } else if (s == "LIEN3") {
51 return CdsTier::LIEN3;
52 }
53 QL_FAIL("Could not parse \"" << s << "\" to CdsTier");
54}
+ Here is the caller graph for this function:

◆ operator<<() [32/73]

std::ostream & operator<< ( ostream &  out,
const CdsTier cdsTier 
)

Definition at line 56 of file creditdefaultswapdata.cpp.

56 {
57 switch (cdsTier) {
58 case CdsTier::SNRFOR:
59 return out << "SNRFOR";
60 case CdsTier::SUBLT2:
61 return out << "SUBLT2";
62 case CdsTier::SNRLAC:
63 return out << "SNRLAC";
64 case CdsTier::SECDOM:
65 return out << "SECDOM";
66 case CdsTier::JRSUBUT2:
67 return out << "JRSUBUT2";
68 case CdsTier::PREFT1:
69 return out << "PREFT1";
70 case CdsTier::LIEN1:
71 return out << "LIEN1";
72 case CdsTier::LIEN2:
73 return out << "LIEN2";
74 case CdsTier::LIEN3:
75 return out << "LIEN3";
76 default:
77 QL_FAIL("Do not recognise CdsTier " << static_cast<int>(cdsTier));
78 }
79}

◆ parseCdsDocClause()

CdsDocClause parseCdsDocClause ( const string &  s)

Definition at line 81 of file creditdefaultswapdata.cpp.

81 {
82 if (s == "CR") {
83 return CdsDocClause::CR;
84 } else if (s == "MM") {
85 return CdsDocClause::MM;
86 } else if (s == "MR") {
87 return CdsDocClause::MR;
88 } else if (s == "XR") {
89 return CdsDocClause::XR;
90 } else if (s == "CR14") {
91 return CdsDocClause::CR14;
92 } else if (s == "MM14") {
93 return CdsDocClause::MM14;
94 } else if (s == "MR14") {
95 return CdsDocClause::MR14;
96 } else if (s == "XR14") {
97 return CdsDocClause::XR14;
98 } else {
99 QL_FAIL("Could not parse \"" << s << "\" to CdsDocClause");
100 }
101}
+ Here is the caller graph for this function:

◆ operator<<() [33/73]

std::ostream & operator<< ( ostream &  out,
const CdsDocClause cdsDocClause 
)

Definition at line 103 of file creditdefaultswapdata.cpp.

103 {
104 switch (cdsDocClause) {
105 case CdsDocClause::CR:
106 return out << "CR";
107 case CdsDocClause::MM:
108 return out << "MM";
109 case CdsDocClause::MR:
110 return out << "MR";
111 case CdsDocClause::XR:
112 return out << "XR";
113 case CdsDocClause::CR14:
114 return out << "CR14";
115 case CdsDocClause::MM14:
116 return out << "MM14";
117 case CdsDocClause::MR14:
118 return out << "MR14";
119 case CdsDocClause::XR14:
120 return out << "XR14";
121 default:
122 QL_FAIL("Do not recognise CdsDocClause " << static_cast<int>(cdsDocClause));
123 }
124}

◆ parseIsdaRulesDefinitions()

IsdaRulesDefinitions parseIsdaRulesDefinitions ( const string &  s)

Definition at line 127 of file creditdefaultswapdata.cpp.

127 {
128 if (s == "2003") {
129 return IsdaRulesDefinitions::y2003;
130 } else if (s == "2014") {
131 return IsdaRulesDefinitions::y2014;
132 } else {
133 QL_FAIL("Could not parse \"" << s << "\" to isdaRulesDefinitions");
134 }
135}

◆ operator<<() [34/73]

ostream & operator<< ( ostream &  out,
const IsdaRulesDefinitions isdaRulesDefinitions 
)

Definition at line 137 of file creditdefaultswapdata.cpp.

137 {
138 switch (isdaRulesDefinitions) {
139 case IsdaRulesDefinitions::y2003:
140 return out << "2003";
141 case IsdaRulesDefinitions::y2014:
142 return out << "2014";
143 default:
144 QL_FAIL("Do not recognise IsdaRulesDefinitions " << static_cast<int>(isdaRulesDefinitions));
145 }
146}

◆ isdaRulesDefinitionsFromDocClause()

IsdaRulesDefinitions isdaRulesDefinitionsFromDocClause ( const CdsDocClause cdsDocClause)

Definition at line 148 of file creditdefaultswapdata.cpp.

148 {
149 switch (cdsDocClause) {
150 case CdsDocClause::CR:
151 case CdsDocClause::MR:
152 case CdsDocClause::XR:
153 case CdsDocClause::MM:
154 return IsdaRulesDefinitions::y2003;
155 case CdsDocClause::CR14:
156 case CdsDocClause::MR14:
157 case CdsDocClause::XR14:
158 case CdsDocClause::MM14:
159 default:
160 return IsdaRulesDefinitions::y2014;
161 }
162}

◆ parseCreditEventType()

CreditEventType parseCreditEventType ( const string &  s)

Definition at line 164 of file creditdefaultswapdata.cpp.

164 {
165 if (s == "BANKRUPTCY") {
166 return CreditEventType::BANKRUPTCY;
167 } else if (s == "FAILURE TO PAY") {
168 return CreditEventType::FAILURE_TO_PAY;
169 } else if (s == "RESTRUCTURING") {
170 return CreditEventType::RESTRUCTURING;
171 } else if (s == "OBLIGATION ACCELERATION") {
172 return CreditEventType::OBLIGATION_ACCELERATION;
173 } else if (s == "OBLIGATION DEFAULT") {
174 return CreditEventType::OBLIGATION_DEFAULT;
175 } else if (s == "REPUDIATION/MORATORIUM") {
176 return CreditEventType::REPUDIATION_MORATORIUM;
177 } else if (s == "GOVERNMENTAL INTERVENTION") {
178 return CreditEventType::GOVERNMENTAL_INTERVENTION;
179 } else {
180 QL_FAIL("Could not parse \"" << s << "\" to a credit event.");
181 }
182}

◆ operator<<() [35/73]

std::ostream & operator<< ( ostream &  out,
const CreditEventType creditEventType 
)

Definition at line 184 of file creditdefaultswapdata.cpp.

184 {
185 switch (creditEventType) {
186 case CreditEventType::BANKRUPTCY:
187 return out << "BANKRUPTCY";
188 case CreditEventType::FAILURE_TO_PAY:
189 return out << "FAILURE TO PAY";
190 case CreditEventType::RESTRUCTURING:
191 return out << "RESTRUCTURING";
192 case CreditEventType::OBLIGATION_ACCELERATION:
193 return out << "OBLIGATION ACCELERATION";
194 case CreditEventType::OBLIGATION_DEFAULT:
195 return out << "OBLIGATION DEFAULT";
196 case CreditEventType::REPUDIATION_MORATORIUM:
197 return out << "REPUDIATION/MORATORIUM";
198 case CreditEventType::GOVERNMENTAL_INTERVENTION:
199 return out << "GOVERNMENTAL INTERVENTION";
200 default:
201 QL_FAIL("Do not recognise CreditEventType " << static_cast<int>(creditEventType));
202 }
203}

◆ isTriggeredDocClause()

bool isTriggeredDocClause ( CdsDocClause  contractDocClause,
CreditEventType  creditEventType 
)

Definition at line 205 of file creditdefaultswapdata.cpp.

205 {
206 switch (creditEventType) {
210 // all of the above include a failure to pay
211 switch (contractDocClause) {
220 return true;
221 default:
222 break;
223 }
224 break;
226 // typically includes a conversion to shares with a write down
228 // it depends on the type of restructure!
229 switch (contractDocClause) {
236 return true;
239 return false;
240 default:
241 break;
242 }
245 // not necessarily a default itself, no examples in record.
246 return false;
247 break;
248 default:
249 break;
250 }
251 QL_FAIL("Could not recognize CreditEventType "
252 << static_cast<int>(creditEventType) << " or CdsDocClause " << static_cast<int>(contractDocClause)
253 << " when identifying whether a doc clause is triggrered for a given credit event type.");
254 return false;
255}

◆ parseCreditEventTiers()

CreditEventTiers parseCreditEventTiers ( const string &  s)

Definition at line 257 of file creditdefaultswapdata.cpp.

257 {
258 if (s == "SNR") {
259 return CreditEventTiers::SNR;
260 } else if (s == "SUB") {
261 return CreditEventTiers::SUB;
262 } else if (s == "SNRLAC") {
263 return CreditEventTiers::SNRLAC;
264 } else if (s == "SNR/SUB") {
265 return CreditEventTiers::SNR_SUB;
266 } else if (s == "SNR/SNRLAC") {
267 return CreditEventTiers::SNR_SNRLAC;
268 } else if (s == "SUB/SNRLAC") {
269 return CreditEventTiers::SUB_SNRLAC;
270 } else if (s == "SNR/SUB/SNRLAC") {
271 return CreditEventTiers::SNR_SUB_SNRLAC;
272 } else {
273 QL_FAIL("Could not parse \"" << s << "\" to a credit event tiers set.");
274 }
275}

◆ operator<<() [36/73]

std::ostream & operator<< ( ostream &  out,
const CreditEventTiers creditEventTiers 
)

Definition at line 277 of file creditdefaultswapdata.cpp.

277 {
278 switch (creditEventTiers) {
279 case CreditEventTiers::SNR:
280 return out << "SNR";
281 case CreditEventTiers::SUB:
282 return out << "SUB";
283 case CreditEventTiers::SNRLAC:
284 return out << "SNRLAC";
285 case CreditEventTiers::SNR_SUB:
286 return out << "SNR/SUB";
287 case CreditEventTiers::SNR_SNRLAC:
288 return out << "SNR/SNRLAC";
289 case CreditEventTiers::SUB_SNRLAC:
290 return out << "SUB/SNRLAC";
291 case CreditEventTiers::SNR_SUB_SNRLAC:
292 return out << "SNR/SUB/SNRLAC";
293 default:
294 QL_FAIL("Do not recognise CreditEventTiers " << static_cast<int>(creditEventTiers));
295 }
296}

◆ isAuctionedSeniority()

bool isAuctionedSeniority ( CdsTier  contractTier,
CreditEventTiers  creditEventTiers 
)

Definition at line 298 of file creditdefaultswapdata.cpp.

298 {
299 switch (creditEventTiers) {
301 switch (contractTier) {
305 return true;
309 return false;
310 default:
311 break;
312 }
313 break;
315 switch (contractTier) {
318 return true;
323 return false;
324 default:
325 break;
326 }
327 break;
329 switch (contractTier) {
331 return true;
337 return false;
338 default:
339 break;
340 }
341 break;
343 switch (contractTier) {
349 return true;
351 return false;
352 default:
353 break;
354 }
355 break;
357 switch (contractTier) {
362 return true;
365 return false;
366 default:
367 break;
368 }
369 break;
371 switch (contractTier) {
375 return true;
379 return false;
380 default:
381 break;
382 }
383 break;
385 switch (contractTier) {
392 return true;
393 default:
394 break;
395 }
396 break;
397 default:
398 break;
399 }
400 QL_FAIL("Could not recognize CreditEventTiers "
401 << static_cast<int>(creditEventTiers) << " or CdsTier " << static_cast<int>(contractTier)
402 << " when identifying the applicability if an event for a given contract tier.");
403 return false;
404}

◆ getLowerAndUpperBound()

std::pair< std::string, std::string > getLowerAndUpperBound ( const std::string &  type,
const std::string &  binaryLevelA,
const std::string &  binaryLevelB 
)

Definition at line 26 of file doubledigitaloption.cpp.

27 {
28 if (type == "Call") {
29 return {binaryLevelA, ore::data::to_string(QL_MAX_REAL)};
30 } else if (type == "Put") {
31 return {ore::data::to_string(QL_MIN_REAL), binaryLevelA};
32 } else if (type == "Collar") {
33 return {binaryLevelA, binaryLevelB};
34 } else {
35 QL_FAIL("DoubleDigitalOption got unexpected option type '"
36 << type << "'. Valid values are 'Call', 'Put' and 'Collar'.");
37 }
38}
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==() [6/13]

bool operator== ( const EngineData lhs,
const EngineData rhs 
)

Definition at line 127 of file enginedata.cpp.

127 {
128 vector<string> products = lhs.products();
129 // this assumes they are both sorted the same
130 if (products != rhs.products())
131 return false;
132 // now loop over the products and check everything
133 for (auto product : products) {
134 if (lhs.model(product) != rhs.model(product) || lhs.modelParameters(product) != rhs.modelParameters(product) ||
135 lhs.engine(product) != rhs.engine(product) ||
136 lhs.engineParameters(product) != rhs.engineParameters(product))
137 return false;
138 }
139 return true;
140}
vector< string > products() const
Return all products.
Definition: enginedata.cpp:120
const map< string, string > & modelParameters(const string &productName) const
Definition: enginedata.hpp:50
const map< string, string > & engineParameters(const string &productName) const
Definition: enginedata.hpp:52
const string & model(const string &productName) const
Definition: enginedata.hpp:49
const string & engine(const string &productName) const
Definition: enginedata.hpp:51
+ Here is the call graph for this function:

◆ operator!=() [2/4]

bool operator!= ( const EngineData lhs,
const EngineData rhs 
)

Definition at line 142 of file enginedata.cpp.

142{ return !(lhs == rhs); }

◆ makeEquityMarginLeg() [1/2]

QuantExt::Leg makeEquityMarginLeg ( const LegData data,
const QuantLib::ext::shared_ptr< EquityIndex2 > &  equityCurve,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 79 of file equityfxlegdata.cpp.

81 {
82 QuantLib::ext::shared_ptr<EquityMarginLegData> eqMarginLegData = QuantLib::ext::dynamic_pointer_cast<EquityMarginLegData>(data.concreteLegData());
83 QL_REQUIRE(eqMarginLegData, "Wrong LegType, expected EquityMargin, got " << data.legType());
84 QuantLib::ext::shared_ptr<ore::data::EquityLegData> eqLegData = eqMarginLegData->equityLegData();
85 QL_REQUIRE(eqLegData, "expected equityLegData");
86 QuantExt::Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
87 DayCounter dc = parseDayCounter(data.dayCounter());
88 BusinessDayConvention bdc = ore::data::parseBusinessDayConvention(data.paymentConvention());
89 bool isTotalReturn = eqLegData->returnType() == EquityReturnType::Total;
90 Real dividendFactor = eqLegData->dividendFactor();
91 Real initialPrice = eqLegData->initialPrice();
92 bool initialPriceIsInTargetCcy = false;
93
94 if (!eqLegData->initialPriceCurrency().empty()) {
95 // parse currencies to handle minor currencies
96 Currency initialPriceCurrency = parseCurrencyWithMinors(eqLegData->initialPriceCurrency());
97 Currency dataCurrency = parseCurrencyWithMinors(data.currency());
98 Currency eqCurrency;
99 // set equity currency
100 if (!equityCurve->currency().empty())
101 eqCurrency = equityCurve->currency();
102 else
103 TLOG("Cannot find currency for equity " << equityCurve->name());
104
105 // initial price currency must match leg or equity currency
106 QL_REQUIRE(initialPriceCurrency == dataCurrency ||
107 initialPriceCurrency == eqCurrency || eqCurrency.empty(),
108 "initial price ccy (" << initialPriceCurrency << ") must match either leg ccy ("
109 << dataCurrency << ") or equity ccy (if given, got '"
110 << eqCurrency << "')");
111 initialPriceIsInTargetCcy = initialPriceCurrency == dataCurrency;
112 // adjust for minor currency
113 initialPrice = convertMinorToMajorCurrency(eqLegData->initialPriceCurrency(), initialPrice);
114 }
115 bool notionalReset = eqLegData->notionalReset();
116 Natural fixingDays = eqLegData->fixingDays();
117 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
118 ScheduleData valuationData = eqLegData->valuationSchedule();
119 Schedule valuationSchedule;
120 if (valuationData.hasData())
121 valuationSchedule = makeSchedule(valuationData, openEndDateReplacement);
122 vector<double> notionals = buildScheduledVector(data.notionals(), data.notionalDates(), schedule);
123 vector<double> rates = buildScheduledVector(eqMarginLegData->rates(), eqMarginLegData->rateDates(), schedule);
124
125 applyAmortization(notionals, data, schedule, false);
126 Leg leg = EquityMarginLeg(schedule, equityCurve, fxIndex)
127 .withCouponRates(rates, dc)
128 .withInitialMarginFactor(eqMarginLegData->initialMarginFactor())
129 .withNotionals(notionals)
130 .withQuantity(eqLegData->quantity())
133 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
134 .withTotalReturn(isTotalReturn)
135 .withDividendFactor(dividendFactor)
136 .withInitialPrice(initialPrice)
137 .withInitialPriceIsInTargetCcy(initialPriceIsInTargetCcy)
138 .withNotionalReset(notionalReset)
139 .withFixingDays(fixingDays)
140 .withValuationSchedule(valuationSchedule)
141 .withMultiplier(eqMarginLegData->multiplier());
142
143 QL_REQUIRE(leg.size() > 0, "Empty Equity Margin Leg");
144
145 return leg;
146}
EquityMarginLeg & withPaymentLag(Natural paymentLag)
EquityMarginLeg & withQuantity(Real)
EquityMarginLeg & withNotionalReset(bool)
EquityMarginLeg & withNotionals(const std::vector< Real > &notionals)
EquityMarginLeg & withFixingDays(Natural)
EquityMarginLeg & withDividendFactor(Real)
EquityMarginLeg & withInitialPrice(Real)
EquityMarginLeg & withInitialPriceIsInTargetCcy(bool)
EquityMarginLeg & withPaymentAdjustment(BusinessDayConvention convention)
EquityMarginLeg & withTotalReturn(bool)
EquityMarginLeg & withPaymentDayCounter(const DayCounter &dayCounter)
EquityMarginLeg & withMultiplier(Real)
EquityMarginLeg & withValuationSchedule(const Schedule &valuationSchedule)
EquityMarginLeg & withInitialMarginFactor(const Real &marginFactor)
EquityMarginLeg & withCouponRates(Rate, const DayCounter &paymentDayCounter, Compounding comp=Simple, Frequency freq=Annual)
Serializable schedule data.
Definition: schedule.hpp:202
bool hasData() const
Check if has any dates/rules/derived schedules.
Definition: schedule.hpp:223
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:310
QuantLib::Real convertMinorToMajorCurrency(const std::string &s, QuantLib::Real value)
Convert a value from a minor ccy to major.
Definition: parsers.cpp:324
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
Definition: parsers.cpp:173
PaymentLag parsePaymentLag(const string &s)
Convert text to PaymentLag.
Definition: parsers.cpp:628
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
Definition: parsers.cpp:209
void applyAmortization(std::vector< Real > &notionals, const LegData &data, const Schedule &schedule, const bool annuityAllowed, const std::vector< Real > &rates)
Definition: legdata.cpp:2593
vector< T > buildScheduledVector(const vector< T > &values, const vector< string > &dates, const Schedule &schedule, const bool checkAllValuesAppearInResult=false)
Definition: legdata.hpp:1061
boost::variant< QuantLib::Period, QuantLib::Natural > PaymentLag
Definition: types.hpp:32
Schedule makeSchedule(const ScheduleDates &data)
Definition: schedule.cpp:263
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeEquityMarginLeg() [2/2]

QuantExt::Leg makeEquityMarginLeg ( const ore::data::LegData data,
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &  equityCurve,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex = nullptr,
const QuantLib::Date &  openEndDateReplacement = QuantLib::Null< QuantLib::Date >() 
)

◆ operator<() [9/14]

bool operator< ( const RequiredFixings::FixingEntry lhs,
const RequiredFixings::FixingEntry rhs 
)

◆ operator<() [10/14]

◆ operator<() [11/14]

Definition at line 162 of file fixingdates.cpp.

◆ operator<<() [37/73]

std::ostream & operator<< ( std::ostream &  out,
const ore::data::RequiredFixings::FixingEntry f 
)

Definition at line 433 of file fixingdates.cpp.

433 {
434
435 std::string indexName = f.indexName;
436 Date fixingDate = f.fixingDate;
437 Date payDate = f.payDate;
438 bool alwaysAddIfPaysOnSettlement = f.alwaysAddIfPaysOnSettlement;
439 bool mandatory = f.mandatory;
440 out << indexName << " " << QuantLib::io::iso_date(fixingDate) << " " << QuantLib::io::iso_date(payDate) << " "
441 << std::boolalpha << alwaysAddIfPaysOnSettlement << " " << std::boolalpha << mandatory << "\n";
442 return out;
443}
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
+ Here is the call graph for this function:

◆ operator<<() [38/73]

std::ostream & operator<< ( std::ostream &  out,
const std::set< ore::data::RequiredFixings::FixingEntry > &  entries 
)

Definition at line 445 of file fixingdates.cpp.

445 {
446 for (auto const& f : entries) {
447 out << f;
448 }
449 return out;
450}

◆ operator<<() [39/73]

std::ostream & operator<< ( std::ostream &  out,
const std::set< ore::data::RequiredFixings::InflationFixingEntry > &  entries 
)

Definition at line 452 of file fixingdates.cpp.

452 {
453 for (auto const& f : entries) {
454 out << f;
455 }
456 return out;
457}

◆ operator<<() [40/73]

std::ostream & operator<< ( std::ostream &  out,
const std::set< ore::data::RequiredFixings::ZeroInflationFixingEntry > &  entries 
)

Definition at line 459 of file fixingdates.cpp.

460 {
461 for (auto const& f : entries) {
462 out << f;
463 }
464 return out;
465}

◆ operator<<() [41/73]

std::ostream & operator<< ( std::ostream &  out,
const RequiredFixings f 
)

allow output of required fixings data via streams

Definition at line 467 of file fixingdates.cpp.

467 {
468 out << "IndexName FixingDate PayDate AlwaysAddIfPaysOnSettlement\n";
469 out << requiredFixings.fixingDates_;
470 out << requiredFixings.zeroInflationFixingDates_;
471 out << requiredFixings.yoyInflationFixingDates_;
472 return out;
473}

◆ addToRequiredFixings()

void addToRequiredFixings ( const QuantLib::Leg &  leg,
const QuantLib::ext::shared_ptr< FixingDateGetter > &  fixingDateGetter 
)

Populates a RequiredFixings instance based on a given QuantLib::Leg

Definition at line 789 of file fixingdates.cpp.

789 {
790 for (auto const& c : leg) {
791 QL_REQUIRE(c, "addToRequiredFixings(), got null cashflow, this is unexpected");
792 c->accept(*fixingDateGetter);
793 }
794}
+ Here is the caller graph for this function:

◆ amendInflationFixingDates()

void amendInflationFixingDates ( std::map< std::string, RequiredFixings::FixingDates > &  fixings)

Inflation fixings are generally available on a monthly, or coarser, frequency. When a portfolio is asked for its fixings, and it contains inflation fixings, ORE will by convention put the fixing date as the 1st day of the applicable inflation period. Some market data providers by convention supply the inflation fixings with the date as the last date of the applicable inflation period. This function scans the fixings map, and moves any inflation fixing dates from the 1st day of the inflation period to the last day of the inflation period. The key in the fixings map is the index name and the value is the set of dates for which we require the fixings.

If inflation indices have been set up via ZeroInflationIndex entries in the Conventions, the conventions should be passed here. If not, the default nullptr parameter will be sufficient.

Definition at line 796 of file fixingdates.cpp.

796 {
797 // Loop over indices and amend any that are of type InflationIndex
798 for (auto& [indexName, fixingDates] : fixings) {
799 auto [isInfIndex, infIndex] = isInflationIndex(indexName);
800 if (isInfIndex) {
801 // We have an inflation index
802 RequiredFixings::FixingDates amendedFixingDates;
803 Frequency f = infIndex->frequency();
804 for (const auto& [d, mandatory] : fixingDates) {
805 auto period = inflationPeriod(d, f);
806 if (d == period.first) {
807 // If the fixing date is the start of the inflation period, move it to the end.
808 amendedFixingDates.addDate(period.second, mandatory);
809 } else {
810 // If the fixing date is not the start of the inflation period, leave it as it is.
811 amendedFixingDates.addDate(d, mandatory);
812 }
813 }
814 // Update the fixings map that was passed in with the new set of dates
815 fixings[indexName] = amendedFixingDates;
816 }
817 }
818}
void addDate(const QuantLib::Date &date, const bool mandatory)
Definition: fixingdates.hpp:93
pair< bool, QuantLib::ext::shared_ptr< ZeroInflationIndex > > isInflationIndex(const string &indexName)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addMarketFixingDates() [1/2]

void addMarketFixingDates ( const Date &  asof,
map< string, RequiredFixings::FixingDates > &  fixings,
const TodaysMarketParameters mktParams,
const Period &  iborLookback,
const Period &  oisLookback,
const Period &  bmaLookback,
const Period &  inflationLookback 
)

Definition at line 820 of file fixingdates.cpp.

822 {
823
824 for (auto const& [configuration, _] : mktParams.configurations()) {
825
826 LOG("Start adding market fixing dates for configuration '" << configuration << "'");
827
828 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
829
830 // If there are ibor indices in the market parameters, add the lookback fixings
831 // IF there are SIFMA / BMA indices, add lookback fixings for the Libor basis index
832 if (mktParams.hasMarketObject(MarketObject::IndexCurve)) {
833
834 QL_REQUIRE(iborLookback >= 0 * Days, "Ibor lookback period must be non-negative");
835
836 DLOG("Start adding market fixing dates for interest rate indices.");
837
838 set<Date> iborDates;
839 set<Date> oisDates;
840 set<Date> bmaDates;
841 WeekendsOnly calendar;
842
843 std::set<std::string> indices;
844 for (auto const& [i, _] : mktParams.mapping(MarketObject::IndexCurve, configuration)) {
845 indices.insert(i);
846 }
847 for (auto const& [i, _] : mktParams.mapping(MarketObject::YieldCurve, configuration)) {
848 QuantLib::ext::shared_ptr<IborIndex> dummy;
849 if (tryParseIborIndex(i, dummy))
850 indices.insert(i);
851 }
852 for (auto const& [_, s] : mktParams.mapping(MarketObject::DiscountCurve, configuration)) {
853 auto spec = parseCurveSpec(s);
854 QuantLib::ext::shared_ptr<IborIndex> dummy;
855 if (tryParseIborIndex(spec->curveConfigID(), dummy))
856 indices.insert(spec->curveConfigID());
857 }
858
859 // For each of the IR indices in market parameters, insert the dates
860 for (const auto& i : indices) {
861 if (isOvernightIndex(i)) {
862 if (oisDates.empty()) {
863 TLOG("Generating fixing dates for overnight indices.");
864 oisDates = generateLookbackDates(asof, oisLookback, calendar);
865 }
866 TLOG("Adding extra fixing dates for overnight index " << i);
867 fixings[i].addDates(oisDates, false);
868
869 } else if (isBmaIndex(i)) {
870 if (bmaDates.empty()) {
871 TLOG("Generating fixing dates for bma/sifma indices.");
872 bmaDates = generateLookbackDates(asof, bmaLookback, calendar);
873 }
874 fixings[i].addDates(bmaDates, false);
875 if (iborDates.empty()) {
876 TLOG("Generating fixing dates for ibor indices.");
877 iborDates = generateLookbackDates(asof, iborLookback, calendar);
878 }
879 std::set<string> liborNames;
880 for (auto const& c : conventions->get(Convention::Type::BMABasisSwap)) {
881 auto bma = QuantLib::ext::dynamic_pointer_cast<BMABasisSwapConvention>(c);
882 QL_REQUIRE(
883 bma, "internal error, could not cast to BMABasisSwapConvention in addMarketFixingDates()");
884 if (bma->bmaIndexName() == i) {
885 liborNames.insert(bma->liborIndexName());
886 }
887 }
888 for (auto const& l : liborNames) {
889 TLOG("Adding extra fixing dates for libor index " << l << " from bma/sifma index " << i);
890 fixings[l].addDates(iborDates, false);
891 }
892 } else {
893 if (iborDates.empty()) {
894 TLOG("Generating fixing dates for ibor indices.");
895 iborDates = generateLookbackDates(asof, iborLookback, calendar);
896 }
897 TLOG("Adding extra fixing dates for ibor index " << i);
898 fixings[i].addDates(iborDates, false);
899 }
900 }
901
902 DLOG("Finished adding market fixing dates for interest rate indices.");
903 }
904
905 // If there are inflation indices in the market parameters, add the lookback fixings
906 if (mktParams.hasMarketObject(MarketObject::ZeroInflationCurve) ||
907 mktParams.hasMarketObject(MarketObject::YoYInflationCurve)) {
908
909 QL_REQUIRE(inflationLookback >= 0 * Days, "Inflation lookback period must be non-negative");
910
911 // Dates that will be used for each of the inflation indices
912 Date lookback = NullCalendar().advance(asof, -inflationLookback);
913 lookback = Date(1, lookback.month(), lookback.year());
914 set<Date> dates;
915 do {
916 TLOG("Adding date " << io::iso_date(lookback) << " to fixings for inflation indices");
917 dates.insert(lookback);
918 lookback = NullCalendar().advance(lookback, 1 * Months);
919 } while (lookback <= asof);
920
921 // For each of the inflation indices in market parameters, insert the dates
922 if (mktParams.hasMarketObject(MarketObject::ZeroInflationCurve)) {
923 for (const auto& kv : mktParams.mapping(MarketObject::ZeroInflationCurve, configuration)) {
924 TLOG("Adding extra fixing dates for (zero) inflation index " << kv.first);
925 fixings[kv.first].addDates(dates, false);
926 }
927 }
928
929 if (mktParams.hasMarketObject(MarketObject::YoYInflationCurve)) {
930 for (const auto& kv : mktParams.mapping(MarketObject::YoYInflationCurve, configuration)) {
931 TLOG("Adding extra fixing dates for (yoy) inflation index " << kv.first);
932 fixings[kv.first].addDates(dates, false);
933 }
934 }
935 }
936
937 // If there are commodity curves, add "fixings" for this month and two previous months. We add "fixings" for
938 // future contracts with expiry from two months hence to two months prior.
939 if (mktParams.hasMarketObject(MarketObject::CommodityCurve)) {
940
941 // "Fixing" dates for commodities.
942 Period commodityLookback = 2 * Months;
943 Date lookback = asof - commodityLookback;
944 lookback = Date(1, lookback.month(), lookback.year());
945 set<Date> dates;
946 do {
947 TLOG("Adding date " << io::iso_date(lookback) << " to fixings for commodities");
948 dates.insert(lookback++);
949 } while (lookback <= asof);
950
951 // Expiry months and years for which we require future contract fixings. For our purposes here, using the
952 // 1st of the month does not matter. We will just use the date to get the appropriate commodity future
953 // index name below when adding the dates and the "-01" will be removed (for non-daily contracts).
954 Size numberMonths = 2;
955 vector<Date> contractExpiries;
956 Date startContract = asof - numberMonths * Months;
957 Date endContract = asof + numberMonths * Months;
958 do {
959 Month m = startContract.month();
960 Year y = startContract.year();
961 TLOG("Adding contract month and year (" << m << "," << y << ")");
962 contractExpiries.push_back(Date(1, m, y));
963 startContract += 1 * Months;
964 } while (startContract <= endContract);
965
966 // For each of the commodity names, create the future contract name with the relevant expiry and insert
967 // the dates. Skip commodity names that do not have future conventions.
968 for (const auto& kv : mktParams.mapping(MarketObject::CommodityCurve, configuration)) {
969
970 QuantLib::ext::shared_ptr<CommodityFutureConvention> cfc;
971 if (conventions->has(kv.first)) {
972 cfc = QuantLib::ext::dynamic_pointer_cast<CommodityFutureConvention>(conventions->get(kv.first));
973 }
974
975 auto commIdx = parseCommodityIndex(kv.first, false);
976 if (cfc) {
977 if (auto oppIdx = QuantLib::ext::dynamic_pointer_cast<OffPeakPowerIndex>(commIdx)) {
978 DLOG("Commodity " << kv.first << " is off-peak power so adding underlying daily contracts.");
979 const auto& opIndex = oppIdx->offPeakIndex();
980 const auto& pIndex = oppIdx->peakIndex();
981 for (const Date& expiry : dates) {
982 auto tmpIdx = oppIdx->clone(expiry);
983 auto opName = opIndex->clone(expiry)->name();
984 TLOG("Adding (date, id) = (" << io::iso_date(expiry) << "," << opName << ")");
985 fixings[opName].addDate(expiry, false);
986 auto pName = pIndex->clone(expiry)->name();
987 TLOG("Adding (date, id) = (" << io::iso_date(expiry) << "," << pName << ")");
988 fixings[pName].addDate(expiry, false);
989 }
990 } else if (cfc->contractFrequency() == Daily) {
991 DLOG("Commodity " << kv.first << " has daily frequency so adding daily contracts.");
992 for (const Date& expiry : dates) {
993 auto indexName = commIdx->clone(expiry)->name();
994 TLOG("Adding (date, id) = (" << io::iso_date(expiry) << "," << indexName << ")");
995 fixings[indexName].addDate(expiry, false);
996 }
997 } else {
998 DLOG("Commodity " << kv.first << " is not daily so adding the monthly contracts.");
999 for (const Date& expiry : contractExpiries) {
1000 auto indexName = commIdx->clone(expiry)->name();
1001 TLOG("Adding extra fixing dates for commodity future " << indexName);
1002 fixings[indexName].addDates(dates, false);
1003 }
1004 }
1005 } else {
1006 // Assumption here is that we have a spot index.
1007 DLOG("Commodity " << kv.first << " does not have future conventions so adding daily fixings.");
1008 auto indexName = commIdx->name();
1009 TLOG("Adding extra fixing dates for commodity spot " << indexName);
1010 fixings[indexName].addDates(dates, false);
1011 }
1012 }
1013 }
1014
1015 LOG("Finished adding market fixing dates for configuration '" << configuration << "'");
1016 }
1017}
const vector< pair< string, MarketConfiguration > > & configurations() const
const map< string, string > & mapping(const MarketObject o, const string &configuration) const
EUR => Yield/EUR/EUR6M, USD => Yield/USD/USD3M etc.
bool hasMarketObject(const MarketObject &o) const
bool isOvernightIndex(const string &indexName)
Return true if the indexName is that of an overnight index, otherwise false.
bool isBmaIndex(const string &indexName)
Return true if the indexName is that of an bma/sifma index, otherwise false.
bool tryParseIborIndex(const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
Try to convert std::string to QuantLib::IborIndex.
QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseCommodityIndex(const string &name, bool hasPrefix, const Handle< PriceTermStructure > &ts, const Calendar &cal, const bool enforceFutureIndex)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addMarketFixingDates() [2/2]

void addMarketFixingDates ( const QuantLib::Date &  asof,
std::map< std::string, RequiredFixings::FixingDates > &  fixings,
const TodaysMarketParameters mktParams,
const QuantLib::Period &  iborLookback = 5 *QuantLib::Days,
const QuantLib::Period &  oisLookback = 4 *QuantLib::Months,
const QuantLib::Period &  bmaLookback = 2 *QuantLib::Weeks,
const QuantLib::Period &  inflationLookback = 1 *QuantLib::Years 
)

Add index and fixing date pairs to fixings that will be potentially needed to build a TodaysMarket.

These additional index and fixing date pairs are found by scanning the mktParams and:

  • for MarketObject::IndexCurve, take the ibor index name and add the dates for each weekday between settlement date minus iborLookback period or oisLookback period and settlement date. The distinction between Ibor and OIS is made here to cover the fixings necessary for OIS futures. The default value of 4 months covers OIS futures with a contract period of up to 3 months. It would need to be configured differently if OIS futures with a longer contract period are possible.
  • for MarketObject::ZeroInflationCurve, take the inflation index and add the first of each month between settlement date minus inflationLookback period and settlement date
  • for MarketObject::YoYInflationCurve, take the inflation index and add the first of each month between settlement date minus inflationLookback period and settlement date
  • for MarketObject::CommodityCurve, add fixings for future contracts expiring 2 months either side of the settlement date. The fixing dates are added for each weekday going back to the first day of the month that precedes the settlement date by 2 months. The approach here will give rise to some spot commodities being given a future contract name and dates added against them - this should not be a problem as there will be no fixings found for them in any case.

The original fixings map may be empty.

◆ makeFormulaBasedIndex()

QuantLib::ext::shared_ptr< QuantExt::FormulaBasedIndex > makeFormulaBasedIndex ( const std::string &  formula,
const QuantLib::ext::shared_ptr< ore::data::Market market,
const std::string &  configuration,
std::map< std::string, QuantLib::ext::shared_ptr< QuantLib::InterestRateIndex > > &  indexMaps,
const Calendar &  fixingCalendar = Calendar() 
)

builds a formula based index using the ibor and swap indices in the given market, the fixing calendar is the joint holiday calendar of all constituents of the resulting index

Definition at line 33 of file formulabasedindexbuilder.cpp.

36 {
37
38 indexMaps.clear();
39 std::vector<QuantLib::ext::shared_ptr<QuantLib::InterestRateIndex>> indices;
40 std::vector<std::string> variables;
41 QuantExt::CompiledFormula compiledFormula = parseFormula(formula, variables);
42 Calendar fixCal = NullCalendar();
43 for (auto const& v : variables) {
44 QuantLib::ext::shared_ptr<InterestRateIndex> index;
45 QuantLib::ext::shared_ptr<IborIndex> dummyIborIndex;
46 if (ore::data::tryParseIborIndex(v, dummyIborIndex)) {
47 index = *market->iborIndex(v, configuration);
48 } else {
49 // if it is not an ibor index, we know it must be a swap index
50 index = *market->swapIndex(v, configuration);
51 }
52 QL_REQUIRE(index != nullptr, "makeFormulaBasedIndex("
53 << formula << "): variable \"" << v
54 << "\" could not resolved as an ibor or swap index in the given market");
55 indices.push_back(index);
56 fixCal = JointCalendar(fixCal, index->fixingCalendar());
57 indexMaps[v] = index;
58 }
59
60 QuantLib::ext::shared_ptr<QuantExt::FormulaBasedIndex> fbi = QuantLib::ext::make_shared<QuantExt::FormulaBasedIndex>(
61 "FormulaBasedIndex", indices, compiledFormula, fixingCalendar == Calendar() ? fixCal : fixingCalendar);
62 return fbi;
63}
QuantExt::CompiledFormula parseFormula(const std::string &text, std::vector< std::string > &variables)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeFormulaBasedLeg()

Leg makeFormulaBasedLeg ( const LegData data,
const QuantLib::ext::shared_ptr< QuantExt::FormulaBasedIndex > &  formulaBasedIndex,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const std::map< std::string, QuantLib::ext::shared_ptr< QuantLib::InterestRateIndex > > &  indexMaps,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 117 of file formulabasedlegdata.cpp.

120 {
121 auto formulaBasedData = QuantLib::ext::dynamic_pointer_cast<FormulaBasedLegData>(data.concreteLegData());
122 QL_REQUIRE(formulaBasedData, "Wrong LegType, expected FormulaBased, got " << data.legType());
123 Currency paymentCurrency = parseCurrency(data.currency());
124 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
125 if (schedule.size() < 2)
126 return Leg();
127 Calendar paymentCalendar;
128 if (data.paymentCalendar().empty())
129 paymentCalendar = schedule.calendar();
130 else
131 paymentCalendar = parseCalendar(data.paymentCalendar());
132 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
133 // day counter is optional in leg data in general, but here we need it
134 QL_REQUIRE(data.dayCounter() != "", "makeFormulaBasedLeg(): day counter must be given");
135 DayCounter dc = parseDayCounter(data.dayCounter());
136 // bdc is optional too, but all the other legs just do this, too ?!
137 // FIXME, to be solved for all leg types, here we do as in the other legs
138 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
139 auto formulaBasedLegData = QuantLib::ext::dynamic_pointer_cast<FormulaBasedLegData>(data.concreteLegData());
140 vector<double> notionals = buildScheduledVector(data.notionals(), data.notionalDates(), schedule);
141
142 ore::data::applyAmortization(notionals, data, schedule);
143 // amortization type annuity is not allowed, check this
144 for (auto const& amort : data.amortizationData()) {
145 if (!amort.initialized())
146 continue;
147 AmortizationType amortizationType = parseAmortizationType(amort.type());
148 QL_REQUIRE(amortizationType != AmortizationType::Annuity,
149 "AmortizationType " << amort.type() << " not supported for Formula based legs");
150 }
151
152 QuantExt::FormulaBasedLeg formulaBasedLeg =
153 QuantExt::FormulaBasedLeg(paymentCurrency, schedule, formulaBasedIndex)
154 .withNotionals(notionals)
155 .withPaymentCalendar(paymentCalendar)
156 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
157 .withPaymentDayCounter(dc)
158 .withPaymentAdjustment(bdc)
159 .withFixingDays(formulaBasedData->fixingDays())
160 .inArrears(formulaBasedData->isInArrears());
161
162 auto couponPricer = getFormulaBasedCouponPricer(formulaBasedIndex, paymentCurrency, engineFactory, indexMaps);
163
164 // make sure leg is built before pricers are set...
165 Leg tmp = formulaBasedLeg;
166 QuantExt::setCouponPricer(tmp, couponPricer);
167 return tmp;
168}
void setCouponPricer(const Leg &leg, const boost::shared_ptr< FloatingRateCouponPricer > &)
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
AmortizationType parseAmortizationType(const std::string &s)
Definition: parsers.cpp:651
AmortizationType
Definition: parsers.hpp:346
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkBarrier()

bool checkBarrier ( Real  spot,
Barrier::Type  type,
Real  barrier 
)

Definition at line 182 of file fxdigitalbarrieroption.cpp.

182 {
183 switch (type) {
184 case Barrier::DownIn:
185 case Barrier::DownOut:
186 return spot <= barrier;
187 case Barrier::UpIn:
188 case Barrier::UpOut:
189 return spot >= barrier;
190 default:
191 QL_FAIL("unknown barrier type " << type);
192 }
193}

◆ lessThan()

bool lessThan ( const string &  s1,
const string &  s2 
)

Definition at line 92 of file legdata.cpp.

92{ return s1 < s2; }
+ Here is the caller graph for this function:

◆ makeSimpleLeg()

Leg makeSimpleLeg ( const LegData data)

Definition at line 934 of file legdata.cpp.

934 {
935 QuantLib::ext::shared_ptr<CashflowData> cashflowData = QuantLib::ext::dynamic_pointer_cast<CashflowData>(data.concreteLegData());
936 QL_REQUIRE(cashflowData, "Wrong LegType, expected CashFlow, got " << data.legType());
937
938 const vector<double>& amounts = cashflowData->amounts();
939 const vector<string>& dates = cashflowData->dates();
940 QL_REQUIRE(amounts.size() == dates.size(), "Amounts / Date size mismatch in makeSimpleLeg."
941 << "Amounts:" << amounts.size() << ", Dates:" << dates.size());
942 Leg leg;
943 for (Size i = 0; i < dates.size(); i++) {
944 Date d = parseDate(dates[i]);
945 leg.push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(amounts[i], d)));
946 }
947 return leg;
948}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeFixedLeg()

Leg makeFixedLeg ( const LegData data,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 950 of file legdata.cpp.

950 {
951
952 QuantLib::ext::shared_ptr<FixedLegData> fixedLegData = QuantLib::ext::dynamic_pointer_cast<FixedLegData>(data.concreteLegData());
953 QL_REQUIRE(fixedLegData, "Wrong LegType, expected Fixed, got " << data.legType());
954
955 // build schedules
956
957 Schedule schedule;
958 Schedule paymentSchedule;
959 ScheduleBuilder scheduleBuilder;
960 scheduleBuilder.add(schedule, data.schedule());
961 scheduleBuilder.add(paymentSchedule, data.paymentSchedule());
962 scheduleBuilder.makeSchedules(openEndDateReplacement);
963
964 // Get explicit payment dates, if given
965
966 vector<Date> paymentDates;
967
968 if (!paymentSchedule.empty()) {
969 paymentDates = paymentSchedule.dates();
970 } else if (!data.paymentDates().empty()) {
971 BusinessDayConvention paymentDatesConvention =
972 data.paymentConvention().empty() ? Unadjusted : parseBusinessDayConvention(data.paymentConvention());
973 Calendar paymentDatesCalendar =
974 data.paymentCalendar().empty() ? NullCalendar() : parseCalendar(data.paymentCalendar());
975 paymentDates = parseVectorOfValues<Date>(data.paymentDates(), &parseDate);
976 for (Size i = 0; i < paymentDates.size(); i++)
977 paymentDates[i] = paymentDatesCalendar.adjust(paymentDates[i], paymentDatesConvention);
978 }
979
980 // set payment calendar
981
982 Calendar paymentCalendar;
983 if (!data.paymentCalendar().empty())
984 paymentCalendar = parseCalendar(data.paymentCalendar());
985 else if (!paymentSchedule.calendar().empty())
986 paymentCalendar = paymentSchedule.calendar();
987 else if (!schedule.calendar().empty())
988 paymentCalendar = schedule.calendar();
989
990 // set day counter and bdc
991
992 DayCounter dc = parseDayCounter(data.dayCounter());
993 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
994
995 // build standard schedules (for non-strict notional dates)
996
997 vector<double> rates = buildScheduledVector(fixedLegData->rates(), fixedLegData->rateDates(), schedule);
998 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
999
1000 // parse payment lag
1001
1002 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
1003
1004 // apply amortization
1005
1006 applyAmortization(notionals, data, schedule, true, rates);
1007
1008 // build leg
1009
1010 if (!data.strictNotionalDates()) {
1011
1012 // no strict notional dates
1013
1014 Leg leg = FixedRateLeg(schedule)
1015 .withNotionals(notionals)
1016 .withCouponRates(rates, dc)
1017 .withPaymentAdjustment(bdc)
1018 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
1019 .withPaymentCalendar(paymentCalendar)
1020 .withLastPeriodDayCounter(data.lastPeriodDayCounter().empty()
1021 ? DayCounter()
1022 : parseDayCounter(data.lastPeriodDayCounter()))
1023 .withPaymentDates(paymentDates);
1024 return leg;
1025
1026 } else {
1027
1028 // strict notional dates
1029
1030 std::vector<Date> notionalDatesAsDates;
1031 std::vector<Date> rateDatesAsDates;
1032
1033 for (auto const& d : data.notionalDates()) {
1034 if (!d.empty())
1035 notionalDatesAsDates.push_back(parseDate(d));
1036 }
1037
1038 for (auto const& d : fixedLegData->rateDates()) {
1039 if (!d.empty())
1040 rateDatesAsDates.push_back(parseDate(d));
1041 }
1042
1043 return makeNonStandardFixedLeg(schedule.dates(), paymentDates, data.notionals(), notionalDatesAsDates,
1044 fixedLegData->rates(), rateDatesAsDates, data.strictNotionalDates(), dc,
1045 paymentCalendar, bdc, boost::apply_visitor(PaymentLagPeriod(), paymentLag));
1046 }
1047}
void makeSchedules(const QuantLib::Date &openEndDateReplacement=QuantLib::Null< QuantLib::Date >())
Definition: schedule.cpp:214
void add(QuantLib::Schedule &schedule, const ScheduleData &scheduleData)
Definition: schedule.cpp:209
Leg makeNonStandardFixedLeg(const std::vector< Date > &calcDates, const std::vector< Date > &payDatesInput, const std::vector< Real > &notionals, const std::vector< Date > &notionalDatesInput, const std::vector< Real > &rates, const std::vector< Date > &rateDatesInput, const bool strictNotionalDates, const DayCounter &dayCounter, const Calendar &payCalendar, const BusinessDayConvention payConv, const Period &payLag)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeZCFixedLeg()

Leg makeZCFixedLeg ( const LegData data,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1049 of file legdata.cpp.

1049 {
1050 QuantLib::ext::shared_ptr<ZeroCouponFixedLegData> zcFixedLegData =
1051 QuantLib::ext::dynamic_pointer_cast<ZeroCouponFixedLegData>(data.concreteLegData());
1052 QL_REQUIRE(zcFixedLegData, "Wrong LegType, expected Zero Coupon Fixed, got " << data.legType());
1053
1054 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
1055
1056 Calendar paymentCalendar;
1057 if (data.paymentCalendar().empty())
1058 paymentCalendar = schedule.calendar();
1059 else
1060 paymentCalendar = parseCalendar(data.paymentCalendar());
1061
1062 BusinessDayConvention payConvention = parseBusinessDayConvention(data.paymentConvention());
1063 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
1064 Natural paymentLagDays = boost::apply_visitor(PaymentLagInteger(), paymentLag);
1065
1066 DayCounter dc = parseDayCounter(data.dayCounter());
1067
1068 Size numNotionals = data.notionals().size();
1069 Size numRates = zcFixedLegData->rates().size();
1070 Size numDates = schedule.size();
1071
1072 QL_REQUIRE(numDates >= 2, "Incorrect number of schedule dates entered, expected at least 2, got " << numDates);
1073 QL_REQUIRE(numNotionals >= 1,
1074 "Incorrect number of notional values entered, expected at least1, got " << numNotionals);
1075 QL_REQUIRE(numRates >= 1, "Incorrect number of rate values entered, expected at least 1, got " << numRates);
1076
1077 vector<Date> dates = schedule.dates();
1078
1079 vector<double> rates = buildScheduledVector(zcFixedLegData->rates(), zcFixedLegData->rateDates(), schedule);
1080 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
1081
1082 Compounding comp = parseCompounding(zcFixedLegData->compounding());
1083 QL_REQUIRE(comp == QuantLib::Compounded || comp == QuantLib::Simple,
1084 "Compounding method " << zcFixedLegData->compounding() << " not supported");
1085
1086 Leg leg;
1087 vector<Date> cpnDates;
1088 cpnDates.push_back(dates.front());
1089
1090 for (Size i = 0; i < numDates - 1; i++) {
1091
1092 double currentNotional = i < notionals.size() ? notionals[i] : notionals.back();
1093 double currentRate = i < rates.size() ? rates[i] : rates.back();
1094 cpnDates.push_back(dates[i + 1]);
1095 Date paymentDate = paymentCalendar.advance(dates[i + 1], paymentLagDays, Days, payConvention);
1096 leg.push_back(QuantLib::ext::make_shared<ZeroFixedCoupon>(paymentDate, currentNotional, currentRate, dc, cpnDates, comp,
1097 zcFixedLegData->subtractNotional()));
1098 }
1099 return leg;
1100}
Compounding parseCompounding(const string &s)
Convert text to QuantLib::Compounding;.
Definition: parsers.cpp:376
vector< T > buildScheduledVectorNormalised(const vector< T > &values, const vector< string > &dates, const Schedule &schedule, const T &defaultValue, const bool checkAllValuesAppearInResult=false)
Definition: legdata.hpp:1139
Real currentNotional(const Leg &leg)
Definition: legdata.cpp:2435
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeIborLeg()

Leg makeIborLeg ( const LegData data,
const QuantLib::ext::shared_ptr< IborIndex > &  index,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const bool  attachPricer,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1102 of file legdata.cpp.

1104 {
1105
1106 QuantLib::ext::shared_ptr<FloatingLegData> floatData = QuantLib::ext::dynamic_pointer_cast<FloatingLegData>(data.concreteLegData());
1107 QL_REQUIRE(floatData, "Wrong LegType, expected Floating, got " << data.legType());
1108
1109 // build schedules
1110
1111 Schedule schedule;
1112 Schedule fixingSchedule;
1113 Schedule resetSchedule;
1114 Schedule paymentSchedule;
1115 ScheduleBuilder scheduleBuilder;
1116 scheduleBuilder.add(schedule, data.schedule());
1117 scheduleBuilder.add(fixingSchedule, floatData->fixingSchedule());
1118 scheduleBuilder.add(resetSchedule, floatData->resetSchedule());
1119 scheduleBuilder.add(paymentSchedule, data.paymentSchedule());
1120 scheduleBuilder.makeSchedules(openEndDateReplacement);
1121
1122 // Get explicit payment dates, if given
1123
1124 vector<Date> paymentDates;
1125
1126 if (!paymentSchedule.empty()) {
1127 paymentDates = paymentSchedule.dates();
1128 } else if (!data.paymentDates().empty()) {
1129 BusinessDayConvention paymentDatesConvention =
1130 data.paymentConvention().empty() ? Unadjusted : parseBusinessDayConvention(data.paymentConvention());
1131 Calendar paymentDatesCalendar =
1132 data.paymentCalendar().empty() ? NullCalendar() : parseCalendar(data.paymentCalendar());
1133 paymentDates = parseVectorOfValues<Date>(data.paymentDates(), &parseDate);
1134 for (Size i = 0; i < paymentDates.size(); i++)
1135 paymentDates[i] = paymentDatesCalendar.adjust(paymentDates[i], paymentDatesConvention);
1136 }
1137
1138 // set payment calendar
1139
1140 Calendar paymentCalendar;
1141 if (!data.paymentCalendar().empty())
1142 paymentCalendar = parseCalendar(data.paymentCalendar());
1143 else if (!paymentSchedule.calendar().empty())
1144 paymentCalendar = paymentSchedule.calendar();
1145 else if (!schedule.calendar().empty())
1146 paymentCalendar = schedule.calendar();
1147
1148 // set day counter and bdc
1149
1150 DayCounter dc = parseDayCounter(data.dayCounter());
1151 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
1152
1153 // flag whether caps / floors are present
1154
1155 bool hasCapsFloors = floatData->caps().size() > 0 || floatData->floors().size() > 0;
1156
1157 // build standard schedules (for non-strict notional dates)
1158
1159 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
1160 vector<double> spreads =
1161 buildScheduledVectorNormalised(floatData->spreads(), floatData->spreadDates(), schedule, 0.0);
1162 vector<double> gearings =
1163 buildScheduledVectorNormalised(floatData->gearings(), floatData->gearingDates(), schedule, 1.0);
1164
1165 // set fixing days and in arrears flag
1166
1167 Size fixingDays = floatData->fixingDays() == Null<Size>() ? index->fixingDays() : floatData->fixingDays();
1168 bool isInArrears = floatData->isInArrears() ? *floatData->isInArrears() : false;
1169
1170 // apply amortization
1171
1172 applyAmortization(notionals, data, schedule, true);
1173
1174 // handle float annuity, which is not done in applyAmortization, for this we can only have one block
1175
1176 if (!data.amortizationData().empty()) {
1177 AmortizationType amortizationType = parseAmortizationType(data.amortizationData().front().type());
1178 if (amortizationType == AmortizationType::Annuity) {
1179 LOG("Build floating annuity notional schedule");
1180 QL_REQUIRE(data.amortizationData().size() == 1,
1181 "Can have one AmortizationData block only for floating leg annuities");
1182 QL_REQUIRE(!hasCapsFloors, "Caps/Floors not supported in floating annuity coupons");
1183 QL_REQUIRE(floatData->gearings().size() == 0, "Gearings not supported in floating annuity coupons");
1184 DayCounter dc = index->dayCounter();
1185 Date startDate = data.amortizationData().front().startDate().empty()
1186 ? Date::minDate()
1187 : parseDate(data.amortizationData().front().startDate());
1188 double annuity = data.amortizationData().front().value();
1189 bool underflow = data.amortizationData().front().underflow();
1190 vector<QuantLib::ext::shared_ptr<Coupon>> coupons;
1191 for (Size i = 0; i < schedule.size() - 1; i++) {
1192 Date paymentDate = paymentCalendar.adjust(schedule[i + 1], bdc);
1193 if (schedule[i] < startDate || i == 0) {
1194 QuantLib::ext::shared_ptr<FloatingRateCoupon> coupon;
1195 if (!floatData->hasSubPeriods()) {
1196 coupon = QuantLib::ext::make_shared<IborCoupon>(paymentDate, notionals[i], schedule[i], schedule[i + 1],
1197 fixingDays, index, gearings[i], spreads[i], Date(),
1198 Date(), dc, isInArrears);
1199 coupon->setPricer(QuantLib::ext::make_shared<BlackIborCouponPricer>());
1200 } else {
1201 coupon = QuantLib::ext::make_shared<QuantExt::SubPeriodsCoupon1>(
1202 paymentDate, notionals[i], schedule[i], schedule[i + 1], index,
1203 floatData->isAveraged() ? QuantExt::SubPeriodsCoupon1::Averaging
1205 index->businessDayConvention(), spreads[i], dc, floatData->includeSpread(), gearings[i]);
1206 coupon->setPricer(QuantLib::ext::make_shared<QuantExt::SubPeriodsCouponPricer1>());
1207 }
1208 coupons.push_back(coupon);
1209 LOG("FloatingAnnuityCoupon: " << i << " " << coupon->nominal() << " " << coupon->amount());
1210 } else {
1211 QL_REQUIRE(coupons.size() > 0,
1212 "FloatingAnnuityCoupon needs at least one predecessor, e.g. a plain IborCoupon");
1213 LOG("FloatingAnnuityCoupon, previous nominal/coupon: " << i << " " << coupons.back()->nominal()
1214 << " " << coupons.back()->amount());
1215 QuantLib::ext::shared_ptr<QuantExt::FloatingAnnuityCoupon> coupon =
1216 QuantLib::ext::make_shared<QuantExt::FloatingAnnuityCoupon>(
1217 annuity, underflow, coupons.back(), paymentDate, schedule[i], schedule[i + 1], fixingDays,
1218 index, gearings[i], spreads[i], Date(), Date(), dc, isInArrears);
1219 coupons.push_back(coupon);
1220 LOG("FloatingAnnuityCoupon: " << i << " " << coupon->nominal() << " " << coupon->amount());
1221 }
1222 }
1223 Leg leg;
1224 for (Size i = 0; i < coupons.size(); i++)
1225 leg.push_back(coupons[i]);
1226 LOG("Floating annuity notional schedule done");
1227 return leg;
1228 }
1229 }
1230
1231 // handle sub periods leg
1232
1233 if (floatData->hasSubPeriods()) {
1234 QL_REQUIRE(floatData->caps().empty() && floatData->floors().empty(),
1235 "SubPeriodsLegs does not support caps or floors");
1236 QL_REQUIRE(!isInArrears, "SubPeriodLegs do not support in arrears fixings");
1237 Leg leg = QuantExt::SubPeriodsLeg1(schedule, index)
1238 .withNotionals(notionals)
1241 .withGearings(gearings)
1242 .withSpreads(spreads)
1243 .withType(floatData->isAveraged() ? QuantExt::SubPeriodsCoupon1::Averaging
1245 .includeSpread(floatData->includeSpread());
1246 QuantExt::setCouponPricer(leg, QuantLib::ext::make_shared<QuantExt::SubPeriodsCouponPricer1>());
1247 return leg;
1248 }
1249
1250 // parse payment lag
1251
1252 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
1253
1254 // handle ibor leg
1255
1256 Leg tmpLeg;
1257 bool isNonStandard;
1258
1259 if (!data.strictNotionalDates() && fixingSchedule.empty() && resetSchedule.empty()) {
1260
1261 // no strict notional dates, no fixing or reset schedule
1262
1263 IborLeg iborLeg = IborLeg(schedule, index)
1264 .withNotionals(notionals)
1265 .withSpreads(spreads)
1266 .withPaymentCalendar(paymentCalendar)
1267 .withPaymentDayCounter(dc)
1268 .withPaymentAdjustment(bdc)
1269 .withFixingDays(fixingDays)
1270 .inArrears(isInArrears)
1271 .withGearings(gearings)
1272 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
1273 .withPaymentDates(paymentDates);
1274 if (floatData->caps().size() > 0)
1275 iborLeg.withCaps(buildScheduledVector(floatData->caps(), floatData->capDates(), schedule));
1276 if (floatData->floors().size() > 0)
1277 iborLeg.withFloors(buildScheduledVector(floatData->floors(), floatData->floorDates(), schedule));
1278
1279 tmpLeg = iborLeg;
1280 isNonStandard = false;
1281
1282 } else {
1283
1284 // strict notional dates, fixing or reset schedule present
1285
1286 QL_REQUIRE(!hasCapsFloors, "Ibor leg with strict notional or reset dates, explicit fixing or reset schedule "
1287 "does not support cap / floors");
1288
1289 std::vector<Date> notionalDatesAsDates;
1290 std::vector<Date> spreadDatesAsDates;
1291 std::vector<Date> gearingDatesAsDates;
1292
1293 for (auto const& d : data.notionalDates()) {
1294 if (!d.empty())
1295 notionalDatesAsDates.push_back(parseDate(d));
1296 }
1297
1298 for (auto const& d : floatData->spreadDates()) {
1299 if (!d.empty())
1300 spreadDatesAsDates.push_back(parseDate(d));
1301 }
1302
1303 for (auto const& d : floatData->gearingDates()) {
1304 if (!d.empty())
1305 gearingDatesAsDates.push_back(parseDate(d));
1306 }
1307
1308 tmpLeg = makeNonStandardIborLeg(index, schedule.dates(), paymentDates, fixingSchedule.dates(),
1309 resetSchedule.dates(), fixingDays, data.notionals(), notionalDatesAsDates,
1310 floatData->spreads(), spreadDatesAsDates, floatData->gearings(),
1311 gearingDatesAsDates, data.strictNotionalDates(), dc, paymentCalendar, bdc,
1312 boost::apply_visitor(PaymentLagPeriod(), paymentLag), isInArrears);
1313
1314 isNonStandard = true;
1315 }
1316
1317 if (attachPricer && (hasCapsFloors || isInArrears || isNonStandard)) {
1318 auto builder = engineFactory->builder("CapFlooredIborLeg");
1319 QL_REQUIRE(builder, "No builder found for CapFlooredIborLeg");
1320 auto cappedFlooredIborBuilder = QuantLib::ext::dynamic_pointer_cast<CapFlooredIborLegEngineBuilder>(builder);
1321 auto couponPricer = cappedFlooredIborBuilder->engine(IndexNameTranslator::instance().oreName(index->name()));
1322 QuantLib::setCouponPricer(tmpLeg, couponPricer);
1323 }
1324
1325 // build naked option leg if required
1326
1327 if (floatData->nakedOption()) {
1328 tmpLeg = StrippedCappedFlooredCouponLeg(tmpLeg);
1329 }
1330
1331 // return the leg
1332
1333 return tmpLeg;
1334}
SubPeriodsLeg1 & withPaymentDayCounter(const DayCounter &dayCounter)
SubPeriodsLeg1 & withType(SubPeriodsCoupon1::Type type)
SubPeriodsLeg1 & withSpreads(const std::vector< Spread > &spreads)
SubPeriodsLeg1 & includeSpread(bool includeSpread)
SubPeriodsLeg1 & withGearings(const std::vector< Real > &gearings)
SubPeriodsLeg1 & withNotionals(const std::vector< Real > &notionals)
SubPeriodsLeg1 & withPaymentAdjustment(BusinessDayConvention convention)
Leg makeNonStandardIborLeg(const QuantLib::ext::shared_ptr< IborIndex > &index, const std::vector< Date > &calcDates, const std::vector< Date > &payDatesInput, const std::vector< Date > &fixingDatesInput, const std::vector< Date > &resetDatesInput, const Size fixingDays, const std::vector< Real > &notionals, const std::vector< Date > &notionalDatesInput, const std::vector< Real > &spreadsInput, const std::vector< Date > &spreadDatesInput, const std::vector< Real > &gearingsInput, const std::vector< Date > &gearingDatesInput, const bool strictNotionalDates, const DayCounter &dayCounter, const Calendar &payCalendar, const BusinessDayConvention payConv, const Period &payLag, const bool isInArrears)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeOISLeg()

Leg makeOISLeg ( const LegData data,
const QuantLib::ext::shared_ptr< OvernightIndex > &  index,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const bool  attachPricer,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1336 of file legdata.cpp.

1338 {
1339 QuantLib::ext::shared_ptr<FloatingLegData> floatData = QuantLib::ext::dynamic_pointer_cast<FloatingLegData>(data.concreteLegData());
1340 QL_REQUIRE(floatData, "Wrong LegType, expected Floating, got " << data.legType());
1341
1342 auto tmp = data.schedule();
1343
1344 /* For schedules with 1D tenor, this ensures that the index calendar supersedes the calendar provided
1345 in the trade XML and using "following" rolling conventions to avoid differing calendars and subsequent
1346 "degenerate schedule" errors in the building of the overnight coupon value date schedules.
1347 Generally, "1D" is an unusual tenor to use (and often just an error in the input data), but we want to
1348 make sure that this edge case works technically. */
1349 for (auto& r : tmp.modifyRules()) {
1350 if (r.tenor() == "1D") {
1351 r.modifyCalendar() = to_string(index->fixingCalendar());
1352 r.modifyConvention() = "F";
1353 r.modifyTermConvention() = "F";
1354 }
1355 }
1356
1357 Schedule schedule = makeSchedule(tmp, openEndDateReplacement);
1358 DayCounter dc = parseDayCounter(data.dayCounter());
1359 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
1360 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
1361
1362 // Get explicit payment dates which in most cases should be empty
1363 vector<Date> paymentDates;
1364 if (!data.paymentDates().empty()) {
1365 BusinessDayConvention paymentDatesConvention =
1366 data.paymentConvention().empty() ? Unadjusted : parseBusinessDayConvention(data.paymentConvention());
1367 Calendar paymentDatesCalendar =
1368 data.paymentCalendar().empty() ? NullCalendar() : parseCalendar(data.paymentCalendar());
1369 paymentDates = parseVectorOfValues<Date>(data.paymentDates(), &parseDate);
1370 for (Size i = 0; i < paymentDates.size(); i++)
1371 paymentDates[i] = paymentDatesCalendar.adjust(paymentDates[i], paymentDatesConvention);
1372 }
1373
1374 // try to set the rate computation period based on the schedule tenor
1375 Period rateComputationPeriod = 0 * Days;
1376 if (!tmp.rules().empty() && !tmp.rules().front().tenor().empty())
1377 rateComputationPeriod = parsePeriod(tmp.rules().front().tenor());
1378 else if (!tmp.dates().empty() && !tmp.dates().front().tenor().empty())
1379 rateComputationPeriod = parsePeriod(tmp.dates().front().tenor());
1380
1381 Calendar paymentCalendar;
1382 if (data.paymentCalendar().empty())
1383 paymentCalendar = index->fixingCalendar();
1384 else
1385 paymentCalendar = parseCalendar(data.paymentCalendar());
1386
1387 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
1388 vector<double> spreads =
1389 buildScheduledVectorNormalised(floatData->spreads(), floatData->spreadDates(), schedule, 0.0);
1390 vector<double> gearings =
1391 buildScheduledVectorNormalised(floatData->gearings(), floatData->gearingDates(), schedule, 1.0);
1392 bool isInArrears = floatData->isInArrears() ? *floatData->isInArrears() : true;
1393
1394 applyAmortization(notionals, data, schedule, false);
1395
1396 if (floatData->isAveraged()) {
1397
1398 QuantLib::ext::shared_ptr<QuantExt::AverageONIndexedCouponPricer> couponPricer =
1399 QuantLib::ext::make_shared<QuantExt::AverageONIndexedCouponPricer>();
1400
1401 QuantLib::ext::shared_ptr<QuantExt::CapFlooredAverageONIndexedCouponPricer> cfCouponPricer;
1402 if (attachPricer && (floatData->caps().size() > 0 || floatData->floors().size() > 0)) {
1403 auto builder = QuantLib::ext::dynamic_pointer_cast<CapFlooredAverageONIndexedCouponLegEngineBuilder>(
1404 engineFactory->builder("CapFlooredAverageONIndexedCouponLeg"));
1405 QL_REQUIRE(builder, "No builder found for CapFlooredAverageONIndexedCouponLeg");
1406 cfCouponPricer = QuantLib::ext::dynamic_pointer_cast<CapFlooredAverageONIndexedCouponPricer>(
1407 builder->engine(IndexNameTranslator::instance().oreName(index->name()), rateComputationPeriod));
1408 QL_REQUIRE(cfCouponPricer, "internal error, could not cast to CapFlooredAverageONIndexedCouponPricer");
1409 }
1410
1412 QuantExt::AverageONLeg(schedule, index)
1413 .withNotionals(notionals)
1414 .withSpreads(spreads)
1415 .withPaymentCalendar(paymentCalendar)
1416 .withGearings(gearings)
1419 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
1420 .withInArrears(isInArrears)
1421 .withLastRecentPeriod(floatData->lastRecentPeriod())
1422 .withLastRecentPeriodCalendar(floatData->lastRecentPeriodCalendar().empty()
1423 ? Calendar()
1424 : parseCalendar(floatData->lastRecentPeriodCalendar()))
1425 .withLookback(floatData->lookback())
1426 .withRateCutoff(floatData->rateCutoff() == Null<Size>() ? 0 : floatData->rateCutoff())
1427 .withFixingDays(floatData->fixingDays())
1428 .withCaps(buildScheduledVectorNormalised<Real>(floatData->caps(), floatData->capDates(), schedule,
1429 Null<Real>()))
1430 .withFloors(buildScheduledVectorNormalised<Real>(floatData->floors(), floatData->capDates(), schedule,
1431 Null<Real>()))
1432 .withNakedOption(floatData->nakedOption())
1433 .includeSpreadInCapFloors(floatData->includeSpread())
1434 .withLocalCapFloor(floatData->localCapFloor())
1437 .withTelescopicValueDates(floatData->telescopicValueDates())
1438 .withPaymentDates(paymentDates);
1439 return leg;
1440
1441 } else {
1442
1443 QuantLib::ext::shared_ptr<QuantExt::OvernightIndexedCouponPricer> couponPricer =
1444 QuantLib::ext::make_shared<QuantExt::OvernightIndexedCouponPricer>();
1445
1446 QuantLib::ext::shared_ptr<QuantExt::CappedFlooredOvernightIndexedCouponPricer> cfCouponPricer;
1447 if (attachPricer && (floatData->caps().size() > 0 || floatData->floors().size() > 0)) {
1448 auto builder = QuantLib::ext::dynamic_pointer_cast<CapFlooredOvernightIndexedCouponLegEngineBuilder>(
1449 engineFactory->builder("CapFlooredOvernightIndexedCouponLeg"));
1450 QL_REQUIRE(builder, "No builder found for CapFlooredOvernightIndexedCouponLeg");
1451 cfCouponPricer = QuantLib::ext::dynamic_pointer_cast<QuantExt::CappedFlooredOvernightIndexedCouponPricer>(
1452 builder->engine(IndexNameTranslator::instance().oreName(index->name()), rateComputationPeriod));
1453 QL_REQUIRE(cfCouponPricer, "internal error, could not cast to CapFlooredAverageONIndexedCouponPricer");
1454 }
1455
1456 Leg leg = QuantExt::OvernightLeg(schedule, index)
1457 .withNotionals(notionals)
1458 .withSpreads(spreads)
1461 .withPaymentCalendar(paymentCalendar)
1462 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
1463 .withGearings(gearings)
1464 .withInArrears(isInArrears)
1465 .withLastRecentPeriod(floatData->lastRecentPeriod())
1466 .withLastRecentPeriodCalendar(floatData->lastRecentPeriodCalendar().empty()
1467 ? Calendar()
1468 : parseCalendar(floatData->lastRecentPeriodCalendar()))
1469 .includeSpread(floatData->includeSpread())
1470 .withLookback(floatData->lookback())
1471 .withFixingDays(floatData->fixingDays())
1472 .withRateCutoff(floatData->rateCutoff() == Null<Size>() ? 0 : floatData->rateCutoff())
1473 .withCaps(buildScheduledVectorNormalised<Real>(floatData->caps(), floatData->capDates(), schedule,
1474 Null<Real>()))
1475 .withFloors(buildScheduledVectorNormalised<Real>(floatData->floors(), floatData->capDates(),
1476 schedule, Null<Real>()))
1477 .withNakedOption(floatData->nakedOption())
1478 .withLocalCapFloor(floatData->localCapFloor())
1481 .withTelescopicValueDates(floatData->telescopicValueDates())
1482 .withPaymentDates(paymentDates);
1483
1484 // If the overnight index is BRL CDI, we need a special coupon pricer
1485 QuantLib::ext::shared_ptr<BRLCdi> brlCdiIndex = QuantLib::ext::dynamic_pointer_cast<BRLCdi>(index);
1486 if (brlCdiIndex)
1487 QuantExt::setCouponPricer(leg, QuantLib::ext::make_shared<BRLCdiCouponPricer>());
1488
1489 return leg;
1490 }
1491}
AverageONLeg & withLastRecentPeriod(const boost::optional< Period > &lastRecentPeriod)
AverageONLeg & withPaymentDates(const std::vector< QuantLib::Date > &paymentDates)
AverageONLeg & withPaymentDayCounter(const DayCounter &dayCounter)
AverageONLeg & includeSpreadInCapFloors(bool includeSpread)
AverageONLeg & withPaymentLag(Natural lag)
AverageONLeg & withLookback(const Period &lookback)
AverageONLeg & withRateCutoff(Natural rateCutoff)
AverageONLeg & withLastRecentPeriodCalendar(const Calendar &lastRecentPeriodCalendar)
AverageONLeg & withPaymentCalendar(const Calendar &calendar)
AverageONLeg & withNakedOption(const bool nakedOption)
AverageONLeg & withLocalCapFloor(const bool localCapFloor)
AverageONLeg & withTelescopicValueDates(bool telescopicValueDates)
AverageONLeg & withPaymentAdjustment(BusinessDayConvention convention)
AverageONLeg & withCapFlooredAverageONIndexedCouponPricer(const boost::shared_ptr< CapFlooredAverageONIndexedCouponPricer > &couponPricer)
AverageONLeg & withNotionals(const std::vector< Real > &notionals)
AverageONLeg & withSpreads(const std::vector< Spread > &spreads)
AverageONLeg & withInArrears(const bool inArrears)
AverageONLeg & withCaps(Rate cap)
AverageONLeg & withFloors(Rate floor)
AverageONLeg & withFixingDays(const Size fixingDays)
AverageONLeg & withAverageONIndexedCouponPricer(const boost::shared_ptr< AverageONIndexedCouponPricer > &couponPricer)
AverageONLeg & withGearings(const std::vector< Real > &gearings)
OvernightLeg & withLookback(const Period &lookback)
OvernightLeg & withGearings(Real gearing)
OvernightLeg & withPaymentCalendar(const Calendar &)
OvernightLeg & withLastRecentPeriod(const boost::optional< Period > &lastRecentPeriod)
OvernightLeg & withFloors(Rate floor)
OvernightLeg & withCapFlooredOvernightIndexedCouponPricer(const boost::shared_ptr< CappedFlooredOvernightIndexedCouponPricer > &couponPricer)
OvernightLeg & withTelescopicValueDates(bool telescopicValueDates)
OvernightLeg & withPaymentAdjustment(BusinessDayConvention)
OvernightLeg & withNakedOption(const bool nakedOption)
OvernightLeg & withFixingDays(const Natural fixingDays)
OvernightLeg & withNotionals(Real notional)
OvernightLeg & withOvernightIndexedCouponPricer(const boost::shared_ptr< OvernightIndexedCouponPricer > &couponPricer)
OvernightLeg & withRateCutoff(const Natural rateCutoff)
OvernightLeg & withCaps(Rate cap)
OvernightLeg & withPaymentDayCounter(const DayCounter &)
OvernightLeg & withInArrears(const bool inArrears)
OvernightLeg & withSpreads(Spread spread)
OvernightLeg & withPaymentDates(const std::vector< Date > &paymentDates)
OvernightLeg & withLocalCapFloor(const bool localCapFloor)
OvernightLeg & includeSpread(bool includeSpread)
OvernightLeg & withPaymentLag(Natural lag)
OvernightLeg & withLastRecentPeriodCalendar(const Calendar &lastRecentPeriodCalendar)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeBMALeg()

Leg makeBMALeg ( const LegData data,
const QuantLib::ext::shared_ptr< QuantExt::BMAIndexWrapper > &  indexWrapper,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1493 of file legdata.cpp.

1494 {
1495 QuantLib::ext::shared_ptr<FloatingLegData> floatData = QuantLib::ext::dynamic_pointer_cast<FloatingLegData>(data.concreteLegData());
1496 QL_REQUIRE(floatData, "Wrong LegType, expected Floating, got " << data.legType());
1497 QuantLib::ext::shared_ptr<BMAIndex> index = indexWrapper->bma();
1498
1499 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
1500 DayCounter dc = parseDayCounter(data.dayCounter());
1501 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
1502 Calendar paymentCalendar;
1503
1504 if (data.paymentCalendar().empty())
1505 paymentCalendar = schedule.calendar();
1506 else
1507 paymentCalendar = parseCalendar(data.paymentCalendar());
1508
1509 vector<Real> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
1510 vector<Real> spreads =
1511 buildScheduledVectorNormalised(floatData->spreads(), floatData->spreadDates(), schedule, 0.0);
1512 vector<Real> gearings =
1513 buildScheduledVectorNormalised(floatData->gearings(), floatData->gearingDates(), schedule, 1.0);
1514 vector<Real> caps =
1515 buildScheduledVectorNormalised(floatData->caps(), floatData->capDates(), schedule, (Real)Null<Real>());
1516 vector<Real> floors =
1517 buildScheduledVectorNormalised(floatData->floors(), floatData->floorDates(), schedule, (Real)Null<Real>());
1518
1519 applyAmortization(notionals, data, schedule, false);
1520
1521 Leg leg = AverageBMALeg(schedule, index)
1522 .withNotionals(notionals)
1523 .withSpreads(spreads)
1524 .withPaymentDayCounter(dc)
1525 .withPaymentCalendar(paymentCalendar)
1526 .withPaymentAdjustment(bdc)
1527 .withGearings(gearings);
1528
1529 // try to set the rate computation period based on the schedule tenor
1530
1531 Period rateComputationPeriod = 0 * Days;
1532 if (!data.schedule().rules().empty() && !data.schedule().rules().front().tenor().empty())
1533 rateComputationPeriod = parsePeriod(data.schedule().rules().front().tenor());
1534 else if (!data.schedule().dates().empty() && !data.schedule().dates().front().tenor().empty())
1535 rateComputationPeriod = parsePeriod(data.schedule().dates().front().tenor());
1536
1537 // handle caps / floors
1538
1539 if (floatData->caps().size() > 0 || floatData->floors().size() > 0) {
1540
1541 QuantLib::ext::shared_ptr<QuantExt::CapFlooredAverageBMACouponPricer> cfCouponPricer;
1542 auto builder = QuantLib::ext::dynamic_pointer_cast<CapFlooredAverageBMACouponLegEngineBuilder>(
1543 engineFactory->builder("CapFlooredAverageBMACouponLeg"));
1544 QL_REQUIRE(builder, "No builder found for CapFlooredAverageBMACouponLeg");
1545 cfCouponPricer = QuantLib::ext::dynamic_pointer_cast<CapFlooredAverageBMACouponPricer>(
1546 builder->engine(IndexNameTranslator::instance().oreName(index->name()), rateComputationPeriod));
1547 QL_REQUIRE(cfCouponPricer, "internal error, could not cast to CapFlooredAverageBMACouponPricer");
1548
1549 for (Size i = 0; i < leg.size(); ++i) {
1550 auto bmaCpn = QuantLib::ext::dynamic_pointer_cast<AverageBMACoupon>(leg[i]);
1551 QL_REQUIRE(bmaCpn, "makeBMALeg(): internal error, exepcted AverageBMACoupon. Contact dev.");
1552 if (caps[i] != Null<Real>() || floors[i] != Null<Real>()) {
1553 auto cpn = QuantLib::ext::make_shared<CappedFlooredAverageBMACoupon>(
1554 bmaCpn, caps[i], floors[i], floatData->nakedOption(), floatData->includeSpread());
1555 cpn->setPricer(cfCouponPricer);
1556 leg[i] = cpn;
1557 }
1558 }
1559 }
1560
1561 // return the leg
1562
1563 return leg;
1564}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeNotionalLeg() [1/2]

Leg makeNotionalLeg ( const Leg &  refLeg,
const bool  initNomFlow,
const bool  finalNomFlow,
const bool  amortNomFlow,
const Natural  notionalPaymentLag,
const BusinessDayConvention  paymentConvention,
const Calendar  paymentCalendar,
const bool  excludeIndexing 
)

Definition at line 1566 of file legdata.cpp.

1568 {
1569
1570 // Assumption - Cashflows on Input Leg are all coupons
1571 // This is the Leg to be populated
1572 Leg leg;
1573
1574 // Initial Flow Amount
1575 if (initNomFlow) {
1576 auto coupon = QuantLib::ext::dynamic_pointer_cast<QuantLib::Coupon>(refLeg[0]);
1577 QL_REQUIRE(coupon, "makeNotionalLeg does not support non-coupon legs");
1578 double initFlowAmt = (excludeIndexing ? unpackIndexedCoupon(coupon) : coupon)->nominal();
1579 Date initDate = coupon->accrualStartDate();
1580 initDate = paymentCalendar.advance(initDate, notionalPaymentLag, Days, paymentConvention);
1581 if (initFlowAmt != 0)
1582 leg.push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(-initFlowAmt, initDate)));
1583 }
1584
1585 // Amortization Flows
1586 if (amortNomFlow) {
1587 for (Size i = 1; i < refLeg.size(); i++) {
1588 auto coupon = QuantLib::ext::dynamic_pointer_cast<QuantLib::Coupon>(refLeg[i]);
1589 QL_REQUIRE(coupon, "makeNotionalLeg does not support non-coupon legs");
1590 auto coupon2 = QuantLib::ext::dynamic_pointer_cast<QuantLib::Coupon>(refLeg[i - 1]);
1591 QL_REQUIRE(coupon, "makeNotionalLeg does not support non-coupon legs");
1592 Date flowDate = coupon->accrualStartDate();
1593 flowDate = paymentCalendar.advance(flowDate, notionalPaymentLag, Days, paymentConvention);
1594 Real initNom = (excludeIndexing ? unpackIndexedCoupon(coupon2) : coupon2)->nominal();
1595 Real newNom = (excludeIndexing ? unpackIndexedCoupon(coupon) : coupon)->nominal();
1596 Real flow = initNom - newNom;
1597 if (flow != 0)
1598 leg.push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(flow, flowDate)));
1599 }
1600 }
1601
1602 // Final Nominal Return at Maturity
1603 if (finalNomFlow) {
1604 auto coupon = QuantLib::ext::dynamic_pointer_cast<QuantLib::Coupon>(refLeg.back());
1605 QL_REQUIRE(coupon, "makeNotionalLeg does not support non-coupon legs");
1606 double finalNomFlow = (excludeIndexing ? unpackIndexedCoupon(coupon) : coupon)->nominal();
1607 Date finalDate = coupon->accrualEndDate();
1608 finalDate = paymentCalendar.advance(finalDate, notionalPaymentLag, Days, paymentConvention);
1609 if (finalNomFlow != 0)
1610 leg.push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(finalNomFlow, finalDate)));
1611 }
1612
1613 return leg;
1614}
boost::shared_ptr< Coupon > unpackIndexedCoupon(const boost::shared_ptr< Coupon > &c)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeCPILeg()

Leg makeCPILeg ( const LegData data,
const QuantLib::ext::shared_ptr< ZeroInflationIndex > &  index,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1616 of file legdata.cpp.

1617 {
1618
1619 QuantLib::ext::shared_ptr<CPILegData> cpiLegData = QuantLib::ext::dynamic_pointer_cast<CPILegData>(data.concreteLegData());
1620 QL_REQUIRE(cpiLegData, "Wrong LegType, expected CPI, got " << data.legType());
1621
1622 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
1623 DayCounter dc = parseDayCounter(data.dayCounter());
1624 Calendar paymentCalendar;
1625
1626 if (data.paymentCalendar().empty())
1627 paymentCalendar = schedule.calendar();
1628 else
1629 paymentCalendar = parseCalendar(data.paymentCalendar());
1630 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
1631
1632 QuantLib::ext::shared_ptr<InflationSwapConvention> cpiSwapConvention = nullptr;
1633
1634 auto inflationConventions = InstrumentConventions::instance().conventions()->get(
1635 cpiLegData->index() + "_INFLATIONSWAP", Convention::Type::InflationSwap);
1636
1637 if (inflationConventions.first)
1638 cpiSwapConvention = QuantLib::ext::dynamic_pointer_cast<InflationSwapConvention>(inflationConventions.second);
1639
1640 Period observationLag;
1641 if (cpiLegData->observationLag().empty()) {
1642 QL_REQUIRE(cpiSwapConvention,
1643 "observationLag is not specified in legData and couldn't find convention for "
1644 << cpiLegData->index() << ". Please add field to trade xml or add convention");
1645 DLOG("Build CPI Leg and use observation lag from standard inflationswap convention");
1646 observationLag = cpiSwapConvention->observationLag();
1647 } else {
1648 observationLag = parsePeriod(cpiLegData->observationLag());
1649 }
1650
1651 CPI::InterpolationType interpolationMethod;
1652 if (cpiLegData->interpolation().empty()) {
1653 QL_REQUIRE(cpiSwapConvention,
1654 "Interpolation is not specified in legData and couldn't find convention for "
1655 << cpiLegData->index() << ". Please add field to trade xml or add convention");
1656 DLOG("Build CPI Leg and use observation lag from standard inflationswap convention");
1657 interpolationMethod = cpiSwapConvention->interpolated() ? CPI::Linear : CPI::Flat;
1658 } else {
1659 interpolationMethod = parseObservationInterpolation(cpiLegData->interpolation());
1660 }
1661
1662 vector<double> rates = buildScheduledVector(cpiLegData->rates(), cpiLegData->rateDates(), schedule);
1663 vector<double> notionals = buildScheduledVector(data.notionals(), data.notionalDates(), schedule);
1664 bool couponCap = cpiLegData->caps().size() > 0;
1665 bool couponFloor = cpiLegData->floors().size() > 0;
1666 bool couponCapFloor = cpiLegData->caps().size() > 0 || cpiLegData->floors().size() > 0;
1667 bool finalFlowCapFloor = cpiLegData->finalFlowCap() != Null<Real>() || cpiLegData->finalFlowFloor() != Null<Real>();
1668
1669 applyAmortization(notionals, data, schedule, false);
1670 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
1671
1672 QuantExt::CPILeg cpiLeg =
1673 QuantExt::CPILeg(schedule, index,
1674 engineFactory->market()->discountCurve(data.currency(),
1675 engineFactory->configuration(MarketContext::pricing)),
1676 cpiLegData->baseCPI(), observationLag)
1677 .withNotionals(notionals)
1680 .withPaymentCalendar(paymentCalendar)
1681 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
1682 .withFixedRates(rates)
1683 .withObservationInterpolation(interpolationMethod)
1684 .withSubtractInflationNominal(cpiLegData->subtractInflationNominal())
1685 .withSubtractInflationNominalAllCoupons(cpiLegData->subtractInflationNominalCoupons());
1686
1687 // the cpi leg uses the first schedule date as the start date, which only makes sense if there are at least
1688 // two dates in the schedule, otherwise the only date in the schedule is the pay date of the cf and a separate
1689 // start date is expected; if both the separate start date and a schedule with more than one date is given
1690 const string& start = cpiLegData->startDate();
1691 if (schedule.size() < 2) {
1692 QL_REQUIRE(!start.empty(), "makeCPILeg(): only one schedule date, a 'StartDate' must be given.");
1693 cpiLeg.withStartDate(parseDate(start));
1694 } else if (!start.empty()) {
1695 DLOG("Schedule with more than 2 dates was provided. The first schedule date "
1696
1697 << io::iso_date(schedule.dates().front()) << " is used as the start date. The 'StartDate' of " << start
1698 << " is not used.");
1699 }
1700 if (couponCap)
1701 cpiLeg.withCaps(buildScheduledVector(cpiLegData->caps(), cpiLegData->capDates(), schedule));
1702
1703 if (couponFloor)
1704 cpiLeg.withFloors(buildScheduledVector(cpiLegData->floors(), cpiLegData->floorDates(), schedule));
1705
1706 if (cpiLegData->finalFlowCap() != Null<Real>())
1707 cpiLeg.withFinalFlowCap(cpiLegData->finalFlowCap());
1708
1709 if (cpiLegData->finalFlowFloor() != Null<Real>())
1710 cpiLeg.withFinalFlowFloor(cpiLegData->finalFlowFloor());
1711
1712 Leg leg = cpiLeg.operator Leg();
1713 Size n = leg.size();
1714 QL_REQUIRE(n > 0, "Empty CPI Leg");
1715
1716 if (couponCapFloor || finalFlowCapFloor) {
1717
1718 string indexName = cpiLegData->index();
1719
1720 // get a coupon pricer for the leg
1721 QuantLib::ext::shared_ptr<EngineBuilder> cpBuilder = engineFactory->builder("CappedFlooredCpiLegCoupons");
1722 QL_REQUIRE(cpBuilder, "No builder found for CappedFlooredCpiLegCoupons");
1723 QuantLib::ext::shared_ptr<CapFlooredCpiLegCouponEngineBuilder> cappedFlooredCpiCouponBuilder =
1724 QuantLib::ext::dynamic_pointer_cast<CapFlooredCpiLegCouponEngineBuilder>(cpBuilder);
1725 QuantLib::ext::shared_ptr<InflationCouponPricer> couponPricer = cappedFlooredCpiCouponBuilder->engine(indexName);
1726
1727 // get a cash flow pricer for the leg
1728 QuantLib::ext::shared_ptr<EngineBuilder> cfBuilder = engineFactory->builder("CappedFlooredCpiLegCashFlows");
1729 QL_REQUIRE(cfBuilder, "No builder found for CappedFlooredCpiLegCashFLows");
1730 QuantLib::ext::shared_ptr<CapFlooredCpiLegCashFlowEngineBuilder> cappedFlooredCpiCashFlowBuilder =
1731 QuantLib::ext::dynamic_pointer_cast<CapFlooredCpiLegCashFlowEngineBuilder>(cfBuilder);
1732 QuantLib::ext::shared_ptr<InflationCashFlowPricer> cashFlowPricer = cappedFlooredCpiCashFlowBuilder->engine(indexName);
1733
1734 // set coupon pricer for the leg
1735 for (Size i = 0; i < leg.size(); i++) {
1736 // nothing to do for the plain CPI Coupon, because the pricer is already set when the leg builder is called
1737 // nothing to do for the plain CPI CashFlow either, because it does not require a pricer
1738
1739 QuantLib::ext::shared_ptr<CappedFlooredCPICoupon> cfCpiCoupon =
1740 QuantLib::ext::dynamic_pointer_cast<CappedFlooredCPICoupon>(leg[i]);
1741 if (cfCpiCoupon && couponCapFloor) {
1742 cfCpiCoupon->setPricer(couponPricer);
1743 }
1744
1745 QuantLib::ext::shared_ptr<CappedFlooredCPICashFlow> cfCpiCashFlow =
1746 QuantLib::ext::dynamic_pointer_cast<CappedFlooredCPICashFlow>(leg[i]);
1747 if (cfCpiCashFlow && finalFlowCapFloor && i == (leg.size() - 1)) {
1748 cfCpiCashFlow->setPricer(cashFlowPricer);
1749 }
1750 }
1751 }
1752
1753 // QuantLib CPILeg automatically adds a Notional Cashflow at maturity date on a CPI swap
1754 if (!data.notionalFinalExchange()) {
1755 leg.pop_back();
1756 }
1757
1758 // build naked option leg if required and we have at least one cap/floor present in the coupon or the final flow
1759 if ((couponCapFloor || finalFlowCapFloor) && cpiLegData->nakedOption()) {
1761 }
1762
1763 return leg;
1764}
CPILeg & withNotionals(Real notional)
CPILeg & withPaymentAdjustment(BusinessDayConvention)
CPILeg & withFinalFlowCap(Rate cap)
CPILeg & withSubtractInflationNominal(bool)
CPILeg & withFixedRates(Real fixedRate)
CPILeg & withFinalFlowFloor(Rate floor)
CPILeg & withCaps(Rate cap)
CPILeg & withPaymentDayCounter(const DayCounter &)
CPILeg & withStartDate(const Date &startDate)
CPILeg & withPaymentCalendar(const Calendar &)
CPILeg & withFloors(Rate floor)
CPILeg & withSubtractInflationNominalAllCoupons(bool subtractInflationNominalAllCoupons)
CPILeg & withObservationInterpolation(CPI::InterpolationType)
QuantLib::CPI::InterpolationType parseObservationInterpolation(const std::string &s)
Convert string to observation interpolation.
Definition: parsers.cpp:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeYoYLeg()

Leg makeYoYLeg ( const LegData data,
const QuantLib::ext::shared_ptr< InflationIndex > &  index,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1766 of file legdata.cpp.

1767 {
1768 QuantLib::ext::shared_ptr<YoYLegData> yoyLegData = QuantLib::ext::dynamic_pointer_cast<YoYLegData>(data.concreteLegData());
1769 QL_REQUIRE(yoyLegData, "Wrong LegType, expected YoY, got " << data.legType());
1770
1771 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
1772 DayCounter dc = parseDayCounter(data.dayCounter());
1773 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
1774 Calendar paymentCalendar;
1775
1776 QuantLib::ext::shared_ptr<InflationSwapConvention> cpiSwapConvention = nullptr;
1777
1778 auto inflationConventions = InstrumentConventions::instance().conventions()->get(
1779 yoyLegData->index() + "_INFLATIONSWAP", Convention::Type::InflationSwap);
1780
1781 if (inflationConventions.first)
1782 cpiSwapConvention = QuantLib::ext::dynamic_pointer_cast<InflationSwapConvention>(inflationConventions.second);
1783
1784 Period observationLag;
1785 if (yoyLegData->observationLag().empty()) {
1786 QL_REQUIRE(cpiSwapConvention,
1787 "observationLag is not specified in legData and couldn't find convention for "
1788 << yoyLegData->index() << ". Please add field to trade xml or add convention");
1789 DLOG("Build CPI Leg and use observation lag from standard inflationswap convention");
1790 observationLag = cpiSwapConvention->observationLag();
1791 } else {
1792 observationLag = parsePeriod(yoyLegData->observationLag());
1793 }
1794
1795 if (data.paymentCalendar().empty())
1796 paymentCalendar = schedule.calendar();
1797 else
1798 paymentCalendar = parseCalendar(data.paymentCalendar());
1799
1800 vector<double> gearings =
1801 buildScheduledVectorNormalised(yoyLegData->gearings(), yoyLegData->gearingDates(), schedule, 1.0);
1802 vector<double> spreads =
1803 buildScheduledVectorNormalised(yoyLegData->spreads(), yoyLegData->spreadDates(), schedule, 0.0);
1804 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
1805
1806 bool irregularYoY = yoyLegData->irregularYoY();
1807 bool couponCap = yoyLegData->caps().size() > 0;
1808 bool couponFloor = yoyLegData->floors().size() > 0;
1809 bool couponCapFloor = yoyLegData->caps().size() > 0 || yoyLegData->floors().size() > 0;
1810 bool addInflationNotional = yoyLegData->addInflationNotional();
1811
1812 applyAmortization(notionals, data, schedule, false);
1813 Leg leg;
1814 if (!irregularYoY) {
1815 auto yoyIndex = QuantLib::ext::dynamic_pointer_cast<YoYInflationIndex>(index);
1816 QL_REQUIRE(yoyIndex, "Need a YoY Inflation Index");
1818 QuantExt::yoyInflationLeg(schedule, paymentCalendar, yoyIndex, observationLag)
1819 .withNotionals(notionals)
1822 .withFixingDays(yoyLegData->fixingDays())
1823 .withGearings(gearings)
1824 .withSpreads(spreads)
1825 .withInflationNotional(addInflationNotional)
1826 .withRateCurve(engineFactory->market()->discountCurve(
1827 data.currency(), engineFactory->configuration(MarketContext::pricing)));
1828
1829 if (couponCap)
1830 yoyLeg.withCaps(buildScheduledVector(yoyLegData->caps(), yoyLegData->capDates(), schedule));
1831
1832 if (couponFloor)
1833 yoyLeg.withFloors(buildScheduledVector(yoyLegData->floors(), yoyLegData->floorDates(), schedule));
1834
1835 leg = yoyLeg.operator Leg();
1836
1837 if (couponCapFloor) {
1838 // get a coupon pricer for the leg
1839 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder("CapFlooredYYLeg");
1840 QL_REQUIRE(builder, "No builder found for CapFlooredYYLeg");
1841 QuantLib::ext::shared_ptr<CapFlooredYoYLegEngineBuilder> cappedFlooredYoYBuilder =
1842 QuantLib::ext::dynamic_pointer_cast<CapFlooredYoYLegEngineBuilder>(builder);
1843 string indexname = yoyLegData->index();
1844 QuantLib::ext::shared_ptr<InflationCouponPricer> couponPricer =
1845 cappedFlooredYoYBuilder->engine(IndexNameTranslator::instance().oreName(indexname));
1846
1847 // set coupon pricer for the leg
1848
1849 for (Size i = 0; i < leg.size(); i++) {
1850 QuantLib::ext::dynamic_pointer_cast<QuantExt::CappedFlooredYoYInflationCoupon>(leg[i])->setPricer(
1851 QuantLib::ext::dynamic_pointer_cast<QuantLib::YoYInflationCouponPricer>(couponPricer));
1852 }
1853
1854 // build naked option leg if required
1855 if (yoyLegData->nakedOption()) {
1857 for (auto const& t : leg) {
1858 auto s = QuantLib::ext::dynamic_pointer_cast<StrippedCappedFlooredYoYInflationCoupon>(t);
1859 }
1860 }
1861 }
1862 } else {
1863 QuantLib::CPI::InterpolationType interpolation = QuantLib::CPI::Flat;
1864 if (cpiSwapConvention && cpiSwapConvention->interpolated()) {
1865 interpolation = QuantLib::CPI::Linear;
1866 }
1867 auto zcIndex = QuantLib::ext::dynamic_pointer_cast<ZeroInflationIndex>(index);
1868 QL_REQUIRE(zcIndex, "Need a Zero Coupon Inflation Index");
1870 QuantExt::NonStandardYoYInflationLeg(schedule, schedule.calendar(), zcIndex, observationLag)
1871 .withNotionals(notionals)
1874 .withFixingDays(yoyLegData->fixingDays())
1875 .withGearings(gearings)
1876 .withSpreads(spreads)
1877 .withRateCurve(engineFactory->market()->discountCurve(
1878 data.currency(), engineFactory->configuration(MarketContext::pricing)))
1879 .withInflationNotional(addInflationNotional)
1880 .withObservationInterpolation(interpolation);
1881
1882 if (couponCap)
1883 yoyLeg.withCaps(buildScheduledVector(yoyLegData->caps(), yoyLegData->capDates(), schedule));
1884
1885 if (couponFloor)
1886 yoyLeg.withFloors(buildScheduledVector(yoyLegData->floors(), yoyLegData->floorDates(), schedule));
1887
1888 leg = yoyLeg.operator Leg();
1889
1890 if (couponCapFloor) {
1891 // get a coupon pricer for the leg
1892 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder("CapFlooredNonStdYYLeg");
1893 QL_REQUIRE(builder, "No builder found for CapFlooredNonStdYYLeg");
1894 QuantLib::ext::shared_ptr<CapFlooredNonStandardYoYLegEngineBuilder> cappedFlooredYoYBuilder =
1895 QuantLib::ext::dynamic_pointer_cast<CapFlooredNonStandardYoYLegEngineBuilder>(builder);
1896 string indexname = zcIndex->name();
1897 QuantLib::ext::shared_ptr<InflationCouponPricer> couponPricer =
1898 cappedFlooredYoYBuilder->engine(IndexNameTranslator::instance().oreName(indexname));
1899
1900 // set coupon pricer for the leg
1901
1902 for (Size i = 0; i < leg.size(); i++) {
1903 QuantLib::ext::dynamic_pointer_cast<QuantExt::NonStandardCappedFlooredYoYInflationCoupon>(leg[i])->setPricer(
1904 QuantLib::ext::dynamic_pointer_cast<QuantExt::NonStandardYoYInflationCouponPricer>(couponPricer));
1905 }
1906
1907 // build naked option leg if required
1908 if (yoyLegData->nakedOption()) {
1910 for (auto const& t : leg) {
1911 auto s = QuantLib::ext::dynamic_pointer_cast<StrippedCappedFlooredYoYInflationCoupon>(t);
1912 }
1913 }
1914 }
1915 }
1916 return leg;
1917}
NonStandardYoYInflationLeg & withPaymentAdjustment(BusinessDayConvention)
NonStandardYoYInflationLeg & withFloors(Rate floor)
NonStandardYoYInflationLeg & withFixingDays(Natural fixingDays)
NonStandardYoYInflationLeg & withRateCurve(const Handle< YieldTermStructure > &rateCurve)
NonStandardYoYInflationLeg & withSpreads(Spread spread)
NonStandardYoYInflationLeg & withPaymentDayCounter(const DayCounter &)
NonStandardYoYInflationLeg & withGearings(Real gearing)
NonStandardYoYInflationLeg & withNotionals(Real notional)
NonStandardYoYInflationLeg & withObservationInterpolation(QuantLib::CPI::InterpolationType interpolation)
NonStandardYoYInflationLeg & withCaps(Rate cap)
NonStandardYoYInflationLeg & withInflationNotional(bool addInflationNotional_)
yoyInflationLeg & withRateCurve(const Handle< YieldTermStructure > &rateCurve)
yoyInflationLeg & withSpreads(Spread spread)
yoyInflationLeg & withFloors(Rate floor)
yoyInflationLeg & withPaymentAdjustment(BusinessDayConvention)
yoyInflationLeg & withNotionals(Real notional)
yoyInflationLeg & withGearings(Real gearing)
yoyInflationLeg & withPaymentDayCounter(const DayCounter &)
yoyInflationLeg & withCaps(Rate cap)
yoyInflationLeg & withInflationNotional(bool addInflationNotional_)
yoyInflationLeg & withFixingDays(Natural fixingDays)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeCMSLeg()

Leg makeCMSLeg ( const LegData data,
const QuantLib::ext::shared_ptr< QuantLib::SwapIndex > &  swapIndex,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const bool  attachPricer,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1919 of file legdata.cpp.

1921 {
1922 QuantLib::ext::shared_ptr<CMSLegData> cmsData = QuantLib::ext::dynamic_pointer_cast<CMSLegData>(data.concreteLegData());
1923 QL_REQUIRE(cmsData, "Wrong LegType, expected CMS, got " << data.legType());
1924
1925 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
1926 DayCounter dc = parseDayCounter(data.dayCounter());
1927 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
1928 Calendar paymentCalendar;
1929 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
1930
1931 if (data.paymentCalendar().empty())
1932 paymentCalendar = schedule.calendar();
1933 else
1934 paymentCalendar = parseCalendar(data.paymentCalendar());
1935
1936 vector<double> spreads =
1937 ore::data::buildScheduledVectorNormalised(cmsData->spreads(), cmsData->spreadDates(), schedule, 0.0);
1938 vector<double> gearings =
1939 ore::data::buildScheduledVectorNormalised(cmsData->gearings(), cmsData->gearingDates(), schedule, 1.0);
1940 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
1941 Size fixingDays = cmsData->fixingDays() == Null<Size>() ? swapIndex->fixingDays() : cmsData->fixingDays();
1942
1943 applyAmortization(notionals, data, schedule, false);
1944
1945 CmsLeg cmsLeg = CmsLeg(schedule, swapIndex)
1946 .withNotionals(notionals)
1947 .withSpreads(spreads)
1948 .withGearings(gearings)
1949 .withPaymentCalendar(paymentCalendar)
1950 .withPaymentDayCounter(dc)
1951 .withPaymentAdjustment(bdc)
1952 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
1953 .withFixingDays(fixingDays)
1954 .inArrears(cmsData->isInArrears());
1955
1956 if (cmsData->caps().size() > 0)
1957 cmsLeg.withCaps(buildScheduledVector(cmsData->caps(), cmsData->capDates(), schedule));
1958
1959 if (cmsData->floors().size() > 0)
1960 cmsLeg.withFloors(buildScheduledVector(cmsData->floors(), cmsData->floorDates(), schedule));
1961
1962 if (!attachPricer)
1963 return cmsLeg;
1964
1965 // Get a coupon pricer for the leg
1966 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder("CMS");
1967 QL_REQUIRE(builder, "No builder found for CmsLeg");
1968 QuantLib::ext::shared_ptr<CmsCouponPricerBuilder> cmsSwapBuilder =
1969 QuantLib::ext::dynamic_pointer_cast<CmsCouponPricerBuilder>(builder);
1970 QuantLib::ext::shared_ptr<FloatingRateCouponPricer> couponPricer =
1971 cmsSwapBuilder->engine(IndexNameTranslator::instance().oreName(swapIndex->iborIndex()->name()));
1972
1973 // Loop over the coupons in the leg and set pricer
1974 Leg tmpLeg = cmsLeg;
1975 QuantLib::setCouponPricer(tmpLeg, couponPricer);
1976
1977 // build naked option leg if required
1978 if (cmsData->nakedOption()) {
1979 tmpLeg = StrippedCappedFlooredCouponLeg(tmpLeg);
1980 }
1981 return tmpLeg;
1982}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeCMBLeg()

Leg makeCMBLeg ( const LegData data,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const bool  attachPricer,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 1984 of file legdata.cpp.

1985 {
1986 QuantLib::ext::shared_ptr<CMBLegData> cmbData = QuantLib::ext::dynamic_pointer_cast<CMBLegData>(data.concreteLegData());
1987 QL_REQUIRE(cmbData, "Wrong LegType, expected CMB, got " << data.legType());
1988
1989 std::string bondIndexName = cmbData->genericBond();
1990 // Expected bondIndexName structure with at least two tokens, separated by "-", of the form FAMILY-TERM or
1991 // FAMILY-MUN, for example: US-CMT-5Y, US-TIPS-10Y, UK-GILT-5Y, DE-BUND-10Y
1992 std::vector<string> tokens;
1993 split(tokens, bondIndexName, boost::is_any_of("-"));
1994 QL_REQUIRE(tokens.size() >= 2,
1995 "Generic Bond Index with at least two tokens separated by - expected, found " << bondIndexName);
1996 std::string securityFamily = tokens[0];
1997 for (Size i = 1; i < tokens.size() - 1; ++i)
1998 securityFamily = securityFamily + "-" + tokens[i];
1999 string underlyingTerm = tokens.back();
2000 Period underlyingPeriod = parsePeriod(underlyingTerm);
2001 LOG("Generic bond id " << bondIndexName << " has family " << securityFamily << " and term " << underlyingPeriod);
2002
2003 Schedule schedule = makeSchedule(data.schedule());
2004 Calendar calendar = schedule.calendar();
2005 int fixingDays = cmbData->fixingDays();
2006 BusinessDayConvention convention = schedule.businessDayConvention();
2007 bool creditRisk = cmbData->hasCreditRisk();
2008
2009 // Get the generic bond reference data, notional 1, credit risk as specified in the leg data
2010 BondData bondData(securityFamily, 1.0, creditRisk);
2011 bondData.populateFromBondReferenceData(engineFactory->referenceData());
2012 DLOG("Bond data for security id " << securityFamily << " loaded");
2013 QL_REQUIRE(bondData.coupons().size() == 1,
2014 "multiple reference bond legs not covered by the CMB leg");
2015 QL_REQUIRE(bondData.coupons().front().schedule().rules().size() == 1,
2016 "multiple bond schedule rules not covered by the CMB leg");
2017 QL_REQUIRE(bondData.coupons().front().schedule().dates().size() == 0,
2018 "dates based bond schedules not covered by the CMB leg");
2019
2020 // Get bond yield conventions
2021 auto ret = InstrumentConventions::instance().conventions()->get(securityFamily, Convention::Type::BondYield);
2022 QuantLib::ext::shared_ptr<BondYieldConvention> conv;
2023 if (ret.first)
2024 conv = QuantLib::ext::dynamic_pointer_cast<BondYieldConvention>(ret.second);
2025 else {
2026 conv = QuantLib::ext::make_shared<BondYieldConvention>();
2027 ALOG("BondYield conventions not found for security " << securityFamily << ", falling back on defaults:"
2028 << " compounding=" << conv->compoundingName()
2029 << ", priceType=" << conv->priceTypeName()
2030 << ", accuracy=" << conv->accuracy()
2031 << ", maxEvaluations=" << conv->maxEvaluations()
2032 << ", guess=" << conv->guess());
2033 }
2034
2035 Schedule bondSchedule = makeSchedule(bondData.coupons().front().schedule());
2036 DayCounter bondDayCounter = parseDayCounter(bondData.coupons().front().dayCounter());
2037 Currency bondCurrency = parseCurrency(bondData.currency());
2038 Calendar bondCalendar = parseCalendar(bondData.calendar());
2039 Size bondSettlementDays = parseInteger(bondData.settlementDays());
2040 BusinessDayConvention bondConvention = bondSchedule.businessDayConvention();
2041 bool bondEndOfMonth = bondSchedule.endOfMonth();
2042 Frequency bondFrequency = bondSchedule.tenor().frequency();
2043
2044 DayCounter dayCounter = parseDayCounter(data.dayCounter());
2045
2046 // Create a ConstantMaturityBondIndex for each schedule start date
2047 DLOG("Create Constant Maturity Bond Indices for each period");
2048 std::vector<QuantLib::ext::shared_ptr<QuantExt::ConstantMaturityBondIndex>> bondIndices;
2049 for (Size i = 0; i < schedule.dates().size() - 1; ++i) {
2050 // Construct bond with start date = accrual start date and maturity = accrual start date + term
2051 // or start = accrual end if in arrears. Adjusted for fixing lag, ignoring bond settlement lags for now.
2052 Date refDate = cmbData->isInArrears() ? schedule[i+1] : schedule[i];
2053 Date start = calendar.advance(refDate, -fixingDays, Days, Preceding);
2054 std::string startDate = to_string(start);
2055 std::string endDate = to_string(start + underlyingPeriod);
2056 bondData.populateFromBondReferenceData(engineFactory->referenceData(), startDate, endDate);
2057 Bond bondTrade(Envelope(), bondData);
2058 bondTrade.build(engineFactory);
2059 auto bond = QuantLib::ext::dynamic_pointer_cast<QuantLib::Bond>(bondTrade.instrument()->qlInstrument());
2060 QuantLib::ext::shared_ptr<QuantExt::ConstantMaturityBondIndex> bondIndex
2061 = QuantLib::ext::make_shared<QuantExt::ConstantMaturityBondIndex>(securityFamily, underlyingPeriod,
2062 // from bond reference data
2063 bondSettlementDays, bondCurrency, bondCalendar, bondDayCounter, bondConvention, bondEndOfMonth,
2064 // underlying forward starting bond
2065 bond,
2066 // yield calculation parameters from conventions, except frequency which is from bond reference data
2067 conv->compounding(), bondFrequency, conv->accuracy(), conv->maxEvaluations(), conv->guess(), conv->priceType());
2068 bondIndices.push_back(bondIndex);
2069 }
2070
2071 // Create a sequence of floating rate coupons linked to those indexes and concatenate them to a leg
2072 DLOG("Create CMB leg");
2073 vector<double> spreads = buildScheduledVectorNormalised(cmbData->spreads(), cmbData->spreadDates(), schedule, 0.0);
2074 vector<double> gearings = buildScheduledVectorNormalised(cmbData->gearings(), cmbData->gearingDates(), schedule, 1.0);
2075 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
2076
2077 // FIXME: Move the following into CmbLeg in cmbcoupon.xpp
2078 QL_REQUIRE(bondIndices.size() == schedule.size() - 1,
2079 "vector size mismatch between schedule (" << schedule.size() << ") "
2080 << "and bond indices (" << bondIndices.size() << ")");
2081 Leg leg;
2082 for (Size i = 0; i < schedule.size() - 1; i++) {
2083 Date paymentDate = calendar.adjust(schedule[i + 1], convention);
2084 DLOG("Coupon " << i << ": "
2085 << io::iso_date(paymentDate) << " "
2086 << notionals[i] << " "
2087 << io::iso_date(schedule[i]) << " "
2088 << io::iso_date(schedule[i+1]) << " "
2089 << cmbData->fixingDays() << " "
2090 << gearings[i] << " "
2091 << spreads[i] << " "
2092 << dayCounter.name());
2093 QuantLib::ext::shared_ptr<CmbCoupon> coupon
2094 = QuantLib::ext::make_shared<CmbCoupon>(paymentDate, notionals[i], schedule[i], schedule[i + 1],
2095 cmbData->fixingDays(), bondIndices[i], gearings[i], spreads[i], Date(), Date(),
2096 dayCounter, cmbData->isInArrears());
2097 auto pricer = QuantLib::ext::make_shared<CmbCouponPricer>();
2098 coupon->setPricer(pricer);
2099 leg.push_back(coupon);
2100 }
2101
2102 return leg;
2103}
Serializable Bond.
Definition: bond.hpp:153
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeDigitalCMSLeg()

Leg makeDigitalCMSLeg ( const LegData data,
const QuantLib::ext::shared_ptr< QuantLib::SwapIndex > &  swapIndex,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const bool  attachPricer,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 2105 of file legdata.cpp.

2107 {
2108 auto digitalCmsData = QuantLib::ext::dynamic_pointer_cast<DigitalCMSLegData>(data.concreteLegData());
2109 QL_REQUIRE(digitalCmsData, "Wrong LegType, expected DigitalCMS");
2110
2111 auto cmsData = QuantLib::ext::dynamic_pointer_cast<CMSLegData>(digitalCmsData->underlying());
2112 QL_REQUIRE(cmsData, "Incomplete DigitalCms Leg, expected CMS data");
2113
2114 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
2115
2116 DayCounter dc = parseDayCounter(data.dayCounter());
2117 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
2118 vector<double> spreads =
2119 ore::data::buildScheduledVectorNormalised(cmsData->spreads(), cmsData->spreadDates(), schedule, 0.0);
2120 vector<double> gearings =
2121 ore::data::buildScheduledVectorNormalised(cmsData->gearings(), cmsData->gearingDates(), schedule, 1.0);
2122 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
2123
2124 double eps = 1e-4;
2125 vector<double> callStrikes =
2126 ore::data::buildScheduledVector(digitalCmsData->callStrikes(), digitalCmsData->callStrikeDates(), schedule);
2127
2128 for (Size i = 0; i < callStrikes.size(); i++) {
2129 if (std::fabs(callStrikes[i]) < eps / 2) {
2130 callStrikes[i] = eps / 2;
2131 }
2132 }
2133
2134 vector<double> callPayoffs =
2135 ore::data::buildScheduledVector(digitalCmsData->callPayoffs(), digitalCmsData->callPayoffDates(), schedule);
2136
2137 vector<double> putStrikes =
2138 ore::data::buildScheduledVector(digitalCmsData->putStrikes(), digitalCmsData->putStrikeDates(), schedule);
2139 vector<double> putPayoffs =
2140 ore::data::buildScheduledVector(digitalCmsData->putPayoffs(), digitalCmsData->putPayoffDates(), schedule);
2141
2142 Size fixingDays = cmsData->fixingDays() == Null<Size>() ? swapIndex->fixingDays() : cmsData->fixingDays();
2143
2144 applyAmortization(notionals, data, schedule, false);
2145
2146 DigitalCmsLeg digitalCmsLeg = DigitalCmsLeg(schedule, swapIndex)
2147 .withNotionals(notionals)
2148 .withSpreads(spreads)
2149 .withGearings(gearings)
2150 // .withPaymentCalendar(paymentCalendar)
2151 .withPaymentDayCounter(dc)
2152 .withPaymentAdjustment(bdc)
2153 .withFixingDays(fixingDays)
2154 .inArrears(cmsData->isInArrears())
2155 .withCallStrikes(callStrikes)
2156 .withLongCallOption(digitalCmsData->callPosition())
2157 .withCallATM(digitalCmsData->isCallATMIncluded())
2158 .withCallPayoffs(callPayoffs)
2159 .withPutStrikes(putStrikes)
2160 .withLongPutOption(digitalCmsData->putPosition())
2161 .withPutATM(digitalCmsData->isPutATMIncluded())
2162 .withPutPayoffs(putPayoffs)
2163 .withReplication(QuantLib::ext::make_shared<DigitalReplication>())
2164 .withNakedOption(cmsData->nakedOption());
2165
2166 if (cmsData->caps().size() > 0 || cmsData->floors().size() > 0)
2167 QL_FAIL("caps/floors not supported in DigitalCMSOptions");
2168
2169 if (!attachPricer)
2170 return digitalCmsLeg;
2171
2172 // Get a coupon pricer for the leg
2173 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder("CMS");
2174 QL_REQUIRE(builder, "No CMS builder found for CmsLeg");
2175 QuantLib::ext::shared_ptr<CmsCouponPricerBuilder> cmsBuilder = QuantLib::ext::dynamic_pointer_cast<CmsCouponPricerBuilder>(builder);
2176 auto cmsPricer = QuantLib::ext::dynamic_pointer_cast<CmsCouponPricer>(
2177 cmsBuilder->engine(IndexNameTranslator::instance().oreName(swapIndex->iborIndex()->name())));
2178 QL_REQUIRE(cmsPricer, "Expected CMS Pricer");
2179
2180 // Loop over the coupons in the leg and set pricer
2181 Leg tmpLeg = digitalCmsLeg;
2182 QuantLib::setCouponPricer(tmpLeg, cmsPricer);
2183
2184 return tmpLeg;
2185}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeCMSSpreadLeg()

Leg makeCMSSpreadLeg ( const LegData data,
const QuantLib::ext::shared_ptr< QuantLib::SwapSpreadIndex > &  swapSpreadIndex,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const bool  attachPricer,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 2187 of file legdata.cpp.

2189 {
2190 QuantLib::ext::shared_ptr<CMSSpreadLegData> cmsSpreadData =
2191 QuantLib::ext::dynamic_pointer_cast<CMSSpreadLegData>(data.concreteLegData());
2192 QL_REQUIRE(cmsSpreadData, "Wrong LegType, expected CMSSpread, got " << data.legType());
2193
2194 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
2195 DayCounter dc = parseDayCounter(data.dayCounter());
2196 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
2197 Calendar paymentCalendar;
2198 if (data.paymentCalendar().empty())
2199 paymentCalendar = schedule.calendar();
2200 else
2201 paymentCalendar = parseCalendar(data.paymentCalendar());
2202
2203 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
2204
2205 vector<double> spreads = ore::data::buildScheduledVectorNormalised(cmsSpreadData->spreads(),
2206 cmsSpreadData->spreadDates(), schedule, 0.0);
2207 vector<double> gearings = ore::data::buildScheduledVectorNormalised(cmsSpreadData->gearings(),
2208 cmsSpreadData->gearingDates(), schedule, 1.0);
2209 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
2210 Size fixingDays =
2211 cmsSpreadData->fixingDays() == Null<Size>() ? swapSpreadIndex->fixingDays() : cmsSpreadData->fixingDays();
2212
2213 applyAmortization(notionals, data, schedule, false);
2214
2215 CmsSpreadLeg cmsSpreadLeg = CmsSpreadLeg(schedule, swapSpreadIndex)
2216 .withNotionals(notionals)
2217 .withSpreads(spreads)
2218 .withGearings(gearings)
2219 .withPaymentCalendar(paymentCalendar)
2220 .withPaymentDayCounter(dc)
2221 .withPaymentAdjustment(bdc)
2222 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
2223 .withFixingDays(fixingDays)
2224 .inArrears(cmsSpreadData->isInArrears());
2225
2226 if (cmsSpreadData->caps().size() > 0)
2227 cmsSpreadLeg.withCaps(buildScheduledVector(cmsSpreadData->caps(), cmsSpreadData->capDates(), schedule));
2228
2229 if (cmsSpreadData->floors().size() > 0)
2230 cmsSpreadLeg.withFloors(buildScheduledVector(cmsSpreadData->floors(), cmsSpreadData->floorDates(), schedule));
2231
2232 if (!attachPricer)
2233 return cmsSpreadLeg;
2234
2235 // Get a coupon pricer for the leg
2236 auto builder1 = engineFactory->builder("CMS");
2237 QL_REQUIRE(builder1, "No CMS builder found for CmsSpreadLeg");
2238 auto cmsBuilder = QuantLib::ext::dynamic_pointer_cast<CmsCouponPricerBuilder>(builder1);
2239 auto cmsPricer = QuantLib::ext::dynamic_pointer_cast<CmsCouponPricer>(cmsBuilder->engine(
2240 IndexNameTranslator::instance().oreName(swapSpreadIndex->swapIndex1()->iborIndex()->name())));
2241 QL_REQUIRE(cmsPricer, "Expected CMS Pricer");
2242 auto builder2 = engineFactory->builder("CMSSpread");
2243 QL_REQUIRE(builder2, "No CMS Spread builder found for CmsSpreadLeg");
2244 auto cmsSpreadBuilder = QuantLib::ext::dynamic_pointer_cast<CmsSpreadCouponPricerBuilder>(builder2);
2245 auto cmsSpreadPricer = cmsSpreadBuilder->engine(swapSpreadIndex->currency(), cmsSpreadData->swapIndex1(),
2246 cmsSpreadData->swapIndex2(), cmsPricer);
2247 QL_REQUIRE(cmsSpreadPricer, "Expected CMS Spread Pricer");
2248
2249 // Loop over the coupons in the leg and set pricer
2250 Leg tmpLeg = cmsSpreadLeg;
2251 QuantLib::setCouponPricer(tmpLeg, cmsSpreadPricer);
2252
2253 // build naked option leg if required
2254 if (cmsSpreadData->nakedOption()) {
2255 tmpLeg = StrippedCappedFlooredCouponLeg(tmpLeg);
2256 }
2257 return tmpLeg;
2258}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeDigitalCMSSpreadLeg()

Leg makeDigitalCMSSpreadLeg ( const LegData data,
const QuantLib::ext::shared_ptr< QuantLib::SwapSpreadIndex > &  swapSpreadIndex,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 2260 of file legdata.cpp.

2262 {
2263 auto digitalCmsSpreadData = QuantLib::ext::dynamic_pointer_cast<DigitalCMSSpreadLegData>(data.concreteLegData());
2264 QL_REQUIRE(digitalCmsSpreadData, "Wrong LegType, expected DigitalCMSSpread");
2265
2266 auto cmsSpreadData = QuantLib::ext::dynamic_pointer_cast<CMSSpreadLegData>(digitalCmsSpreadData->underlying());
2267 QL_REQUIRE(cmsSpreadData, "Incomplete DigitalCmsSpread Leg, expected CMSSpread data");
2268
2269 Schedule schedule = makeSchedule(data.schedule(), openEndDateReplacement);
2270 DayCounter dc = parseDayCounter(data.dayCounter());
2271 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
2272
2273 Calendar paymentCalendar;
2274 if (data.paymentCalendar().empty())
2275 paymentCalendar = schedule.calendar();
2276 else
2277 paymentCalendar = parseCalendar(data.paymentCalendar());
2278
2279 vector<double> spreads = ore::data::buildScheduledVectorNormalised(cmsSpreadData->spreads(),
2280 cmsSpreadData->spreadDates(), schedule, 0.0);
2281 vector<double> gearings = ore::data::buildScheduledVectorNormalised(cmsSpreadData->gearings(),
2282 cmsSpreadData->gearingDates(), schedule, 1.0);
2283 vector<double> notionals = buildScheduledVectorNormalised(data.notionals(), data.notionalDates(), schedule, 0.0);
2284
2285 double eps = 1e-4;
2286 vector<double> callStrikes = ore::data::buildScheduledVector(digitalCmsSpreadData->callStrikes(),
2287 digitalCmsSpreadData->callStrikeDates(), schedule);
2288
2289 for (Size i = 0; i < callStrikes.size(); i++) {
2290 if (std::fabs(callStrikes[i]) < eps / 2) {
2291 callStrikes[i] = eps / 2;
2292 }
2293 }
2294
2295 vector<double> callPayoffs = ore::data::buildScheduledVector(digitalCmsSpreadData->callPayoffs(),
2296 digitalCmsSpreadData->callPayoffDates(), schedule);
2297
2298 vector<double> putStrikes = ore::data::buildScheduledVector(digitalCmsSpreadData->putStrikes(),
2299 digitalCmsSpreadData->putStrikeDates(), schedule);
2300 vector<double> putPayoffs = ore::data::buildScheduledVector(digitalCmsSpreadData->putPayoffs(),
2301 digitalCmsSpreadData->putPayoffDates(), schedule);
2302
2303 Size fixingDays =
2304 cmsSpreadData->fixingDays() == Null<Size>() ? swapSpreadIndex->fixingDays() : cmsSpreadData->fixingDays();
2305
2306 applyAmortization(notionals, data, schedule, false);
2307
2308 DigitalCmsSpreadLeg digitalCmsSpreadLeg = DigitalCmsSpreadLeg(schedule, swapSpreadIndex)
2309 .withNotionals(notionals)
2310 .withSpreads(spreads)
2311 .withGearings(gearings)
2312 .withPaymentDayCounter(dc)
2313 .withPaymentCalendar(paymentCalendar)
2314 .withPaymentAdjustment(bdc)
2315 .withFixingDays(fixingDays)
2316 .inArrears(cmsSpreadData->isInArrears())
2317 .withCallStrikes(callStrikes)
2318 .withLongCallOption(digitalCmsSpreadData->callPosition())
2319 .withCallATM(digitalCmsSpreadData->isCallATMIncluded())
2320 .withCallPayoffs(callPayoffs)
2321 .withPutStrikes(putStrikes)
2322 .withLongPutOption(digitalCmsSpreadData->putPosition())
2323 .withPutATM(digitalCmsSpreadData->isPutATMIncluded())
2324 .withPutPayoffs(putPayoffs)
2325 .withReplication(QuantLib::ext::make_shared<DigitalReplication>())
2326 .withNakedOption(cmsSpreadData->nakedOption());
2327
2328 if (cmsSpreadData->caps().size() > 0 || cmsSpreadData->floors().size() > 0)
2329 QL_FAIL("caps/floors not supported in DigitalCMSSpreadOptions");
2330
2331 // Get a coupon pricer for the leg
2332 auto builder1 = engineFactory->builder("CMS");
2333 QL_REQUIRE(builder1, "No CMS builder found for CmsSpreadLeg");
2334 auto cmsBuilder = QuantLib::ext::dynamic_pointer_cast<CmsCouponPricerBuilder>(builder1);
2335 auto cmsPricer = QuantLib::ext::dynamic_pointer_cast<CmsCouponPricer>(cmsBuilder->engine(
2336 IndexNameTranslator::instance().oreName(swapSpreadIndex->swapIndex1()->iborIndex()->name())));
2337 QL_REQUIRE(cmsPricer, "Expected CMS Pricer");
2338 auto builder2 = engineFactory->builder("CMSSpread");
2339 QL_REQUIRE(builder2, "No CMS Spread builder found for CmsSpreadLeg");
2340 auto cmsSpreadBuilder = QuantLib::ext::dynamic_pointer_cast<CmsSpreadCouponPricerBuilder>(builder2);
2341 auto cmsSpreadPricer = cmsSpreadBuilder->engine(swapSpreadIndex->currency(), cmsSpreadData->swapIndex1(),
2342 cmsSpreadData->swapIndex2(), cmsPricer);
2343 QL_REQUIRE(cmsSpreadPricer, "Expected CMS Spread Pricer");
2344
2345 // Loop over the coupons in the leg and set pricer
2346 Leg tmpLeg = digitalCmsSpreadLeg;
2347 QuantLib::setCouponPricer(tmpLeg, cmsSpreadPricer);
2348
2349 return tmpLeg;
2350}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeEquityLeg() [1/2]

Leg makeEquityLeg ( const LegData data,
const QuantLib::ext::shared_ptr< EquityIndex2 > &  equityCurve,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex,
const QuantLib::Date &  openEndDateReplacement 
)

Definition at line 2352 of file legdata.cpp.

2353 {
2354 QuantLib::ext::shared_ptr<EquityLegData> eqLegData = QuantLib::ext::dynamic_pointer_cast<EquityLegData>(data.concreteLegData());
2355 QL_REQUIRE(eqLegData, "Wrong LegType, expected Equity, got " << data.legType());
2356
2357 DayCounter dc;
2358 if (data.dayCounter().empty())
2359 dc = Actual365Fixed();
2360 else
2361 dc = parseDayCounter(data.dayCounter());
2362 BusinessDayConvention bdc = parseBusinessDayConvention(data.paymentConvention());
2363
2364 Real dividendFactor = eqLegData->dividendFactor();
2365 Real initialPrice = eqLegData->initialPrice();
2366 bool initialPriceIsInTargetCcy = false;
2367
2368 if (!eqLegData->initialPriceCurrency().empty()) {
2369 // parse currencies to handle minor currencies
2370 Currency initialPriceCurrency = parseCurrencyWithMinors(eqLegData->initialPriceCurrency());
2371 Currency dataCurrency = parseCurrencyWithMinors(data.currency());
2372 Currency eqCurrency;
2373 // set equity currency
2374 if (!eqLegData->eqCurrency().empty())
2375 eqCurrency = parseCurrencyWithMinors(eqLegData->eqCurrency());
2376 else if (!equityCurve->currency().empty())
2377 eqCurrency = equityCurve->currency();
2378 else
2379 TLOG("Cannot find currency for equity " << equityCurve->name());
2380
2381 // initial price currency must match leg or equity currency
2382 QL_REQUIRE(initialPriceCurrency == dataCurrency || initialPriceCurrency == eqCurrency || eqCurrency.empty(),
2383 "initial price ccy (" << initialPriceCurrency << ") must match either leg ccy (" << dataCurrency
2384 << ") or equity ccy (if given, got '" << eqCurrency << "')");
2385 initialPriceIsInTargetCcy = initialPriceCurrency == dataCurrency;
2386 // adjust for minor currency
2387 initialPrice = convertMinorToMajorCurrency(eqLegData->initialPriceCurrency(), initialPrice);
2388 }
2389 bool notionalReset = eqLegData->notionalReset();
2390 Natural fixingDays = eqLegData->fixingDays();
2391 PaymentLag paymentLag = parsePaymentLag(data.paymentLag());
2392
2393 ScheduleBuilder scheduleBuilder;
2394
2395 ScheduleData scheduleData = data.schedule();
2396 Schedule schedule;
2397 scheduleBuilder.add(schedule, scheduleData);
2398
2399 ScheduleData valuationData = eqLegData->valuationSchedule();
2400 Schedule valuationSchedule;
2401 if (valuationData.hasData())
2402 scheduleBuilder.add(valuationSchedule, valuationData);
2403
2404 scheduleBuilder.makeSchedules(openEndDateReplacement);
2405
2406 vector<double> notionals = buildScheduledVector(data.notionals(), data.notionalDates(), schedule);
2407
2408 Calendar paymentCalendar;
2409 if (data.paymentCalendar().empty())
2410 paymentCalendar = schedule.calendar();
2411 else
2412 paymentCalendar = parseCalendar(data.paymentCalendar());
2413
2414 applyAmortization(notionals, data, schedule, false);
2415 Leg leg = EquityLeg(schedule, equityCurve, fxIndex)
2416 .withNotionals(notionals)
2417 .withQuantity(eqLegData->quantity())
2420 .withPaymentCalendar(paymentCalendar)
2421 .withPaymentLag(boost::apply_visitor(PaymentLagInteger(), paymentLag))
2422 .withReturnType(eqLegData->returnType())
2423 .withDividendFactor(dividendFactor)
2424 .withInitialPrice(initialPrice)
2425 .withInitialPriceIsInTargetCcy(initialPriceIsInTargetCcy)
2426 .withNotionalReset(notionalReset)
2427 .withFixingDays(fixingDays)
2428 .withValuationSchedule(valuationSchedule);
2429
2430 QL_REQUIRE(leg.size() > 0, "Empty Equity Leg");
2431
2432 return leg;
2433}
EquityLeg & withInitialPriceIsInTargetCcy(bool)
EquityLeg & withDividendFactor(Real)
EquityLeg & withPaymentCalendar(const Calendar &calendar)
EquityLeg & withFixingDays(Natural)
EquityLeg & withNotionalReset(bool)
EquityLeg & withQuantity(Real)
EquityLeg & withNotionals(const std::vector< Real > &notionals)
EquityLeg & withInitialPrice(Real)
EquityLeg & withPaymentDayCounter(const DayCounter &dayCounter)
EquityLeg & withValuationSchedule(const Schedule &valuationSchedule)
EquityLeg & withPaymentAdjustment(BusinessDayConvention convention)
EquityLeg & withPaymentLag(Natural paymentLag)
EquityLeg & withReturnType(EquityReturnType)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentNotional()

Real currentNotional ( const Leg &  leg)

Definition at line 2435 of file legdata.cpp.

2435 {
2436 Date today = Settings::instance().evaluationDate();
2437 // assume the leg is sorted
2438 // We just take the first coupon::nominal we find, otherwise return 0
2439 for (auto cf : leg) {
2440 if (cf->date() > today) {
2441 QuantLib::ext::shared_ptr<Coupon> coupon = QuantLib::ext::dynamic_pointer_cast<QuantLib::Coupon>(cf);
2442 if (coupon)
2443 return coupon->nominal();
2444 }
2445 }
2446 return 0;
2447}
+ Here is the caller graph for this function:

◆ originalNotional()

Real originalNotional ( const Leg &  leg)

Definition at line 2449 of file legdata.cpp.

2449 {
2450 // assume the leg is sorted
2451 // We just take the first coupon::nominal we find, otherwise return 0
2452 if (leg.size() > 0) {
2453 QuantLib::ext::shared_ptr<Coupon> coupon = QuantLib::ext::dynamic_pointer_cast<QuantLib::Coupon>(leg.front());
2454 if (coupon)
2455 return coupon->nominal();
2456 }
2457 return 0;
2458}
+ Here is the caller graph for this function:

◆ buildAmortizationScheduleFixedAmount()

vector< double > buildAmortizationScheduleFixedAmount ( const vector< double > &  notionals,
const Schedule &  schedule,
const AmortizationData data 
)

Definition at line 2460 of file legdata.cpp.

2461 {
2462 DLOG("Build fixed amortization notional schedule");
2463 vector<double> nominals = normaliseToSchedule(notionals, schedule, (Real)Null<Real>());
2464 Date startDate = data.startDate().empty() ? Date::minDate() : parseDate(data.startDate());
2465 Date endDate = data.endDate().empty() ? Date::maxDate() : parseDate(data.endDate());
2466 bool underflow = data.underflow();
2467 Period amortPeriod = data.frequency().empty() ? 0 * Days : parsePeriod(data.frequency());
2468 double amort = data.value();
2469 Date lastAmortDate = Date::minDate();
2470 for (Size i = 0; i < schedule.size() - 1; i++) {
2471 if (i > 0 && (lastAmortDate == Date::minDate() || schedule[i] > lastAmortDate + amortPeriod - 4 * Days) &&
2472 schedule[i] >= startDate && schedule[i] < endDate) { // FIXME: tolerance
2473 nominals[i] = nominals[i - 1] - amort;
2474 lastAmortDate = schedule[i];
2475 } else if (i > 0 && lastAmortDate > Date::minDate()) {
2476 nominals[i] = nominals[i - 1];
2477 }
2478 if (amort > nominals[i] && underflow == false)
2479 amort = std::max(nominals[i], 0.0);
2480 }
2481 DLOG("Fixed amortization notional schedule done");
2482 return nominals;
2483}
vector< T > normaliseToSchedule(const vector< T > &values, const Schedule &schedule, const T &defaultValue)
Definition: legdata.hpp:1131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildAmortizationScheduleRelativeToInitialNotional()

vector< double > buildAmortizationScheduleRelativeToInitialNotional ( const vector< double > &  notionals,
const Schedule &  schedule,
const AmortizationData data 
)

Definition at line 2485 of file legdata.cpp.

2487 {
2488 DLOG("Build notional schedule with amortizations expressed as percentages of initial notional");
2489 vector<double> nominals = normaliseToSchedule(notionals, schedule, (Real)Null<Real>());
2490 Date startDate = data.startDate().empty() ? Date::minDate() : parseDate(data.startDate());
2491 Date endDate = data.endDate().empty() ? Date::maxDate() : parseDate(data.endDate());
2492 bool underflow = data.underflow();
2493 Period amortPeriod = data.frequency().empty() ? 0 * Days : parsePeriod(data.frequency());
2494 double amort = data.value() * nominals.front();
2495 Date lastAmortDate = Date::minDate();
2496 for (Size i = 0; i < schedule.size() - 1; i++) {
2497 if (i > 0 && (lastAmortDate == Date::minDate() || schedule[i] > lastAmortDate + amortPeriod - 4 * Days) &&
2498 schedule[i] >= startDate && schedule[i] < endDate) { // FIXME: tolerance
2499 nominals[i] = nominals[i - 1] - amort;
2500 lastAmortDate = schedule[i];
2501 } else if (i > 0 && lastAmortDate > Date::minDate())
2502 nominals[i] = nominals[i - 1];
2503 if (amort > nominals[i] && underflow == false) {
2504 amort = std::max(nominals[i], 0.0);
2505 }
2506 }
2507 DLOG("Fixed amortization notional schedule done");
2508 return nominals;
2509}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildAmortizationScheduleRelativeToPreviousNotional()

vector< double > buildAmortizationScheduleRelativeToPreviousNotional ( const vector< double > &  notionals,
const Schedule &  schedule,
const AmortizationData data 
)

Definition at line 2511 of file legdata.cpp.

2513 {
2514 DLOG("Build notional schedule with amortizations expressed as percentages of previous notionals");
2515 vector<double> nominals = normaliseToSchedule(notionals, schedule, (Real)Null<Real>());
2516 Date startDate = data.startDate().empty() ? Date::minDate() : parseDate(data.startDate());
2517 Date endDate = data.endDate().empty() ? Date::maxDate() : parseDate(data.endDate());
2518 Period amortPeriod = data.frequency().empty() ? 0 * Days : parsePeriod(data.frequency());
2519 double fraction = data.value();
2520 QL_REQUIRE(fraction < 1.0 || close_enough(fraction, 1.0),
2521 "amortization fraction " << fraction << " expected to be <= 1");
2522 Date lastAmortDate = Date::minDate();
2523 for (Size i = 0; i < schedule.size() - 1; i++) {
2524 if (i > 0 && (lastAmortDate == Date::minDate() || schedule[i] > lastAmortDate + amortPeriod - 4 * Days) &&
2525 schedule[i] >= startDate && schedule[i] < endDate) { // FIXME: tolerance
2526 nominals[i] = nominals[i - 1] * (1.0 - fraction);
2527 lastAmortDate = schedule[i];
2528 } else if (i > 0 && lastAmortDate > Date::minDate())
2529 nominals[i] = nominals[i - 1];
2530 }
2531 DLOG("Fixed amortization notional schedule done");
2532 return nominals;
2533}
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildAmortizationScheduleFixedAnnuity()

vector< double > buildAmortizationScheduleFixedAnnuity ( const vector< double > &  notionals,
const vector< double > &  rates,
const Schedule &  schedule,
const AmortizationData data,
const DayCounter &  dc 
)

Definition at line 2535 of file legdata.cpp.

2537 {
2538 DLOG("Build fixed annuity notional schedule");
2539 vector<double> nominals = normaliseToSchedule(notionals, schedule, (Real)Null<Real>());
2540 Date startDate = data.startDate().empty() ? Date::minDate() : parseDate(data.startDate());
2541 Date endDate = data.endDate().empty() ? Date::maxDate() : parseDate(data.endDate());
2542 bool underflow = data.underflow();
2543 double annuity = data.value();
2544 Real amort = 0.0;
2545 Date lastAmortDate = Date::minDate();
2546 for (Size i = 0; i < schedule.size() - 1; i++) {
2547 if (i > 0 && schedule[i] >= startDate && schedule[i] < endDate) {
2548 nominals[i] = nominals[i - 1] - amort;
2549 lastAmortDate = schedule[i];
2550 } else if (i > 0 && lastAmortDate > Date::minDate())
2551 nominals[i] = nominals[i - 1];
2552 Real dcf = dc.yearFraction(schedule[i], schedule[i + 1]);
2553 Real rate = i < rates.size() ? rates[i] : rates.back();
2554 amort = annuity - rate * nominals[i] * dcf;
2555 if (amort > nominals[i] && underflow == false) {
2556 amort = std::max(nominals[i], 0.0);
2557 }
2558 }
2559 DLOG("Fixed Annuity notional schedule done");
2560 return nominals;
2561}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildAmortizationScheduleLinearToMaturity()

vector< double > buildAmortizationScheduleLinearToMaturity ( const vector< double > &  notionals,
const Schedule &  schedule,
const AmortizationData data 
)

Definition at line 2563 of file legdata.cpp.

2564 {
2565 DLOG("Build linear-to-maturity notional schedule");
2566 vector<double> nominals = normaliseToSchedule(notionals, schedule, (Real)Null<Real>());
2567 Date startDate = data.startDate().empty() ? Date::minDate() : parseDate(data.startDate());
2568 Date endDate = data.endDate().empty() ? Date::maxDate() : parseDate(data.endDate());
2569 Period amortPeriod = data.frequency().empty() ? 0 * Days : parsePeriod(data.frequency());
2570 Date lastAmortDate = Date::minDate();
2571 Real periodAmortization = Null<Real>();
2572 Real accumulatedAmortization = 0.0;
2573 for (Size i = 0; i < schedule.size() - 1; ++i) {
2574 if (schedule[i] >= startDate && periodAmortization == Null<Real>()) {
2575 periodAmortization = nominals[i] / static_cast<Real>(schedule.size() - i);
2576 }
2577 if (i > 0 && schedule[i] >= startDate && schedule[i] < endDate) {
2578 accumulatedAmortization += periodAmortization;
2579 }
2580 if (i > 0 && (lastAmortDate == Date::minDate() || schedule[i] > lastAmortDate + amortPeriod - 4 * Days) &&
2581 schedule[i] >= startDate && schedule[i] < endDate) {
2582 nominals[i] = nominals[i - 1] - accumulatedAmortization;
2583 accumulatedAmortization = 0.0;
2584 lastAmortDate = schedule[i];
2585 } else if (i > 0 && lastAmortDate > Date::minDate()) {
2586 nominals[i] = nominals[i - 1];
2587 }
2588 }
2589 DLOG("Linear-to-maturity notional schedule done");
2590 return nominals;
2591}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyAmortization()

void applyAmortization ( std::vector< Real > &  notionals,
const LegData data,
const Schedule &  schedule,
const bool  annuityAllowed,
const std::vector< Real > &  rates 
)

Definition at line 2593 of file legdata.cpp.

2594 {
2595 Date lastEndDate = Date::minDate();
2596 for (Size i = 0; i < data.amortizationData().size(); ++i) {
2597 const AmortizationData& amort = data.amortizationData()[i];
2598 if (!amort.initialized())
2599 continue;
2600 QL_REQUIRE(i == 0 || !amort.startDate().empty(),
2601 "All AmortizationData blocks except the first require a StartDate");
2602 Date startDate = amort.startDate().empty() ? Date::minDate() : parseDate(amort.startDate());
2603 QL_REQUIRE(startDate >= lastEndDate, "Amortization start date ("
2604 << startDate << ") is earlier than last end date (" << lastEndDate
2605 << ")");
2606 lastEndDate = amort.endDate().empty() ? Date::minDate() : parseDate(amort.endDate());
2607 AmortizationType amortizationType = parseAmortizationType(amort.type());
2608 if (amortizationType == AmortizationType::FixedAmount)
2609 notionals = buildAmortizationScheduleFixedAmount(notionals, schedule, amort);
2610 else if (amortizationType == AmortizationType::RelativeToInitialNotional)
2611 notionals = buildAmortizationScheduleRelativeToInitialNotional(notionals, schedule, amort);
2612 else if (amortizationType == AmortizationType::RelativeToPreviousNotional)
2613 notionals = buildAmortizationScheduleRelativeToPreviousNotional(notionals, schedule, amort);
2614 else if (amortizationType == AmortizationType::Annuity) {
2615 QL_REQUIRE(annuityAllowed, "Amortization type Annuity not allowed for leg type " << data.legType());
2616 if (!rates.empty())
2617 notionals = buildAmortizationScheduleFixedAnnuity(notionals, rates, schedule, amort,
2618 parseDayCounter(data.dayCounter()));
2619 } else if (amortizationType == AmortizationType::LinearToMaturity) {
2620 notionals = buildAmortizationScheduleLinearToMaturity(notionals, schedule, amort);
2621 } else {
2622 QL_FAIL("AmortizationType " << amort.type() << " not supported");
2623 }
2624 // check that for a floating leg we only have one amortization block, if the type is annuity
2625 // we recognise a floating leg by an empty (fixed) rates vector
2626 if (rates.empty() && amortizationType == AmortizationType::Annuity) {
2627 QL_REQUIRE(data.amortizationData().size() == 1,
2628 "Floating Leg supports only one amortisation block of type Annuity");
2629 }
2630 }
2631}
Serializable object holding amortization rules.
Definition: legdata.hpp:805
const string & endDate() const
Amortization end date.
Definition: legdata.hpp:825
const string & startDate() const
Amortization start date.
Definition: legdata.hpp:823
const string & type() const
FixedAmount, RelativeToInitialNotional, RelativeToPreviousNotional, Annuity.
Definition: legdata.hpp:819
vector< double > buildAmortizationScheduleLinearToMaturity(const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
Definition: legdata.cpp:2563
vector< double > buildAmortizationScheduleFixedAmount(const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
Definition: legdata.cpp:2460
vector< double > buildAmortizationScheduleRelativeToInitialNotional(const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
Definition: legdata.cpp:2485
vector< double > buildAmortizationScheduleRelativeToPreviousNotional(const vector< double > &notionals, const Schedule &schedule, const AmortizationData &data)
Definition: legdata.cpp:2511
vector< double > buildAmortizationScheduleFixedAnnuity(const vector< double > &notionals, const vector< double > &rates, const Schedule &schedule, const AmortizationData &data, const DayCounter &dc)
Definition: legdata.cpp:2535
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyIndexing()

void applyIndexing ( Leg &  leg,
const LegData data,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
RequiredFixings requiredFixings,
const QuantLib::Date &  openEndDateReplacement,
const bool  useXbsCurves 
)

Definition at line 2633 of file legdata.cpp.

2635 {
2636 for (auto const& indexing : data.indexing()) {
2637 if (indexing.hasData()) {
2638 DLOG("apply indexing (index='" << indexing.index() << "') to leg of type " << data.legType());
2639 QL_REQUIRE(engineFactory, "applyIndexing: engineFactory required");
2640
2641 // we allow indexing by equity, commodity and FX indices (technically any QuantLib::Index
2642 // will work, so the list of index types can be extended here if required)
2643 QuantLib::ext::shared_ptr<Index> index;
2644 string config = engineFactory->configuration(MarketContext::pricing);
2645 if (boost::starts_with(indexing.index(), "EQ-")) {
2646 string eqName = indexing.index().substr(3);
2647 index = *engineFactory->market()->equityCurve(eqName, config);
2648 } else if (boost::starts_with(indexing.index(), "FX-")) {
2649 auto tmp = parseFxIndex(indexing.index());
2650 Currency ccy1 = tmp->targetCurrency();
2651 Currency ccy2 = tmp->sourceCurrency();
2652 QL_REQUIRE(ccy1.code() == data.currency() || ccy2.code() == data.currency(),
2653 "applyIndexing: fx index '" << indexing.index() << "' ccys do not match leg ccy ("
2654 << data.currency() << ")");
2655 std::string domestic = data.currency();
2656 std::string foreign = ccy1.code() == domestic ? ccy2.code() : ccy1.code();
2657 index = buildFxIndex(indexing.index(), domestic, foreign, engineFactory->market(),
2658 engineFactory->configuration(MarketContext::pricing), useXbsCurves);
2659
2660 } else if (boost::starts_with(indexing.index(), "COMM-")) {
2661 auto tmp = parseCommodityIndex(indexing.index());
2662 index = parseCommodityIndex(indexing.index(), true,
2663 engineFactory->market()->commodityPriceCurve(tmp->underlyingName(), config),
2664 tmp->fixingCalendar());
2665 } else if (boost::starts_with(indexing.index(), "BOND-")) {
2666 // if we build a bond index, we add the required fixings for the bond underlying
2667 QuantLib::ext::shared_ptr<BondIndex> bi = parseBondIndex(indexing.index());
2668 QL_REQUIRE(!(QuantLib::ext::dynamic_pointer_cast<BondFuturesIndex>(bi)),
2669 "BondFuture Legs are not yet supported");
2670 BondData bondData(bi->securityName(), 1.0);
2671 BondIndexBuilder bondIndexBuilder(bondData, indexing.indexIsDirty(), indexing.indexIsRelative(),
2672 parseCalendar(indexing.fixingCalendar()),
2673 indexing.indexIsConditionalOnSurvival(), engineFactory);
2674 index = bondIndexBuilder.bondIndex();
2675 bondIndexBuilder.addRequiredFixings(requiredFixings, leg);
2676 } else {
2677 QL_FAIL("invalid index '" << indexing.index()
2678 << "' in indexing data, expected EQ-, FX-, COMM-, BOND- index");
2679 }
2680
2681 QL_REQUIRE(index, "applyIndexing(): index is null, this is unexpected");
2682
2683 // apply the indexing
2684 IndexedCouponLeg indLeg(leg, indexing.quantity(), index);
2685 indLeg.withInitialFixing(indexing.initialFixing());
2686 // we set the initial notional fixing only if we have an initial exchange, otherwise this is applied to the
2687 // first notional payment appearing in the leg
2688 if (data.notionalInitialExchange())
2689 indLeg.withInitialNotionalFixing(indexing.initialNotionalFixing());
2690 indLeg.withFixingDays(indexing.fixingDays());
2691 indLeg.inArrearsFixing(indexing.inArrearsFixing());
2692 if (indexing.valuationSchedule().hasData())
2693 indLeg.withValuationSchedule(makeSchedule(indexing.valuationSchedule(), openEndDateReplacement));
2694 if (!indexing.fixingCalendar().empty())
2695 indLeg.withFixingCalendar(parseCalendar(indexing.fixingCalendar()));
2696 if (!indexing.fixingConvention().empty())
2697 indLeg.withFixingConvention(parseBusinessDayConvention(indexing.fixingConvention()));
2698 leg = indLeg;
2699 }
2700 }
2701}
QuantLib::ext::shared_ptr< FxIndex > parseFxIndex(const string &s, const Handle< Quote > &fxSpot, const Handle< YieldTermStructure > &sourceYts, const Handle< YieldTermStructure > &targetYts, const bool useConventions)
Convert std::string to QuantExt::FxIndex.
QuantLib::ext::shared_ptr< BondIndex > parseBondIndex(const string &name)
Convert std::string to QuantExt::BondIndex.
QuantLib::ext::shared_ptr< QuantExt::FxIndex > buildFxIndex(const string &fxIndex, const string &domestic, const string &foreign, const QuantLib::ext::shared_ptr< Market > &market, const string &configuration, bool useXbsCurves)
Definition: marketdata.cpp:137
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ joinLegs()

Leg joinLegs ( const std::vector< Leg > &  legs)

Definition at line 2703 of file legdata.cpp.

2703 {
2704 Leg masterLeg;
2705 Size lastLeg = Null<Size>();
2706 for (Size i = 0; i < legs.size(); ++i) {
2707 // skip empty legs
2708 if (legs[i].empty())
2709 continue;
2710 // check if the periods of adjacent legs are consistent
2711 if (lastLeg != Null<Size>()) {
2712 auto lcpn = QuantLib::ext::dynamic_pointer_cast<Coupon>(legs[lastLeg].back());
2713 auto fcpn = QuantLib::ext::dynamic_pointer_cast<Coupon>(legs[i].front());
2714 QL_REQUIRE(lcpn, "joinLegs: expected coupon as last cashflow in leg #" << lastLeg);
2715 QL_REQUIRE(fcpn, "joinLegs: expected coupon as first cashflow in leg #" << i);
2716 QL_REQUIRE(lcpn->accrualEndDate() == fcpn->accrualStartDate(),
2717 "joinLegs: accrual end date of last coupon in leg #"
2718 << lastLeg << " (" << lcpn->accrualEndDate()
2719 << ") is not equal to accrual start date of first coupon in leg #" << i << " ("
2720 << fcpn->accrualStartDate() << ")");
2721 lastLeg = i;
2722 }
2723 // copy legs together
2724 masterLeg.insert(masterLeg.end(), legs[i].begin(), legs[i].end());
2725 }
2726 return masterLeg;
2727}
+ Here is the caller graph for this function:

◆ buildNotionalLeg()

Leg buildNotionalLeg ( const LegData data,
const Leg &  leg,
RequiredFixings requiredFixings,
const QuantLib::ext::shared_ptr< Market > &  market,
const std::string &  configuration 
)

Definition at line 2729 of file legdata.cpp.

2730 {
2731
2732 if (!data.isNotResetXCCY()) {
2733 // If we have an FX resetting leg, add the notional amount at the start and end of each coupon period.
2734 DLOG("Building Resetting XCCY Notional leg");
2735 Real foreignNotional = data.foreignAmount();
2736
2737 QL_REQUIRE(!data.fxIndex().empty(), "buildNotionalLeg(): need fx index for fx resetting leg");
2738 auto fxIndex =
2739 buildFxIndex(data.fxIndex(), data.currency(), data.foreignCurrency(), market, configuration, true);
2740
2741 PaymentLag notionalPayLag = parsePaymentLag(data.notionalPaymentLag());
2742 Natural payLagInteger = boost::apply_visitor(PaymentLagInteger(), notionalPayLag);
2743 const Calendar& payCalendar = parseCalendar(data.paymentCalendar());
2744 const BusinessDayConvention& payConvention = parseBusinessDayConvention(data.paymentConvention());
2745
2746 Leg resettingLeg;
2747 for (Size j = 0; j < leg.size(); j++) {
2748
2749 QuantLib::ext::shared_ptr<Coupon> c = QuantLib::ext::dynamic_pointer_cast<Coupon>(leg[j]);
2750 QL_REQUIRE(c, "Expected each cashflow in FX resetting leg to be of type Coupon");
2751
2752 const Date& initFlowDate = payCalendar.advance(c->accrualStartDate(), payLagInteger, Days, payConvention);
2753 const Date& finalFlowDate = payCalendar.advance(c->accrualEndDate(), payLagInteger, Days, payConvention);
2754
2755 // Build a pair of notional flows, one at the start and one at the end of the accrual period.
2756 // They both have the same FX fixing date => same amount in this leg's currency.
2757 QuantLib::ext::shared_ptr<CashFlow> outCf;
2758 QuantLib::ext::shared_ptr<CashFlow> inCf;
2759 Date fixingDate;
2760 if (j == 0) {
2761
2762 // Two possibilities for first coupon:
2763 // 1. we have not been given a domestic notional so it is an FX linked coupon
2764 // 2. we have been given an explicit domestic notional so it is a simple cashflow
2765 if (data.notionals().size() == 0) {
2766 fixingDate = fxIndex->fixingDate(c->accrualStartDate());
2767 if (data.notionalInitialExchange()) {
2768 outCf = QuantLib::ext::make_shared<FXLinkedCashFlow>(initFlowDate, fixingDate, -foreignNotional,
2769 fxIndex);
2770 }
2771 // if there is only one period we generate the cash flow at the period end
2772 // only if there is a final notional exchange
2773 if (leg.size() > 1 || data.notionalFinalExchange()) {
2774 inCf = QuantLib::ext::make_shared<FXLinkedCashFlow>(finalFlowDate, fixingDate, foreignNotional,
2775 fxIndex);
2776 }
2777 } else {
2778 if (data.notionalInitialExchange()) {
2779 outCf = QuantLib::ext::make_shared<SimpleCashFlow>(-c->nominal(), initFlowDate);
2780 }
2781 if (leg.size() > 1 || data.notionalFinalExchange()) {
2782 inCf = QuantLib::ext::make_shared<SimpleCashFlow>(c->nominal(), finalFlowDate);
2783 }
2784 }
2785 } else {
2786 fixingDate = fxIndex->fixingDate(c->accrualStartDate());
2787 outCf =
2788 QuantLib::ext::make_shared<FXLinkedCashFlow>(initFlowDate, fixingDate, -foreignNotional, fxIndex);
2789 // we don't want a final one, unless there is notional exchange
2790 if (j < leg.size() - 1 || data.notionalFinalExchange()) {
2791 inCf =
2792 QuantLib::ext::make_shared<FXLinkedCashFlow>(finalFlowDate, fixingDate, foreignNotional, fxIndex);
2793 }
2794 }
2795
2796 // Add the cashflows to the notional leg if they have been populated
2797 if (outCf) {
2798 resettingLeg.push_back(outCf);
2799 if (fixingDate != Date())
2800 requiredFixings.addFixingDate(fixingDate, data.fxIndex(), outCf->date());
2801 }
2802 if (inCf) {
2803 resettingLeg.push_back(inCf);
2804 if (fixingDate != Date())
2805 requiredFixings.addFixingDate(fixingDate, data.fxIndex(), inCf->date());
2806 }
2807 }
2808
2809 if (data.notionalAmortizingExchange()) {
2810 QL_FAIL("Cannot have an amortizing notional with FX reset");
2811 }
2812
2813 return resettingLeg;
2814
2815 } else if ((data.notionalInitialExchange() || data.notionalFinalExchange() || data.notionalAmortizingExchange()) &&
2816 (data.legType() != "CPI")) {
2817
2818 // check for notional exchanges on non FX reseting trades
2819
2820 PaymentLag notionalPayLag = parsePaymentLag(data.notionalPaymentLag());
2821 Natural notionalPayLagInteger = boost::apply_visitor(PaymentLagInteger(), notionalPayLag);
2822
2823 return makeNotionalLeg(leg, data.notionalInitialExchange(), data.notionalFinalExchange(),
2824 data.notionalAmortizingExchange(), notionalPayLagInteger,
2825 parseBusinessDayConvention(data.paymentConvention()),
2826 parseCalendar(data.paymentCalendar()), true);
2827 } else {
2828 return Leg();
2829 }
2830}
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
Leg makeNotionalLeg(const Leg &refLeg, const bool initNomFlow, const bool finalNomFlow, const bool amortNomFlow, const Natural notionalPaymentLag, const BusinessDayConvention paymentConvention, const Calendar paymentCalendar, const bool excludeIndexing)
Definition: legdata.cpp:1566
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCmbLegCreditRiskCurrency()

std::string getCmbLegCreditRiskCurrency ( const CMBLegData ld,
const QuantLib::ext::shared_ptr< ReferenceDataManager > &  refData 
)

Definition at line 2851 of file legdata.cpp.

2851 {
2852 if (auto bondRefData = getCmbLegRefData(ld, refData)) {
2853 std::string security = getCmbLegSecurity(ld.genericBond());
2854 BondData bd(security, 1.0);
2855 bd.populateFromBondReferenceData(bondRefData);
2856 return bd.currency();
2857 }
2858 return std::string();
2859}
const string & genericBond() const
Definition: legdata.hpp:705
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCmbLegCreditQualifierMapping()

std::pair< std::string, SimmCreditQualifierMapping > getCmbLegCreditQualifierMapping ( const CMBLegData ld,
const QuantLib::ext::shared_ptr< ReferenceDataManager > &  refData,
const std::string &  tradeId,
const std::string &  tradeType 
)

Definition at line 2862 of file legdata.cpp.

2863 {
2864 string source;
2866 std::string security = getCmbLegSecurity(ld.genericBond());
2867 if (auto bondRefData = getCmbLegRefData(ld, refData)) {
2868 source = ore::data::securitySpecificCreditCurveName(security, bondRefData->bondData().creditCurveId);
2869 target.targetQualifier = security;
2870 target.creditGroup = bondRefData->bondData().creditGroup;
2871 }
2872 if (source.empty() || target.targetQualifier.empty()) {
2873 ore::data::StructuredTradeErrorMessage(tradeId, tradeType, "getCmbLegCreditQualifierMapping()",
2874 "Could not set mapping for CMB Leg security '" +
2875 security +
2876 "'. Check security name and reference data.")
2877 .log();
2878 }
2879 return std::make_pair(source, target);
2880}
void log() const
generate Boost log record to pass to corresponding sinks
Definition: log.cpp:491
Utility class for Structured Trade errors, contains the Trade ID and Type.
std::string securitySpecificCreditCurveName(const std::string &securityId, const std::string &creditCurveId)
Definition: marketdata.cpp:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeNotionalLeg() [2/2]

Leg makeNotionalLeg ( const Leg &  refLeg,
const bool  initNomFlow,
const bool  finalNomFlow,
const bool  amortNomFlow,
const QuantLib::Natural  notionalPaymentLag,
const BusinessDayConvention  paymentConvention,
const Calendar  paymentCalendar,
const bool  excludeIndexing = true 
)

◆ makeEquityLeg() [2/2]

Leg makeEquityLeg ( const LegData data,
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &  equityCurve,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex = nullptr,
const QuantLib::Date &  openEndDateReplacement = Null< Date >() 
)

◆ buildScheduledVector()

vector< T > buildScheduledVector ( const vector< T > &  values,
const vector< string > &  dates,
const Schedule &  schedule,
const bool  checkAllValuesAppearInResult = false 
)

Definition at line 1061 of file legdata.hpp.

1062 {
1063 if (values.size() < 2 || dates.size() == 0)
1064 return values;
1065
1066 QL_REQUIRE(values.size() == dates.size(), "Value / Date size mismatch in buildScheduledVector."
1067 << "Value:" << values.size() << ", Dates:" << dates.size());
1068
1069 // parse the dates
1070 std::vector<QuantLib::Date> parsedDates;
1071 std::transform(dates.begin(), dates.end(), std::back_inserter(parsedDates), &parseDate);
1072
1073 // adjust the dates using the schedule calendar and roll convention
1074 if (!schedule.calendar().empty()) {
1075 for (auto& d : parsedDates)
1076 if(d != Date())
1077 d = schedule.calendar().adjust(d, schedule.businessDayConvention());
1078 }
1079
1080 // Need to use schedule logic
1081 // Length of data will be 1 less than schedule
1082 //
1083 // Notional 100
1084 // Notional {startDate 2015-01-01} 200
1085 // Notional {startDate 2016-01-01} 300
1086 //
1087 // Given schedule June, Dec from 2014 to 2016 (6 dates, 5 coupons)
1088 // we return 100, 100, 200, 200, 300
1089
1090 // The first node must not have a date.
1091 // If the second one has a date, all the rest must have, and we process
1092 // If the second one does not have a date, none of them must have one
1093 // and we return the vector unaffected.
1094 QL_REQUIRE(parsedDates.front() == Date(), "Invalid date " << dates.front() << " for first node");
1095 if (parsedDates[1] == Date()) {
1096 // They must all be empty and then we return values
1097 for (Size i = 2; i < dates.size(); i++) {
1098 QL_REQUIRE(parsedDates[i] == Date(), "Invalid date " << dates[i] << " for node " << i
1099 << ". Cannot mix dates and non-dates attributes");
1100 }
1101 return values;
1102 }
1103
1104 // We have nodes with date attributes now
1105 Size len = schedule.size() - 1;
1106 vector<T> data(len);
1107 Size j = 0, max_j = parsedDates.size() - 1; // j is the index of date/value vector. 0 to max_j
1108 Date d = parsedDates[j + 1]; // The first start date
1109 for (Size i = 0; i < len; i++) { // loop over data vector and populate it.
1110 // If j == max_j we just fall through and take the final value
1111 while (schedule[i] >= d && j < max_j) {
1112 j++;
1113 if (j < max_j) {
1114 QL_REQUIRE(parsedDates[j + 1] != Date(), "Cannot have empty date attribute for node " << j + 1);
1115 d = parsedDates[j + 1];
1116 }
1117 }
1118 data[i] = values[j];
1119 }
1120
1121 if (checkAllValuesAppearInResult) {
1122 auto it = checkAllValuesAppearInScheduledVector<T>(data, values);
1123 QL_REQUIRE(it == values.end(),
1124 "buildScheduledVector: input value '" << *it << " does not appear in the result vector");
1125 }
1126
1127 return data;
1128}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normaliseToSchedule()

vector< T > normaliseToSchedule ( const vector< T > &  values,
const Schedule &  schedule,
const T &  defaultValue 
)

Definition at line 1131 of file legdata.hpp.

1131 {
1132 vector<T> res = values;
1133 if (res.size() < schedule.size() - 1)
1134 res.resize(schedule.size() - 1, res.size() == 0 ? defaultValue : res.back());
1135 return res;
1136}
+ Here is the caller graph for this function:

◆ buildScheduledVectorNormalised()

vector< T > buildScheduledVectorNormalised ( const vector< T > &  values,
const vector< string > &  dates,
const Schedule &  schedule,
const T &  defaultValue,
const bool  checkAllValuesAppearInResult = false 
)

Definition at line 1139 of file legdata.hpp.

1140 {
1141 return normaliseToSchedule(buildScheduledVector(values, dates, schedule, checkAllValuesAppearInResult), schedule,
1142 defaultValue);
1143}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAllValuesAppearInScheduledVector()

vector< T >::const_iterator checkAllValuesAppearInScheduledVector ( const vector< T > &  scheduledVecotr,
const vector< T > &  inputValues 
)

Definition at line 1146 of file legdata.hpp.

1147 {
1148 auto s = scheduledVector.begin();
1149 auto i = inputValues.begin();
1150 while (i != inputValues.end()) {
1151 if (s == scheduledVector.end())
1152 return i;
1153 if (*i == *s) {
1154 ++i;
1155 } else {
1156 ++s;
1157 }
1158 }
1159 return i;
1160}

◆ makeNonStandardIborLeg() [1/2]

Leg makeNonStandardIborLeg ( const QuantLib::ext::shared_ptr< IborIndex > &  index,
const std::vector< Date > &  calcDates,
const std::vector< Date > &  payDatesInput,
const std::vector< Date > &  fixingDatesInput,
const std::vector< Date > &  resetDatesInput,
const Size  fixingDays,
const std::vector< Real > &  notionals,
const std::vector< Date > &  notionalDatesInput,
const std::vector< Real > &  spreadsInput,
const std::vector< Date > &  spreadDatesInput,
const std::vector< Real > &  gearingsInput,
const std::vector< Date > &  gearingDatesInput,
const bool  strictNotionalDates,
const DayCounter &  dayCounter,
const Calendar &  payCalendar,
const BusinessDayConvention  payConv,
const Period &  payLag,
const bool  isInArrears 
)

Definition at line 28 of file makenonstandardlegs.cpp.

35 {
36
37 // add spread and gearing if none is given
38
39 std::vector<Real> spreads = spreadsInput, gearings = gearingsInput;
40
41 if (spreads.empty()) {
42 spreads.push_back(0.0);
43 }
44
45 if (gearings.empty()) {
46 gearings.push_back(1.0);
47 }
48
49 // checks
50
51 QL_REQUIRE(calcDates.size() >= 2,
52 "makeNonStandardIborLeg(): calc dates size (" << calcDates.size() << ") >= 2 required");
53 QL_REQUIRE(!notionals.empty(), "makeNonStandardIborLeg(): empty notinoals");
54 QL_REQUIRE(notionalDatesInput.empty() || notionalDatesInput.size() == notionals.size() - 1,
55 "makeNonStandardIborLeg(): notional dates (" << notionalDatesInput.size() << ") must match notional ("
56 << notionals.size() << ") minus 1");
57 QL_REQUIRE(spreadDatesInput.empty() || spreadDatesInput.size() == spreads.size() - 1,
58 "makeNonStandardIborLeg(): spread dates (" << spreadDatesInput.size() << ") must match spread ("
59 << spreads.size() << ") minus 1");
60 QL_REQUIRE(gearingDatesInput.empty() || gearingDatesInput.size() == gearings.size() - 1,
61 "makeNonStandardIborLeg(): gearing dates (" << gearingDatesInput.size() << ") must match gearing ("
62 << gearings.size() << ") minus 1");
63
64 // populate pay dates, reset dates, fixing dates, notional dates if not explicitly given
65
66 std::vector<Date> payDates(payDatesInput);
67 std::vector<Date> resetDates(resetDatesInput);
68 std::vector<Date> fixingDates(fixingDatesInput);
69 std::vector<Date> notionalDates(notionalDatesInput);
70 std::vector<Date> spreadDates(spreadDatesInput);
71 std::vector<Date> gearingDates(gearingDatesInput);
72
73 if (payDates.empty()) {
74 for (Size i = 1; i < calcDates.size(); ++i) {
75 payDates.push_back(payCalendar.advance(calcDates[i], payLag, payConv));
76 }
77 }
78
79 if (resetDates.empty() && fixingDates.empty()) {
80 for (Size i = 0; i < calcDates.size() - 1; ++i) {
81 resetDates.push_back(calcDates[i]);
82 fixingDates.push_back(index->fixingCalendar().advance(isInArrears ? calcDates[i + 1] : calcDates[i],
83 -static_cast<int>(fixingDays) * Days, Preceding));
84 }
85 } else if (resetDates.empty()) {
86 for (Size i = 0; i < fixingDates.size(); ++i) {
87 resetDates.push_back(index->fixingCalendar().advance(fixingDates[i], fixingDays * Days, Following));
88 }
89 } else if (fixingDates.empty()) {
90 for (Size i = 0; i < resetDates.size(); ++i) {
91 fixingDates.push_back(
92 index->fixingCalendar().advance(resetDates[i], -static_cast<int>(fixingDays) * Days, Preceding));
93 }
94 }
95
96 if (notionalDates.empty()) {
97 for (Size i = 1; i < notionals.size(); ++i)
98 notionalDates.push_back(calcDates[i]);
99 }
100
101 if (spreadDates.empty()) {
102 for (Size i = 1; i < spreads.size(); ++i)
103 spreadDates.push_back(calcDates[i]);
104 }
105
106 if (gearingDates.empty()) {
107 for (Size i = 1; i < gearings.size(); ++i)
108 gearingDates.push_back(calcDates[i]);
109 }
110
111 // more checks
112
113 QL_REQUIRE(payDates.size() == calcDates.size() - 1, "makeNonStandardIborLeg(): pay dates size ("
114 << payDates.size() << ") = calc dates size ("
115 << calcDates.size() << ") minus 1 required");
116 QL_REQUIRE(fixingDates.size() == resetDates.size(), "makeNonStandardIborLeg(): fixing dates ("
117 << fixingDates.size() << ") must match reset dates ("
118 << resetDates.size() << ")");
119
120 for (Size i = 0; i < fixingDates.size(); ++i) {
121 QL_REQUIRE(resetDates[i] <= calcDates.back(), "makeNonStandardIborLeg(): reset date at "
122 << i << " (" << resetDates[i]
123 << ") must be less or equal last calculation date ("
124 << calcDates.back());
125 }
126
127 for (Size i = 0; i < calcDates.size() - 1; ++i) {
128 QL_REQUIRE(calcDates[i] <= calcDates[i + 1], "makeNonStandardIborLeg(): calc date at "
129 << i << " (" << calcDates[i]
130 << ") must be less or equal calc date at " << (i + 1) << " ("
131 << calcDates[i + 1]);
132 }
133
134 for (Size i = 0; i < fixingDates.size() - 1; ++i) {
135 QL_REQUIRE(fixingDates[i] <= fixingDates[i + 1], "makeNonStandardIborLeg(): fixing date at "
136 << i << " (" << fixingDates[i]
137 << ") must be less or equal fixing date at " << (i + 1)
138 << " (" << fixingDates[i + 1] << ")");
139 }
140
141 for (Size i = 0; i < resetDates.size() - 1; ++i) {
142 QL_REQUIRE(resetDates[i] <= resetDates[i + 1], "makeNonStandardIborLeg(): reset date at "
143 << i << " (" << resetDates[i]
144 << ") must be less or equal reset date at " << (i + 1)
145 << " (" << resetDates[i + 1] << ")");
146 }
147
148 // build calculation periods including broken periods due to notional resets or fixing resets
149
150 std::set<Date> effCalcDates;
151
152 for (auto const& d : calcDates)
153 effCalcDates.insert(d);
154
155 for (auto const& d : resetDates) {
156 if (d >= calcDates.front() && d < calcDates.back())
157 effCalcDates.insert(d);
158 }
159
160 if (strictNotionalDates) {
161 for (auto const& d : notionalDates) {
162 if (d >= calcDates.front() && d < calcDates.back())
163 effCalcDates.insert(d);
164 }
165 }
166
167 // build coupons
168
169 Leg leg;
170
171 for (auto startDate = effCalcDates.begin(); startDate != std::next(effCalcDates.end(), -1); ++startDate) {
172 // determine calc end date from start date
173
174 Date endDate = *std::next(startDate, 1);
175
176 if (endDate > calcDates.back())
177 continue;
178
179 // determine pay date
180
181 auto nextCalcDate = std::lower_bound(calcDates.begin(), calcDates.end(), endDate);
182 Date payDate = payDates[std::max<Size>(1, std::distance(calcDates.begin(), nextCalcDate)) - 1];
183
184 // determine reset and thereby fixing date
185
186 auto nextReset = std::upper_bound(resetDates.begin(), resetDates.end(), *startDate);
187 QL_REQUIRE(nextReset != resetDates.begin(),
188 "makeNonStandardIborLeg(): calc start date "
189 << *startDate << " is before first reset date " << *resetDates.begin()
190 << ". Ensure that there is a reset date on or before the calc start date.");
191 Date fixingDate = fixingDates[std::distance(resetDates.begin(), nextReset) - 1];
192
193 // determine notional
194
195 auto notionalDate = std::upper_bound(notionalDates.begin(), notionalDates.end(), *startDate);
196 Real notional =
197 notionals[std::min<Size>(notionals.size() - 1, std::distance(notionalDates.begin(), notionalDate))];
198
199 // determine spread
200
201 auto spreadDate = std::upper_bound(spreadDates.begin(), spreadDates.end(), *startDate);
202 Real spread = spreads[std::min<Size>(spreads.size() - 1, std::distance(spreadDates.begin(), spreadDate))];
203
204 // determine gearing
205
206 auto gearingDate = std::upper_bound(gearingDates.begin(), gearingDates.end(), *startDate);
207 Real gearing = gearings[std::min<Size>(gearings.size() - 1, std::distance(gearingDates.begin(), gearingDate))];
208
209 // build coupon
210
211 leg.push_back(QuantLib::ext::make_shared<IborCoupon>(payDate, notional, *startDate, endDate, fixingDate, index, gearing,
212 spread, Date(), Date(), dayCounter));
213 }
214
215 return leg;
216}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeNonStandardFixedLeg() [1/2]

Leg makeNonStandardFixedLeg ( const std::vector< Date > &  calcDates,
const std::vector< Date > &  payDatesInput,
const std::vector< Real > &  notionals,
const std::vector< Date > &  notionalDatesInput,
const std::vector< Real > &  rates,
const std::vector< Date > &  rateDatesInput,
const bool  strictNotionalDates,
const DayCounter &  dayCounter,
const Calendar &  payCalendar,
const BusinessDayConvention  payConv,
const Period &  payLag 
)

Definition at line 218 of file makenonstandardlegs.cpp.

222 {
223
224 // checks
225
226 QL_REQUIRE(calcDates.size() >= 2,
227 "makeNonStandardFixedLeg(): calc dates size (" << calcDates.size() << ") >= 2 required");
228 QL_REQUIRE(!notionals.empty(), "makeNonStandardFixedLeg(): empty notinoals");
229 QL_REQUIRE(!rates.empty(), "makeNonStandardFixedLeg(): empty rates");
230 QL_REQUIRE(notionalDatesInput.empty() || notionalDatesInput.size() == notionals.size() - 1,
231 "makeNonStandardFixedLeg(): notional dates (" << notionalDatesInput.size() << ") must match notional ("
232 << notionals.size() << ") minus 1");
233 QL_REQUIRE(rateDatesInput.empty() || rateDatesInput.size() == rates.size() - 1,
234 "makeNonStandardIborLeg(): rate dates (" << rateDatesInput.size() << ") must match rate ("
235 << rates.size() << ") minus 1");
236
237 for (Size i = 0; i < calcDates.size() - 1; ++i) {
238 QL_REQUIRE(calcDates[i] <= calcDates[i + 1], "makeNonStandardFixedLeg(): calc date at "
239 << i << " (" << calcDates[i]
240 << ") must be less or equal calc date at " << (i + 1) << " ("
241 << calcDates[i + 1] << ")");
242 }
243
244 // populate pay dates, notional dates if not given
245
246 std::vector<Date> payDates(payDatesInput);
247 std::vector<Date> notionalDates(notionalDatesInput);
248 std::vector<Date> rateDates(rateDatesInput);
249
250 if (payDates.empty()) {
251 for (Size i = 1; i < calcDates.size(); ++i) {
252 payDates.push_back(payCalendar.advance(calcDates[i], payLag, payConv));
253 }
254 }
255
256 if (notionalDates.empty()) {
257 for (Size i = 1; i < notionals.size(); ++i)
258 notionalDates.push_back(calcDates[i]);
259 }
260
261 if (rateDates.empty()) {
262 for (Size i = 1; i < rates.size(); ++i)
263 rateDates.push_back(calcDates[i]);
264 }
265
266 // more checks
267
268 QL_REQUIRE(payDates.size() == calcDates.size() - 1, "makeNonStandardFixedLeg(): pay dates size ("
269 << payDates.size() << ") = calc dates size ("
270 << calcDates.size() << ") minus 1 required");
271
272 // build calculation periods including broken periods due to notional resets or fixing resets
273
274 std::set<Date> effCalcDates;
275
276 for (auto const& d : calcDates)
277 effCalcDates.insert(d);
278
279 if (strictNotionalDates)
280 for (auto const& d : notionalDates) {
281 if (d >= calcDates.front() && d < calcDates.back())
282 effCalcDates.insert(d);
283 }
284
285 // build coupons
286
287 Leg leg;
288
289 for (auto startDate = effCalcDates.begin(); startDate != std::next(effCalcDates.end(), -1); ++startDate) {
290
291 // determine calc end date from start date
292
293 Date endDate = *std::next(startDate, 1);
294
295 if (endDate >= calcDates.back())
296 continue;
297
298 // determine pay date
299
300 auto nextCalcDate = std::lower_bound(calcDates.begin(), calcDates.end(), endDate);
301 Date payDate = payDates[std::max<Size>(1, std::distance(calcDates.begin(), nextCalcDate)) - 1];
302
303 // determine notional
304
305 auto notionalDate = std::upper_bound(notionalDates.begin(), notionalDates.end(), *startDate);
306 Real notional =
307 notionals[std::min<Size>(notionals.size() - 1, std::distance(notionalDates.begin(), notionalDate))];
308
309 // determine rate
310
311 auto rateDate = std::upper_bound(rateDates.begin(), rateDates.end(), *startDate);
312 Real rate = rates[std::min<Size>(rates.size() - 1, std::distance(rateDates.begin(), rateDate))];
313
314 // build coupon
315
316 leg.push_back(QuantLib::ext::make_shared<FixedRateCoupon>(payDate, notional, rate, dayCounter, *startDate, endDate,
317 Date(), Date()));
318 }
319
320 return leg;
321}
+ Here is the caller graph for this function:

◆ makeNonStandardIborLeg() [2/2]

QuantLib::Leg makeNonStandardIborLeg ( const QuantLib::ext::shared_ptr< QuantLib::IborIndex > &  index,
const std::vector< QuantLib::Date > &  calcDates,
const std::vector< QuantLib::Date > &  payDates,
const std::vector< QuantLib::Date > &  fixingDates,
const std::vector< QuantLib::Date > &  resetDates,
const QuantLib::Size  fixingDays,
const std::vector< QuantLib::Real > &  notionals,
const std::vector< QuantLib::Date > &  notionalDates,
const std::vector< QuantLib::Real > &  spreads,
const std::vector< QuantLib::Date > &  spreadDates,
const std::vector< QuantLib::Real > &  gearings,
const std::vector< QuantLib::Date > &  gearingDates,
const bool  strictNotionalDates,
const QuantLib::DayCounter &  dayCounter,
const QuantLib::Calendar &  payCalendar,
const QuantLib::BusinessDayConvention  payConv,
const QuantLib::Period &  payLag,
const bool  isInArrears 
)

◆ makeNonStandardFixedLeg() [2/2]

QuantLib::Leg makeNonStandardFixedLeg ( const std::vector< QuantLib::Date > &  calcDates,
const std::vector< QuantLib::Date > &  payDates,
const std::vector< QuantLib::Real > &  notionals,
const std::vector< QuantLib::Date > &  notionalDates,
const std::vector< QuantLib::Real > &  rates,
const std::vector< QuantLib::Date > &  rateDates,
const bool  strictNotionalDates,
const QuantLib::DayCounter &  dayCounter,
const QuantLib::Calendar &  payCalendar,
const QuantLib::BusinessDayConvention  payConv,
const QuantLib::Period &  payLag 
)

◆ parseCsaType()

CSA::Type parseCsaType ( const string &  s)

Definition at line 29 of file nettingsetdefinition.cpp.

29 {
30 static map<string, CSA::Type> t = {
31 {"Bilateral", CSA::Bilateral}, {"CallOnly", CSA::CallOnly}, {"PostOnly", CSA::PostOnly}};
32
33 auto it = t.find(s);
34 if (it != t.end()) {
35 return it->second;
36 } else {
37 QL_FAIL("Cannot convert \"" << s << "\" to CSA::Type");
38 }
39}
+ Here is the caller graph for this function:

◆ operator<<() [42/73]

std::ostream & operator<< ( std::ostream &  out,
CSA::Type  t 
)

Definition at line 41 of file nettingsetdefinition.cpp.

41 {
42 switch (t) {
43 case CSA::Bilateral:
44 return out << "Bilateral";
45 case CSA::CallOnly:
46 return out << "CallOnly";
47 case CSA::PostOnly:
48 return out << "PostOnly";
49 default:
50 QL_FAIL("csa type not covered");
51 }
52}

◆ operator<() [12/14]

bool operator< ( const NettingSetDetails lhs,
const NettingSetDetails rhs 
)

Comparison operators.

Definition at line 93 of file nettingsetdetails.cpp.

93 {
94 return std::tie(lhs.nettingSetId(), lhs.agreementType(), lhs.callType(), lhs.initialMarginType(),
95 lhs.legalEntityId()) < std::tie(rhs.nettingSetId(), rhs.agreementType(), rhs.callType(),
96 rhs.initialMarginType(), rhs.legalEntityId());
97}
const string & initialMarginType() const
const string & nettingSetId() const
const string & callType() const
const string & legalEntityId() const
const string & agreementType() const
+ Here is the call graph for this function:

◆ operator==() [7/13]

bool operator== ( const NettingSetDetails lhs,
const NettingSetDetails rhs 
)

Definition at line 99 of file nettingsetdetails.cpp.

99 {
100 return (lhs.nettingSetId() == rhs.nettingSetId() && lhs.agreementType() == rhs.agreementType() &&
101 lhs.callType() == rhs.callType() && lhs.initialMarginType() == rhs.initialMarginType() &&
102 lhs.legalEntityId() == rhs.legalEntityId());
103}
+ Here is the call graph for this function:

◆ operator!=() [3/4]

bool operator!= ( const NettingSetDetails lhs,
const NettingSetDetails rhs 
)

Definition at line 105 of file nettingsetdetails.cpp.

105{ return !(lhs == rhs); }

◆ operator<<() [43/73]

std::ostream & operator<< ( std::ostream &  out,
const NettingSetDetails nettingSetDetails 
)

Enable writing of netting set details.

Definition at line 107 of file nettingsetdetails.cpp.

107 {
108 std::ostream& tmp = out << "NettingSetId=\'" << nettingSetDetails.nettingSetId() << "\'";
109
110 if (!nettingSetDetails.emptyOptionalFields()) {
111 return tmp << ", AgreementType=\'" << nettingSetDetails.agreementType() << "\', CallType=\'"
112 << nettingSetDetails.callType() << "\', InitialMarginType=\'"
113 << nettingSetDetails.initialMarginType() << "\', LegalEntityId=\'"
114 << nettingSetDetails.legalEntityId() << "\'";
115 }
116
117 return tmp;
118}
+ Here is the call graph for this function:

◆ operator<<() [44/73]

std::ostream & operator<< ( ostream &  out,
const OptionPaymentData::RelativeTo relativeTo 
)

Print RelativeTo enum values.

Definition at line 107 of file optionpaymentdata.cpp.

107 {
108 switch (relativeTo) {
109 case OptionPaymentData::RelativeTo::Expiry:
110 return out << "Expiry";
111 case OptionPaymentData::RelativeTo::Exercise:
112 return out << "Exercise";
113 default:
114 QL_FAIL("Could not convert the relativeTo enum value to string.");
115 }
116}

◆ buildTrade()

std::pair< QuantLib::ext::shared_ptr< Trade >, bool > buildTrade ( QuantLib::ext::shared_ptr< Trade > &  trade,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const std::string &  context,
const bool  ignoreTradeBuildFail,
const bool  buildFailedTrades,
const bool  emitStructuredError 
)

Definition at line 269 of file portfolio.cpp.

272 {
273 try {
274 trade->reset();
275 trade->build(engineFactory);
276 TLOG("Required Fixings for trade " << trade->id() << ":");
277 TLOGGERSTREAM(trade->requiredFixings());
278 return std::make_pair(nullptr, true);
279 } catch (std::exception& e) {
280 if (emitStructuredError) {
281 StructuredTradeErrorMessage(trade, "Error building trade for context '" + context + "'", e.what()).log();
282 } else {
283 ALOG("Error building trade '" << trade->id() << "' for context '" + context + "': " + e.what());
284 }
285 if (ignoreTradeBuildFail) {
286 return std::make_pair(trade, false);
287 } else if (buildFailedTrades) {
288 QuantLib::ext::shared_ptr<FailedTrade> failed = QuantLib::ext::make_shared<FailedTrade>();
289 failed->id() = trade->id();
290 failed->setUnderlyingTradeType(trade->tradeType());
291 failed->setEnvelope(trade->envelope());
292 failed->build(engineFactory);
293 failed->resetPricingStats(trade->getNumberOfPricings(), trade->getCumulativePricingTime());
294 LOG("Built failed trade with id " << failed->id());
295 return std::make_pair(failed, false);
296 } else {
297 return std::make_pair(nullptr, false);
298 }
299 }
300}
#define TLOGGERSTREAM(text)
Definition: log.hpp:633
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==() [8/13]

bool operator== ( const RangeBound a,
const RangeBound b 
)

Definition at line 66 of file rangebound.cpp.

66 {
67 return a.from() == b.from() && a.to() == b.to() && a.leverage() == b.leverage() && a.strike() == b.strike() &&
69}
Real leverage() const
Definition: rangebound.hpp:51
Real strike() const
Definition: rangebound.hpp:52
Real strikeAdjustment() const
Definition: rangebound.hpp:53
+ Here is the call graph for this function:

◆ operator<<() [45/73]

std::ostream & operator<< ( std::ostream &  out,
const RangeBound t 
)

Definition at line 80 of file rangebound.cpp.

80 {
81 return out << "[" << output(t.from()) << ", " << output(t.to()) << "] x " << output(t.leverage()) << " @ "
82 << output(t.strike()) << " +- " << output(t.strikeAdjustment());
83}
+ Here is the call graph for this function:

◆ operator<<() [46/73]

std::ostream & operator<< ( std::ostream &  out,
const std::vector< RangeBound > &  t 
)

Definition at line 85 of file rangebound.cpp.

85 {
86 std::ostringstream s;
87 s << "[ ";
88 for (Size i = 0; i < t.size(); ++i)
89 s << t[i] << (i < t.size() - 1 ? ", " : "");
90 s << " ]";
91 return out << s.str();
92}

◆ operator<() [13/14]

bool operator< ( const CreditIndexConstituent lhs,
const CreditIndexConstituent rhs 
)

Compare CreditIndexConstituent instances using their name.

Definition at line 199 of file referencedata.cpp.

199{ return lhs.name() < rhs.name(); }
const std::string & name() const
+ Here is the call graph for this function:

◆ createReferenceDatumBuilder()

QuantLib::ext::shared_ptr< AbstractReferenceDatumBuilder > createReferenceDatumBuilder ( )

Definition at line 71 of file referencedatafactory.hpp.

71 {
72 return QuantLib::ext::make_shared<T>();
73}

◆ makeSchedule() [1/7]

QuantLib::Schedule makeSchedule ( const ScheduleDates data)

Definition at line 263 of file schedule.cpp.

263 {
264 QL_REQUIRE(data.dates().size() > 0, "Must provide at least 1 date for Schedule");
265 Calendar calendar = parseCalendar(data.calendar());
266 BusinessDayConvention convention = ModifiedFollowing;
267 if (!data.convention().empty())
268 convention = parseBusinessDayConvention(data.convention());
269 // Avoid compiler warning on gcc
270 // https://www.boost.org/doc/libs/1_74_0/libs/optional/doc/html/boost_optional/tutorial/
271 // gotchas/false_positive_with__wmaybe_uninitialized.html
272 auto tenor = boost::make_optional(false, Period());
273 if (!data.tenor().empty())
274 tenor = parsePeriod(data.tenor());
275 bool endOfMonth = false;
276 if (!data.endOfMonth().empty())
277 endOfMonth = parseBool(data.endOfMonth());
278 ext::optional<BusinessDayConvention> endOfMonthConvention = boost::none;
279 if (!data.endOfMonthConvention().empty())
280 endOfMonthConvention = parseBusinessDayConvention(data.endOfMonthConvention());
281
282 // Ensure that Schedule ctor is passed a vector of unique ordered dates.
283 std::set<Date> uniqueDates;
284 for (const string& d : data.dates())
285 uniqueDates.insert(calendar.adjust(parseDate(d), convention));
286
287 return QuantLib::Schedule(vector<Date>(uniqueDates.begin(), uniqueDates.end()), calendar, convention, boost::none,
288 tenor, boost::none, endOfMonth, vector<bool>(0), false, false, endOfMonthConvention);
289}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeSchedule() [2/7]

Schedule makeSchedule ( const ScheduleDerived data,
const Schedule &  baseSchedule 
)

Definition at line 291 of file schedule.cpp.

291 {
292
293 string strCalendar = data.calendar();
294 Calendar calendar;
295 if (strCalendar.empty()) {
296 calendar = NullCalendar();
297 WLOG("No calendar provided in Schedule, attempting to use a null calendar.");
298 }
299 else
300 calendar = parseCalendar(strCalendar);
301
302 BusinessDayConvention convention;
303 string strConvention = data.convention();
304 if (strConvention.empty())
305 convention = BusinessDayConvention::Unadjusted;
306 else
307 convention = parseBusinessDayConvention(strConvention);
308
309 string strShift = data.shift();
310 Period shift;
311 if (strShift.empty())
312 shift = 0 * Days;
313 else
314 shift = parsePeriod(data.shift());
315
316 const std::vector<QuantLib::Date>& baseDates = baseSchedule.dates();
317 std::vector<QuantLib::Date> derivedDates;
318 QuantLib::Date derivedDate;
319 for (const Date& d : baseDates) {
320 derivedDate = calendar.advance(d, shift, convention);
321 derivedDates.push_back(derivedDate);
322 }
323 ext::optional<BusinessDayConvention> endOfMonthConvention = boost::none;
324 if (baseSchedule.hasEndOfMonthBusinessDayConvention())
325 endOfMonthConvention = baseSchedule.endOfMonthBusinessDayConvention();
326
327 return QuantLib::Schedule(vector<Date>(derivedDates.begin(), derivedDates.end()), calendar, convention, boost::none,
328 baseSchedule.tenor(), boost::none, baseSchedule.endOfMonth(), std::vector<bool>(0),
329 data.removeFirstDate(), data.removeLastDate(),
330 endOfMonthConvention);
331}
+ Here is the call graph for this function:

◆ makeSchedule() [3/7]

Schedule makeSchedule ( const ScheduleRules data,
const Date &  openEndDateReplacement 
)

Definition at line 333 of file schedule.cpp.

333 {
334 QL_REQUIRE(!data.endDate().empty() || openEndDateReplacement != Null<Date>(),
335 "makeSchedule(): Schedule does not have an end date, this is not supported in this context / for this "
336 "trade type. Please provide an end date.");
337 QL_REQUIRE(!data.endDate().empty() || data.lastDate().empty(),
338 "makeSchedule(): If no end date is given, a last date is not allowed either. Please remove the last "
339 "date from the schedule.");
340 Calendar calendar = parseCalendar(data.calendar());
341 if (calendar == NullCalendar())
342 WLOG("No calendar provided in Schedule, attempting to use a null calendar.");
343 Date startDate = parseDate(data.startDate());
344 Date endDate = data.endDate().empty() ? openEndDateReplacement : parseDate(data.endDate());
345 // Handle trivial case here
346 if (startDate == endDate)
347 return Schedule(vector<Date>(1, startDate), calendar);
348
349 QL_REQUIRE(startDate < endDate, "StartDate " << startDate << " is ahead of EndDate " << endDate);
350
351 Date firstDate = parseDate(data.firstDate());
352 Date lastDate = parseDate(data.lastDate());
353 if (firstDate != Date() && lastDate != Date())
354 QL_REQUIRE(firstDate <= lastDate, "Schedule::makeSchedule firstDate must be before lastDate");
355
356 Period tenor = parsePeriod(data.tenor());
357
358 // defaults
359 BusinessDayConvention bdc = ModifiedFollowing;
360 BusinessDayConvention bdcEnd = ModifiedFollowing;
361 DateGeneration::Rule rule = DateGeneration::Forward;
362 bool endOfMonth = false;
363 ext::optional<BusinessDayConvention> endOfMonthConvention = boost::none;
364
365 // now check the strings, if they are empty we take defaults
366 if (!data.convention().empty())
367 bdc = parseBusinessDayConvention(data.convention());
368 if (!data.termConvention().empty())
369 bdcEnd = parseBusinessDayConvention(data.termConvention());
370 else
371 bdcEnd = bdc; // except here
372
373 if (!data.endOfMonth().empty())
374 endOfMonth = parseBool(data.endOfMonth());
375 if (!data.endOfMonthConvention().empty())
376 endOfMonthConvention = parseBusinessDayConvention(data.endOfMonthConvention());
377
378 if (!data.rule().empty()) {
379
380 // handle special rules outside the QuantLib date generation rules
381
382 if (data.rule() == "EveryThursday") {
383 auto dates = everyWeekDayDates(startDate, endDate, firstDate, QuantLib::Thursday);
384 for (auto& d : dates)
385 d = calendar.adjust(d, bdc);
386 return QuantLib::Schedule(dates, calendar, bdc, bdcEnd, tenor, rule, endOfMonth, std::vector<bool>(0), false, false, endOfMonthConvention);
387 } else if (data.rule() == "BusinessWeek" || data.rule() == "CalendarWeek") {
388 auto dates = weeklyDates(startDate, endDate, firstDate, data.rule() == "CalendarWeek");
389 for (auto& d : dates)
390 d = calendar.adjust(d, bdc);
391 return QuantLib::Schedule(dates, calendar, bdc, bdcEnd, tenor, rule, endOfMonth, std::vector<bool>(0), data.removeFirstDate(), data.removeLastDate(), endOfMonthConvention);
392 }
393
394 // parse rule for further processing below
395
396 rule = parseDateGenerationRule(data.rule());
397 }
398
399 // handling of date generation rules that require special adjustments
400
401 if ((rule == DateGeneration::CDS || rule == DateGeneration::CDS2015) &&
402 (firstDate != Null<Date>() || lastDate != Null<Date>())) {
403 // Special handling of first date and last date in combination with CDS and CDS2015 rules:
404 // To be able to construct CDS schedules with front or back stub periods, we overwrite the
405 // first (last) date of the schedule built in QL with a given first (last) date
406 // The schedule builder in QL itself is not capable of doing this, it just throws an exception
407 // if a first (last) date is given in combination with a CDS / CDS2015 date generation rule.
408 std::vector<Date> dates = QuantLib::Schedule(startDate, endDate, tenor, calendar, bdc, bdcEnd, rule, endOfMonth,
409 Date(), Date(), false, false, endOfMonthConvention)
410 .dates();
411 QL_REQUIRE(!dates.empty(),
412 "got empty CDS or CDS2015 schedule, startDate = " << startDate << ", endDate = " << endDate);
413 if (firstDate != Date())
414 dates.front() = firstDate;
415 if (lastDate != Date())
416 dates.back() = lastDate;
417 return QuantLib::Schedule(dates, calendar, bdc, bdcEnd, tenor, rule, endOfMonth, std::vector<bool>(0),
418 data.removeFirstDate(), data.removeLastDate(), endOfMonthConvention);
419 }
420
421 // default handling (QuantLib scheduler)
422
423 return QuantLib::Schedule(startDate, endDate, tenor, calendar, bdc, bdcEnd, rule, endOfMonth, firstDate, lastDate,
424 data.removeFirstDate(), data.removeLastDate(), endOfMonthConvention);
425}
+ Here is the call graph for this function:

◆ makeSchedule() [4/7]

Schedule makeSchedule ( const ScheduleData data,
const Date &  openEndDateReplacement,
const map< string, QuantLib::Schedule > &  baseSchedules 
)

Definition at line 445 of file schedule.cpp.

445 {
446 if(!data.hasData())
447 return Schedule();
448 // only the last rule-based schedule is allowed to have an open end date, check this
449 for (Size i = 1; i < data.rules().size(); ++i) {
450 QL_REQUIRE(!data.rules()[i - 1].endDate().empty(),
451 "makeSchedule(): only last schedule is allowed to have an open end date");
452 }
453 // build all the date and rule based sub-schedules we have
454 vector<Schedule> schedules;
455 for (auto& d : data.dates())
456 schedules.push_back(makeSchedule(d));
457 for (auto& r : data.rules())
458 schedules.push_back(makeSchedule(r, openEndDateReplacement));
459 if (!baseSchedules.empty())
460 for (auto& dv : data.derived()) {
461 auto baseSchedule = baseSchedules.find(dv.baseSchedule());
462 QL_REQUIRE(baseSchedule != baseSchedules.end(), "makeSchedule(): could not find base schedule \"" << dv.baseSchedule() << "\"");
463 schedules.push_back(makeSchedule(dv, baseSchedule->second));
464 }
465 QL_REQUIRE(!schedules.empty(), "No dates or rules to build Schedule from");
466 if (schedules.size() == 1)
467 // if we have just one, use that (most common case)
468 return schedules.front();
469 else {
470 // if we have multiple, combine them
471
472 // 1) sort by start date
473 std::sort(schedules.begin(), schedules.end(),
474 [](const Schedule& lhs, const Schedule& rhs) -> bool { return lhs.startDate() < rhs.startDate(); });
475
476 // 2) check if meta data is present, and if yes if it is consistent across schedules;
477 // the only exception is the term date convention, this is taken from the last schedule always
478 BusinessDayConvention convention = Null<BusinessDayConvention>(),
479 termConvention = Unadjusted; // initialization prevents gcc warning
480 Calendar calendar;
481 Period tenor;
482 DateGeneration::Rule rule = DateGeneration::Zero; // initialization prevents gcc warning
483 bool endOfMonth = false; // initialization prevents gcc warning
484 BusinessDayConvention endOfMonthConvention = Null<BusinessDayConvention>();
485 bool hasCalendar = false, hasConvention = false, hasTermConvention = false, hasTenor = false, hasRule = false,
486 hasEndOfMonth = false, hasEndOfMonthConvention = false, hasConsistentCalendar = true,
487 hasConsistentConvention = true, hasConsistentTenor = true, hasConsistentRule = true,
488 hasConsistentEndOfMonth = true, hasConsistentEndOfMonthConvention = true;
489 for (auto& d : data.dates()) {
490 updateData<Calendar>(d.calendar(), calendar, hasCalendar, hasConsistentCalendar, parseCalendarTemp);
491 updateData<BusinessDayConvention>(d.convention(), convention, hasConvention, hasConsistentConvention,
492 parseBusinessDayConvention);
493 updateData<Period>(d.tenor(), tenor, hasTenor, hasConsistentTenor, parsePeriod);
494 }
495 for (auto& d : data.rules()) {
496 updateData<Calendar>(d.calendar(), calendar, hasCalendar, hasConsistentCalendar, parseCalendarTemp);
497 updateData<BusinessDayConvention>(d.convention(), convention, hasConvention, hasConsistentConvention,
498 parseBusinessDayConvention);
499 updateData<Period>(d.tenor(), tenor, hasTenor, hasConsistentTenor, parsePeriod);
500 updateData<bool>(d.endOfMonth(), endOfMonth, hasEndOfMonth, hasConsistentEndOfMonth, parseBool);
501 updateData<BusinessDayConvention>(d.endOfMonthConvention(), endOfMonthConvention, hasEndOfMonthConvention,
502 hasConsistentEndOfMonthConvention, parseBusinessDayConvention);
503 updateData<DateGeneration::Rule>(d.rule(), rule, hasRule, hasConsistentRule, parseDateGenerationRule);
504 if (d.termConvention() != "") {
505 hasTermConvention = true;
506 termConvention = parseBusinessDayConvention(d.termConvention());
507 }
508 }
509
510 // 3) combine dates and fill isRegular flag
511 const Schedule& s0 = schedules.front();
512 vector<Date> dates = s0.dates();
513 std::vector<bool> isRegular(s0.dates().size() - 1, false);
514 if (s0.hasIsRegular())
515 isRegular = s0.isRegular();
516 // will be removed, if next schedule's front date is matching the last date of current schedule
517 isRegular.push_back(false);
518 for (Size i = 1; i < schedules.size(); ++i) {
519 const Schedule& s = schedules[i];
520 QL_REQUIRE(dates.back() <= s.dates().front(), "Dates mismatch");
521 // if the end points match up, skip one to avoid duplicates, otherwise take both
522 Size offset = dates.back() == s.dates().front() ? 1 : 0;
523 isRegular.erase(isRegular.end() - offset,
524 isRegular.end()); // correct for superfluous flags from previous schedule
525 // add isRegular information, if available, otherwise assume irregular periods
526 if (s.hasIsRegular()) {
527 isRegular.insert(isRegular.end(), s.isRegular().begin(), s.isRegular().end());
528 } else {
529 for (Size ii = 0; ii < s.dates().size() - 1; ++ii)
530 isRegular.push_back(false);
531 }
532 if (i < schedules.size() - 1) {
533 // will be removed if next schedule's front date is matching last date of current schedule
534 isRegular.push_back(false);
535 }
536 // add the dates
537 dates.insert(dates.end(), s.dates().begin() + offset, s.dates().end());
538 }
539
540 // 4) Build schedule
541 return QuantLib::Schedule(
542 dates, hasCalendar && hasConsistentCalendar ? calendar : NullCalendar(),
543 hasConvention && hasConsistentConvention ? convention : Unadjusted,
544 hasTermConvention ? ext::optional<BusinessDayConvention>(termConvention) : boost::none,
545 hasTenor && hasConsistentTenor ? ext::optional<Period>(tenor) : boost::none,
546 hasRule && hasConsistentRule ? ext::optional<DateGeneration::Rule>(rule) : boost::none,
547 hasEndOfMonth && hasConsistentEndOfMonth ? ext::optional<bool>(endOfMonth) : boost::none, isRegular,
548 false, false,
549 hasEndOfMonthConvention && hasConsistentEndOfMonthConvention
550 ? ext::optional<BusinessDayConvention>(endOfMonthConvention)
551 : boost::none);
552 }
553}
+ Here is the call graph for this function:

◆ makeSchedule() [5/7]

QuantLib::Schedule makeSchedule ( const ScheduleData data,
const QuantLib::Date &  openEndDateReplacement = QuantLib::Null< QuantLib::Date >(),
const map< string, QuantLib::Schedule > &  baseSchedules = map< string, QuantLib::Schedule >() 
)

Functions.

◆ makeSchedule() [6/7]

QuantLib::Schedule makeSchedule ( const ScheduleRules rules,
const QuantLib::Date &  openEndDateReplacement = QuantLib::Null< QuantLib::Date >() 
)

◆ makeSchedule() [7/7]

QuantLib::Schedule makeSchedule ( const ScheduleDerived derived,
const QuantLib::Schedule &  baseSchedule 
)

◆ isdaSubProductSwap()

std::string isdaSubProductSwap ( const std::string &  tradeId,
const vector< LegData > &  legData 
)

Definition at line 323 of file swap.cpp.

323 {
324
325 Size nFixed = 0;
326 Size nFloating = 0;
327 for (Size i = 0; i < legData.size(); ++i) {
328 std::string type = legData[i].legType();
329 if (type == "Fixed" ||
330 type == "ZeroCouponFixed" ||
331 type == "Cashflow"||
332 type == "CommodityFixed")
333 nFixed++;
334 else if (type == "Floating" ||
335 type == "CPI" ||
336 type == "YY" ||
337 type == "CMS" ||
338 type == "DigitalCMS" ||
339 type == "CMSSpread" ||
340 type == "DigitalCMSSpread" ||
341 type == "CMB" ||
342 type == "Equity"||
343 type == "DurationAdjustedCMS"||
344 type == "FormulaBased"||
345 type =="CommodityFloating"||
346 type =="EquityMargin")
347 nFloating++;
348 else {
349 ALOG("leg type " << type << " not mapped for trade " << tradeId);
350 }
351 }
352
353 if (nFixed == 0)
354 return string("Basis");
355 else if (nFloating >= 1)
356 return string("Fixed Float");
357 else
358 return string("Fixed Fixed");
359}
+ Here is the caller graph for this function:

◆ addTRSRequiredFixings()

void addTRSRequiredFixings ( RequiredFixings fixings,
const std::vector< Leg > &  returnLegs,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  ind = nullptr 
)

Definition at line 42 of file trs.cpp.

43 {
44 QL_REQUIRE(returnLegs.size() > 0, "TrsUnderlyingBuilder: No returnLeg built");
45 auto fdg = QuantLib::ext::make_shared<FixingDateGetter>(fixings);
46 fdg->setAdditionalFxIndex(ind);
47 for (const auto& rl : returnLegs)
48 addToRequiredFixings(rl, fdg);
49}
void addToRequiredFixings(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseTrsFundingNotionalType()

TRS::FundingData::NotionalType parseTrsFundingNotionalType ( const std::string &  s)

Definition at line 789 of file trs.cpp.

789 {
790 auto it = types.left.find(s);
791 QL_REQUIRE(it != types.left.end(),
792 "parseTrsFundingNotionalType '" << s << "' failed, expected PeriodReset, DailyReset, Fixed");
793 return it->second;
794}
boost::bimap< std::string, TRS::FundingData::NotionalType > types
Definition: trs.cpp:783
+ Here is the caller graph for this function:

◆ operator<<() [47/73]

std::ostream & operator<< ( std::ostream &  os,
const TRS::FundingData::NotionalType  t 
)

Definition at line 796 of file trs.cpp.

796 {
797 auto it = types.right.find(t);
798 QL_REQUIRE(it != types.right.end(), "operator<<(" << static_cast<int>(t) << ") failed, this is an internal error.");
799 os << it->second;
800 return os;
801}

◆ modifyBondTRSLeg()

void modifyBondTRSLeg ( QuantLib::Leg &  leg,
QuantLib::Date  issueDate 
)

Definition at line 37 of file trsunderlyingbuilder.cpp.

37 {
38 auto it = leg.begin();
39 while (it != leg.end()) {
40 auto cf = QuantLib::ext::dynamic_pointer_cast<QuantExt::BondTRSCashFlow>(*it);
41 if (cf) {
42 if (cf->fixingEndDate() < issueDate) {
43 it = leg.erase(it);
44 continue;
45 } else if (cf->fixingStartDate() < issueDate)
46 cf->setFixingStartDate(issueDate);
47 }
48 ++it;
49 }
50}
+ Here is the caller graph for this function:

◆ makeBondTRSLeg() [1/2]

Leg makeBondTRSLeg ( const std::vector< Date > &  valuationDates,
const std::vector< Date > &  paymentDates,
const BondIndexBuilder bondIndexBuilder,
Real  initialPrice,
QuantLib::ext::shared_ptr< QuantExt::FxIndex fxIndex 
)

Definition at line 52 of file trsunderlyingbuilder.cpp.

54 {
55
56 Leg returnLeg =
57 QuantExt::BondTRSLeg(valuationDates, paymentDates, bondIndexBuilder.bond().bondData().bondNotional(),
58 bondIndexBuilder.bondIndex(), fxIndex).withInitialPrice(initialPrice);
59 modifyBondTRSLeg(returnLeg, parseDate(bondIndexBuilder.bond().bondData().issueDate()));
60 return returnLeg;
61}
BondTRSLeg & withInitialPrice(Real)
const string & issueDate() const
Definition: bond.hpp:90
Real bondNotional() const
Definition: bond.hpp:95
const BondData & bondData() const
inspectors
Definition: bond.hpp:166
QuantLib::ext::shared_ptr< QuantExt::BondIndex > bondIndex() const
void modifyBondTRSLeg(QuantLib::Leg &leg, QuantLib::Date issueDate)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeBondTRSLeg() [2/2]

Leg makeBondTRSLeg ( const std::vector< Date > &  valuationDates,
const std::vector< Date > &  paymentDates,
const BondIndexBuilder bondIndexBuilder,
QuantLib::Real  initialPrice = QuantLib::Null< QuantLib::Real >(),
QuantLib::ext::shared_ptr< QuantExt::FxIndex fxIndex = nullptr 
)

◆ readEventData()

ScriptedTradeEventData readEventData ( XMLNode node)

Definition at line 379 of file worstofbasketswap.cpp.

379 {
380 ScriptedTradeEventData eventData;
381
382 string name = XMLUtils::getNodeName(node);
383 if (XMLNode* sch = XMLUtils::getChildNode(node, "DerivedSchedule")) {
384 string baseSchedule = XMLUtils::getChildValue(sch, "BaseSchedule", true);
385
386 string shift = XMLUtils::getChildValue(sch, "Shift", false);
387 shift = shift.empty() ? "0D" : shift;
388
389 string calendar = XMLUtils::getChildValue(sch, "Calendar", false);
390 calendar = calendar.empty() ? "NullCalendar" : calendar;
391
392 string convention = XMLUtils::getChildValue(sch, "Convention", false);
393 convention = convention.empty() ? "Unadjusted" : convention;
394
395 eventData = ScriptedTradeEventData(name, baseSchedule, shift, calendar, convention);
396
397 } else {
398 ScheduleData scheduleData = ScheduleData();
399 scheduleData.fromXML(node);
400 eventData = ScriptedTradeEventData(name, scheduleData);
401 }
402
403 return eventData;
404}
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeEventData()

XMLNode * writeEventData ( XMLDocument doc,
ScriptedTradeEventData eventData 
)

Definition at line 503 of file worstofbasketswap.cpp.

503 {
504 XMLNode* n = doc.allocNode(eventData.name());
505 if (eventData.type() == ScriptedTradeEventData::Type::Derived) {
506 XMLNode* derivedSchedule = doc.allocNode("DerivedSchedule");
507 XMLUtils::addChild(doc, derivedSchedule, "BaseSchedule", eventData.baseSchedule());
508 XMLUtils::addChild(doc, derivedSchedule, "Shift", eventData.shift());
509 XMLUtils::addChild(doc, derivedSchedule, "Calendar", eventData.calendar());
510 XMLUtils::addChild(doc, derivedSchedule, "Convention", eventData.convention());
511 XMLUtils::appendNode(n, derivedSchedule);
512 } else if (eventData.type() == ScriptedTradeEventData::Type::Array) {
513 if (!eventData.schedule().dates().empty()) {
514 vector<ScheduleDates> scheduleDates = eventData.schedule().dates();
515 for (auto& d : scheduleDates)
516 XMLUtils::appendNode(n, d.toXML(doc));
517 } else {
518 vector<ScheduleRules> scheduleRules = eventData.schedule().rules();
519 for (auto& r : scheduleRules)
520 XMLUtils::appendNode(n, r.toXML(doc));
521 }
522 //ScheduleData scheduleData = eventData.schedule();
523 //XMLUtils::appendNode(n, scheduleData.toXML(doc));
524 } else {
525 QL_FAIL(":writeEventData(): unexpected ScriptedTradeEventData::Type");
526 }
527 return n;
528}
const vector< ScheduleDates > & dates() const
Definition: schedule.hpp:228
const vector< ScheduleRules > & rules() const
Definition: schedule.hpp:229
const std::string & convention() const
const ScheduleData & schedule() const
const std::string & name() const
const std::string & shift() const
const std::string & baseSchedule() const
const std::string & calendar() const
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addColumnToExisitingReport()

QuantLib::ext::shared_ptr< ore::data::InMemoryReport > addColumnToExisitingReport ( const std::string &  columnName,
const std::string &  value,
const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &  report 
)

Adds a column to an existing InMemoryReport, the column value will be set to value for all existing rows Caution: This copies all existing values of the report and create a new one

Definition at line 29 of file utilities.cpp.

30 {
31 QuantLib::ext::shared_ptr<ore::data::InMemoryReport> newReport =
32 QuantLib::ext::make_shared<ore::data::InMemoryReport>();
33 if (report != nullptr) {
34 newReport->addColumn(columnName, string());
35 for (size_t i = 0; i < report->columns(); i++) {
36 newReport->addColumn(report->header(i), report->columnType(i), report->columnPrecision(i));
37 }
38 for (size_t row = 0; row < report->rows(); row++) {
39 newReport->next();
40 newReport->add(value);
41 for (size_t col = 0; col < report->columns(); col++) {
42 newReport->add(report->data(col)[row]);
43 }
44 }
45 newReport->end();
46 }
47 return newReport;
48}

◆ addColumnsToExisitingReport()

QuantLib::ext::shared_ptr< ore::data::InMemoryReport > addColumnsToExisitingReport ( const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &  newColsReport,
const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &  report 
)

Definition at line 51 of file utilities.cpp.

52 {
53 QuantLib::ext::shared_ptr<ore::data::InMemoryReport> newReport =
54 QuantLib::ext::make_shared<ore::data::InMemoryReport>();
55 if (report != nullptr && newColsReport->rows() == 1) {
56
57 for (size_t i = 0; i < newColsReport->columns(); ++i) {
58 newReport->addColumn(newColsReport->header(i), newColsReport->columnType(i),
59 newColsReport->columnPrecision(i));
60 }
61 for (size_t i = 0; i < report->columns(); i++) {
62 newReport->addColumn(report->header(i), report->columnType(i), report->columnPrecision(i));
63 }
64 for (size_t row = 0; row < report->rows(); row++) {
65 newReport->next();
66 for (size_t i = 0; i < newColsReport->columns(); ++i) {
67 newReport->add(newColsReport->data(i)[0]);
68 }
69 for (size_t col = 0; col < report->columns(); col++) {
70 newReport->add(report->data(col)[row]);
71 }
72 }
73 newReport->end();
74 }
75 return newReport;
76}

◆ concatenateReports()

QuantLib::ext::shared_ptr< ore::data::InMemoryReport > concatenateReports ( const std::vector< QuantLib::ext::shared_ptr< ore::data::InMemoryReport > > &  reports)

Definition at line 79 of file utilities.cpp.

79 {
80 if (!reports.empty() && reports.front() != nullptr) {
81 auto firstReport = reports.front();
82 QuantLib::ext::shared_ptr<InMemoryReport> concatenatedReport =
83 QuantLib::ext::make_shared<InMemoryReport>(*firstReport);
84 for (size_t i = 1; i < reports.size(); i++) {
85 if (reports[i] != nullptr) {
86 concatenatedReport->add(*reports[i]);
87 }
88 }
89 return concatenatedReport;
90 }
91 return nullptr;
92}

◆ to_string() [1/4]

std::string to_string ( const LocationInfo l)

Definition at line 28 of file ast.cpp.

28 {
29 if (l.initialised) {
30 if (l.lineStart == l.lineEnd && l.columnStart <= l.columnEnd)
31 return 'L' + std::to_string(l.lineStart) + ':' + std::to_string(l.columnStart) + ':' +
32 std::to_string(l.columnEnd - l.columnStart);
33 else
34 return 'L' + std::to_string(l.lineStart) + ':' + std::to_string(l.columnStart) + "-L" +
35 std::to_string(l.lineEnd) + ':' + std::to_string(l.columnEnd);
36 } else
37 return "L?";
38}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ to_string() [2/4]

std::string to_string ( const ASTNodePtr  root,
const bool  printLocationInfo 
)

Definition at line 157 of file astprinter.cpp.

157 {
158 ASTPrinter p(printLocationInfo);
159 root->accept(p);
160 return p.str();
161}
+ Here is the call graph for this function:

◆ reset()

void reset ( const ASTNodePtr  root)

Definition at line 44 of file astresetter.cpp.

44 {
45 ASTResetter r;
46 root->accept(r);
47}
+ Here is the caller graph for this function:

◆ to_script()

std::string to_script ( const ASTNodePtr  root)

Definition at line 773 of file asttoscriptconverter.cpp.

773 {
774 ASTToScriptConverter p;
775 root->accept(p);
776 return p.script;
777}
+ Here is the caller graph for this function:

◆ operator<<() [48/73]

std::ostream & operator<< ( std::ostream &  out,
const Context context 
)

Definition at line 51 of file context.cpp.

51 {
52 constexpr Size wd1 = 30, wd2 = 10;
53 for (auto const& v : context.scalars) {
54 out << std::setw(wd1) << std::left << v.first;
55 out << "(" << std::setw(wd2) << valueTypeLabels.at(v.second.which()) << ")";
56 if (std::find(context.constants.begin(), context.constants.end(), v.first) != context.constants.end())
57 out << " const ";
58 else
59 out << " ";
60 out << std::left << v.second << '\n';
61 }
62 for (auto const& v : context.arrays) {
63 Size counter = 0;
64 for (auto const& d : v.second) {
65 out << std::setw(wd1) << std::left << (v.first + "[" + std::to_string(counter + 1) + "]");
66 out << "(" << std::setw(wd2) << valueTypeLabels.at(d.which()) << ")";
67 if (std::find(context.constants.begin(), context.constants.end(), v.first) != context.constants.end())
68 out << " const ";
69 else
70 out << " ";
71 out << std::left << d << '\n';
72 ++counter;
73 }
74 }
75 return out;
76}
std::map< std::string, ValueType > scalars
Definition: context.hpp:45
std::map< std::string, std::vector< ValueType > > arrays
Definition: context.hpp:46
std::set< std::string > constants
Definition: context.hpp:41

◆ addModelParameter()

std::size_t addModelParameter ( ComputationGraph g,
std::vector< std::pair< std::size_t, std::function< double(void)> > > &  m,
const std::string &  id,
std::function< double(void)>  f 
)

Definition at line 480 of file modelcgimpl.cpp.

481 {
482 std::size_t n;
483 if (n = g.variable(id, ComputationGraph::VarDoesntExist::Nan); n == ComputationGraph::nan) {
484 n = cg_var(g, id, ComputationGraph::VarDoesntExist::Create);
485 m.push_back(std::make_pair(n, f));
486 }
487 return n;
488}
std::size_t variable(const std::string &name, const bool createIfNotExists=false)
std::size_t cg_var(ComputationGraph &g, const std::string &name, const bool createIfNotExists)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSloppyDate()

Date getSloppyDate ( const Date &  d,
const bool  sloppyDates,
const std::set< Date > &  dates 
)

Definition at line 490 of file modelcgimpl.cpp.

490 {
491 if (!sloppyDates)
492 return d;
493 auto s = std::lower_bound(dates.begin(), dates.end(), d);
494 if (s == dates.end())
495 return *dates.rbegin();
496 return *s;
497}
+ Here is the caller graph for this function:

◆ generateRandomAST()

ASTNodePtr generateRandomAST ( const Size  maxSequenceLength,
const Size  maxDepth,
const Size  seed 
)

Definition at line 616 of file randomastgenerator.cpp.

616 {
617 RandomASTGenerator gen(maxSequenceLength, maxDepth, seed);
618 gen.createInstructionSequence();
619 return gen.current;
620}
+ Here is the caller graph for this function:

◆ operator<<() [49/73]

std::ostream & operator<< ( std::ostream &  out,
const ParserError error 
)

Definition at line 32 of file scriptparser.cpp.

32 {
33 if (!error.stoppedParsingAt.initialised) {
34 out << "parsing succeeded";
35 } else {
36 out << "parsing stopped at " << to_string(error.stoppedParsingAt) << "\n";
37 if (error.expectedWhere.initialised) {
38 out << "expected " << error.expectedWhat << " in " << to_string(error.expectedWhere) << ":\n";
39 out << error.scriptCurrentLine << "\n";
40 out << std::string(std::max<Size>(error.expectedWhere.columnStart, 1) - 1, ' ') << "^--- here\n";
41 } else {
42 out << "remaining input is\n<<<<<<<<<<\n" << error.remainingInput << "\n>>>>>>>>>>\n";
43 }
44 }
45 return out;
46}
Real error
Definition: utilities.cpp:65
+ Here is the call graph for this function:

◆ printCodeContext()

std::string printCodeContext ( std::string  script,
const ASTNode loc,
bool  compact 
)

Definition at line 76 of file scriptparser.cpp.

76 {
77
78 if (!loc)
79 return "(script reference is not available)\n";
80
81 // assume we have either newline or return, but not return alone (old mac csv format?)
82 boost::replace_all(script, "\r", "");
83
84 auto l = loc->locationInfo;
85 if (l.lineEnd < l.lineStart || (l.lineEnd == l.lineStart && l.columnEnd <= l.columnStart))
86 return "(script reference invalid: " + to_string(l) + ")\n";
87
88 std::string res;
89 // if compact is true, we remove leading/trailing symbols used for DLOGGERSTREAM for cleaner error message in log
90 if (compact == false)
91 res += "<<<<<<<<<<\n";
92
93 Size pos = 0, currentLine = 1;
94 for (Size line = l.lineStart; line <= l.lineEnd; ++line) {
95 // look for the current line
96 while (pos < script.size() && currentLine < line) {
97 if (script[pos] == '\n')
98 ++currentLine;
99 ++pos;
100 }
101 if (pos == script.size())
102 break;
103 // look for the line end position in the current line
104 Size posLineEnd = pos;
105 while (posLineEnd < script.size() && script[posLineEnd] != '\n')
106 ++posLineEnd;
107 // add current line to the result
108 std::string curr = std::string(std::next(script.begin(), pos), std::next(script.begin(), posLineEnd));
109 if (compact) {
110 boost::algorithm::trim(curr);
111 res += curr + ' ';
112 } else {
113 res += curr + '\n';
114 }
115 // underline the relevant part of the current line
116 Size columnStart = 1, columnEnd = posLineEnd - pos + 1;
117 if (line == l.lineStart)
118 columnStart = l.columnStart;
119 if (line == l.lineEnd)
120 columnEnd = l.columnEnd;
121 if (columnEnd < columnStart)
122 return "(script reference internal error: columnEnd (" + std::to_string(columnEnd) +
123 ") should be >= columnStart (" + std::to_string(columnStart) + "))";
124 // adjust column start so that trailing spaces are not underlined
125 while (columnStart < columnEnd && pos + columnStart < script.size() &&
126 script[pos + std::max<Size>(columnStart, 1) - 1] == ' ')
127 ++columnStart;
128 if (compact == false)
129 res +=
130 std::string(std::max<Size>(columnStart, 1) - 1, ' ') + std::string(columnEnd - columnStart, '=') + '\n';
131 }
132
133 if (compact == false)
134 res += ">>>>>>>>>>\n";
135 return res;
136}
std::string script
LocationInfo locationInfo
Definition: ast.hpp:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coarsenDateGrid()

std::vector< Date > coarsenDateGrid ( const std::vector< Date > &  date,
const std::string &  rule,
const Date &  referenceDate = Null< Date >() 
)

coarsens given date grid starting at eval date using the given rule, which is of the form 3M(1W),1Y(1M),5Y(3M),10Y(1Y),50Y(5Y) the rough idea is out to 3M at least a 1W spacing is used, output 1Y a 1M spacing etc. for the exact algorithm that generates the coarsened grid, see the code

Definition at line 41 of file utilities.cpp.

41 {
42
43 // if rule is empty return original grid
44
45 if (rule.empty())
46 return dates;
47
48 // get ref date and prepare result vector
49
50 Date refDate = referenceDate == Null<Date>() ? Settings::instance().evaluationDate() : referenceDate;
51
52 std::vector<Date> result;
53
54 // parse the rule
55
56 std::vector<std::pair<Period, Period>> grid;
57 std::vector<std::string> tokens;
58 boost::split(tokens, rule, boost::is_any_of(","));
59 for (auto const& t : tokens) {
60 std::vector<std::string> tmp;
61 boost::split(tmp, t, boost::is_any_of("()"));
62 QL_REQUIRE(tmp.size() == 3, "coarsenGrid: invalid rule token '" << t << "', expected e.g. '10Y(1M)'");
63 grid.push_back(std::make_pair(parsePeriod(tmp[0]), parsePeriod(tmp[1])));
64 }
65
66 // keep all dates <= refDate
67
68 auto d = dates.begin();
69 for (; d != dates.end() && *d <= refDate; ++d) {
70 result.push_back(*d);
71 }
72
73 // step through the rule grid...
74
75 Date start = refDate;
76 for (auto const& p : grid) {
77 Date end = refDate + p.first;
78
79 do {
80
81 // look at subperiods defined by the second tenor in the rule
82
83 start = std::min(end, start + p.second);
84
85 // avoid too short stubs at the end
86 if (static_cast<double>(end - start) / static_cast<double>(end - (end - p.second)) < 0.2)
87 start = end;
88
89 // for each subperiod keep at most one date, if there are several in the subperiod, keep the latest one
90
91 std::vector<Date> candidates;
92 while (d != dates.end() && *d <= start)
93 candidates.push_back(*d++);
94
95 if (!candidates.empty())
96 result.push_back(candidates.back());
97 } while (start < end);
98
99 start = end;
100 }
101
102 return result;
103}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScript()

std::pair< std::string, ScriptedTradeScriptData > getScript ( const ScriptedTrade scriptedTrade,
const ScriptLibraryData scriptLibrary,
const std::string &  purpose,
const bool  fallBackOnEmptyPurpose 
)

get product tag + script, if a name is defined in the scriptTrade, get the script from the library, otherwise from the trade itself; use the give purpose and fall back on an empty purpose if specified

Definition at line 105 of file utilities.cpp.

108 {
109 if (!scriptedTrade.scriptName().empty()) {
110 DLOG("get script '" << scriptedTrade.scriptName() << "' for purpose '" << purpose
111 << "' (fallBackOnEmptyPurpose=" << std::boolalpha << fallBackOnEmptyPurpose
112 << ") from script library");
113 return scriptLibrary.get(scriptedTrade.scriptName(), purpose, fallBackOnEmptyPurpose);
114 } else {
115 DLOG("get script for purpose '" << purpose << "' (fallBackOnEmptyPurpose=" << std::boolalpha
116 << fallBackOnEmptyPurpose << ") from inline script in scripted trade");
117 return std::make_pair(scriptedTrade.productTag(), scriptedTrade.script(purpose, fallBackOnEmptyPurpose));
118 }
119}
std::pair< std::string, ScriptedTradeScriptData > get(const std::string &scriptName, const std::string &purpose, const bool fallBackOnEmptyPurpose=true) const
const std::string & productTag() const
const std::map< std::string, ScriptedTradeScriptData > & script() const
const std::string & scriptName() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseScript()

ASTNodePtr parseScript ( const std::string &  code)

parse script and return ast

Definition at line 121 of file utilities.cpp.

121 {
122 ScriptParser parser(code);
123 DLOG("parsing script (size " << code.size() << ")");
124 if (parser.success()) {
125 DLOG("successfully parsed the script");
126 } else {
127 ALOG("an error occured during script parsing:");
128 LOGGERSTREAM(parser.error());
129 LOG("full script is:");
130 LOG("<<<<<<<<<<");
131 LOGGERSTREAM(code);
132 LOG(">>>>>>>>>>");
133 QL_FAIL("scripted trade could not be built due to parser errors, see log for more details.");
134 }
135 return parser.ast();
136}
#define LOGGERSTREAM(text)
Definition: log.hpp:631
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convertIndexToCamCorrelationEntry()

std::pair< std::string, Period > convertIndexToCamCorrelationEntry ( const std::string &  i)

convert a IR / FX / EQ index name to a correlation label that is understood by the cam builder; return the tenor of the index too (or 0*Days if not applicable)

Definition at line 138 of file utilities.cpp.

138 {
139 IndexInfo info(i);
140 if (info.isIr()) {
141 return std::make_pair("IR#" + info.ir()->currency().code(), info.ir()->tenor());
142 } else if (info.isInf()) {
143 return std::make_pair("INF#" + info.infName(), 0 * Days);
144 } else if (info.isFx()) {
145 return std::make_pair("FX#" + info.fx()->sourceCurrency().code() + info.fx()->targetCurrency().code(),
146 0 * Days);
147 } else if (info.isEq()) {
148 return std::make_pair("EQ#" + info.eq()->name(), 0 * Days);
149 } else if (info.isComm()) {
150 return std::make_pair("COM#" + info.commName(), 0 * Days);
151 } else {
152 QL_FAIL("convertIndextoCamCorrelationEntry(): index '" << i << "' not recognised");
153 }
154}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkDuplicateName()

void checkDuplicateName ( const QuantLib::ext::shared_ptr< Context context,
const std::string &  name 
)

check whether variable name is already present in given context, if yes throw an exception

Definition at line 156 of file utilities.cpp.

156 {
157 auto scalar = context->scalars.find(name);
158 auto array = context->arrays.find(name);
159 QL_REQUIRE(scalar == context->scalars.end() && array == context->arrays.end(),
160 "variable '" << name << "' already declared.");
161}
+ Here is the caller graph for this function:

◆ makeContext()

QuantLib::ext::shared_ptr< Context > makeContext ( const Size  nPaths,
const std::string &  gridCoarsening,
const std::vector< std::string > &  schedulesEligibleForCoarsening,
const QuantLib::ext::shared_ptr< ReferenceDataManager > &  referenceData,
const std::vector< ScriptedTradeEventData > &  events,
const std::vector< ScriptedTradeValueTypeData > &  numbers,
const std::vector< ScriptedTradeValueTypeData > &  indices,
const std::vector< ScriptedTradeValueTypeData > &  currencies,
const std::vector< ScriptedTradeValueTypeData > &  daycounters 
)

build a context from the given data and apply the given gridCoarsening rule, if required

Definition at line 163 of file utilities.cpp.

170 {
171
172 TLOG("make context");
173
174 auto context = QuantLib::ext::make_shared<Context>();
175
176
177 map<string, ScriptedTradeEventData> derivedSchedules;
178 for (auto const& x : events) {
179 TLOG("adding event " << x.name());
180 if (x.type() == ScriptedTradeEventData::Type::Value) {
181 checkDuplicateName(context, x.name());
182 Date d = parseDate(x.value());
183 context->scalars[x.name()] = EventVec{nPaths, d};
184 } else if (x.type() == ScriptedTradeEventData::Type::Array) {
185 checkDuplicateName(context, x.name());
186 QuantLib::Schedule s;
187 try {
188 s = makeSchedule(x.schedule());
189 } catch (const std::exception& e) {
190 QL_FAIL("failed building schedule '" << x.name() << "': " << e.what());
191 }
192 std::vector<Date> c;
193 if (std::find(schedulesEligibleForCoarsening.begin(), schedulesEligibleForCoarsening.end(), x.name()) !=
194 schedulesEligibleForCoarsening.end()) {
195 c = coarsenDateGrid(s.dates(), gridCoarsening);
196 if (!gridCoarsening.empty()) {
197 TLOG("apply grid coarsening rule = " << gridCoarsening << " to '" << x.name()
198 << "', resulting grid:")
199 for (auto const& d : c) {
200 TLOG("date " << ore::data::to_string(d));
201 }
202 }
203 } else {
204 c = s.dates();
205 }
206 std::vector<ValueType> tmp;
207 for (auto const& d : c)
208 tmp.push_back(EventVec{nPaths, d});
209 context->arrays[x.name()] = tmp;
210 QL_REQUIRE(!tmp.empty(), "empty event array '" << x.name() << "' not allowed");
211 } else if (x.type() == ScriptedTradeEventData::Type::Derived) {
212 derivedSchedules[x.name()] = x;
213 } else {
214 QL_FAIL("unexpected ScriptedTradeEventData::Type");
215 }
216 context->constants.insert(x.name());
217 }
218
219 bool calculated;
220 while (derivedSchedules.size() > 0) {
221 calculated = false;
222 for (auto& ds : derivedSchedules) {
223 auto base = context->arrays.find(ds.second.baseSchedule());
224 checkDuplicateName(context, ds.second.name());
225 if (base != context->arrays.end()) {
226 try {
227 Calendar cal = parseCalendar(ds.second.calendar());
228 BusinessDayConvention conv = parseBusinessDayConvention(ds.second.convention());
229 Period shift = parsePeriod(ds.second.shift());
230 std::vector<ValueType> tmp;
231 for (auto const& d : base->second) {
232 QL_REQUIRE(d.which() == ValueTypeWhich::Event,
233 "expected event in base schedule, got " << valueTypeLabels.at(d.which()));
234 EventVec e = QuantLib::ext::get<EventVec>(d);
235 tmp.push_back(EventVec{nPaths, cal.advance(e.value, shift, conv)});
236 }
237 context->arrays[ds.second.name()] = tmp;
238 derivedSchedules.erase(ds.second.name());
239 calculated = true;
240 } catch (const std::exception& e) {
241 QL_FAIL("failed building derived schedule '" << ds.second.name() << "': " << e.what());
242 }
243 break;
244 }
245 }
246
247 // If, after looping through the full list of derived schedules, we are unable to build any of them.
248 if (!calculated) {
249 for (const auto& ds : derivedSchedules) {
250 ALOG("Failed to build the derived schedule: " << ds.first);
251 }
252 QL_FAIL("Failed to build at least one derived schedule");
253 break;
254 }
255 }
256
257 for (auto const& x : numbers) {
258 TLOG("adding number " << x.name());
259 checkDuplicateName(context, x.name());
260 if (!x.isArray()) {
261 double d = parseReal(x.value());
262 context->scalars[x.name()] = RandomVariable(nPaths, d);
263 } else {
264 std::vector<ValueType> tmp;
265 for (auto const& d : x.values())
266 tmp.push_back(RandomVariable(nPaths, parseReal(d)));
267 context->arrays[x.name()] = tmp;
268 QL_REQUIRE(!tmp.empty(), "empty number array '" << x.name() << "' not allowed");
269 }
270 context->constants.insert(x.name());
271 }
272
273 for (auto const& x : indices) {
274 TLOG("adding index " << x.name());
275 checkDuplicateName(context, x.name());
276 if (!x.isArray()) {
277 context->scalars[x.name()] = IndexVec{nPaths, x.value()};
278 } else {
279 std::vector<ValueType> tmp;
280 for (auto const& d : x.values())
281 tmp.push_back(IndexVec{nPaths, d});
282 context->arrays[x.name()] = tmp;
283 QL_REQUIRE(!tmp.empty(), "empty index array '" << x.name() << "' not allowed");
284 }
285 context->constants.insert(x.name());
286 }
287
288 for (auto const& x : currencies) {
289 TLOG("adding currency " << x.name());
290 checkDuplicateName(context, x.name());
291 if (!x.isArray()) {
292 context->scalars[x.name()] = CurrencyVec{nPaths, x.value()};
293 } else {
294 std::vector<ValueType> tmp;
295 for (auto const& d : x.values())
296 tmp.push_back(CurrencyVec{nPaths, d});
297 context->arrays[x.name()] = tmp;
298 QL_REQUIRE(!tmp.empty(), "empty currency array '" << x.name() << "' not allowed");
299 }
300 context->constants.insert(x.name());
301 }
302
303 for (auto const& x : daycounters) {
304 TLOG("adding daycounter " << x.name());
305 checkDuplicateName(context, x.name());
306 if (!x.isArray()) {
307 context->scalars[x.name()] = DaycounterVec{nPaths, x.value()};
308 } else {
309 std::vector<ValueType> tmp;
310 for (auto const& d : x.values())
311 tmp.push_back(DaycounterVec{nPaths, d});
312 context->arrays[x.name()] = tmp;
313 QL_REQUIRE(!tmp.empty(), "empty currency array '" << x.name() << "' not allowed");
314 }
315 context->constants.insert(x.name());
316 }
317
318 DLOG("context built with " << context->scalars.size() << " scalars and " << context->arrays.size() << " arrays.");
319 return context;
320}
std::vector< Date > coarsenDateGrid(const std::vector< Date > &dates, const std::string &rule, const Date &referenceDate)
Definition: utilities.cpp:41
void checkDuplicateName(const QuantLib::ext::shared_ptr< Context > context, const std::string &name)
Definition: utilities.cpp:156
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addNewSchedulesToContext()

void addNewSchedulesToContext ( QuantLib::ext::shared_ptr< Context context,
const std::vector< ScriptedTradeScriptData::NewScheduleData > &  newSchedules 
)

add new schedules (as specified in the script node) to schedules

Definition at line 322 of file utilities.cpp.

323 {
324 for (auto const& x : newSchedules) {
325 DLOG("adding new schedule " << x.name());
326 checkDuplicateName(context, x.name());
327 std::vector<std::vector<ValueType>> sources;
328 for (auto const& s : x.sourceSchedules()) {
329 auto d = context->arrays.find(s);
330 QL_REQUIRE(d != context->arrays.end(),
331 "ScriptedTradeGenericEngineBuilder::engineBuilder(): did not find source schedule '"
332 << s << "' when building new schedule '" << x.name() << "'");
333 sources.push_back(d->second);
334 }
335 std::vector<ValueType> result;
336 if (x.operation() == "Join") {
337 std::set<QuantLib::Date> tmp;
338 Size n = 0;
339 for (auto const& s : sources) {
340 for (auto const& d : s) {
341 tmp.insert(QuantLib::ext::get<EventVec>(d).value);
342 n = QuantLib::ext::get<EventVec>(d).size;
343 }
344 }
345 for (auto const& d : tmp) {
346 result.push_back(EventVec{n, d});
347 }
348 context->arrays[x.name()] = result;
349 context->constants.insert(x.name());
350 } else {
351 QL_FAIL("new schedule operation '" << x.operation() << "' not supported");
352 }
353 }
354}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ amendContextVariablesSizes()

void amendContextVariablesSizes ( QuantLib::ext::shared_ptr< Context context,
const Size  newSize 
)

maend the variables sizes in a context to a new size, this is only possible for deterministic variables

Definition at line 379 of file utilities.cpp.

379 {
380 SizeSetter setter(newSize);
381 for (auto& x : context->scalars)
382 boost::apply_visitor(setter, x.second);
383 for (auto& v : context->arrays)
384 for (auto& x : v.second)
385 boost::apply_visitor(setter, x);
386}
+ Here is the caller graph for this function:

◆ operator<<() [50/73]

std::ostream & operator<< ( std::ostream &  o,
const IndexInfo i 
)

Definition at line 484 of file utilities.cpp.

484 {
485 o << "index '" << i.name() << "'";
486 if (i.isFx())
487 o << ", type FX, index name '" << i.fx()->name() << "'";
488 if (i.isEq())
489 o << ", type EQ, index name '" << i.eq()->name() << "'";
490 if (i.isComm())
491 o << ", type COMM";
492 if (i.isIrIbor())
493 o << ", type IR Ibor, index name '" << i.irIbor()->name() << "'";
494 if (i.isIrSwap())
495 o << ", type IR Swap, index name '" << i.irSwap()->name() << "'";
496 if (i.isGeneric())
497 o << ", type Generic, index name '" << i.generic()->name() << "'";
498 return o;
499}
std::string name() const
Definition: utilities.hpp:98
QuantLib::ext::shared_ptr< Index > generic() const
Definition: utilities.hpp:124
bool isComm() const
Definition: utilities.hpp:102
QuantLib::ext::shared_ptr< SwapIndex > irSwap() const
Definition: utilities.hpp:122
bool isIrIbor() const
Definition: utilities.hpp:104
QuantLib::ext::shared_ptr< EquityIndex2 > eq() const
Definition: utilities.hpp:110
bool isGeneric() const
Definition: utilities.hpp:107
QuantLib::ext::shared_ptr< IborIndex > irIbor() const
Definition: utilities.hpp:115
bool isFx() const
Definition: utilities.hpp:100
QuantLib::ext::shared_ptr< FxIndex > fx() const
Definition: utilities.hpp:109
bool isIrSwap() const
Definition: utilities.hpp:105
bool isEq() const
Definition: utilities.hpp:101
+ Here is the call graph for this function:

◆ parseScriptedCommodityIndex()

QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseScriptedCommodityIndex ( const std::string &  indexName,
const QuantLib::Date &  obsDate = Date() 
)

This method tries to parse an commodity index name used in the scripting context

0) COMM-name 1) COMM-name-YYYY-MM-DD

2) COMM-name-YYYY-MM

3) CMMM-name#N#D#Cal 4) COMM-name#N#D

5) COMM-name#N

6) COMM-name!N

Here 0) - 2) are corresponding to the usual ORE conventions while 3) - 6) are specific to the scripting module: Expressions of the form 3) - 5) are resolved to one of the forms 1) and 2) using a given commodity future expiry calculator as follows:

3) COMM-name#N#D#Cal is resolved to the (N+1)th future with expiry greater than the given obsDate advanced by D business days w.r.t. Calendar Cal, N >= 0 4) as 3), Cal is taken as the commodity index's fixing calendar 5) as 4), D is set to 0 if not given 6) COMM-name!N is resolved to the future with month / year equal to the obsDate and monthOffst = N, N >=0

Notice that the forms 1) and 2) can be parsed without an obsDate and a commodity future convention given. If no convention is given, the fixing calendar in the index is set to the NullCalendar. In case a commodity future convention is given for the name, the fixing calendar is set to the calendar from the convention.

TODO if the form is COMM-name-YYYY-MM, the day of month of the expiry date will be set to 01, consistently with the ORE index parser, even if a convention is present, that would allow us to determine the correct expiry date. Should we use that latter date in the returned index?

Forms 3) to 6) on the other hand require a commodity future convention in any case, and an obsDate.

Definition at line 530 of file utilities.cpp.

531 {
532
533 QL_REQUIRE(!indexName.empty(), "parseScriptedCommodityIndex(): empty index name");
534 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
535 std::vector<std::string> tokens;
536 boost::split(tokens, indexName, boost::is_any_of("#!"));
537 std::string plainIndexName = tokens.front();
538 std::string commName = parseCommodityIndex(plainIndexName)->underlyingName();
539
540 QuantLib::ext::shared_ptr<CommodityFutureConvention> convention;
541 if (conventions->has(commName)) {
542 convention = QuantLib::ext::dynamic_pointer_cast<CommodityFutureConvention>(conventions->get(commName));
543 }
544 Calendar fixingCalendar = convention ? convention->calendar() : NullCalendar();
545
546 std::vector<std::string> tokens1;
547 boost::split(tokens1, indexName, boost::is_any_of("#"));
548 std::vector<std::string> tokens2;
549 boost::split(tokens2, indexName, boost::is_any_of("!"));
550
551 QuantLib::ext::shared_ptr<CommodityIndex> res;
552 if (tokens1.size() >= 2) {
553 // handle form 3)- 5), i.e. COMM-name#N#D#Cal, COMM-name#N#D, COMM-name#N
554 QL_REQUIRE(tokens.size() <= 4,
555 "parseScriptedCommodityIndex(): expected COMM-Name#N, Comm-Name#N#D, Comm-Name#N#D#Cal, got '"
556 << indexName << "'");
557 QL_REQUIRE(convention,
558 "parseScriptedCommodityIndex(): commodity future convention required for '" << indexName << "'");
559 QL_REQUIRE(obsDate != Date(), "parseScriptedCommodityIndex(): obsDate required for '" << indexName << "'");
560 int offset = std::stoi(tokens[1]);
561 int deliveryRollDays = 0;
562 if (tokens.size() >= 3)
563 deliveryRollDays = parseInteger(tokens[2]);
564 Calendar rollCal = tokens.size() == 4 ? parseCalendar(tokens[3]) : fixingCalendar;
565 ConventionsBasedFutureExpiry expiryCalculator(*convention);
566 Date adjustedObsDate = deliveryRollDays != 0 ? rollCal.advance(obsDate, deliveryRollDays * Days) : obsDate;
567 res = parseCommodityIndex(commName, false, Handle<PriceTermStructure>(), fixingCalendar, true);
568 res = res->clone(expiryCalculator.nextExpiry(true, adjustedObsDate, offset));
569 } else if (tokens2.size() >= 2) {
570 // handle form 6), i.e. COMM-name!N
571 QL_REQUIRE(tokens.size() <= 2,
572 "parseScriptedCommodityIndex(): expected COMM-Name!N, got '" << indexName << "'");
573 QL_REQUIRE(convention,
574 "parseScriptedCommodityIndex(): commodity future convention required for '" << indexName << "'");
575 QL_REQUIRE(obsDate != Date(), "parseScriptedCommodityIndex(): obsDate required for '" << indexName << "'");
576 int offset = std::stoi(tokens[1]);
577 ConventionsBasedFutureExpiry expiryCalculator(*convention);
578 res = parseCommodityIndex(commName, false, Handle<PriceTermStructure>(), fixingCalendar, true);
579 res = res->clone(expiryCalculator.expiryDate(obsDate, offset));
580 } else {
581 // handle 0), 1) and 2)
582 res = parseCommodityIndex(indexName, true, QuantLib::Handle<QuantExt::PriceTermStructure>(), fixingCalendar,
583 false);
584 }
585
586 TLOG("parseScriptCommodityIndex(" << indexName << "," << QuantLib::io::iso_date(obsDate) << ") = " << res->name());
587 return res;
588}
Perform date calculations for future contracts based on conventions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseScriptedInflationIndex()

std::pair< QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex >, std::string > parseScriptedInflationIndex ( const std::string &  indexName)

This method tries to parse an inflation index name used in the scripting context

1) EUHICPXT 2) EUHICPXT::F 3) EUHICPXT::L

Here 1) is the original form used in ORE. This represents a non-interpolated index. 2,3) is the extended form including a flag indicating the interpolation F (flat, =1) or L (linear)

The function returns a ql inflation index accounting for the interpolation (but without ts attached), and the ORE index name without the #F, #L suffix.

Definition at line 593 of file utilities.cpp.

593 {
594 QL_REQUIRE(!indexName.empty(), "parseScriptedInflationIndex(): empty index name");
595 std::vector<std::string> tokens;
596 boost::split(tokens, indexName, boost::is_any_of("#"));
597 std::string plainIndexName = tokens.front();
598 bool interpolated = false;
599 if (tokens.size() == 1) {
600 interpolated = false;
601 } else if (tokens.size() == 2) {
602 QL_REQUIRE(tokens[1] == "F" || tokens[1] == "L", "parseScriptedInflationIndex(): expected ...#[L|F], got ...#"
603 << tokens[1] << " in '" << indexName << "'");
604 interpolated = tokens[1] == "L";
605 } else {
606 QL_FAIL("parseScriptedInflationIndex(): expected IndexName or IndexName#[F|L], got '" << indexName << "'");
607 }
608 return std::make_pair(
609 parseZeroInflationIndex(plainIndexName, interpolated, Handle<ZeroInflationTermStructure>()),
610 plainIndexName);
611}
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex(const string &s, const Handle< ZeroInflationTermStructure > &h)
Convert std::string to QuantLib::ZeroInflationIndex.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scriptedIndexName()

std::string scriptedIndexName ( const QuantLib::ext::shared_ptr< Underlying > &  underlying)

Builds an index (EQ-SP5-EUR, FX-ECB-EUR-USD, ...) that can be used in scripted trades, from an underlying

Definition at line 614 of file utilities.cpp.

614 {
615 if (underlying->type() == "Equity") {
616 return "EQ-" + underlying->name();
617 } else if (underlying->type() == "FX") {
618 return "FX-" + underlying->name();
619 } else if (underlying->type() == "Commodity") {
620 QuantLib::ext::shared_ptr<CommodityUnderlying> comUnderlying =
621 QuantLib::ext::dynamic_pointer_cast<CommodityUnderlying>(underlying);
622 std::string tmp = "COMM-" + comUnderlying->name();
623 if (comUnderlying->priceType().empty() || comUnderlying->priceType() == "Spot") {
624 return tmp;
625 } else if (comUnderlying->priceType() == "FutureSettlement") {
626 tmp += "#" + std::to_string(comUnderlying->futureMonthOffset() == Null<Size>()
627 ? 0
628 : comUnderlying->futureMonthOffset());
629 if (comUnderlying->deliveryRollDays() != Null<Size>()) {
630 tmp += "#" + std::to_string(comUnderlying->deliveryRollDays());
631 if (!comUnderlying->deliveryRollCalendar().empty()) {
632 tmp += "#" + comUnderlying->deliveryRollCalendar();
633 }
634 }
635 return tmp;
636 } else {
637 QL_FAIL("underlying price type '" << comUnderlying->priceType() << "' for commodity underlying '"
638 << comUnderlying->name() << "' not handled.");
639 }
640 } else if (underlying->type() == "InterestRate") {
641 return underlying->name();
642 } else if (underlying->type() == "Inflation") {
643 QuantLib::ext::shared_ptr<InflationUnderlying> infUnderlying =
644 QuantLib::ext::dynamic_pointer_cast<InflationUnderlying>(underlying);
645 if (infUnderlying->interpolation() == QuantLib::CPI::InterpolationType::Linear)
646 return underlying->name() + "#L";
647 else if (infUnderlying->interpolation() == QuantLib::CPI::InterpolationType::Flat)
648 return underlying->name() + "#F";
649 else {
650 QL_FAIL("observation interpolation " << infUnderlying->interpolation()
651 << " not covered in scripted inflation indexes");
652 }
653 } else if (underlying->type() == "Basic") {
654 return underlying->name();
655 } else {
656 QL_FAIL("underlying type '" << underlying->type() << "' not handled.");
657 }
658}
+ Here is the caller graph for this function:

◆ getInflationSimulationLag()

Size getInflationSimulationLag ( const QuantLib::ext::shared_ptr< ZeroInflationIndex > &  index)

Get inflation simulation lag in calendar days

Definition at line 660 of file utilities.cpp.

660 {
661 // this is consistent with the lag computation in CrossAssetModel::infDki()
662 Date d1 = index->zeroInflationTermStructure()->baseDate();
663 Date d2 = index->zeroInflationTermStructure()->referenceDate();
664 QL_DEPRECATED_DISABLE_WARNING
665 if (!index->interpolated()) {
666 d2 = inflationPeriod(d2, index->frequency()).first;
667 }
668 QL_DEPRECATED_ENABLE_WARNING
669 return d2 - d1;
670}
+ Here is the caller graph for this function:

◆ getCalibrationStrikes()

std::map< std::string, std::vector< Real > > getCalibrationStrikes ( const std::vector< ScriptedTradeScriptData::CalibrationData > &  calibrationSpec,
const QuantLib::ext::shared_ptr< Context > &  context 
)

Get map index => calibration strikes as vector<Real> from calibration spec and context

Definition at line 673 of file utilities.cpp.

674 {
675 std::map<std::string, std::vector<Real>> result;
676 for (auto const& c : calibrationSpec) {
677
678 std::vector<std::string> indexNames;
679 // set up index
680 auto index = context->scalars.find(c.index());
681 if (index != context->scalars.end()) {
682 QL_REQUIRE(index->second.which() == ValueTypeWhich::Index,
683 "calibration index variable '" << c.index() << "' must evaluate to an index");
684 std::string indexName = QuantLib::ext::get<IndexVec>(index->second).value;
685 // replace fixing source tag in FX indices by GENERIC, since this is what is passed to the model
686 // TODO FX indices might be reorganised vs. a base ccy != their original target ccy, is there anything
687 // we can do to get an effective calibration at the specified deal strike?
688 IndexInfo info(indexName);
689 if (info.isFx())
690 indexName =
691 "FX-GENERIC-" + info.fx()->sourceCurrency().code() + "-" + info.fx()->targetCurrency().code();
692 indexNames.push_back(indexName);
693 } else {
694 auto indexes = context->arrays.find(c.index());
695 if (indexes != context->arrays.end()) {
696 for (Size i = 0; i < indexes->second.size(); ++i) {
697 QL_REQUIRE(indexes->second[i].which() == ValueTypeWhich::Index,
698 "calibration strike variable '" << c.index() << "[" << i
699 << "]' must evaluate to an index");
700 auto indexName = QuantLib::ext::get<IndexVec>(indexes->second[i]).value;
701 IndexInfo info(indexName);
702 if (info.isFx())
703 indexName = "FX-GENERIC-" + info.fx()->sourceCurrency().code() + "-" +
704 info.fx()->targetCurrency().code();
705 indexNames.push_back(indexName);
706 }
707 } else
708 QL_FAIL("did not find calibration index variable '" << c.index()
709 << "' (as scalar or array) in context");
710 }
711
712
713 // loop over calibration strikes for index
714 for (auto const& strikeStr : c.strikes()) {
715 auto strike = context->scalars.find(strikeStr);
716 if (strike != context->scalars.end()) {
717 QL_REQUIRE(strike->second.which() == ValueTypeWhich::Number,
718 "calibration strike variable '" << strikeStr << "' must evaluate to a number");
719 auto strikeNum = QuantLib::ext::get<RandomVariable>(strike->second);
720 QL_REQUIRE(strikeNum.deterministic(), "calibration strike variable '"
721 << strikeStr << "' must be deterministic, got "
722 << strikeNum);
723 QL_REQUIRE(indexNames.size() == 1, "Can only have one index if one strike provided");
724 result[indexNames.at(0)].push_back(strikeNum.at(0));
725 DLOG("add calibration strike for index '" << indexNames.at(0) << "': " << strikeNum.at(0));
726 } else {
727 auto strikeVec = context->arrays.find(strikeStr);
728 if (strikeVec != context->arrays.end()) {
729 QL_REQUIRE(strikeVec->second.size() % indexNames.size() == 0,
730 "StrikeVec must contain the same number of strikes for each index");
731 auto strikeSize = strikeVec->second.size() / indexNames.size();
732 Size ind = 0;
733 for (Size j = 0; j < indexNames.size(); j++) {
734 for (Size i = 0; i < strikeSize; ++i) {
735 QL_REQUIRE(strikeVec->second[ind].which() == ValueTypeWhich::Number,
736 "calibration strike variable '" << strikeStr << "[" << i
737 << "]' must evaluate to a number");
738 auto strikeNum = QuantLib::ext::get<RandomVariable>(strikeVec->second[ind]);
739 QL_REQUIRE(strikeNum.deterministic(), "calibration strike variable '"
740 "calibration strike variable '"
741 << strikeStr << "[" << i
742 << "]' must be deterministic, got "
743 << strikeNum);
744 result[indexNames[j]].push_back(strikeNum.at(0));
745 DLOG("add calibration strike for index '" << indexNames[j] << "' from : '" << strikeStr
746 << "[" << i << "]' " << strikeNum.at(0));
747 ind++;
748 }
749 }
750 } else {
751 WLOG("getCalibrationStrikes: did not find calibration strike variable '" << strikeStr
752 << "' (as scalar or array) in context forcalibration index variable '" << c.index());
753 }
754 }
755 }
756 }
757 return result;
758}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [51/73]

std::ostream & operator<< ( std::ostream &  out,
const EventVec a 
)

Definition at line 27 of file value.cpp.

27 {
28 out << a.value;
29 return out;
30}

◆ operator<<() [52/73]

std::ostream & operator<< ( std::ostream &  out,
const CurrencyVec a 
)

Definition at line 32 of file value.cpp.

32 {
33 out << a.value;
34 return out;
35}
std::string value
Definition: value.hpp:47

◆ operator<<() [53/73]

std::ostream & operator<< ( std::ostream &  out,
const IndexVec a 
)

Definition at line 37 of file value.cpp.

37 {
38 out << a.value;
39 return out;
40}
std::string value
Definition: value.hpp:52

◆ operator<<() [54/73]

std::ostream & operator<< ( std::ostream &  out,
const DaycounterVec a 
)

Definition at line 42 of file value.cpp.

42 {
43 out << a.value;
44 return out;
45}
std::string value
Definition: value.hpp:57

◆ deterministic()

bool deterministic ( const ValueType v)

Definition at line 144 of file value.cpp.

144{ return boost::apply_visitor(IsDet(), v); }
+ Here is the caller graph for this function:

◆ size()

Size size ( const ValueType v)

Definition at line 145 of file value.cpp.

145{ return boost::apply_visitor(SizeGetter(), v); }
+ Here is the caller graph for this function:

◆ operator==() [9/13]

bool operator== ( const EventVec a,
const EventVec b 
)

Definition at line 147 of file value.cpp.

147{ return a.value == b.value && a.size == b.size; }

◆ operator==() [10/13]

bool operator== ( const CurrencyVec a,
const CurrencyVec b 
)

Definition at line 148 of file value.cpp.

148{ return a.value == b.value && a.size == b.size; }

◆ operator==() [11/13]

bool operator== ( const IndexVec a,
const IndexVec b 
)

Definition at line 149 of file value.cpp.

149{ return a.value == b.value && a.size == b.size; }

◆ operator==() [12/13]

bool operator== ( const DaycounterVec a,
const DaycounterVec b 
)

Definition at line 150 of file value.cpp.

150{ return a.value == b.value && a.size == b.size; }

◆ operator+()

ValueType operator+ ( const ValueType x,
const ValueType y 
)

Definition at line 152 of file value.cpp.

152 {
153 return boost::apply_visitor(
154 BinaryOp([](const RandomVariable& x, const RandomVariable& y) -> RandomVariable { return x + y; }), x, y);
155}

◆ operator-() [1/2]

ValueType operator- ( const ValueType x,
const ValueType y 
)

Definition at line 157 of file value.cpp.

157 {
158 return boost::apply_visitor(
159 BinaryOp([](const RandomVariable& x, const RandomVariable& y) -> RandomVariable { return x - y; }), x, y);
160}

◆ operator*()

ValueType operator* ( const ValueType x,
const ValueType y 
)

Definition at line 162 of file value.cpp.

162 {
163 return boost::apply_visitor(
164 BinaryOp([](const RandomVariable& x, const RandomVariable& y) -> RandomVariable { return x * y; }), x, y);
165}

◆ operator/()

ValueType operator/ ( const ValueType x,
const ValueType y 
)

Definition at line 167 of file value.cpp.

167 {
168 return boost::apply_visitor(
169 BinaryOp([](const RandomVariable& x, const RandomVariable& y) -> RandomVariable { return x / y; }), x, y);
170}

◆ min() [1/2]

ValueType min ( const ValueType x,
const ValueType y 
)

Definition at line 172 of file value.cpp.

172 {
173 return boost::apply_visitor(
174 BinaryOp([](const RandomVariable& x, const RandomVariable& y) -> RandomVariable { return min(x, y); }), x, y);
175}
RandomVariable min(RandomVariable x, const RandomVariable &y)
+ Here is the call graph for this function:

◆ max() [1/2]

ValueType max ( const ValueType x,
const ValueType y 
)

Definition at line 177 of file value.cpp.

177 {
178 return boost::apply_visitor(
179 BinaryOp([](const RandomVariable& x, const RandomVariable& y) -> RandomVariable { return max(x, y); }), x, y);
180}
RandomVariable max(RandomVariable x, const RandomVariable &y)
+ Here is the call graph for this function:

◆ pow()

ValueType pow ( const ValueType x,
const ValueType y 
)

Definition at line 182 of file value.cpp.

182 {
183 return boost::apply_visitor(
184 BinaryOp([](const RandomVariable& x, const RandomVariable& y) -> RandomVariable { return pow(x, y); }), x, y);
185}
RandomVariable pow(RandomVariable x, const RandomVariable &y)
+ Here is the call graph for this function:

◆ operator-() [2/2]

ValueType operator- ( const ValueType x)

Definition at line 187 of file value.cpp.

187{ return boost::apply_visitor(UnaryOp(std::negate<RandomVariable>()), x); }

◆ abs()

ValueType abs ( const ValueType x)

Definition at line 189 of file value.cpp.

189 {
190 return boost::apply_visitor(UnaryOp([](const RandomVariable& x) -> RandomVariable { return abs(x); }), x);
191}
+ Here is the call graph for this function:

◆ exp()

ValueType exp ( const ValueType x)

Definition at line 193 of file value.cpp.

193 {
194 return boost::apply_visitor(UnaryOp([](const RandomVariable& x) -> RandomVariable { return exp(x); }), x);
195}
RandomVariable exp(RandomVariable x)
+ Here is the call graph for this function:

◆ log()

ValueType log ( const ValueType x)

Definition at line 197 of file value.cpp.

197 {
198 return boost::apply_visitor(UnaryOp([](const RandomVariable& x) -> RandomVariable { return log(x); }), x);
199}
+ Here is the call graph for this function:

◆ sqrt()

ValueType sqrt ( const ValueType x)

Definition at line 201 of file value.cpp.

201 {
202 return boost::apply_visitor(UnaryOp([](const RandomVariable& x) -> RandomVariable { return sqrt(x); }), x);
203}
RandomVariable sqrt(RandomVariable x)
+ Here is the call graph for this function:

◆ normalCdf()

ValueType normalCdf ( const ValueType x)

Definition at line 205 of file value.cpp.

205 {
206 return boost::apply_visitor(UnaryOp([](const RandomVariable& x) -> RandomVariable { return normalCdf(x); }), x);
207}
RandomVariable normalCdf(RandomVariable x)
+ Here is the call graph for this function:

◆ normalPdf()

ValueType normalPdf ( const ValueType x)

Definition at line 209 of file value.cpp.

209 {
210 return boost::apply_visitor(UnaryOp([](const RandomVariable& x) -> RandomVariable { return normalPdf(x); }), x);
211}
RandomVariable normalPdf(RandomVariable x)
+ Here is the call graph for this function:

◆ typeSafeAssign()

ValueType typeSafeAssign ( ValueType x,
const ValueType y 
)

Definition at line 213 of file value.cpp.

213{ return boost::apply_visitor(Assignment(), x, y); }
+ Here is the caller graph for this function:

◆ equal()

Filter equal ( const ValueType x,
const ValueType y 
)

Definition at line 215 of file value.cpp.

215 {
216 return boost::apply_visitor(
217 BinaryComp(
218 [](const RandomVariable& x, const RandomVariable& y) -> Filter { return close_enough(x, y); },
219 [](const EventVec& x, const EventVec& y) -> Filter {
220 QL_REQUIRE(x.size == y.size, "inconsistent size EventVec (" << x.size << ", " << y.size << ")");
221 return Filter(x.size, x.value == y.value);
222 },
223 [](const IndexVec& x, const IndexVec& y) -> Filter {
224 QL_REQUIRE(x.size == y.size, "inconsistent size IndexVec (" << x.size << ", " << y.size << ")");
225 return Filter(x.size, x.value == y.value);
226 },
227 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter {
228 QL_REQUIRE(x.size == y.size, "inconsistent size CurrencyVec (" << x.size << ", " << y.size << ")");
229 return Filter(x.size, x.value == y.value);
230 },
231 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
232 QL_REQUIRE(x.size == y.size, "inconsistent size DaycounterVec (" << x.size << ", " << y.size << ")");
233 return Filter(x.size, x.value == y.value);
234 },
235 [](const Filter& x, const Filter& y) -> Filter { return equal(x, y); }),
236 x, y);
237}
Filter equal(Filter x, const Filter &y)
+ Here is the call graph for this function:

◆ notequal()

Filter notequal ( const ValueType x,
const ValueType y 
)

Definition at line 239 of file value.cpp.

239 {
240 return boost::apply_visitor(
241 BinaryComp(
242 [](const RandomVariable& x, const RandomVariable& y) -> Filter { return !close_enough(x, y); },
243 [](const EventVec& x, const EventVec& y) -> Filter {
244 QL_REQUIRE(x.size == y.size, "inconsistent size EventVec (" << x.size << ", " << y.size << ")");
245 return Filter(x.size, x.value != y.value);
246 },
247 [](const IndexVec& x, const IndexVec& y) -> Filter {
248 QL_REQUIRE(x.size == y.size, "inconsistent size IndexVec (" << x.size << ", " << y.size << ")");
249 return Filter(x.size, x.value != y.value);
250 },
251 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter {
252 QL_REQUIRE(x.size == y.size, "inconsistent size CurrencyVec (" << x.size << ", " << y.size << ")");
253 return Filter(x.size, x.value != y.value);
254 },
255 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
256 QL_REQUIRE(x.size == y.size, "inconsistent size DaycounterVec (" << x.size << ", " << y.size << ")");
257 return Filter(x.size, x.value != y.value);
258 },
259 [](const Filter& x, const Filter& y) -> Filter { return !equal(x, y); }),
260 x, y);
261}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lt()

Filter lt ( const ValueType x,
const ValueType y 
)

Definition at line 263 of file value.cpp.

263 {
264 return boost::apply_visitor(
265 BinaryComp(
266 [](const RandomVariable& x, const RandomVariable& y) -> Filter { return x < y; },
267 [](const EventVec& x, const EventVec& y) -> Filter {
268 QL_REQUIRE(x.size == y.size, "inconsistent size EventVec (" << x.size << ", " << y.size << ")");
269 return Filter(x.size, x.value < y.value);
270 },
271 [](const IndexVec& x, const IndexVec& y) -> Filter { QL_FAIL("invalid comparison lt for IndexVec"); },
272 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter {
273 QL_FAIL("invalid comparison lt for CurrencyVec");
274 },
275 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
276 QL_FAIL("invalid comparison lt for DaycounterVec");
277 },
278 [](const Filter& x, const Filter& y) -> Filter { QL_FAIL("invalid comparison lt for Filter"); }),
279 x, y);
280}
+ Here is the caller graph for this function:

◆ gt()

Filter gt ( const ValueType x,
const ValueType y 
)

Definition at line 282 of file value.cpp.

282 {
283 return boost::apply_visitor(
284 BinaryComp(
285 [](const RandomVariable& x, const RandomVariable& y) -> Filter { return x > y; },
286 [](const EventVec& x, const EventVec& y) -> Filter {
287 QL_REQUIRE(x.size == y.size, "inconsistent size EventVec (" << x.size << ", " << y.size << ")");
288 return Filter(x.size, x.value > y.value);
289 },
290 [](const IndexVec& x, const IndexVec& y) -> Filter { QL_FAIL("invalid comparison gt for IndexVec"); },
291 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter {
292 QL_FAIL("invalid comparison gt for CurrencyVec");
293 },
294 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
295 QL_FAIL("invalid comparison gt for DaycounterVec");
296 },
297 [](const Filter& x, const Filter& y) -> Filter { QL_FAIL("invalid comparison gt for Filter"); }),
298 x, y);
299}
+ Here is the caller graph for this function:

◆ leq()

Filter leq ( const ValueType x,
const ValueType y 
)

Definition at line 301 of file value.cpp.

301 {
302 return boost::apply_visitor(
303 BinaryComp(
304 [](const RandomVariable& x, const RandomVariable& y) -> Filter { return x <= y; },
305 [](const EventVec& x, const EventVec& y) -> Filter {
306 QL_REQUIRE(x.size == y.size, "inconsistent size EventVec (" << x.size << ", " << y.size << ")");
307 return Filter(x.size, x.value <= y.value);
308 },
309 [](const IndexVec& x, const IndexVec& y) -> Filter { QL_FAIL("invalid comparison leq for IndexVec"); },
310 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter {
311 QL_FAIL("invalid comparison leq for CurrencyVec");
312 },
313 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
314 QL_FAIL("invalid comparison leq for DaycounterVec");
315 },
316 [](const Filter& x, const Filter& y) -> Filter { QL_FAIL("invalid comparison leq for Filter"); }),
317
318 x, y);
319}
+ Here is the caller graph for this function:

◆ geq()

Filter geq ( const ValueType x,
const ValueType y 
)

Definition at line 321 of file value.cpp.

321 {
322 return boost::apply_visitor(
323 BinaryComp(
324 [](const RandomVariable& x, const RandomVariable& y) -> Filter { return x >= y; },
325 [](const EventVec& x, const EventVec& y) -> Filter {
326 QL_REQUIRE(x.size == y.size, "inconsistent size EventVec (" << x.size << ", " << y.size << ")");
327 return Filter(x.size, x.value >= y.value);
328 },
329 [](const IndexVec& x, const IndexVec& y) -> Filter { QL_FAIL("invalid comparison geq for IndexVec"); },
330 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter {
331 QL_FAIL("invalid comparison geq for CurrencyVec");
332 },
333 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
334 QL_FAIL("invalid comparison geq for DaycounterVec");
335 },
336 [](const Filter& x, const Filter& y) -> Filter { QL_FAIL("invalid comparison geq for Filter"); }),
337
338 x, y);
339}
+ Here is the caller graph for this function:

◆ logicalNot()

Filter logicalNot ( const ValueType x)

Definition at line 341 of file value.cpp.

341 {
342 return boost::apply_visitor(
343 UnaryComp([](const RandomVariable& x) -> Filter { QL_FAIL("invalid logicalNot for RandomVariable"); },
344 [](const EventVec& x) -> Filter { QL_FAIL("invalid logicalNot for EventVec"); },
345 [](const IndexVec& x) -> Filter { QL_FAIL("invalid logicalNot for IndexVec"); },
346 [](const CurrencyVec& x) -> Filter { QL_FAIL("invalid logicalNot for CurrencyVec"); },
347 [](const DaycounterVec& x) -> Filter { QL_FAIL("invalid logicalNot for DaycounterVec"); },
348 [](const Filter& x) -> Filter { return !x; }),
349 x);
350}

◆ logicalAnd()

Filter logicalAnd ( const ValueType x,
const ValueType y 
)

Definition at line 352 of file value.cpp.

352 {
353 return boost::apply_visitor(
354 BinaryComp(
355 [](const RandomVariable& x, const RandomVariable& y) -> Filter {
356 QL_FAIL("invalid logicalAnd for RandomVariable");
357 },
358 [](const EventVec& x, const EventVec& y) -> Filter { QL_FAIL("invalid logicalAnd for EventVec"); },
359 [](const IndexVec& x, const IndexVec& y) -> Filter { QL_FAIL("invalid logicalAnd for IndexVec"); },
360 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter { QL_FAIL("invalid logicalAnd for CurrencyVec"); },
361 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
362 QL_FAIL("invalid logicalAnd for DaycounterVec");
363 },
364 [](const Filter& x, const Filter& y) -> Filter { return x && y; }),
365 x, y);
366}

◆ logicalOr()

Filter logicalOr ( const ValueType x,
const ValueType y 
)

Definition at line 368 of file value.cpp.

368 {
369 return boost::apply_visitor(
370 BinaryComp(
371 [](const RandomVariable& x, const RandomVariable& y) -> Filter {
372 QL_FAIL("invalid logicalOr for RandomVariable");
373 },
374 [](const EventVec& x, const EventVec& y) -> Filter { QL_FAIL("invalid logicalOr for EventVec"); },
375 [](const IndexVec& x, const IndexVec& y) -> Filter { QL_FAIL("invalid logicalOr for IndexVec"); },
376 [](const CurrencyVec& x, const CurrencyVec& y) -> Filter { QL_FAIL("invalid logicalOr for CurrencyVec"); },
377 [](const DaycounterVec& x, const DaycounterVec& y) -> Filter {
378 QL_FAIL("invalid logicalOr for DaycounterVec");
379 },
380 [](const Filter& x, const Filter& y) -> Filter { return x || y; }),
381 x, y);
382}

◆ operator<() [14/14]

bool operator< ( const CorrelationFactor lhs,
const CorrelationFactor rhs 
)

Definition at line 42 of file correlationmatrix.cpp.

42 {
43 return tie(lhs.type, lhs.name, lhs.index) < tie(rhs.type, rhs.name, rhs.index);
44}
QuantExt::CrossAssetModel::AssetType type

◆ operator==() [13/13]

bool operator== ( const CorrelationFactor lhs,
const CorrelationFactor rhs 
)

Definition at line 46 of file correlationmatrix.cpp.

46 {
47 return lhs.type == rhs.type && lhs.name == rhs.name && lhs.index == rhs.index;
48}

◆ operator!=() [4/4]

bool operator!= ( const CorrelationFactor lhs,
const CorrelationFactor rhs 
)

Definition at line 50 of file correlationmatrix.cpp.

50 {
51 return !(lhs == rhs);
52}

◆ operator<<() [55/73]

std::ostream & operator<< ( ostream &  out,
const CorrelationFactor f 
)

Allow CorrelationFactors to be written.

Definition at line 54 of file correlationmatrix.cpp.

54 {
55 return out << f.type << ":" << f.name << ":" << f.index;
56}

◆ parseCorrelationFactor()

CorrelationFactor parseCorrelationFactor ( const std::string &  name,
const char  separator = ':' 
)

Parse a correlation factor name. For example, a name like IR:EUR is parsed to a CorrelationFactor with type, name and index set to IR, EUR and 0 respectively. Note that the name is of the form type:name and the index is always set to 0 initially. The actual index is set separately.

Definition at line 58 of file correlationmatrix.cpp.

58 {
59
60 std::string sep(1, separator);
61 vector<string> tokens;
62 boost::split(tokens, name, boost::is_any_of(sep));
63
64 QL_REQUIRE(tokens.size() == 2 || tokens.size() == 3,
65 "parseCorrelationFactor(" << name << "): expected 2 or 3 tokens separated by separator ('" << sep
66 << "'), e.g. 'IR" << sep << "USD' or 'INF" << sep << "UKRPI" << sep << "0'");
67
68 return {parseCamAssetType(tokens[0]), tokens[1],
69 static_cast<Size>(tokens.size() == 3 ? parseInteger(tokens[3]) : 0)};
70}
QuantExt::CrossAssetModel::AssetType parseCamAssetType(const string &s)
Definition: parsers.cpp:839
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadCurrencyHedgedIndexDecomposition() [1/2]

QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexDecomposition > loadCurrencyHedgedIndexDecomposition ( const std::string &  name,
const QuantLib::ext::shared_ptr< ReferenceDataManager > &  refDataMgr,
const QuantLib::ext::shared_ptr< CurveConfigurations > &  curveConfigs 
)

Definition at line 16 of file currencyhedgedequityindexdecomposition.cpp.

17 {
18 QuantLib::ext::shared_ptr<CurrencyHedgedEquityIndexReferenceDatum> indexRefData;
19 QuantLib::ext::shared_ptr<EquityIndexReferenceDatum> underlyingRefData;
20 std::map<std::string, std::pair<double, std::string>> currencyWeightsAndFxIndexNames;
21
22 if (refDataMgr) {
23 if (refDataMgr->hasData("CurrencyHedgedEquityIndex", name))
24 indexRefData = QuantLib::ext::dynamic_pointer_cast<CurrencyHedgedEquityIndexReferenceDatum>(
25 refDataMgr->getData("CurrencyHedgedEquityIndex", name));
26
27 if (indexRefData != nullptr && refDataMgr->hasData("EquityIndex", indexRefData->underlyingIndexName()))
28 underlyingRefData = QuantLib::ext::dynamic_pointer_cast<EquityIndexReferenceDatum>(
29 refDataMgr->getData("EquityIndex", indexRefData->underlyingIndexName()));
30 }
31
32 if (indexRefData == nullptr || underlyingRefData == nullptr) {
33 return nullptr;
34 }
35
36 // Load currency Weights
37 std::map<std::string, double> currencyWeights;
38 std::string indexCurrency;
39 std::string underlyingIndexCurrency;
40 std::string fxIndexName;
41
42 // Get currency hedged index currency
43 if (curveConfigs && curveConfigs->hasEquityCurveConfig(indexRefData->id())) {
44 indexCurrency = curveConfigs->equityCurveConfig(indexRefData->id())->currency();
45 } else {
46 WLOG("Can not find curveConfig for " << indexRefData->id() << " and can not determine the index currecy");
47 return nullptr;
48 }
49
50
51 if (curveConfigs && curveConfigs->hasEquityCurveConfig(indexRefData->underlyingIndexName())) {
52
53 // Get Fx Index to convert UnderlyingIndexCCY into HedgedIndexCurrency
54 std::string underlyingIndexName = indexRefData->underlyingIndexName();
55 underlyingIndexCurrency =
56 curveConfigs->equityCurveConfig(indexRefData->underlyingIndexName())->currency();
57
58 auto fxIndexIt = indexRefData->fxIndexes().find(underlyingIndexCurrency);
59 if (fxIndexIt != indexRefData->fxIndexes().end()) {
60 fxIndexName = fxIndexIt->second;
61 } else {
62 fxIndexName = "FX-GENERIC-" + indexCurrency + "-" + underlyingIndexCurrency;
63 }
64
65 // Load the currency weights at referenceDate for hedge notionals
66 QuantLib::Date refDate =
67 CurrencyHedgedEquityIndexDecomposition::referenceDate(indexRefData, Settings::instance().evaluationDate());
68
69 std::map<std::string, double> underlyingIndexWeightsAtRebalancing;
70
71 if (indexRefData->currencyWeights().empty()) {
72 QuantLib::ext::shared_ptr<ReferenceDatum> undIndexRefDataAtRefDate;
73 try {
74 undIndexRefDataAtRefDate = refDataMgr->getData("EquityIndex", underlyingIndexName, refDate);
75 } catch (...) {
76 // Try to load ref data, but don't throw on error
77 }
78 if (undIndexRefDataAtRefDate) {
79 underlyingIndexWeightsAtRebalancing =
80 QuantLib::ext::dynamic_pointer_cast<EquityIndexReferenceDatum>(undIndexRefDataAtRefDate)->underlyings();
81 }
82 } else {
83 underlyingIndexWeightsAtRebalancing = indexRefData->currencyWeights();
84 }
85
86 if (underlyingIndexWeightsAtRebalancing.empty()) {
87 currencyWeights[underlyingIndexCurrency] = 1.0;
88 } else {
89 for (const auto& [name, weight] : underlyingIndexWeightsAtRebalancing) {
90 // try look up currency in reference data and add if FX delta risk if necessary
91 if (curveConfigs->hasEquityCurveConfig(name)) {
92 auto ecc = curveConfigs->equityCurveConfig(name);
93 auto eqCcy = ecc->currency();
94 currencyWeights[eqCcy] += weight;
95 } else {
96 // Assume Index currency
97 currencyWeights[underlyingIndexCurrency] += weight;
98 }
99 }
100 }
101 }
102
103 for (const auto& [currency, weight] : currencyWeights) {
104 if (currency != indexCurrency) {
105 auto defaultIndexIt = indexRefData->fxIndexes().find(currency);
106 if (defaultIndexIt != indexRefData->fxIndexes().end()) {
107 currencyWeightsAndFxIndexNames[currency] = std::make_pair(weight, defaultIndexIt->second);
108 } else {
109 currencyWeightsAndFxIndexNames[currency] =
110 std::make_pair(weight, "FX-GENERIC-" + indexCurrency + "-" + currency);
111 }
112 }
113 }
114 return QuantLib::ext::make_shared<CurrencyHedgedEquityIndexDecomposition>(name, indexRefData, underlyingRefData,
115 indexCurrency, underlyingIndexCurrency,
116 fxIndexName, currencyWeightsAndFxIndexNames);
117}
vector< string > curveConfigs
+ Here is the call graph for this function:

◆ loadCurrencyHedgedIndexDecomposition() [2/2]

QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexDecomposition > loadCurrencyHedgedIndexDecomposition ( const std::string &  name,
const QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > &  refDataMgr,
const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &  curveConfigs 
)

◆ dataBuilders()

void dataBuilders ( )

Definition at line 219 of file databuilders.cpp.

219 {
220
221 static boost::shared_mutex mutex;
222 static bool hasRun = false;
223
224 boost::unique_lock<boost::shared_mutex> lock(mutex);
225
226 if (hasRun)
227 return;
228
229 hasRun = true;
230
231 ORE_REGISTER_LEG_DATA("Cashflow", CashflowData, false)
232 ORE_REGISTER_LEG_DATA("Fixed", FixedLegData, false)
233 ORE_REGISTER_LEG_DATA("ZeroCouponFixed", ZeroCouponFixedLegData, false)
234 ORE_REGISTER_LEG_DATA("Floating", FloatingLegData, false)
235 ORE_REGISTER_LEG_DATA("CPI", CPILegData, false)
237 ORE_REGISTER_LEG_DATA("CMS", CMSLegData, false)
238 ORE_REGISTER_LEG_DATA("CMB", CMBLegData, false)
239 ORE_REGISTER_LEG_DATA("DigitalCMS", DigitalCMSLegData, false)
240 ORE_REGISTER_LEG_DATA("CMSSpread", CMSSpreadLegData, false)
241 ORE_REGISTER_LEG_DATA("DigitalCMSSpread", DigitalCMSSpreadLegData, false)
242 ORE_REGISTER_LEG_DATA("Equity", EquityLegData, false)
243 ORE_REGISTER_LEG_DATA("CommodityFixed", CommodityFixedLegData, false)
244 ORE_REGISTER_LEG_DATA("CommodityFloating", CommodityFloatingLegData, false)
245 ORE_REGISTER_LEG_DATA("DurationAdjustedCMS", DurationAdjustedCmsLegData, false)
246 ORE_REGISTER_LEG_DATA("EquityMargin", EquityMarginLegData, false)
247 ORE_REGISTER_LEG_DATA("FormulaBased", FormulaBasedLegData, false)
248
252
264
267
290 ORE_REGISTER_TRADE_BUILDER("EquityVarianceSwap", EqVarSwap, false)
291 ORE_REGISTER_TRADE_BUILDER("FxVarianceSwap", FxVarSwap, false)
292 ORE_REGISTER_TRADE_BUILDER("CommodityVarianceSwap", ComVarSwap, false)
327
328 ORE_REGISTER_TRADE_BUILDER("TotalReturnSwap", TRS, false)
329 ORE_REGISTER_TRADE_BUILDER("ContractForDifference", CFD, false)
336
372 ORE_REGISTER_TRADE_BUILDER("EquityPairwiseVarianceSwap", EqPairwiseVarSwap, false)
373 ORE_REGISTER_TRADE_BUILDER("FxPairwiseVarianceSwap", FxPairwiseVarSwap, false)
374
378
396
404
406
510
518
520
526
529
534
544
547}
Accrual Bond Repo Engine Builder.
Definition: bondrepo.hpp:54
Balance Guaranteed Swap Discounting Engine Builder.
Balance Guaranteed Swap Flexi Swap LGM Grid Engine Builder.
Serializable Balance Guaranteed Swap.
Black CDS option engine builder for CDS options.
Black CDS option engine builder for index CDS options.
Bond Basket Reference Data.
Discounting Engine Builder class for Bonds.
Definition: bond.hpp:65
Multi State Engine Builder class for Bonds.
Definition: bond.hpp:114
Engine builder for bond option.
Definition: bondoption.hpp:49
Serializable Constant Maturity Bond Yield Leg Data.
Definition: legdata.hpp:687
Serializable CMS Leg Data.
Definition: legdata.hpp:414
Serializable CMS Spread Leg Data.
Definition: legdata.hpp:548
Serializable CPI Leg Data.
Definition: legdata.hpp:281
Serializable Swaption.
Multileg option engine builder for external cam, with additional simulation dates (AMC)
FX forward engine builder for external cam, with additional simulation dates (AMC)
Definition: fxforward.hpp:72
FX option engine builder for external cam, with additional simulation dates (AMC)
Definition: fxoption.hpp:74
Multileg option engine builder for external cam, with additional simulation dates (AMC)
Implementation of SwapEngineBuilderBase using MC pricer for external cam / AMC.
Definition: swap.hpp:153
MultiLeg option engine builder for MC pricer.
Engine Builder for Caps, Floors and Collars on an IborIndex.
Definition: capfloor.hpp:36
Serializable cap, floor, collar.
Definition: capfloor.hpp:37
CouponPricer Builder for CapFlooredAVerageBMACouponLeg.
CouponPricer Builder for CapFlooredOvernightIndexedCouponLeg.
CouponPricer Builder for Capped/Floored CPI Inflation Leg.
CouponPricer Builder for CapFlooredIborLeg.
CouponPricer Builder for Capped/Floored YoY Inflation Leg.
CouponPricer Builder for CapFlooredOvernightIndexedCouponLeg.
CouponPricer Builder for Capped/Floored YoY Inflation Leg.
Serializable Cashflow Leg Data.
Definition: legdata.hpp:89
CouponPricer Builder for CmsSpreadLeg.
Definition: cmsspread.hpp:43
Analytical Engine builder for Commodity Average Price Options.
Monte Carlo Engine builder for Commodity Average Price Options.
Commodity digital option trade representation as call spread.
Continuous Analytic Engine Builder for European Asian Commodity Geometric Average Price Options.
Discrete Analytic Engine Builder for European Asian Commodity Geometric Average Price Options.
Discrete Analytic Engine Builder for European Asian Commodity Geometric Average Strike Options.
Discrete Monte Carlo Engine Builder for European Asian Commodity Arithmetic Average Price Options.
Discrete Monte Carlo Engine Builder for European Asian Commodity Arithmetic Average Strike Options.
Discrete Monte Carlo Engine Builder for European Asian Commodity Geometric Average Price Options.
Discrete Analytic TW Engine Builder for European Asian Commodity Arithmetic Average Price Options.
Engine builder for commodity forward.
EquityIndex Reference data, contains the names and weights of an equity index.
Commodity option trade representation.
Serializable Commodity Position.
Analytical Engine builder for Commodity Spread Options.
Engine builder for Commodity Swaps.
Analytical Approximation Engine builder for Commodity Swaptions.
Monte Carlo Engine builder for Commodity Swaptions.
Composite Trade class.
Engine Builder for CPI Caps, Floors and Collars.
Definition: cpicapfloor.hpp:37
Credit index reference data, contains a set of index constituents.
CreditIndex Reference data, contains the names and weights of a credit index.
Discounted Cashflows Engine Builder for Cross Currency Swaps.
Definition: swap.hpp:126
Engine Builder for Cross Currency Swaps.
Serializable Digital CMS Leg Data.
Definition: legdata.hpp:479
Serializable Digital CMS Spread Leg Data.
Definition: legdata.hpp:620
Discounting Bond Repo Engine Builder.
Definition: bondrepo.hpp:45
Engine Builder for American Equity Options using Barone Adesi Whaley Approximation.
Engine Builder for American Equity Options using Finite Difference Method.
Serializable EQ Barrier Option.
Engine Builder for European EQ Digital Options.
Serializable EQ Digital Option.
Serializable Equity Double Barrier Option.
Analytical Engine Builder for EQ Double Touch Options.
SerializableEQ Double One-Touch/No-Touch Option.
Continuous Analytic Engine Builder for European Asian Equity Geometric Average Price Options.
Discrete Analytic Engine Builder for European Asian Equity Geometric Average Price Options.
Discrete Analytic Engine Builder for European Asian Equity Geometric Average Strike Options.
Discrete Monte Carlo Engine Builder for European Asian Equity Arithmetic Average Price Options.
Discrete Monte Carlo Engine Builder for European Asian Equity Arithmetic Average Strike Options.
Discrete Monte Carlo Engine Builder for European Asian Equity Geometric Average Price Options.
Discrete Analytic TW Engine Builder for European Asian Equity Arithmetic Average Price Options.
Serializable EQ European Barrier Option.
Engine Builder for Composite European Equity Options.
Engine Builder for European Equity Options with analytical sensitivities.
Engine Builder for European Equity Option Options.
Engine Builder for European Equity Forwards.
Serializable EQ Futures Option.
EquityIndex Reference data, contains the names and weights of an equity index.
Serializable Fixed Leg Data.
Definition: legdata.hpp:754
Serializable Equity Margin Leg Data.
Serializable Equity Option.
Serializable Equity Option Position.
Engine Builder for EQ Outperformance Option.
Serializable EQ Outperformance Option.
Serializable Equity Position.
Serializable Equity Swap contract.
Definition: equityswap.hpp:37
Engine Builder for EQ Touch Options.
Serializable EQ One-Touch/No-Touch Option.
European Swaption Engine Builder.
Definition: swaption.hpp:57
Serializable Fixed Leg Data.
Definition: legdata.hpp:117
Flexi Swap Discounting Engine Builder.
Definition: flexiswap.hpp:82
Serializable Flexi-Swap.
Definition: flexiswap.hpp:36
Flexi Swap LGM Grid Engine Builder.
Definition: flexiswap.hpp:88
Serializable Floating Leg Data.
Definition: legdata.hpp:179
Serializable ForwardRateAgreement.
Engine Builder for American Fx Options using Barone Adesi Whaley Approximation.
Definition: fxoption.hpp:67
Engine Builder for American Fx Options using Finite Difference Method.
Definition: fxoption.hpp:56
Serializable Fx Average Forward.
Serializable FX Barrier Option.
Engine Builder for European FX Digital Barrier Options.
Serializable FX Digital Barrier Option.
Engine Builder for European cash-settled FX Digital Options.
Engine Builder for European FX Digital Options.
Serializable FX Digital Option.
Analytical Engine Builder for FX Double Barrier Options.
Serializable FX Double Barrier Option.
Analytical Engine Builder for FX Double Touch Options.
Serializable FX Double One-Touch/No-Touch Option.
Continuous Analytic Engine Builder for European Asian Fx Geometric Average Price Options.
Discrete Analytic Engine Builder for European Asian Fx Geometric Average Price Options.
Discrete Analytic Engine Builder for European Asian Fx Geometric Average Strike Options.
Discrete Monte Carlo Engine Builder for European Asian Fx Arithmetic Average Price Options.
Discrete Monte Carlo Engine Builder for European Asian Fx Arithmetic Average Strike Options.
Discrete Monte Carlo Engine Builder for European Asian Fx Geometric Average Price Options.
Discrete Analytic TW Engine Builder for European Asian Fx Arithmetic Average Price Options.
Serializable FX European Barrier Option.
Engine Builder for European FX Options with analytical sensitivities.
Engine Builder for European Fx Option Options.
Definition: fxoption.hpp:37
Engine Builder for FX Forwards.
Definition: fxforward.hpp:54
Serializable FX KIKO Barrier Option.
Serializable FX Option.
Definition: fxoption.hpp:38
Serializable FX Swap.
Definition: fxswap.hpp:36
Engine Builder for FX Touch Options.
Serializable FX One-Touch/No-Touch Option.
Serializable Cross Currency Swap contract.
Implementation of BermudanAmericanSwaptionEngineBuilder using LGM FD pricer.
Definition: swaption.hpp:94
Implementation of BermudanAmericanSwaptionEngineBuilder using LGM Grid pricer.
Definition: swaption.hpp:82
Implementation of LGMBermudanAmericanSwaptionEngineBuilder using MC pricer.
Definition: swaption.hpp:106
Midpoint engine builder class for credit default swaps.
Multi State Engine Builder class for CDS.
Midpoint Engine Builder class for IndexCreditDefaultSwaps.
Engine Builder for Pairwise Variance Swaps.
Engine Builder for Quanto European Equity Option Options.
RPA Numeric LGM engine builder for swap underlyings.
RPA Numeric LGM engine builder for tlock underlyings.
Engine Builder for Single Currency Swaps.
Engine Builder for Single Currency Swaps.
Definition: swap.hpp:65
Engine Builder for Single Currency Swaps.
Definition: swap.hpp:86
Serializable Swap, Single and Cross Currency.
Definition: swap.hpp:36
Serializable Swaption.
Definition: swaption.hpp:39
Engine Builder for Variance Swaps.
Engine Builder for Year on Year Caps, Floors and Collars on an IborIndex.
Definition: yoycapfloor.hpp:37
Serializable YoY Leg Data.
Definition: legdata.hpp:349
Serializable Fixed Leg Data.
Definition: legdata.hpp:145
#define ORE_REGISTER_LEG_DATA(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_LEGBUILDER(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_TRS_UNDERLYING_BUILDER(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_REFERENCE_DATUM(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_BOND_BUILDER(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_CALIBRATION_INSTRUMENT(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_COMPUTE_FRAMEWORK_CREATOR(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_TRADE_BUILDER(NAME, CLASS, OVERWRITE)
#define ORE_REGISTER_AMC_ENGINE_BUILDER(CLASS, OVERWRITE)
#define ORE_REGISTER_ENGINE_BUILDER(CLASS, OVERWRITE)
#define ORE_REGISTER_AMCCG_ENGINE_BUILDER(CLASS, OVERWRITE)

◆ generateShiftedDateGrid()

QuantLib::ext::shared_ptr< DateGrid > generateShiftedDateGrid ( const QuantLib::ext::shared_ptr< DateGrid > &  dg,
const QuantLib::Period &  shift 
)

Definition at line 312 of file dategrid.cpp.

313 {
314 DLOG("Building shifted date grid with shift of " << shift);
315 vector<Date> defaultDates = dg->dates();
316 vector<Date> closeOutDates;
317 for (auto d : defaultDates) {
318 Date closeOut = dg->calendar().adjust(d + shift);
319 closeOutDates.push_back(closeOut);
320 }
321 QuantLib::ext::shared_ptr<DateGrid> newDg = QuantLib::ext::make_shared<DateGrid>(closeOutDates, dg->calendar(), dg->dayCounter());
322 return newDg;
323}

◆ combineDateGrids()

QuantLib::ext::shared_ptr< DateGrid > combineDateGrids ( const QuantLib::ext::shared_ptr< DateGrid > &  dg1,
const QuantLib::ext::shared_ptr< DateGrid > &  dg2 
)

Definition at line 325 of file dategrid.cpp.

326 {
327 DLOG("Combining date grids");
328 vector<Date> combinedVec;
329 vector<Date> dates1 = dg1->dates();
330 vector<Date> dates2 = dg2->dates();
331 combinedVec.reserve(dates1.size() + dates2.size());
332 combinedVec.insert(combinedVec.end(), dates1.begin(), dates1.end());
333 combinedVec.insert(combinedVec.end(), dates2.begin(), dates2.end());
334 std::sort(combinedVec.begin(), combinedVec.end());
335 auto last = std::unique(combinedVec.begin(), combinedVec.end());
336 combinedVec.erase(last, combinedVec.end());
337 // FIXME: Check that grid calendars and day counters match?
338 QuantLib::ext::shared_ptr<DateGrid> newDg = QuantLib::ext::make_shared<DateGrid>(combinedVec, dg1->calendar(), dg1->dayCounter());
339 return newDg;
340}

◆ parseFormula() [1/2]

QuantExt::CompiledFormula parseFormula ( const std::string &  text,
std::vector< std::string > &  variables 
)

parse formula and store it as a CompiledFormula instance, the variables vector contains the label of the variables for each index

Definition at line 24 of file formulaparser.cpp.

24 {
25 variables.clear();
26 auto mapping = [&variables](const std::string& s) {
27 auto it = std::find(variables.begin(), variables.end(), s);
28 if (it != variables.end()) {
29 return QuantExt::CompiledFormula(QuantLib::Size(it - variables.begin()));
30 } else {
31 variables.push_back(s);
32 return QuantExt::CompiledFormula(QuantLib::Size(variables.size() - 1));
33 }
34 };
35 return parseFormula<QuantExt::CompiledFormula>(text, mapping);
36} // parseFormula
+ Here is the caller graph for this function:

◆ parseFormula() [2/2]

T parseFormula ( const std::string &  text,
const std::function< T(std::string)> &  variableMapping = {} 
)

evaluate arithmetic expression, T must provide operators T+T, T-T, -T, T*T, T/T, abs(T), exp(T), gtZero(T), geqZero(T), log(T), max(T,T), min(T,T), pow(T,T) variables are written as "{variable}"

Definition at line 62 of file formulaparser.hpp.

62 {
63
64 namespace fusion = boost::fusion;
65 namespace phoenix = boost::phoenix;
66 namespace qi = boost::spirit::qi;
67 namespace ascii = boost::spirit::ascii;
68
69 typedef std::string::const_iterator Iterator;
70
71 using ascii::alnum;
72 using ascii::char_;
73 using ascii::space;
74 using qi::double_;
75 using qi::lexeme;
76 using qi::lit;
77 using namespace qi::labels;
78
79 qi::rule<Iterator, std::string(), ascii::space_type> variable;
80 qi::rule<Iterator, ascii::space_type> factor;
81 qi::rule<Iterator, ascii::space_type> term;
82 qi::rule<Iterator, ascii::space_type> expression;
83
84 std::stack<T> evalStack;
85
86 auto pushConstant = [&evalStack](const double x) { evalStack.push(T(x)); };
87 auto pushVariable = [&variableMapping, &evalStack, &text](const std::string& s) {
88 QL_REQUIRE(variableMapping, "parseFormula(" << text << "): could not resolve variable \"" << s
89 << "\", because no variable mapping is given");
90 evalStack.push(variableMapping(s));
91 };
92
93 struct doUnaryOp {
94 doUnaryOp(std::stack<T>& evalStack, const std::function<T(T)>& op) : evalStack_(evalStack), op_(op) {}
95 void operator()() const {
96 QL_REQUIRE(evalStack_.size() > 0, "parseFormula(): internal error, empty stack for unary operation");
97 T x = evalStack_.top();
98 evalStack_.pop();
99 T y = op_(x);
100 evalStack_.push(y);
101 }
102 std::stack<T>& evalStack_;
103 const std::function<T(T)> op_;
104 };
105
106 struct doBinaryOp {
107 doBinaryOp(std::stack<T>& evalStack, const std::function<T(T, T)>& op) : evalStack_(evalStack), op_(op) {}
108 void operator()() const {
109 QL_REQUIRE(evalStack_.size() > 1,
110 "parseFormula(): internal error, stack size too small for binary operation");
111 T rhs = evalStack_.top();
112 evalStack_.pop();
113 T lhs = evalStack_.top();
114 evalStack_.pop();
115 evalStack_.push(op_(lhs, rhs));
116 }
117 std::stack<T>& evalStack_;
118 const std::function<T(T, T)> op_;
119 };
120
121 auto doNegate = doUnaryOp(evalStack, [](const T& x) { return -x; });
122 auto doAbs = doUnaryOp(evalStack, [](const T& x) { return abs(x); });
123 auto doGtZero = doUnaryOp(evalStack, [](const T& x) { return gtZero(x); });
124 auto doGeqZero = doUnaryOp(evalStack, [](const T& x) { return geqZero(x); });
125 auto doExp = doUnaryOp(evalStack, [](const T& x) { return exp(x); });
126 auto doLog = doUnaryOp(evalStack, [](const T& x) { return log(x); });
127 //
128 auto doMultiply = doBinaryOp(evalStack, [](const T& x, const T& y) { return x * y; });
129 auto doDivide = doBinaryOp(evalStack, [](const T& x, const T& y) { return x / y; });
130 auto doPlus = doBinaryOp(evalStack, [](const T& x, const T& y) { return x + y; });
131 auto doMinus = doBinaryOp(evalStack, [](const T& x, const T& y) { return x - y; });
132 auto doMax = doBinaryOp(evalStack, [](const T& x, const T& y) { return max(x, y); });
133 auto doMin = doBinaryOp(evalStack, [](const T& x, const T& y) { return min(x, y); });
134 auto doPow = doBinaryOp(evalStack, [](const T& x, const T& y) { return pow(x, y); });
135
136 // clang-format off
137
138 variable = '{' >> lexeme[+(char_ - '}') [_val += qi::labels::_1] ] >> '}';
139 factor = double_ [ pushConstant ]
140 | variable [ pushVariable ]
141 | '(' >> expression >> ')'
142 | '-' >> factor [ doNegate ]
143 | lit("abs(") >> expression [ doAbs ] >> ')'
144 | lit("exp(") >> expression [ doExp ] >> ')'
145 | lit("gtZero(") >> expression [ doGtZero ] >> ')'
146 | lit("geqZero(") >> expression [ doGeqZero ] >> ')'
147 | lit("log(") >> expression [ doLog ] >> ')'
148 | lit("max(") >> expression >> ',' >> expression [ doMax ] >> ')'
149 | lit("min(") >> expression >> ',' >> expression [ doMin ] >> ')'
150 | lit("pow(") >> expression >> ',' >> expression [ doPow ] >> ')';
151 term = factor >> *( ('*' >> factor) [ doMultiply ]
152 | ('/' >> factor) [ doDivide ] );
153 expression = term >> *( ('+' >> term) [ doPlus ]
154 | ('-' >> term) [ doMinus ]);
155
156 // clang-format on
157
158 std::string::const_iterator iter = text.begin();
159 std::string::const_iterator end = text.end();
160 bool r = phrase_parse(iter, end, expression, space);
161
162 if (r && iter == end) {
163 return evalStack.top();
164 } else {
165 std::string::const_iterator some = iter + 30;
166 std::string context(iter, (some > end) ? end : some);
167 QL_FAIL("parseFormula(" << text << "): parsing failed, stopped at \"" + context + "...\"");
168 }
169 return evalStack.top();
170}
double geqZero(const double x)
double gtZero(const double x)
const std::function< RandomVariable(const RandomVariable &, const RandomVariable &)> op_
Definition: value.cpp:66
+ Here is the call graph for this function:

◆ gtZero()

double gtZero ( const double  x)

Definition at line 54 of file formulaparser.hpp.

54{ return x > 0.0 && !QuantLib::close_enough(x, 0.0) ? 1.0 : 0.0; }
+ Here is the caller graph for this function:

◆ geqZero()

double geqZero ( const double  x)

Definition at line 55 of file formulaparser.hpp.

55{ return x > 0.0 || QuantLib::close_enough(x, 0.0) ? 1.0 : 0.0; }
+ Here is the caller graph for this function:

◆ max() [2/2]

double max ( const double  x,
const double  y 
)

Definition at line 56 of file formulaparser.hpp.

56{ return std::max(x, y); }
+ Here is the call graph for this function:

◆ min() [2/2]

double min ( const double  x,
const double  y 
)

Definition at line 57 of file formulaparser.hpp.

57{ return std::min(x, y); }

◆ checkOneToOne()

void checkOneToOne ( const map< string, QuantLib::ext::shared_ptr< OvernightIndex > > &  onIndices,
const map< string, QuantLib::ext::shared_ptr< IborIndexParser > > &  iborIndices 
)

Definition at line 191 of file indexparser.cpp.

192 {
193
194 // Should not attempt to add the same family name to the set if the provided mappings are one to one
195 set<string> familyNames;
196
197 for (const auto& kv : onIndices) {
198 auto p = familyNames.insert(kv.second->familyName());
199 QL_REQUIRE(p.second, "Duplicate mapping for overnight index family " << *p.first << " not allowed");
200 }
201
202 for (const auto& kv : iborIndices) {
203 auto p = familyNames.insert(kv.second->family());
204 QL_REQUIRE(p.second, "Duplicate mapping for ibor index family " << *p.first << " not allowed");
205 }
206}
+ Here is the caller graph for this function:

◆ parseIborIndex()

QuantLib::ext::shared_ptr< IborIndex > parseIborIndex ( const string &  s,
string &  tenor,
const Handle< YieldTermStructure > &  h 
)

Definition at line 259 of file indexparser.cpp.

259 {
260
261 // Check the index string is of the required form before doing anything
262 vector<string> tokens;
263 split(tokens, s, boost::is_any_of("-"));
264 QL_REQUIRE(tokens.size() == 2 || tokens.size() == 3,
265 "Two or three tokens required in " << s << ": CCY-INDEX or CCY-INDEX-TERM");
266
267 // Variables used below
268 string indexStem = tokens[0] + "-" + tokens[1];
269 if (tokens.size() == 3) {
270 tenor = tokens[2];
271 } else {
272 tenor = "";
273 }
274
275 const QuantLib::ext::shared_ptr<Conventions>& conventions = InstrumentConventions::instance().conventions();
276 QuantLib::ext::shared_ptr<Convention> c;
277 if (conventions->has(s, Convention::Type::IborIndex) || conventions->has(s, Convention::Type::OvernightIndex))
278 c = conventions->get(s);
279
280 // if we have a convention given, set up the index using this convention, this overrides the parsing from
281 // hardcoded strings below if there is an overlap
282 if (c) {
283 QL_REQUIRE(c->id() == s, "ibor index convention id ('"
284 << c->id() << "') not matching ibor index string to parse ('" << s << "'");
285 Currency ccy = parseCurrency(tokens[0]);
286 if (auto conv = QuantLib::ext::dynamic_pointer_cast<OvernightIndexConvention>(c)) {
287 QL_REQUIRE(tenor.empty(), "no tenor allowed for convention based overnight index ('" << s << "')");
288 auto res = QuantLib::ext::make_shared<OvernightIndex>(tokens[0] + "-" + tokens[1], conv->settlementDays(), ccy,
289 parseCalendar(conv->fixingCalendar()),
290 parseDayCounter(conv->dayCounter()), h);
291 IndexNameTranslator::instance().add(res->name(), s);
292 return res;
293 } else if (auto conv = QuantLib::ext::dynamic_pointer_cast<IborIndexConvention>(c)) {
294 QL_REQUIRE(!tenor.empty(), "no tenor given for convention based Ibor index ('" << s << "'");
295 auto res = QuantLib::ext::make_shared<IborIndex>(tokens[0] + "-" + tokens[1], parsePeriod(tenor),
296 conv->settlementDays(), ccy, parseCalendar(conv->fixingCalendar()),
297 parseBusinessDayConvention(conv->businessDayConvention()),
298 conv->endOfMonth(), parseDayCounter(conv->dayCounter()), h);
299 IndexNameTranslator::instance().add(res->name(), s);
300 return res;
301 } else {
302 QL_FAIL("invalid convention passed to parseIborIndex(): expected OvernightIndexConvention or "
303 "IborIndexConvention");
304 }
305 }
306
307 // if we do not have a convention, look up the index in the hardcoded maps below
308
309 // Map from our _unique internal name_ to an overnight index
310 static map<string, QuantLib::ext::shared_ptr<OvernightIndex>> onIndices = {
311 {"EUR-EONIA", QuantLib::ext::make_shared<Eonia>()},
312 {"EUR-ESTER", QuantLib::ext::make_shared<Estr>()},
313 {"GBP-SONIA", QuantLib::ext::make_shared<Sonia>()},
314 {"JPY-TONAR", QuantLib::ext::make_shared<Tonar>()},
315 {"SGD-SORA", QuantLib::ext::make_shared<Sora>()},
316 {"CHF-TOIS", QuantLib::ext::make_shared<CHFTois>()},
317 {"CHF-SARON", QuantLib::ext::make_shared<CHFSaron>()},
318 {"USD-FedFunds", QuantLib::ext::make_shared<FedFunds>()},
319 {"USD-SOFR", QuantLib::ext::make_shared<Sofr>()},
320 {"USD-Prime", QuantLib::ext::make_shared<PrimeIndex>()},
321 {"USD-AMERIBOR", QuantLib::ext::make_shared<USDAmeribor>()},
322 {"AUD-AONIA", QuantLib::ext::make_shared<Aonia>()},
323 {"CAD-CORRA", QuantLib::ext::make_shared<CORRA>()},
324 {"DKK-DKKOIS", QuantLib::ext::make_shared<DKKOis>()},
325 {"SEK-SIOR", QuantLib::ext::make_shared<SEKSior>()},
326 {"COP-IBR", QuantLib::ext::make_shared<COPIbr>()},
327 {"BRL-CDI", QuantLib::ext::make_shared<BRLCdi>()},
328 {"NOK-NOWA", QuantLib::ext::make_shared<Nowa>()},
329 {"CLP-CAMARA", QuantLib::ext::make_shared<CLPCamara>()},
330 {"NZD-OCR", QuantLib::ext::make_shared<Nzocr>()},
331 {"PLN-POLONIA", QuantLib::ext::make_shared<PLNPolonia>()},
332 {"INR-MIBOROIS", QuantLib::ext::make_shared<INRMiborOis>()},
333 {"GBP-BoEBase", QuantLib::ext::make_shared<BOEBaseRateIndex>()},
334 {"HKD-HONIA", QuantLib::ext::make_shared<HKDHonia>()},
335 {"SEK-STINA", QuantLib::ext::make_shared<SEKStina>()},
336 {"DKK-CITA", QuantLib::ext::make_shared<DKKCita>()},
337 {"THB-THOR", QuantLib::ext::make_shared<THBThor>()}};
338
339 // Map from our _unique internal name_ to an ibor index (the period does not matter here)
340 static map<string, QuantLib::ext::shared_ptr<IborIndexParser>> iborIndices = {
341 {"AUD-BBSW", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Bbsw>>()},
342 {"AUD-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<AUDLibor>>()},
343 {"EUR-EURIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Euribor>>()},
344 {"EUR-EURIBOR365", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Euribor365>>()},
345 {"CAD-CDOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Cdor>>()},
346 {"CNY-SHIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Shibor>>()},
347 {"CZK-PRIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<CZKPribor>>()},
348 {"EUR-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<EURLibor>>()},
349 {"USD-AMBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<USDAmbor>>()},
350 {"USD-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<USDLibor>>()},
351 {"GBP-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<GBPLibor>>()},
352 {"JPY-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<JPYLibor>>()},
353 {"JPY-TIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Tibor>>()},
354 {"JPY-EYTIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<JPYEYTIBOR>>()},
355 {"CAD-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<CADLibor>>()},
356 {"CHF-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<CHFLibor>>()},
357 {"SEK-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<SEKLibor>>()},
358 {"SEK-STIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<SEKStibor>>()},
359 {"NOK-NIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<NOKNibor>>()},
360 {"HKD-HIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<HKDHibor>>()},
361 {"CNH-HIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<CNHHibor>>()},
362 {"CNH-SHIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<CNHShibor>>()},
363 {"SAR-SAIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<SAibor>>()},
364 {"SGD-SIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<SGDSibor>>()},
365 {"SGD-SOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<SGDSor>>()},
366 {"DKK-CIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<DKKCibor>>()},
367 {"DKK-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<DKKLibor>>()},
368 {"HUF-BUBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<HUFBubor>>()},
369 {"IDR-IDRFIX", QuantLib::ext::make_shared<IborIndexParserWithPeriod<IDRIdrfix>>()},
370 {"IDR-JIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<IDRJibor>>()},
371 {"ILS-TELBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<ILSTelbor>>()},
372 {"INR-MIFOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<INRMifor>>()},
373 {"MXN-TIIE", QuantLib::ext::make_shared<IborIndexParserWithPeriod<MXNTiie>>()},
374 {"PLN-WIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Wibor>>()},
375 {"SKK-BRIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<SKKBribor>>()},
376 {"NZD-BKBM", QuantLib::ext::make_shared<IborIndexParserWithPeriod<NZDBKBM>>()},
377 {"TRY-TRLIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<TRLibor>>()},
378 {"TWD-TAIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<TWDTaibor>>()},
379 {"MYR-KLIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<MYRKlibor>>()},
380 {"KRW-CD", QuantLib::ext::make_shared<IborIndexParserWithPeriod<KRWCd>>()},
381 {"KRW-KORIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<KRWKoribor>>()},
382 {"ZAR-JIBAR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Jibar>>()},
383 {"RUB-MOSPRIME", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Mosprime>>()},
384 {"RUB-KEYRATE", QuantLib::ext::make_shared<IborIndexParserWithPeriod<RUBKeyRate>>()},
385 {"THB-BIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<THBBibor>>()},
386 {"THB-THBFIX", QuantLib::ext::make_shared<IborIndexParserWithPeriod<THBFIX>>()},
387 {"PHP-PHIREF", QuantLib::ext::make_shared<IborIndexParserWithPeriod<PHPPhiref>>()},
388 {"RON-ROBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<Robor>>()},
389 {"DEM-LIBOR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<DEMLibor>>()},
390 {"CNY-REPOFIX", QuantLib::ext::make_shared<IborIndexParserWithPeriod<CNYRepoFix>>()},
391 {"USD-SOFR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<QuantExt::SofrTerm>>()},
392 {"GBP-SONIA", QuantLib::ext::make_shared<IborIndexParserWithPeriod<QuantExt::SoniaTerm>>()},
393 {"JPY-TONAR", QuantLib::ext::make_shared<IborIndexParserWithPeriod<QuantExt::TonarTerm>>()},
394 {"CAD-CORRA", QuantLib::ext::make_shared<IborIndexParserWithPeriod<QuantExt::CORRATerm>>()}};
395
396 // Check (once) that we have a one-to-one mapping
397 static bool checked = false;
398 if (!checked) {
399 checkOneToOne(onIndices, iborIndices);
400 checked = true;
401 }
402
403 // Simple single case for USD-SIFMA (i.e. BMA)
404 if (indexStem == "USD-SIFMA") {
405 QL_REQUIRE(tenor.empty(), "A tenor is not allowed with USD-SIFMA as it is implied");
406 auto res = QuantLib::ext::make_shared<BMAIndexWrapper>(QuantLib::ext::make_shared<BMAIndex>(h));
407 IndexNameTranslator::instance().add(res->name(), s);
408 return res;
409 }
410
411 // Ibor indices with a tenor, this includes OIS term rates like USD-SOFR-3M
412 auto it = iborIndices.find(indexStem);
413 if (it != iborIndices.end() && !tenor.empty()) {
414 Period p = parsePeriod(tenor);
415 auto res = it->second->build(p, h);
416 IndexNameTranslator::instance().add(res->name(), s);
417 return res;
418 }
419
420 // Overnight indices
421 auto onIt = onIndices.find(indexStem);
422 if (onIt != onIndices.end()) {
423 QL_REQUIRE(tenor.empty(),
424 "A tenor is not allowed with the overnight index " << indexStem << " as it is implied");
425 auto res = onIt->second->clone(h);
426 IndexNameTranslator::instance().add(res->name(), s);
427 return res;
428 }
429
430 // GENERIC indices
431 if (tokens[1] == "GENERIC") {
432 Period p = parsePeriod(tenor);
433 auto ccy = parseCurrency(tokens[0]);
434 auto res = QuantLib::ext::make_shared<GenericIborIndex>(p, ccy, h);
435 IndexNameTranslator::instance().add(res->name(), s);
436 return res;
437 }
438
439 QL_FAIL("parseIborIndex \"" << s << "\" not recognized");
440}
void checkOneToOne(const map< string, QuantLib::ext::shared_ptr< OvernightIndex > > &onIndices, const map< string, QuantLib::ext::shared_ptr< IborIndexParser > > &iborIndices)
+ Here is the call graph for this function:

◆ parseZeroInflationIndex()

QL_DEPRECATED QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex ( const string &  s,
bool  isInterpolated,
const Handle< ZeroInflationTermStructure > &  h 
)

Definition at line 670 of file indexparser.cpp.

672 {
673
674 const QuantLib::ext::shared_ptr<Conventions>& conventions = InstrumentConventions::instance().conventions();
675
676 // If conventions are non-null and we have provided a convention of type InflationIndex with a name equal to the
677 // string s, we use that convention to construct the inflation index.
678 if (conventions) {
679 pair<bool, QuantLib::ext::shared_ptr<Convention>> p = conventions->get(s, Convention::Type::ZeroInflationIndex);
680 if (p.first) {
681 auto c = QuantLib::ext::dynamic_pointer_cast<ZeroInflationIndexConvention>(p.second);
682 auto index = QuantLib::ext::make_shared<ZeroInflationIndex>(s, c->region(), c->revised(), isInterpolated,
683 c->frequency(), c->availabilityLag(), c->currency(), h);
684 IndexNameTranslator::instance().add(index->name(), s);
685 return index;
686 }
687 }
688
689 static map<string, QuantLib::ext::shared_ptr<ZeroInflationIndexParserBase>> m = {
690 {"AUCPI", QuantLib::ext::make_shared<ZeroInflationIndexParserWithFrequency<AUCPI>>(Quarterly)},
691 {"AU CPI", QuantLib::ext::make_shared<ZeroInflationIndexParserWithFrequency<AUCPI>>(Quarterly)},
692 {"BEHICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<BEHICP>>()},
693 {"BE HICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<BEHICP>>()},
694 {"EUHICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICP>>()},
695 {"EU HICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICP>>()},
696 {"EUHICPXT", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICPXT>>()},
697 {"EU HICPXT", QuantLib::ext::make_shared<ZeroInflationIndexParser<EUHICPXT>>()},
698 {"FRHICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRHICP>>()},
699 {"FR HICP", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRHICP>>()},
700 {"FRCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRCPI>>()},
701 {"FR CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<FRCPI>>()},
702 {"UKRPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<UKRPI>>()},
703 {"UK RPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<UKRPI>>()},
704 {"USCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<USCPI>>()},
705 {"US CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<USCPI>>()},
706 {"ZACPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<ZACPI>>()},
707 {"ZA CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<ZACPI>>()},
708 {"SECPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<SECPI>>()},
709 {"DKCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<DKCPI>>()},
710 {"CACPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<CACPI>>()},
711 {"ESCPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<ESCPI>>()},
712 {"DECPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<DECPI>>()},
713 {"DE CPI", QuantLib::ext::make_shared<ZeroInflationIndexParser<DECPI>>()}
714 };
715
716 auto it = m.find(s);
717 if (it != m.end()) {
718 QL_DEPRECATED_DISABLE_WARNING
719 auto index = it->second->build(isInterpolated, h);
720 QL_DEPRECATED_ENABLE_WARNING
721 IndexNameTranslator::instance().add(index->name(), s);
722 return index;
723 } else {
724 QL_FAIL("parseZeroInflationIndex: \"" << s << "\" not recognized");
725 }
726}

◆ parseCommodityIndex()

QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseCommodityIndex ( const string &  name,
bool  hasPrefix,
const Handle< PriceTermStructure > &  ts,
const Calendar &  cal,
const bool  enforceFutureIndex 
)

Definition at line 797 of file indexparser.cpp.

799 {
800
801 // Whether we check for "COMM-" prefix depends on hasPrefix.
802 string commName = name;
803 if (hasPrefix) {
804 // Make sure the prefix is correct
805 string prefix = name.substr(0, 5);
806 QL_REQUIRE(prefix == "COMM-", "A commodity index string must start with 'COMM-' but got " << prefix);
807 commName = name.substr(5);
808 }
809
810 // Now take the remainder of the string
811 // for spot indices, this should just be the commodity name (possibly containing hyphens)
812 // for future indices, this is of the form NAME-YYYY-MM or NAME-YYYY-MM-DD where NAME is the commodity name
813 // (possibly containing hyphens) and YYYY-MM(-DD) is the expiry date of the futures contract
814 Date expiry;
815
816 // Check for form NAME-YYYY-MM-DD
817 if (commName.size() > 10) {
818 string test = commName.substr(commName.size() - 10);
819 if (boost::regex_match(test, boost::regex("\\d{4}-\\d{2}-\\d{2}"))) {
820 expiry = parseDate(test);
821 commName = commName.substr(0, commName.size() - test.size() - 1);
822 }
823 }
824
825 // Check for form NAME-YYYY-MM if NAME-YYYY-MM-DD failed
826 if (expiry == Date() && commName.size() > 7) {
827 string test = commName.substr(commName.size() - 7);
828 if (boost::regex_match(test, boost::regex("\\d{4}-\\d{2}"))) {
829 expiry = parseDate(test + "-01");
830 commName = commName.substr(0, commName.size() - test.size() - 1);
831 }
832 }
833
834 // Name to use when creating the index. This may be updated if we have a commodity future convention and IndexName
835 // is provided by the convention.
836 string indexName = commName;
837
838 // Do we have a commodity future convention for the commodity.
839 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
840 pair<bool, QuantLib::ext::shared_ptr<Convention>> p = conventions->get(commName, Convention::Type::CommodityFuture);
841 QuantLib::ext::shared_ptr<CommodityFutureConvention> convention;
842 if (p.first) {
843
844 convention = QuantLib::ext::dynamic_pointer_cast<CommodityFutureConvention>(p.second);
845
846 if (!convention->indexName().empty())
847 indexName = convention->indexName();
848
849 // If we have provided OffPeakPowerIndexData, we use that to construct the off peak power commodity index.
850 if (convention->offPeakPowerIndexData()) {
851
852 const auto& oppIdxData = *convention->offPeakPowerIndexData();
853
854 if (expiry == Date()) {
855 // If expiry is still not set use any date (off peak index is calendar daily)
856 expiry = Settings::instance().evaluationDate();
857 }
858 string suffix = "-" + to_string(expiry);
859
860 auto offPeakIndex = QuantLib::ext::dynamic_pointer_cast<CommodityFuturesIndex>(parseCommodityIndex(
861 oppIdxData.offPeakIndex() + suffix, false));
862 auto peakIndex = QuantLib::ext::dynamic_pointer_cast<CommodityFuturesIndex>(parseCommodityIndex(
863 oppIdxData.peakIndex() + suffix, false));
864
865 auto index = QuantLib::ext::make_shared<OffPeakPowerIndex>(indexName, expiry, offPeakIndex, peakIndex,
866 oppIdxData.offPeakHours(), oppIdxData.peakCalendar(), ts);
867 IndexNameTranslator::instance().add(index->name(), hasPrefix ? name : "COMM-" + name);
868 DLOG("parseCommodityIndex(" << name << ") -> " << index->name() << " with expiry " << index->expiryDate());
869 return index;
870 }
871 }
872
873 // Create and return the required future index
874 QuantLib::ext::shared_ptr<CommodityIndex> index;
875 if (expiry != Date() || (convention && enforceFutureIndex)) {
876
877 // If expiry is empty, just use any valid expiry.
878 if (expiry == Date()) {
879 ConventionsBasedFutureExpiry feCalc(*convention);
880 expiry = feCalc.nextExpiry();
881 }
882
883 bool keepDays = convention && convention->contractFrequency() == Daily;
884
885 Calendar cdr = cal;
886 if (convention && cdr == NullCalendar()) {
887 cdr = convention->calendar();
888 }
889
890 auto basisCurve = ts.empty() ? nullptr :
891 QuantLib::ext::dynamic_pointer_cast<CommodityBasisPriceTermStructure>(*ts);
892
893 if (basisCurve) {
894 index = QuantLib::ext::make_shared<CommodityBasisFutureIndex>(indexName, expiry, cdr, basisCurve);
895 } else {
896 index = QuantLib::ext::make_shared<CommodityFuturesIndex>(indexName, expiry, cdr, keepDays, ts);
897 }
898
899
900
901 } else {
902 index = QuantLib::ext::make_shared<CommoditySpotIndex>(commName, cal, ts);
903 }
904 IndexNameTranslator::instance().add(index->name(), index->name());
905 DLOG("parseCommodityIndex(" << name << ") -> " << index->name() << " with expiry " << index->expiryDate());
906 return index;
907}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFxIndex()

bool isFxIndex ( const std::string &  indexName)

Check if index is an fx index

Definition at line 1027 of file indexparser.cpp.

1027 {
1028 std::vector<string> tokens;
1029 split(tokens, indexName, boost::is_any_of("-"));
1030 return tokens.size() == 4 && tokens[0] == "FX";
1031}
+ Here is the caller graph for this function:

◆ inverseFxIndex()

std::string inverseFxIndex ( const std::string &  indexName)

Invert an fx index

Definition at line 1033 of file indexparser.cpp.

1033 {
1034 std::vector<string> tokens;
1035 split(tokens, indexName, boost::is_any_of("-"));
1036 QL_REQUIRE(tokens.size() == 4 && tokens[0] == "FX", "no fx index given (" << indexName << ")");
1037 return "FX-" + tokens[1] + "-" + tokens[3] + "-" + tokens[2];
1038}
+ Here is the caller graph for this function:

◆ getStartAndLag()

std::pair< QuantLib::Date, QuantLib::Period > getStartAndLag ( const QuantLib::Date &  asof,
const InflationSwapConvention conv 
)

Definition at line 27 of file inflationstartdate.cpp.

28 {
29
31
32 // If no roll schedule, just return (as of, convention's obs lag).
33 if (conv.publicationRoll() == IPR::None) {
34 return make_pair(asof, Period());
35 }
36
37 // If there is a publication roll, call getStart to retrieve the date.
38 Date d = getInflationSwapStart(asof, conv);
39
40 // Date in inflation period related to the inflation index value.
41 Date dateInPeriod = d - Period(conv.index()->frequency());
42
43 // Find period between dateInPeriod and asof. This will be the inflation curve's obsLag.
44 QL_REQUIRE(dateInPeriod < asof, "InflationCurve: expected date in inflation period ("
45 << io::iso_date(dateInPeriod) << ") to be before the as of date ("
46 << io::iso_date(asof) << ").");
47 Period curveObsLag = (asof - dateInPeriod) * Days;
48
49 return make_pair(d, curveObsLag);
50}
PublicationRoll publicationRoll() const
QuantLib::ext::shared_ptr< ZeroInflationIndex > index() const
PublicationRoll
Rule for determining when inflation swaps roll to observing latest inflation index release.
QuantLib::Date getInflationSwapStart(const Date &asof, const InflationSwapConvention &convention)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInflationSwapStart() [2/2]

QuantLib::Date getInflationSwapStart ( const QuantLib::Date &  asof,
const InflationSwapConvention conv 
)

Definition at line 52 of file inflationstartdate.cpp.

52 {
53
55
56 // If no roll schedule, just return (as of, convention's obs lag).
57 if (conv.publicationRoll() == IPR::None) {
58 return asof;
59 }
60
61 // Get schedule and check not empty
62 const Schedule& ps = conv.publicationSchedule();
63 QL_REQUIRE(!ps.empty(), "InflationCurve: roll on publication is true for "
64 << conv.id() << " but the publication schedule is empty.");
65
66 // Check the schedule dates cover the as of date.
67 const vector<Date>& ds = ps.dates();
68 QL_REQUIRE(ds.front() < asof, "InflationCurve: first date in the publication schedule ("
69 << io::iso_date(ds.front()) << ") should be before the as of date ("
70 << io::iso_date(asof) << ").");
71 QL_REQUIRE(asof < ds.back(), "InflationCurve: last date in the publication schedule ("
72 << io::iso_date(ds.back()) << ") should be after the as of date ("
73 << io::iso_date(asof) << ").");
74
75 // Find d such that d_- < asof <= d. If necessary, move to the next publication schedule date. We
76 // know that there is another date because asof < ds.back() is checked above.
77 auto it = lower_bound(ds.begin(), ds.end(), asof);
78 Date d = *it;
79 if (asof == d && conv.publicationRoll() == IPR::OnPublicationDate) {
80 d = *next(it);
81 }
82
83 // Move d back availability lag and the 15th of that month is the helper's start date.
84 // Note: the 15th of the month is specific to AU CPI. We may need to generalise later.
85 d -= conv.index()->availabilityLag();
86
87 return Date(15, d.month(), d.year());
88}
const string & id() const
Definition: conventions.hpp:91
const Schedule & publicationSchedule() const
+ Here is the call graph for this function:

◆ operator<<() [56/73]

std::ostream & operator<< ( std::ostream &  out,
const StructuredMessage::Category category 
)

Definition at line 645 of file log.cpp.

645 {
646 if (category == StructuredMessage::Category::Error)
647 out << "Error";
648 else if (category == StructuredMessage::Category::Warning)
649 out << "Warning";
650 else if (category == StructuredMessage::Category::Unknown)
651 out << "UnknownType";
652 else
653 QL_FAIL("operator<<: Unsupported enum value for StructuredMessage::Category");
654
655 return out;
656}

◆ operator<<() [57/73]

std::ostream & operator<< ( std::ostream &  out,
const StructuredMessage::Group group 
)

Definition at line 658 of file log.cpp.

658 {
659 if (group == StructuredMessage::Group::Analytics)
660 out << "Analytics";
661 else if (group == StructuredMessage::Group::Configuration)
662 out << "Configuration";
663 else if (group == StructuredMessage::Group::Model)
664 out << "Model";
665 else if (group == StructuredMessage::Group::Curve)
666 out << "Curve";
667 else if (group == StructuredMessage::Group::Trade)
668 out << "Trade";
669 else if (group == StructuredMessage::Group::Fixing)
670 out << "Fixing";
671 else if (group == StructuredMessage::Group::Logging)
672 out << "Logging";
673 else if (group == StructuredMessage::Group::ReferenceData)
674 out << "Reference Data";
675 else if (group == StructuredMessage::Group::Unknown)
676 out << "UnknownType";
677 else
678 QL_FAIL("operator<<: Unsupported enum value for StructuredMessage::Group");
679
680 return out;
681}

◆ xccyCurveName()

std::string xccyCurveName ( const std::string &  ccyCode)

For a given currency code, ccyCode, return the internal name for the cross currency based yield curve.

For a given currency code, ccyCode, this function returns __XCCY__-ccyCode. This curve, if available, is currently used in special cases to allow for separate discount curves when discounting the cashflows on cross currency interest rate swaps.

Definition at line 39 of file marketdata.cpp.

39{ return xccyCurveNamePrefix + "-" + ccyCode; }
const string xccyCurveNamePrefix
Definition: marketdata.cpp:37
+ Here is the caller graph for this function:

◆ xccyYieldCurve() [1/2]

QuantLib::Handle< QuantLib::YieldTermStructure > xccyYieldCurve ( const QuantLib::ext::shared_ptr< Market > &  market,
const std::string &  ccyCode,
const std::string &  configuration = Market::defaultConfiguration 
)

Attempt to return a yield curve from the market using the name generated by xccyCurveName(ccyCode). If no yield curve is available, return the discount curve for the given currency code, ccyCode.

Definition at line 41 of file marketdata.cpp.

42 {
43 bool dummy;
44 return xccyYieldCurve(market, ccyCode, dummy, configuration);
45}
Handle< YieldTermStructure > xccyYieldCurve(const QuantLib::ext::shared_ptr< Market > &market, const string &ccyCode, const string &configuration)
Definition: marketdata.cpp:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xccyYieldCurve() [2/2]

QuantLib::Handle< QuantLib::YieldTermStructure > xccyYieldCurve ( const QuantLib::ext::shared_ptr< Market > &  market,
const std::string &  ccyCode,
bool outXccyExists,
const std::string &  configuration = Market::defaultConfiguration 
)

Attempt to return a yield curve from the market using the name generated by xccyCurveName(ccyCode). If no yield curve is available, return the discount curve for the given currency code, ccyCode. The parameter outXccyExists is populated with true if a yield curve was found under xccyCurveName(ccyCode) and it is populated with false if there was no such yield curve.

Definition at line 47 of file marketdata.cpp.

48 {
49
50 Handle<YieldTermStructure> curve;
51 string xccyCurve = xccyCurveName(ccyCode);
52 outXccyExists = true;
53 try {
54 curve = market->yieldCurve(xccyCurve, configuration);
55 } catch (const Error&) {
56 DLOG("Could not link " << ccyCode << " termstructure to cross currency yield curve " << xccyCurve
57 << " so just using " << ccyCode << " discount curve.");
58 curve = market->discountCurve(ccyCode, configuration);
59 outXccyExists = false;
60 }
61
62 return curve;
63}
string xccyCurveName(const string &ccyCode)
Definition: marketdata.cpp:39
+ Here is the call graph for this function:

◆ indexOrYieldCurve()

QuantLib::Handle< QuantLib::YieldTermStructure > indexOrYieldCurve ( const QuantLib::ext::shared_ptr< Market > &  market,
const std::string &  name,
const std::string &  configuration = Market::defaultConfiguration 
)

Get a yield curve by name, where name can refer to an index or a yield curve name

Definition at line 65 of file marketdata.cpp.

66 {
67 try {
68 return market->iborIndex(name, configuration)->forwardingTermStructure();
69 } catch (...) {
70 }
71 try {
72 return market->yieldCurve(name, configuration);
73 } catch (...) {
74 }
75 QL_FAIL("Could not find index or yield curve with name '" << name << "' under configuration '" << configuration
76 << "' or default configuration.");
77}
+ Here is the caller graph for this function:

◆ securitySpecificCreditCurveName()

std::string securitySpecificCreditCurveName ( const std::string &  securityId,
const std::string &  creditCurveId 
)

For a given security id and credit curve id return the internal name for a security specific copy of the credit curve. This is used to separate sensitivities on credit curves by securities.

Definition at line 79 of file marketdata.cpp.

79 {
80 auto tmp = "__SECCRCRV_" + securityId + "_&_" + creditCurveId + "_&_";
81 return tmp;
82}
+ Here is the caller graph for this function:

◆ creditCurveNameFromSecuritySpecificCreditCurveName()

std::string creditCurveNameFromSecuritySpecificCreditCurveName ( const std::string &  name)

Return the credit curve id for a name generated with securitySpecificCreditCurveName(). If the name was not generated with securitySpecificCreditCurveName(), return the input name unchanged.

Definition at line 84 of file marketdata.cpp.

84 {
85 if (boost::starts_with(name, "__SECCRCRV_")) {
86 std::size_t pos = name.find("_&_", 11);
87 if (pos != std::string::npos) {
88 std::size_t pos2 = name.find("_&_", pos + 3);
89 if (pos2 != std::string::npos) {
90 auto tmp = name.substr(pos + 3, pos2 - (pos + 3));
91 return tmp;
92 }
93 }
94 }
95 return name;
96}
+ Here is the caller graph for this function:

◆ securitySpecificCreditCurve()

QuantLib::Handle< QuantExt::CreditCurve > securitySpecificCreditCurve ( const QuantLib::ext::shared_ptr< Market > &  market,
const std::string &  securityId,
const std::string &  creditCurveId,
const std::string &  configuration = Market::defaultConfiguration 
)

Attempt to return a security specific default curve using the name generated by 'securitySpecificCreditCurveName()'. If no such curve is available return the credit curve for the given creditCurveId.

Definition at line 98 of file marketdata.cpp.

101 {
102 Handle<QuantExt::CreditCurve> curve;
103 std::string name = securitySpecificCreditCurveName(securityId, creditCurveId);
104 try {
105 curve = market->defaultCurve(name, configuration);
106 } catch (const std::exception&) {
107 DLOG("Could not link " << securityId << " to security specific credit curve " << name << " so just using "
108 << creditCurveId << " default curve.");
109 curve = market->defaultCurve(creditCurveId, configuration);
110 }
111 return curve;
112}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prettyPrintInternalCurveName()

std::string prettyPrintInternalCurveName ( std::string  name)

Pretty print an internal curve name occuring (once or several times) in a string (e.g. in a risk factor name).

Definition at line 114 of file marketdata.cpp.

114 {
115 std::size_t pos = 0;
116 bool found;
117 do {
118 found = false;
119 std::size_t pos2 = name.find("__SECCRCRV_", pos);
120 if (pos2 != std::string::npos) {
121 std::size_t pos3 = name.find("_&_", pos2);
122 if (pos3 != std::string::npos) {
123 std::size_t pos4 = name.find("_&_", pos3 + 3);
124 if (pos4 != std::string::npos) {
125 name.replace(pos2, pos4 + 3 - pos2,
126 name.substr(pos2 + 11, pos3 - (pos2 + 11)) + "(" +
127 name.substr(pos3 + 3, pos4 - (pos3 + 3)) + ")");
128 pos = pos + (pos4 - pos2 - 12);
129 found = true;
130 }
131 }
132 }
133 } while (found);
134 return name;
135}

◆ buildFxIndex()

QuantLib::ext::shared_ptr< QuantExt::FxIndex > buildFxIndex ( const string &  fxIndex,
const string &  domestic,
const string &  foreign,
const QuantLib::ext::shared_ptr< Market > &  market,
const string &  configuration,
bool  useXbsCurves = false 
)

Build an Fx Index given a market. Note: sold==domestic, bought==foreign

Definition at line 137 of file marketdata.cpp.

139 {
140
141 auto fxInd = parseFxIndex(fxIndex);
142
143 string source = fxInd->sourceCurrency().code();
144 string target = fxInd->targetCurrency().code();
145 string family = fxInd->familyName();
146
147 fxInd = *market->fxIndex("FX-" + family + "-" + foreign + "-" + domestic);
148
149 QL_REQUIRE((domestic == target && foreign == source) || (domestic == source && foreign == target),
150 "buildFxIndex(): index '" << fxIndex << "' does not match given currencies " << domestic << ", "
151 << foreign);
152
153 if (!useXbsCurves)
154 return fxInd;
155
156 return fxInd->clone(Handle<Quote>(), xccyYieldCurve(market, foreign, configuration),
157 xccyYieldCurve(market, domestic, configuration));
158}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFxIndexConventions()

std::tuple< Natural, Calendar, BusinessDayConvention > getFxIndexConventions ( const string &  index)

Definition at line 160 of file marketdata.cpp.

160 {
161 // can take an fx index or ccy pair e.g. EURUSD
162 string ccy1, ccy2;
163 string fixingSource;
164 if (isFxIndex(index)) {
165 auto ind = parseFxIndex(index);
166 ccy1 = ind->sourceCurrency().code();
167 ccy2 = ind->targetCurrency().code();
168 fixingSource = ind->familyName();
169 } else {
170 QL_REQUIRE(index.size() == 6, "getFxIndexConventions: index must be an FXIndex of form FX-ECB-EUR-USD, "
171 << "or a currency pair e.g. EURUSD, got '" + index + "'");
172 ccy1 = index.substr(0, 3);
173 ccy2 = index.substr(3);
174 fixingSource = "GENERIC";
175 }
176
177 if (ccy1 == ccy2)
178 return std::make_tuple(0, NullCalendar(), Unadjusted);
179
180 const QuantLib::ext::shared_ptr<Conventions>& conventions = InstrumentConventions::instance().conventions();
181 QuantLib::ext::shared_ptr<Convention> con;
182 // first look for the index and inverse index directly
183 try {
184 con = conventions->get("FX-" + fixingSource + "-" + ccy1 + "-" + ccy2);
185 } catch (...) {
186 }
187 if (con == nullptr) {
188 try {
189 con = conventions->get("FX-" + fixingSource + "-" + ccy2 + "-" + ccy1);
190 } catch (...) {
191 }
192 }
193 // then by currency pair and inverse currency pair (getFxConvention() handles both)
194 if (con == nullptr) {
195 try {
196 con = conventions->getFxConvention(ccy1, ccy2);
197 } catch (...) {
198 }
199 }
200 if (auto fxCon = QuantLib::ext::dynamic_pointer_cast<FXConvention>(con)) {
201 TLOG("getFxIndexConvention(" << index << "): " << fxCon->spotDays() << " / " << fxCon->advanceCalendar().name()
202 << " from convention.");
203 return std::make_tuple(fxCon->spotDays(), fxCon->advanceCalendar(), fxCon->convention());
204 } else if (auto comCon = QuantLib::ext::dynamic_pointer_cast<CommodityForwardConvention>(con); comCon !=nullptr
205 && (isPseudoCurrency(ccy1) || isPseudoCurrency(ccy2))) {
206 TLOG("getFxIndexConvention(" << index << "): " << fxCon->spotDays() << " / " << fxCon->advanceCalendar().name()
207 << " from convention.");
208 return std::make_tuple(0, comCon->advanceCalendar(), comCon->bdc());
209 }
210
211 // default calendar for pseudo currencies is USD
212 if (isPseudoCurrency(ccy1))
213 ccy1 = "USD";
214 if (isPseudoCurrency(ccy2))
215 ccy2 = "USD";
216
217 try {
218 Calendar cal = parseCalendar(ccy1 + "," + ccy2);
219 TLOG("getFxIndexConvention(" << index << "): 2 (default) / " << cal.name()
220 << " (from ccys), no convention found.");
221 return std::make_tuple(2, cal, Following);
222 } catch (const std::exception& e) {
223 ALOG("could not get fx index convention for '" << index << "': " << e.what() << ", continue with 'USD'");
224 }
225 TLOG("getFxIndexConvention(" << index
226 << "): 2 (default) / USD (default), no convention found, could not parse calendar '"
227 << (ccy1 + "," + ccy2) << "'");
228 return std::make_tuple(2, parseCalendar("USD"), Following);
229}
bool isPseudoCurrency(const string &code)
check for pseudo currency = precious metal or crypto currency *‍/
Definition: parsers.cpp:318
bool isFxIndex(const std::string &indexName)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ splitCurveIdWithTenor()

std::pair< std::string, QuantLib::Period > splitCurveIdWithTenor ( const std::string &  curveId)

Split curve name NAME_5Y into (NAME, 5Y), the period can be empty if not given

Definition at line 231 of file marketdata.cpp.

231 {
232 Size pos = creditCurveId.rfind("_");
233 if (pos != std::string::npos) {
234 Period term;
235 string termString = creditCurveId.substr(pos + 1, creditCurveId.length());
236 if (tryParse<Period>(termString, term, parsePeriod)) {
237 return make_pair(creditCurveId.substr(0, pos), term);
238 }
239 }
240 return make_pair(creditCurveId, 0 * Days);
241}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ indexCdsDefaultCurve()

QuantLib::Handle< QuantExt::CreditCurve > indexCdsDefaultCurve ( const QuantLib::ext::shared_ptr< Market > &  market,
const std::string &  creditCurveId,
const std::string &  config 
)

Get default curve for index cds from market:

  • if creditCurveId ends on _5Y (or any other term), use that to get the curve from the market
  • if such a curve is not available, fall back to creditCurveId without that suffix

Definition at line 243 of file marketdata.cpp.

245 {
246 try {
247 return market->defaultCurve(creditCurveId, config);
248 } catch (...) {
249 DLOG("indexCdsDefaultCurve: could not get '" << creditCurveId << "', fall back on curve id without tenor.");
250 }
251
252 auto p = splitCurveIdWithTenor(creditCurveId);
253 return market->defaultCurve(p.first, config);
254}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isOnePeriod()

bool isOnePeriod ( const string &  s)

return true if s represents a period of the form [0-9][D|W|M|Y] (i.e. 1Y6M would return false)

Definition at line 159 of file parsers.cpp.

159 {
160 if (s.empty())
161 return false;
162 char c = std::toupper(s.back());
163 if (!(c == 'D' || c == 'W' || c == 'M' || c == 'Y'))
164 return false;
165 for (auto c = s.cbegin(); c != std::next(s.end(), -1); std::advance(c, 1))
166 if (*c < '0' || *c > '9')
167 return false;
168 return true;
169}
+ Here is the caller graph for this function:

◆ parseDateOrPeriod()

void parseDateOrPeriod ( const string &  s,
Date &  d,
Period &  p,
bool isDate 
)

Definition at line 522 of file parsers.cpp.

522 {
523 auto r = parseDateOrPeriod(s);
524 boost::apply_visitor(legacy_date_or_period_visitor(d, p, isDate), r);
525}
+ Here is the call graph for this function:

◆ parseListOfValues()

std::vector< string > parseListOfValues ( string  s,
const char  escape,
const char  delim,
const char  quote 
)

Definition at line 639 of file parsers.cpp.

639 {
640 boost::trim(s);
641 std::vector<string> vec;
642 boost::escaped_list_separator<char> sep(escape, delim, quote);
643 boost::tokenizer<boost::escaped_list_separator<char>> tokens(s, sep);
644 for (auto r : tokens) {
645 boost::trim(r);
646 vec.push_back(r);
647 }
648 return vec;
649}
+ Here is the caller graph for this function:

◆ parseAmortizationType()

AmortizationType parseAmortizationType ( const std::string &  s)

Definition at line 651 of file parsers.cpp.

651 {
652 static map<string, AmortizationType> type = {
653 {"None", AmortizationType::None},
654 {"FixedAmount", AmortizationType::FixedAmount},
655 {"RelativeToInitialNotional", AmortizationType::RelativeToInitialNotional},
656 {"RelativeToPreviousNotional", AmortizationType::RelativeToPreviousNotional},
657 {"Annuity", AmortizationType::Annuity},
658 {"LinearToMaturity", AmortizationType::LinearToMaturity}};
659
660 auto it = type.find(s);
661 if (it != type.end()) {
662 return it->second;
663 } else {
664 QL_FAIL("Amortitazion type \"" << s << "\" not recognized");
665 }
666}
+ Here is the caller graph for this function:

◆ parseExtrapolation()

Extrapolation parseExtrapolation ( const string &  s)

Parse Extrapolation from string.

Definition at line 778 of file parsers.cpp.

778 {
779 if (s == "None") {
780 return Extrapolation::None;
781 } else if (s == "UseInterpolator" || s == "Linear") {
782 return Extrapolation::UseInterpolator;
783 } else if (s == "Flat") {
784 return Extrapolation::Flat;
785 } else {
786 QL_FAIL("Extrapolation '" << s << "' not recognized");
787 }
788}
+ Here is the caller graph for this function:

◆ operator<<() [58/73]

std::ostream & operator<< ( std::ostream &  os,
Extrapolation  extrap 
)

Write Extrapolation, extrap, to stream.

Definition at line 791 of file parsers.cpp.

791 {
792 switch (extrap) {
793 case Extrapolation::None:
794 return os << "None";
795 case Extrapolation::UseInterpolator:
796 return os << "UseInterpolator";
797 case Extrapolation::Flat:
798 return os << "Flat";
799 default:
800 QL_FAIL("Unknown Extrapolation");
801 }
802}

◆ parseOvernightIndexFutureNettingType()

QuantLib::RateAveraging::Type parseOvernightIndexFutureNettingType ( const std::string &  s)

Convert text to QuantLib::RateAveraging::Type.

Definition at line 970 of file parsers.cpp.

970 {
971 if (s == "Averaging") {
972 return QuantLib::RateAveraging::Type::Simple;
973 } else if (s == "Compounding") {
974 return QuantLib::RateAveraging::Type::Compound;
975 } else {
976 QL_FAIL("Overnight Index Future Netting Type '" << s << "' not known, expected 'Averaging' or 'Compounding'");
977 }
978}
+ Here is the caller graph for this function:

◆ operator<<() [59/73]

std::ostream & operator<< ( std::ostream &  os,
QuantLib::RateAveraging::Type  t 
)

Write QuantLib::RateAveraging::Type to stream.

Definition at line 980 of file parsers.cpp.

980 {
981 if (t == QuantLib::RateAveraging::Type::Simple)
982 return os << "Averaging";
983 else if (t == QuantLib::RateAveraging::Type::Compound)
984 return os << "Compounding";
985 else {
986 QL_FAIL("Internal error: unknown RateAveraging::Type - check implementation of operator<< "
987 "for this enum");
988 }
989}

◆ parseFutureDateGenerationRule()

FutureConvention::DateGenerationRule parseFutureDateGenerationRule ( const std::string &  s)

Convert text to FutureConvention::DateGeneration.

Definition at line 991 of file parsers.cpp.

991 {
992 if (s == "IMM")
993 return FutureConvention::DateGenerationRule::IMM;
994 else if (s == "FirstDayOfMonth")
995 return FutureConvention::DateGenerationRule::FirstDayOfMonth;
996 else {
997 QL_FAIL("FutureConvention / DateGenerationRule '" << s << "' not known, expect 'IMM' or 'FirstDayOfMonth'");
998 }
999}
+ Here is the caller graph for this function:

◆ operator<<() [60/73]

std::ostream & operator<< ( std::ostream &  os,
FutureConvention::DateGenerationRule  t 
)

Write QuantLib::RateAveraging::Type to stream.

Definition at line 1001 of file parsers.cpp.

1001 {
1002 if (t == FutureConvention::DateGenerationRule::IMM)
1003 return os << "IMM";
1004 else if (t == FutureConvention::DateGenerationRule::FirstDayOfMonth)
1005 return os << "FirstDayOfMonth";
1006 else {
1007 QL_FAIL("Internal error: unknown FutureConvention::DateGenerationRule - check implementation of operator<< "
1008 "for this enum");
1009 }
1010}

◆ parseInflationSwapPublicationRoll()

InflationSwapConvention::PublicationRoll parseInflationSwapPublicationRoll ( const string &  s)

Convert text to InflationSwapConvention::PublicationRoll.

Definition at line 1012 of file parsers.cpp.

1012 {
1014 if (s == "None") {
1015 return IPR::None;
1016 } else if (s == "OnPublicationDate") {
1017 return IPR::OnPublicationDate;
1018 } else if (s == "AfterPublicationDate") {
1019 return IPR::AfterPublicationDate;
1020 } else {
1021 QL_FAIL("InflationSwapConvention::PublicationRoll '"
1022 << s << "' not known, expect "
1023 << "'None', 'OnPublicationDate' or 'AfterPublicationDate'");
1024 }
1025}
+ Here is the caller graph for this function:

◆ operator<<() [61/73]

std::ostream & operator<< ( ostream &  os,
InflationSwapConvention::PublicationRoll  pr 
)

Write InflationSwapConvention::PublicationRoll to stream.

Definition at line 1077 of file parsers.cpp.

1077 {
1079 if (pr == IPR::None) {
1080 return os << "None";
1081 } else if (pr == IPR::OnPublicationDate) {
1082 return os << "OnPublicationDate";
1083 } else if (pr == IPR::AfterPublicationDate) {
1084 return os << "AfterPublicationDate";
1085 } else {
1086 QL_FAIL("Unknown InflationSwapConvention::PublicationRoll.");
1087 }
1088}

◆ operator<<() [62/73]

std::ostream & operator<< ( std::ostream &  os,
SobolBrownianGenerator::Ordering  t 
)

Write QuantLib::SobolBrownianGenerator::Ordering to stream.

Definition at line 1090 of file parsers.cpp.

1090 {
1091 static map<SobolBrownianGenerator::Ordering, string> m = {{SobolBrownianGenerator::Ordering::Factors, "Factors"},
1092 {SobolBrownianGenerator::Ordering::Steps, "Steps"},
1093 {SobolBrownianGenerator::Ordering::Diagonal, "Diagonal"}};
1094 auto it = m.find(t);
1095 if (it != m.end()) {
1096 return os << it->second;
1097 } else {
1098 QL_FAIL("Internal error: unknown SobolBrownianGenerator::Ordering - check implementation of operator<< "
1099 "for this enum");
1100 }
1101}

◆ operator<<() [63/73]

std::ostream & operator<< ( std::ostream &  os,
SobolRsg::DirectionIntegers  t 
)

Write QuantLib::SobolRsg::DirectionIntegers to stream.

Definition at line 1103 of file parsers.cpp.

1103 {
1104 static map<SobolRsg::DirectionIntegers, string> m = {
1105 {SobolRsg::DirectionIntegers::Unit, "Unit"},
1106 {SobolRsg::DirectionIntegers::Jaeckel, "Jaeckel"},
1107 {SobolRsg::DirectionIntegers::SobolLevitan, "SobolLevitan"},
1108 {SobolRsg::DirectionIntegers::SobolLevitanLemieux, "SobolLevitanLemieux"},
1109 {SobolRsg::DirectionIntegers::JoeKuoD5, "JoeKuoD5"},
1110 {SobolRsg::DirectionIntegers::JoeKuoD6, "JoeKuoD6"},
1111 {SobolRsg::DirectionIntegers::JoeKuoD7, "JoeKuoD7"},
1112 {SobolRsg::DirectionIntegers::Kuo, "Kuo"},
1113 {SobolRsg::DirectionIntegers::Kuo2, "Kuo2"},
1114 {SobolRsg::DirectionIntegers::Kuo3, "Kuo3"}};
1115 auto it = m.find(t);
1116 if (it != m.end()) {
1117 return os << it->second;
1118 } else {
1119 QL_FAIL("Internal error: unknown SobolRsg::DirectionIntegers - check implementation of operator<< "
1120 "for this enum");
1121 }
1122}

◆ operator<<() [64/73]

std::ostream & operator<< ( std::ostream &  out,
QuantExt::CrossAssetModel::Discretization  dis 
)

Enum to string used in ScenarioGeneratorData's toXML.

Definition at line 1124 of file parsers.cpp.

1124 {
1125 switch (dis) {
1126 case QuantExt::CrossAssetModel::Discretization::Exact:
1127 return out << "Exact";
1128 case QuantExt::CrossAssetModel::Discretization::Euler:
1129 return out << "Euler";
1130 default:
1131 return out << "?";
1132 }
1133}

◆ parseAveragingDataPeriod()

CommodityFutureConvention::AveragingData::CalculationPeriod parseAveragingDataPeriod ( const string &  s)

Convert text to CommodityFutureConvention::AveragingData::CalculationPeriod.

Definition at line 1136 of file parsers.cpp.

1136 {
1137 if (s == "PreviousMonth") {
1138 return ADCP::PreviousMonth;
1139 } else if (s == "ExpiryToExpiry") {
1140 return ADCP::ExpiryToExpiry;
1141 } else {
1142 QL_FAIL("AveragingData::CalculationPeriod '" << s << "' not known, expect "
1143 << "'PreviousMonth' or 'ExpiryToExpiry'");
1144 }
1145}
+ Here is the caller graph for this function:

◆ operator<<() [65/73]

std::ostream & operator<< ( ostream &  os,
ADCP  cp 
)

Write CommodityFutureConvention::AveragingData::CalculationPeriod to stream.

Definition at line 1147 of file parsers.cpp.

1147 {
1148 if (cp == ADCP::PreviousMonth) {
1149 return os << "PreviousMonth";
1150 } else if (cp == ADCP::ExpiryToExpiry) {
1151 return os << "ExpiryToExpiry";
1152 } else {
1153 QL_FAIL("Unknown AveragingData::CalculationPeriod.");
1154 }
1155}

◆ parsePriceSegmentType()

PriceSegment::Type parsePriceSegmentType ( const string &  s)

Convert text to PriceSegment::Type.

Definition at line 1158 of file parsers.cpp.

1158 {
1159 if (s == "Future") {
1160 return PST::Future;
1161 } else if (s == "AveragingFuture") {
1162 return PST::AveragingFuture;
1163 } else if (s == "AveragingSpot") {
1164 return PST::AveragingSpot;
1165 } else if (s == "AveragingOffPeakPower") {
1166 return PST::AveragingOffPeakPower;
1167 } else if (s == "OffPeakPowerDaily") {
1168 return PST::OffPeakPowerDaily;
1169 } else {
1170 QL_FAIL("PriceSegment::Type '" << s << "' not known, expect "
1171 << "'Future', 'AveragingFuture' or 'AveragingSpot'");
1172 }
1173}
+ Here is the caller graph for this function:

◆ operator<<() [66/73]

std::ostream & operator<< ( ostream &  os,
PriceSegment::Type  pst 
)

Write PriceSegment::Type to stream.

Definition at line 1175 of file parsers.cpp.

1175 {
1176 if (pst == PST::Future) {
1177 return os << "Future";
1178 } else if (pst == PST::AveragingFuture) {
1179 return os << "AveragingFuture";
1180 } else if (pst == PST::AveragingSpot) {
1181 return os << "AveragingSpot";
1182 } else if (pst == PST::AveragingOffPeakPower) {
1183 return os << "AveragingOffPeakPower";
1184 } else if (pst == PST::OffPeakPowerDaily) {
1185 return os << "OffPeakPowerDaily";
1186 } else {
1187 QL_FAIL("Unknown PriceSegment::Type.");
1188 }
1189}

◆ parseCommodityQuantityFrequency()

QuantExt::CommodityQuantityFrequency parseCommodityQuantityFrequency ( const string &  s)

Convert text to QuantExt::CommodityQuantityFrequency.

Definition at line 1192 of file parsers.cpp.

1192 {
1193 if (iequals(s, "PerCalculationPeriod")) {
1194 return CQF::PerCalculationPeriod;
1195 } else if (iequals(s, "PerCalendarDay")) {
1196 return CQF::PerCalendarDay;
1197 } else if (iequals(s, "PerPricingDay")) {
1198 return CQF::PerPricingDay;
1199 } else if (iequals(s, "PerHour")) {
1200 return CQF::PerHour;
1201 } else if (iequals(s, "PerHourAndCalendarDay")) {
1202 return CQF::PerHourAndCalendarDay;
1203 } else {
1204 QL_FAIL("Could not parse " << s << " to CommodityQuantityFrequency");
1205 }
1206}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [67/73]

std::ostream & operator<< ( ostream &  os,
CommodityQuantityFrequency  cqf 
)

Write QuantExt::CommodityQuantityFrequency to stream.

Definition at line 1208 of file parsers.cpp.

1208 {
1209 if (cqf == CQF::PerCalculationPeriod) {
1210 return os << "PerCalculationPeriod";
1211 } else if (cqf == CQF::PerCalendarDay) {
1212 return os << "PerCalendarDay";
1213 } else if (cqf == CQF::PerPricingDay) {
1214 return os << "PerPricingDay";
1215 } else if (cqf == CQF::PerHour) {
1216 return os << "PerHour";
1217 } else if (cqf == CQF::PerHourAndCalendarDay) {
1218 return os << "PerHourAndCalendarDay";
1219 } else {
1220 QL_FAIL("Do not recognise CommodityQuantityFrequency " << static_cast<int>(cqf));
1221 }
1222}

◆ operator<<() [68/73]

ostream & operator<< ( ostream &  os,
Rounding::Type  t 
)

Definition at line 1224 of file parsers.cpp.

1224 {
1225 static map<Rounding::Type, string> m = {{Rounding::Type::Up, "Up"},
1226 {Rounding::Type::Down, "Down"},
1227 {Rounding::Type::Closest, "Closest"},
1228 {Rounding::Type::Floor, "Floor"},
1229 {Rounding::Type::Ceiling, "Ceiling"}};
1230 auto it = m.find(t);
1231 if (it != m.end()) {
1232 return os << it->second;
1233 } else {
1234 QL_FAIL("Internal error: unknown Rounding::Type - check implementation of operator<< "
1235 "for this enum");
1236 }
1237}

◆ operator<<() [69/73]

std::ostream & operator<< ( std::ostream &  os,
QuantExt::BondIndex::PriceQuoteMethod  p 
)

Write PriceQuoteMethod to stream.

Definition at line 1271 of file parsers.cpp.

1271 {
1272 if (p == QuantExt::BondIndex::PriceQuoteMethod::PercentageOfPar)
1273 os << "PercentageOfPar";
1274 else if (p == QuantExt::BondIndex::PriceQuoteMethod::CurrencyPerUnit)
1275 os << "CurrencyPerUnit";
1276 else
1277 os << "Unknown PriceQuoteMethod (" << static_cast<int>(p) << ")";
1278 return os;
1279}

◆ getCorrelationTokens()

std::vector< std::string > getCorrelationTokens ( const std::string &  name)

Helper function to get the two tokens in a correlation name Index2:Index1.

Definition at line 1281 of file parsers.cpp.

1281 {
1282 // Look for & first as it avoids collisions with : which can be used in an index name
1283 // if it is not there we fall back on the old behaviour
1284 string delim;
1285 if (name.find('&') != std::string::npos)
1286 delim = "&";
1287 else
1288 delim = "/:,";
1289 vector<string> tokens;
1290 boost::split(tokens, name, boost::is_any_of(delim));
1291 QL_REQUIRE(tokens.size() == 2,
1292 "invalid correlation name '" << name << "', expected Index2:Index1 or Index2/Index1 or Index2&Index1");
1293 return tokens;
1294}
+ Here is the caller graph for this function:

◆ normaliseFxIndex()

string normaliseFxIndex ( const std::string &  indexName)

Convert FX index name to market standard dominance.

Definition at line 1351 of file parsers.cpp.

1351 {
1352 auto fx = ore::data::parseFxIndex(indexName);
1353 std::string ccy1 = fx->sourceCurrency().code();
1354 std::string ccy2 = fx->targetCurrency().code();
1355 if (ore::data::fxDominance(ccy1, ccy2) != ccy1 + ccy2)
1356 return ore::data::inverseFxIndex(indexName);
1357 else
1358 return indexName;
1359}
string fxDominance(const string &s1, const string &s2)
Convert FX pair to market standard dominance.
Definition: parsers.cpp:1296
+ Here is the call graph for this function:

◆ parseCreditPortfolioSensitivityDecomposition()

CreditPortfolioSensitivityDecomposition parseCreditPortfolioSensitivityDecomposition ( const std::string &  s)

Convert text to CreditPortfolioSensitivitiyDecomposition.

Definition at line 1374 of file parsers.cpp.

1374 {
1375 if (s == "Underlying") {
1376 return CreditPortfolioSensitivityDecomposition::Underlying;
1377 } else if (s == "NotionalWeighted") {
1378 return CreditPortfolioSensitivityDecomposition::NotionalWeighted;
1379 } else if (s == "LossWeighted") {
1380 return CreditPortfolioSensitivityDecomposition::LossWeighted;
1381 } else if (s == "DeltaWeighted") {
1382 return CreditPortfolioSensitivityDecomposition::DeltaWeighted;
1383 } else {
1384 QL_FAIL("CreditPortfolioSensitivityDecomposition '"
1385 << s << "' invalid, expected Underlying, NotionalWeighted, LossWeighted, DeltaWeighted");
1386 }
1387}
+ Here is the caller graph for this function:

◆ operator<<() [70/73]

std::ostream & operator<< ( std::ostream &  os,
const CreditPortfolioSensitivityDecomposition  d 
)

Output operator for CreditPortfolioSensitivityDecomposition.

Definition at line 1389 of file parsers.cpp.

1389 {
1390 if (d == CreditPortfolioSensitivityDecomposition::Underlying) {
1391 return os << "Underlying";
1392 } else if (d == CreditPortfolioSensitivityDecomposition::NotionalWeighted) {
1393 return os << "NotionalWeighted";
1394 } else if (d == CreditPortfolioSensitivityDecomposition::LossWeighted) {
1395 return os << "LossWeighted";
1396 } else if (d == CreditPortfolioSensitivityDecomposition::DeltaWeighted) {
1397 return os << "DeltaWeighted";
1398 } else {
1399 QL_FAIL("Unknonw CreditPortfolioSensitivitiyDecomposition value " << static_cast<std::size_t>(d));
1400 }
1401}

◆ operator<<() [71/73]

std::ostream & operator<< ( std::ostream &  out,
SabrParametricVolatility::ModelVariant  m 
)

Definition at line 1478 of file parsers.cpp.

1478 {
1479 if (m == SabrParametricVolatility::ModelVariant::Hagan2002Lognormal) {
1480 out << "Hagan2002Lognormal";
1481 } else if (m == SabrParametricVolatility::ModelVariant::Hagan2002Normal) {
1482 out << "Hagan2002Normal";
1483 } else if (m == SabrParametricVolatility::ModelVariant::Hagan2002NormalZeroBeta) {
1484 out << "Hagan200NormalZeroBeta";
1485 } else if (m == SabrParametricVolatility::ModelVariant::Antonov2015FreeBoundaryNormal) {
1486 out << "AntonovNormalZeroBeta";
1487 } else if (m == SabrParametricVolatility::ModelVariant::KienitzLawsonSwaynePde) {
1488 out << "KienitzLawsonSwaynePde";
1489 } else if (m == SabrParametricVolatility::ModelVariant::FlochKennedy) {
1490 out << "FlochKennedy";
1491 } else {
1492 QL_FAIL("SabrParametricVolatility::ModelVariant (" << static_cast<int>(m)
1493 << ") not recognized. This is an internal error.");
1494 }
1495 return out;
1496}

◆ operator<<() [72/73]

std::ostream & operator<< ( std::ostream &  os,
Exercise::Type  type 
)

Definition at line 1498 of file parsers.cpp.

1498 {
1499 if (type == Exercise::European) {
1500 os << "European";
1501 } else if (type == Exercise::Bermudan) {
1502 os << "Bermudan";
1503 } else if (type == Exercise::American) {
1504 os << "American";
1505 } else {
1506 QL_FAIL("Exercise::Type (" << static_cast<int>(type)
1507 << " not recognized. Expected 'European', 'Bermudan', or 'American'.");
1508 }
1509
1510 return os;
1511}

◆ parseVectorOfValues()

std::vector< T > parseVectorOfValues ( std::vector< std::string >  str,
std::function< T(string)>  parser 
)

Definition at line 335 of file parsers.hpp.

335 {
336 std::vector<T> vec;
337 for (auto s : str) {
338 vec.push_back(parser(s));
339 }
340 return vec;
341}

◆ tryParseCurrency()

bool tryParseCurrency ( const std::string &  str,
Currency &  obj 
)

Definition at line 438 of file parsers.hpp.

438 {
439 DLOG("tryParse: attempting to parse currency from " << str);
440 try {
441 obj = parseCurrency(str);
442 } catch (...) {
443 TLOG("String " << str << " could not be parsed");
444 return false;
445 }
446 return true;
447}
MarketObject obj
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [73/73]

std::ostream & operator<< ( std::ostream &  out,
const TimePeriod t 
)

Definition at line 50 of file timeperiod.cpp.

50 {
51 for (Size i = 0; i < t.numberOfContiguousParts(); ++i) {
52 out << QuantLib::io::iso_date(t.startDates()[i]) << " to " << QuantLib::io::iso_date(t.endDates()[i]);
53 if (i < t.numberOfContiguousParts() - 1)
54 out << " + ";
55 }
56 return out;
57}
const std::vector< Date > & endDates() const
Definition: timeperiod.hpp:53
const std::vector< Date > & startDates() const
Definition: timeperiod.hpp:52
Size numberOfContiguousParts() const
Definition: timeperiod.hpp:51
+ Here is the call graph for this function:

◆ totalTimePeriod()

TimePeriod totalTimePeriod ( std::vector< std::string >  timePeriods,
Size  mporDays,
const QuantLib::Calendar &  calendar 
)

Definition at line 59 of file timeperiod.cpp.

59 {
60 vector<Date> allDates;
61 for (const string& s : timePeriods) {
62 auto dates = parseListOfValues<Date>(s, &parseDate);
63 for (const auto& d : dates)
64 allDates.push_back(d);
65 }
66
67 TimePeriod period(allDates);
68
69 Date minDate = *std::min_element(period.startDates().begin(), period.startDates().end());
70 Date maxDate = *std::max_element(period.endDates().begin(), period.endDates().end());
71
72 vector<Date> finalDates;
73 finalDates.push_back(minDate);
74 finalDates.push_back(maxDate);
75
76 TimePeriod totalPeriod(finalDates, mporDays, calendar);
77 return totalPeriod;
78}
Handles non-contiguous time period.
Definition: timeperiod.hpp:41
+ Here is the call graph for this function:

◆ to_string() [3/4]

std::string to_string ( const Date &  date)

Definition at line 43 of file to_string.cpp.

43 {
44 if (date == Date())
45 return "1901-01-01";
46
47 char buf[11];
48 int y = date.year();
49 int m = static_cast<int>(date.month());
50 int d = date.dayOfMonth();
51
52 int n = snprintf(buf, sizeof(buf), "%04d-%02d-%02d", y, m, d);
53 QL_REQUIRE(n == 10, "Failed to convert date " << date << " to_string() n:" << n);
54 return std::string(buf);
55}
+ Here is the call graph for this function:

◆ to_string() [4/4]

std::string to_string ( const Period &  period)

Definition at line 59 of file to_string.cpp.

59 {
60 Integer n = period.length();
61 Integer m = 0;
62 std::ostringstream o;
63 switch (period.units()) {
64 case Days:
65 if (n>=7) {
66 m = n/7;
67 o << m << "W";
68 n = n%7;
69 }
70 if (n != 0 || m == 0) {
71 o << n << "D";
72 return o.str();
73 }
74 else {
75 return o.str();
76 }
77 case Weeks: {
78 o << n << "W";
79 return o.str();
80 }
81 case Months:
82 if (n>=12) {
83 m = n/12;
84 o << n/12 << "Y";
85 n = n%12;
86 }
87 if (n != 0 || m == 0) {
88 o << n << "M";
89 return o.str();
90 }
91 else {
92 return o.str();
93 }
94 case Years: {
95 o << n << "Y";
96 return o.str();
97 }
98 default:
99 ALOG("unknown time unit (" << Integer(period.units()) << ")");
100 o << period;
101 return o.str();
102 }
103}
+ Here is the call graph for this function:

◆ partitionQuotes() [1/2]

void partitionQuotes ( const set< string > &  quoteNames,
set< string > &  names,
set< string > &  regexes 
)

Definition at line 96 of file wildcard.cpp.

96 {
97
98 for (const string& n : quoteNames) {
99 ore::data::Wildcard w(n, false);
100 if (w.hasWildcard())
101 regexes.insert(w.regex());
102 else
103 names.insert(n);
104 }
105}
+ Here is the call graph for this function:

◆ partitionQuotes() [2/2]

void partitionQuotes ( const set< string > &  quoteNames,
set< string > &  names,
set< string > &  regexes,
std::set< std::string > &  prefixes,
const bool  aggressivePrefixes 
)

Definition at line 107 of file wildcard.cpp.

108 {
109
110 for (const string& n : quoteNames) {
111 ore::data::Wildcard w(n, true, aggressivePrefixes);
112 if (w.hasWildcard()) {
113 if (w.isPrefix())
114 prefixes.insert(w.prefix());
115 else
116 regexes.insert(w.regex());
117 } else
118 names.insert(n);
119 }
120}
+ Here is the call graph for this function:

◆ getUniqueWildcard()

boost::optional< Wildcard > getUniqueWildcard ( const C &  c)

checks if at most one element in C has a wild card and returns it in this case

Definition at line 65 of file wildcard.hpp.

65 {
66 for (auto const& a : c) {
67 Wildcard w(a);
68 if (w.hasWildcard()) {
69 QL_REQUIRE(c.size() == 1, "If wild cards are used, only one entry should exist.");
70 return w;
71 }
72 }
73 return boost::none;
74}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ volatilityTypeMap

const BmType volatilityTypeMap
Initial value:
=
list_of<BmType::value_type>("Normal", CapFloorVolatilityCurveConfig::VolatilityType::Normal)(
"Lognormal", CapFloorVolatilityCurveConfig::VolatilityType::Lognormal)(
"ShiftedLognormal", CapFloorVolatilityCurveConfig::VolatilityType::ShiftedLognormal)

Definition at line 45 of file capfloorvolcurveconfig.cpp.

◆ validInterps

const set<string> validInterps = {"Linear", "LinearFlat", "BackwardFlat", "Cubic", "CubicFlat"}

Definition at line 52 of file capfloorvolcurveconfig.cpp.

◆ types

boost::bimap<std::string, TRS::FundingData::NotionalType> types
Initial value:
= boost::assign::list_of<boost::bimap<std::string, TRS::FundingData::NotionalType>::relation>
("PeriodReset", TRS::FundingData::NotionalType::PeriodReset)
("DailyReset", TRS::FundingData::NotionalType::DailyReset)
("Fixed", TRS::FundingData::NotionalType::Fixed)

Definition at line 783 of file trs.cpp.

◆ xccyCurveNamePrefix

const std::string xccyCurveNamePrefix = "__XCCY__"

Definition at line 37 of file marketdata.cpp.