예제 #1
0
        /// <summary>
        /// Detailed constructor
        /// </summary>
        /// <param name="curveID"></param>
        /// <param name="curveDescription"></param>
        public FXSpotConfig(string curveID, string curveDescription) : base(curveID, curveDescription)
        {
            Utils.QL_REQUIRE(curveID.Length == 6, () => "FXSpot curveID must be of the form Ccy1Ccy2");
            Currency ccy1 = Parsers.ParseCurrency(curveID.Substring(0, 3));
            Currency ccy2 = Parsers.ParseCurrency(curveID.Substring(3, 3));

            _quotes.Add("FX/RATE/" + ccy1.code + "/" + ccy2.code);
        }
예제 #2
0
 public virtual void Build()
 {
     _spotDays        = Parsers.ParseInteger(_strSpotDays);
     _sourceCurrency  = Parsers.ParseCurrency(_strSourceCurrency);
     _targetCurrency  = Parsers.ParseCurrency(_strTargetCurrency);
     _pointsFactor    = Parsers.ParseDouble(_strPointsFactor);
     _advanceCalendar = _strAdvanceCalendar == "" ? new NullCalendar() : Parsers.ParseCalendar(_strAdvanceCalendar);
     _spotRelative    = _strSpotRelative == "" ? true : Parsers.ParseBool(_strSpotRelative);
 }
예제 #3
0
        public override void Build(EngineFactory engineFactory)
        {
            Currency boughtCcy    = Parsers.ParseCurrency(_boughtCurrency);
            Currency soldCcy      = Parsers.ParseCurrency(_soldCurrency);
            Date     maturityDate = Parsers.ParseDate(_maturityDate);

            //QL_REQUIRE(tradeActions().empty(), "TradeActions not supported for FxForward");

            try
            {
                //DLOG("Build FxForward with maturity date " << QuantLib::io::iso_date(maturityDate));

                QLNet.Instrument instrument = new FxForward(_boughtAmount, boughtCcy, _soldAmount, soldCcy, maturityDate, false);

                //instrument_.reset(new VanillaInstrument(instrument));

                _npvCurrency = _soldCurrency;
                _notional    = _soldAmount;
                _maturity    = maturityDate;
            }
            catch (Exception ex)
            {
                //_instrument.reset();
                throw;
            }

            SimpleCashFlow cf1 = new SimpleCashFlow(_boughtAmount, maturityDate);
            SimpleCashFlow cf2 = new SimpleCashFlow(_soldAmount, maturityDate);

            _legs = new List <List <CashFlow> >()
            {
                new List <CashFlow> {
                    cf1, cf2
                }
            };

            _legCurrencies = new List <string> {
                _boughtCurrency, _soldCurrency
            };
            _legPayers = new List <bool> {
                false, true
            };

            // set Pricing engine
            EngineBuilder builder = engineFactory.Builder(_tradeType);

            QLNet.Utils.QL_REQUIRE(builder != null, () => "No builder found for " + _tradeType);
            FxForwardEngineBuilder fxBuilder = builder as FxForwardEngineBuilder;

            _instrument.setPricingEngine(fxBuilder.Engine(boughtCcy, soldCcy));

            //DLOG("FxForward leg 0: " << legs_[0][0]->date() << " " << legs_[0][0]->amount());
            //DLOG("FxForward leg 1: " << legs_[1][0]->date() << " " << legs_[1][0]->amount());
        }
예제 #4
0
        public override void FromXML(XmlNode node)
        {
            CheckNode(node, "FXSpot");
            _curveID = GetChildValue(node, "CurveId", true);
            Utils.QL_REQUIRE(_curveID.Length == 6, () => "FXSpot curveID must be of the form Ccy1Ccy2");
            Currency ccy1 = Parsers.ParseCurrency(_curveID.Substring(0, 3));
            Currency ccy2 = Parsers.ParseCurrency(_curveID.Substring(3, 3));

            _quotes.Add("FX/RATE/" + ccy1.code + "/" + ccy2.code);

            _curveDescription = GetChildValue(node, "CurveDescription", true);
        }
예제 #5
0
        public override List <string> Quotes()
        {
            if (_quotes.Count == 0)
            {
                List <string> tokens = _swapIndexBase.Split('-').ToList();

                Currency ccy = Parsers.ParseCurrency(tokens[0]);

                string baseStr = "SWAPTION/" + _volatilityType + "/" + ccy.code + "/";


                if (_dimension == Dimension.ATM)
                {
                    foreach (var o in _optionTenors)
                    {
                        foreach (var s in _swapTenors)
                        {
                            string ss = "";
                            ss += baseStr + o.ToString() + "/" + s + "/ATM";
                            _quotes.Add(ss);
                        }
                    }
                }
                else
                {
                    foreach (var o in _smileOptionTenors)
                    {
                        foreach (var s in _smileSwapTenors)
                        {
                            foreach (var sp in _smileSpreads)
                            {
                                string ss = "";
                                ss += baseStr + o.ToString() + "/" + s + "/Smile/" + sp;
                                _quotes.Add(ss);
                            }
                        }
                    }
                }
            }

            return(_quotes);
        }