Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XccySpreadCurve"/> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="nameSpace">THe client namespace</param>
        /// <param name="fpmlData">The FPML data.</param>
        /// <param name="properties">The properties for the pricing strucuture.</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="rollCalendar">The rollCalendar.</param>
        public XccySpreadCurve(ILogger logger, ICoreCache cache, String nameSpace,
                               Pair <PricingStructure, PricingStructureValuation> fpmlData,
                               NamedValueSet properties, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
            : base(logger, cache, nameSpace, new RateCurveIdentifier(properties))
        {
            SetFpMLData(fpmlData, false);
            var yieldCurveValuation = (YieldCurveValuation)fpmlData.Second;

            BasicAssetValuation[] assetQuote = yieldCurveValuation.inputs.assetQuote;
            string     algorithm             = ((YieldCurve)fpmlData.First).algorithm;
            DateTime   baseDate   = yieldCurveValuation.baseDate.Value;
            IRateCurve baseCurve  = ExtractCurve(logger, cache, nameSpace, assetQuote, BaseCurveName, algorithm, baseDate, fixingCalendar, rollCalendar);
            IRateCurve quoteCurve = ExtractCurve(logger, cache, nameSpace, assetQuote, QuoteCurveName, algorithm, baseDate, fixingCalendar, rollCalendar);

            string[]  fxInstruments = ExtractInstruments(assetQuote, FxCurveName);
            decimal[] fxValues      = ExtractValues(assetQuote, FxCurveName);
            FxCurve   fxCurve       = null;

            if (fxInstruments.Any())
            {
                string curveName         = $"{fxInstruments[0].Substring(0, 3)}-{fxInstruments[0].Substring(3, 3)}";
                var    curveId           = new FxCurveIdentifier(PricingStructureTypeEnum.FxCurve, curveName, baseDate);
                var    qas               = AssetHelper.ParseToFxRateSet(fxInstruments, fxValues, null);
                var    fxCurveProperties = curveId.GetProperties();
                fxCurve = new FxCurve(logger, cache, nameSpace, fxCurveProperties, qas, fixingCalendar, rollCalendar);
            }
            var instruments = ExtractInstruments(assetQuote, null);
            var values      = ExtractValues(assetQuote, null);

            Initialize(logger, cache, nameSpace, properties, baseCurve, quoteCurve, instruments, values, fxCurve, fixingCalendar, rollCalendar);
        }
Beispiel #2
0
 /// <summary>
 /// Sets the fpML data.
 /// </summary>
 /// <param name="fpmlData">The FPML data.</param>
 /// <param name="includeId">Include an id check.</param>
 protected void SetFpMLData(Pair <PricingStructure, PricingStructureValuation> fpmlData, Boolean includeId)
 {
     PricingStructure          = fpmlData.First;
     PricingStructureValuation = fpmlData.Second;
     if (includeId)
     {
         DateTime baseDate = PricingStructureValuation.baseDate.Value;
         PricingStructureIdentifier = new FxCurveIdentifier(PricingStructureTypeEnum.FxCurve, PricingStructure.id, baseDate);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FxDerivedCurve"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="cache">The cache.</param>
 /// <param name="nameSpace">The client namespace</param>
 /// <param name="curve1">The currency1 data. This should be against USD.
 /// This must also be the currency1 curve for the derived fx curve.</param>
 /// <param name="curve2">The currency2 data. This should be against USD.</param>
 /// <param name="newFxCurveProperties">The new FxCurve properties .</param>
 public FxDerivedCurve(ILogger logger, ICoreCache cache, string nameSpace, FxCurve curve1, FxCurve curve2, NamedValueSet newFxCurveProperties)
 {
     PricingStructureData       = new PricingStructureData(CurveType.Child, AssetClass.Fx, newFxCurveProperties);
     FxCurve1                   = curve1;
     FxCurve2                   = curve2;
     Currency1                  = curve1.GetQuotedCurrencyPair().currency1.Value != "USD" ? curve1.GetQuotedCurrencyPair().currency1.Value : curve1.GetQuotedCurrencyPair().currency2.Value;
     Currency2                  = curve2.GetQuotedCurrencyPair().currency1.Value != "USD" ? curve2.GetQuotedCurrencyPair().currency1.Value : curve2.GetQuotedCurrencyPair().currency2.Value;
     SpotDate                   = GetSpotDate(logger, cache, nameSpace, null, null, FxCurve1.GetBaseDate());//Create the new identifier.
     PricingStructureIdentifier = new FxCurveIdentifier(newFxCurveProperties);
 }
Beispiel #4
0
        public void FxCurveIdConstructByIdTest()
        {
            const string curveId   = "AUD-USD";
            var          fxCurveId = new FxCurveIdentifier(curveId);

            Assert.IsNotNull(fxCurveId);
            Assert.IsNotNull(fxCurveId.Currency);
            Assert.AreEqual("AUD", fxCurveId.Currency.Value);
            Assert.AreEqual("USD", fxCurveId.QuoteCurrency.Value);
            Assert.AreEqual("USD", fxCurveId.QuotedCurrencyPair.currency2.Value);

            Debug.Print("RateCurveIdentifier : {0} BuildDateTime : {1} CurveName : {2} PricingStructureType : {3} Algorithm : {4}Currency : {5} BaseDate : {6}",
                        fxCurveId.Id, fxCurveId.BuildDateTime, fxCurveId.CurveName, fxCurveId.PricingStructureType,
                        fxCurveId.Algorithm, fxCurveId.Currency.Value, fxCurveId.BaseDate);
        }
        /// <summary>
        /// Sets the fpML data.
        /// </summary>
        /// <param name="fpmlData">The FPML data.</param>
        private void SetFpMLData(Pair <PricingStructure, PricingStructureValuation> fpmlData)
        {
            PricingStructure          = fpmlData.First;
            PricingStructureValuation = fpmlData.Second;
            try
            {
                if (null == PricingStructureIdentifier)
                {
                    PricingStructureIdentifier = new FxCurveIdentifier(PricingStructure.id);
                }
            }
// ReSharper disable EmptyGeneralCatchClause
            catch // b/c the FxCurveIdentifier ctor throws the exception
// ReSharper restore EmptyGeneralCatchClause
            {
            }
        }
Beispiel #6
0
        public void PricingStructureIdTestWithProperties12()
        {
            var props = new NamedValueSet();

            props.Set(CurveProp.PricingStructureType, "FxCurve");
            props.Set(CurveProp.CurveName, "AUD-USD");
            props.Set("BuildDateTime", _baseDate);
            props.Set(CurveProp.BaseDate, _baseDate);
            props.Set("Algorithm", "Default");
            props.Set("Identifier", "Alex");
            props.Set("CurrencyPair", "AUD-USD");
            props.Set("QuoteBasis", "Currency2PerCurrency1");
            var curveId = new FxCurveIdentifier(props);

            Debug.Print("RateCurveIdentifier : {0} BuildDateTime : {1} CurveName : {2} PricingStructureType : {3} Algorithm : {4}Currency : {5} BaseDate : {6} QuotedCurrencyPair1 : {7} QuotedCurrencyPair2 : {8}",
                        curveId.Id, curveId.BuildDateTime, curveId.CurveName, curveId.PricingStructureType,
                        curveId.Algorithm, curveId.Currency.Value, curveId.BaseDate, curveId.QuotedCurrencyPair.currency1.Value, curveId.QuotedCurrencyPair.currency2.Value);
        }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="properties">The properties.</param>
 /// <param name="algorithmHolder">The algorithmHolder.</param>
 public EquityCurve(NamedValueSet properties, PricingStructureAlgorithmsHolder algorithmHolder)
 {
     PricingStructureData       = new PricingStructureData(CurveType.Parent, AssetClass.Equity, properties);
     PricingStructureIdentifier = new FxCurveIdentifier(properties);
     Initialize(properties, algorithmHolder);
 }