예제 #1
0
 static bool HandleLines(IList<string> lines, Market market, char[] seps, StringBuilder sb)
 {
     //Read First Line to fin Vol Surface and if its Rho or Nu
     bool isRho = true;
     InterestVolatility vol = null;
     var firstLine = lines.FirstOrDefault();
     if (string.IsNullOrEmpty(firstLine))
     {
         sb.Append("Cannot parse first line");
         return false;
     }
     var ss = firstLine.Split(seps);
     var sdate = ss[2];
     var stype = ss[3];
     var ticker = ss[4];
     var date = SimpleDate.Parse(sdate);
     isRho = stype.ToUpper().Contains("RHO");
      var isBeta = stype.ToUpper().Contains("BETA");
     ss = ticker.Split('.');
     var name = ss[0];
     var ccy = ss[1];
     var time = date.ToDateTime(23, 59, 59);
     market.Time = time;
     market.ClearMarketDatas();
     var vols = market.GetAll(true, false, false, true, false, false, false, false, false, false, false, false, false);
     foreach (var im in vols)
     {
         var ivol = im as InterestVolatility;
         if (ivol != null && ivol.Currency.Equals(ccy))
         {
             vol = ivol;
             break;
         }
     }
     if (vol == null)
     {
         sb.Append("Cannot Find Any Vol for " + ticker);
         return false;
     }
     var output = vol.Output as InterestVolatilityOutput;
     if (output == null)
     {
         sb.Append("Invalid Vol not built " + vol);
         return false;
     }
     var data = new List<SabrData>();
     foreach (var line in lines)
     {
         var d = new SabrData();
         ss = line.Split(seps);
         var tick = ss[4];
         d.Date = SimpleDate.Parse(ss[2]).ToDateTime();
         d.ComponentTicker = tick;
         d.InstrumentType = ss[3];
         d.Value = Convert.ToDouble(ss[5]);
         data.Add(d);
     }
     return HandleData(vol, isRho, isBeta, data, market, sb);
 }