Esempio n. 1
0
        public void visit(TenorBasisYieldCurveSegment s)
        {
            string aCurveID = s.ShortProjectionCurveID();

            if (_curveID != aCurveID && aCurveID != "")
            {
                _requiredYieldCurveIDs.Add(aCurveID);
            }
            aCurveID = s.LongProjectionCurveID();
            if (_curveID != aCurveID && aCurveID != "")
            {
                _requiredYieldCurveIDs.Add(aCurveID);
            }
        }
Esempio n. 2
0
        public override void FromXML(XmlNode node)
        {
            CheckNode(node, "YieldCurve");

            // Read in the mandatory nodes.
            _curveID          = GetChildValue(node, "CurveId", true);
            _curveDescription = GetChildValue(node, "CurveDescription", true);
            _currency         = GetChildValue(node, "Currency", true);
            _discountCurveID  = GetChildValue(node, "DiscountCurve", true);

            // Read in the segments.
            XmlNode segmentsNode = GetChildNode(node, "Segments");

            if (segmentsNode != null)
            {
                XmlNode child = GetChildNode(segmentsNode, "");
                while (child != null)
                {
                    YieldCurveSegment segment   = new YieldCurveSegment();
                    string            childName = GetNodeName(child);

                    if (childName == "Direct")
                    {
                        segment = new DirectYieldCurveSegment();
                    }
                    else if (childName == "Simple")
                    {
                        segment = new SimpleYieldCurveSegment();
                    }
                    else if (childName == "AverageOIS")
                    {
                        segment = new AverageOISYieldCurveSegment();
                    }
                    else if (childName == "TenorBasis")
                    {
                        segment = new TenorBasisYieldCurveSegment();
                    }
                    else if (childName == "CrossCurrency")
                    {
                        segment = new CrossCcyYieldCurveSegment();
                    }
                    else if (childName == "ZeroSpread")
                    {
                        segment = new ZeroSpreadedYieldCurveSegment();
                    }
                    else
                    {
                        Utils.QL_FAIL("Yield curve segment node name not recognized.");
                    }

                    if (segment != null)
                    {
                        try
                        {
                            segment.FromXML(child);
                        }
                        catch (Exception ex)
                        {
                            //ALOG("Exception parsing yield curve segment XML Node, name = " + childName + " and curveID = " + _curveID + " : " + ex.ToString();
                        }
                    }
                    else
                    {
                        //LOG("Unable to build yield curve segment for name = " << childName << " and curveID = " << curveID_);
                    }

                    _curveSegments.Add(segment);
                    child = GetNextSibling(child, "");
                }
            }
            else
            {
                Utils.QL_FAIL("No Segments node in XML doc for yield curve ID = " + _curveID);
            }

            // Read in the optional nodes.

            // Empty strings if not there (or if there and empty).
            _interpolationVariable = GetChildValue(node, "InterpolationVariable", false);
            _interpolationMethod   = GetChildValue(node, "InterpolationMethod", false);
            _zeroDayCounter        = GetChildValue(node, "YieldCurveDayCounter", false);

            // Add hardcoded defaults for now.
            if (_interpolationVariable == "")
            {
                _interpolationVariable = "Discount";
            }
            if (_interpolationMethod == "")
            {
                _interpolationMethod = _interpolationVariable == "Zero" ? "Linear" : "LogLinear";
            }
            if (_zeroDayCounter == "")
            {
                _zeroDayCounter = "A365";
            }
            XmlNode nodeToTest = GetChildNode(node, "Extrapolation");

            if (nodeToTest != null)
            {
                _extrapolation = GetChildValueAsBool(node, "Extrapolation", false);
            }
            else
            {
                _extrapolation = true;
            }
            nodeToTest = GetChildNode(node, "Tolerance");
            if (nodeToTest != null)
            {
                _tolerance = GetChildValueAsDouble(node, "Tolerance", false);
            }
            else
            {
                _tolerance = 1.0e-12;
            }

            PopulateRequiredYieldCurveIDs();
        }