コード例 #1
0
        /// <summary>
        /// Libor discounting (considering 'Tenor Spread') 
        /// </summary>
        /// <param name="marketTuple">'Libor', 'Swap' and 'TenorSpread' are included in marketTuple</param>
        /// <returns>discount factors</returns>
        public Dictionary<double, double> CalcDiscountFactor(MarketTuple marketTuple)
        {
            var df = new Dictionary<double, double>();

            var diff = DifferencesBetween3Mand6M(marketTuple.TenorSpreadList)[0.25];

            foreach (var l in marketTuple.LiborList)
            {
                if (l.Term == 0.25)
                    df[0.25] = 1 / (1 + ((l.LiborRate + diff) * 0.25));
                if (l.Term == 0.5)
                    df[0.5] = 1 / (1 + l.LiborRate * 0.5);
            }

            foreach (var s in marketTuple.SwapList)
            {
                if (s.Term >= 1)
                {
                    double sum = 0;
                    foreach (var v in df.Values)
                        sum = (sum + v - df[0.25]) / 2;
                    df[s.Term] = (1 - sum * s.SwapRate) / (1 + s.SwapRate / 2);
                }
            }
            return df;
        }
コード例 #2
0
ファイル: MarketTuple.cs プロジェクト: InuT/StrawberryCake
 public MarketTuple CreateMarketTuple(string liborPath, string swapPath)
 {
     var m = new MarketTuple();
     m.LiborList = GenericMarketLoader<Libor>.LoadMarket(liborPath);
     m.SwapList = GenericMarketLoader<Swap>.LoadMarket(swapPath);
     return m;
 }
コード例 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dfc"></param>
        /// <param name="marketTuple"></param>
        /// <returns></returns>
        public Dictionary<double, double> CalcZeroYieldCurve(IDFCalculator dfc, MarketTuple marketTuple)
        {
            var discountFactor = dfc.CalcDiscountFactor(marketTuple);

            var zeroYield = new Dictionary<double, double>();
            foreach (var df in discountFactor)
                zeroYield.Add(df.Key, Math.Log(df.Value));

            return zeroYield;
        }
コード例 #4
0
        /// <summary>
        /// Libor discounting (not considering 'Tenor Spread') 
        /// </summary>
        /// <param name="marketTuple">'Libor' and 'Swap' are included in marketTuple</param>
        /// <returns>discount factors</returns>
        public Dictionary<double, double> CalcDiscountFactor(MarketTuple marketTuple)
        {
            var df = new Dictionary<double, double>();
            foreach (var lr in marketTuple.LiborList)
            {
                if (lr.Term == 0.5)
                    df.Add(lr.Term, 1 / (1 + lr.LiborRate * 0.5));
                if (lr.Term == 1.0)
                    df.Add(lr.Term, 1 / (1 + lr.LiborRate));
            }

            foreach (var sr in marketTuple.SwapList)
            {
                if (sr.Term > 1)
                {
                    double sum = 0;
                    foreach (var v in df.Values)
                        sum = sum + v;

                    df[sr.Term] = (1 - sum * sr.SwapRate / 2) / (1 + sr.SwapRate / 2);
                }
            }
            return df;
        }