Пример #1
0
        public override void PriceTradelet(Tradelet tradelet, Exposure _expo, DateTime marketDate)
        {
            Trade trade = tradelet.MyTrade;
            if (trade.isExcercised) return;

            Product prod = tradelet.MyTrade.MyProduct;
            CurveSeries curves = prod.ReturnCurveSeries();
            VolCurveSeries volCurves = prod.ReturnVolCurveSeries();
            TradingCenter tc = prod.TC;

            double Premium, Delta, FwdDelta, Gamma, FwdGamma, Vega, Theta, Rho, vol, priceUL, iRate, hcRate;
            DateTime expDate, matDate;
            iRate = 0; //@@@
            hcRate = 0; // @@@

            List<DateTime> delDates, expoDates;
            double nrDays = (tradelet.DelEnd - tradelet.DelStart).TotalDays;
            double dailyDelta;

            if (trade.OptionTenorType == TENOR_TYPE.DAY) // @@@better switch! also we can use EACHTENOR! which provides exactely this!!
            {
                delDates = TradingCenter.TCEachDay(tradelet.DelStart, tradelet.DelEnd).ToList();
            }
            else
            {
                delDates = new List<DateTime>();
                delDates.Add(tradelet.DelStart);
            }

            foreach (DateTime day in delDates.Where(k => k > marketDate).ToList()) // no exposure on option  trades, although we should never get here as expired? @@@ first introduce an "Expired!"
            {
                expDate = tc.GetGasOptExDate(trade.OptionTenorType, day, isExchange);
                if (expDate <= marketDate) break; // @@@ make dates eventually with hours, etc. // on marketDate the excercise will be triggered

                matDate = tc.GetGasMaturityDate(trade.OptionTenorType, day, isExchange); // @@@ ICE payment date?
                priceUL = curves.GetValue(trade.OptionTenorType, day, marketDate);
                vol = volCurves.GetValue(trade.OptionTenorType, day, marketDate, SURFACE_TYPE.MONEYNESS, trade.Strike / priceUL);

                Debugger.AddDebugLine("Dnum = " + trade.DealID + "; marketDate = " + marketDate.ToShortDateString() + "; expDate = " + expDate.ToShortDateString());
                RWE_API.Final_Wrapper.GenOptWithGreeks(out Premium, out Delta, out FwdDelta, out Gamma, out FwdGamma, out Vega,
                                            out Theta, out Rho, trade.OptionType, priceUL, trade.Strike, vol, iRate, hcRate, expDate, matDate, marketDate);

                dailyDelta = prod.UnitSet.ToFullSize(trade.Volume, 1) * FwdDelta; //@@@ watch out for Exposure Type FWDDELTA vs DELTA!! ... fix
                if (trade.OptionTenorType == TENOR_TYPE.DAY)
                {
                    expoDates = new List<DateTime>(); expoDates.Add(day);
                }
                else
                {
                    expoDates = delDates;
                }
                SplitExpoToDaily_tofix(_expo, EXPOSURE_TYPE.DELTA, expoDates, dailyDelta);
                SplitExpoToDaily_tofix(_expo, EXPOSURE_TYPE.PNL, expoDates, dailyDelta * (Premium - trade.Price));

                // @@@ CFDate wrong

            }
        }
Пример #2
0
        // remember: 'virtual' can be overwritten, 'abstract' must be overwritten
        public virtual void PriceTradelet(Tradelet tradelet, Exposure _expo, DateTime marketDate)
        {
            if (tradelet.DelEnd < marketDate) return;
            Trade trade = tradelet.MyTrade;

            Product prod = tradelet.MyTrade.MyProduct;
            CurveSeries curves = prod.ReturnCurveSeries();
            TradingCenter tc = prod.TC;

            List<DateTime> delDates, expoDates;
            double nrDays = (tradelet.DelEnd - tradelet.DelStart).TotalDays;
            double dailyDelta;

            delDates = TradingCenter.TCEachDay(tradelet.DelStart, tradelet.DelEnd).ToList();

            double priceUL = 0;
            foreach (DateTime day in delDates)
            {
                if (day > marketDate) priceUL = curves.GetValue(TENOR_TYPE.DAY, day, marketDate);
                dailyDelta = prod.UnitSet.ToFullSize(trade.Volume, 1);

                _expo.AddExpo(EXPOSURE_TYPE.DELTA, TENOR_TYPE.DAY, day, dailyDelta);
                if(day > marketDate) _expo.AddExpo(EXPOSURE_TYPE.PNL, TENOR_TYPE.DAY, day, dailyDelta * (priceUL - trade.Price));

            }
        }