예제 #1
0
 public static MonthCodeYear GetMonthOffset(this MonthCodeYear input_, int offset_)
 {
   var asMonthYear = new MonthYear((int) input_.Month, input_.Year);
   var converted = asMonthYear.GetMonthOffset(offset_);
   return new MonthCodeYear((MonthCode) converted.Month, converted.Year);
 }
예제 #2
0
    private static Bond findBond(IEnumerable<Bond> bonds_, MonthYear month_, int yearsMaturity_, DateTime currDate, int nthAuction)
    {
        Logger.InfoFormat(typeof(Generator), "searching CT bond for {0} series", yearsMaturity_);
      var overrIDE = _CT_overrides.FirstOrDefault(x => x.Item1 == yearsMaturity_ && x.Item2.Equals(month_));

      if (overrIDE != null)
        return bonds_.FirstOrDefault(x => String.Compare(x.SymmetryCode, overrIDE.Item3, StringComparison.OrdinalIgnoreCase) == 0);

      //var bonds = bonds_.Where(x => x.Maturity.Value.Month == month_.Month && x.Maturity.Value.Year == month_.Year + yearsMaturity_);

      //if (bonds.Count() > 1)
      //{
      //  Logger.Debug(string.Format("More than one bond found for {0} with {1} years to maturity", month_.ToString(), yearsMaturity_.ToString()), typeof(Generator));
      //  Array.ForEach(bonds.ToArray(),x=>Logger.Debug(string.Format("{0} - {1} - {2}",x.SymmetryCode,x.DisplayName,x.IssueDate),typeof(Generator)));
      //}
      //var  bond = bonds_.FirstOrDefault(x => x.Maturity.Value.Month == month_.Month && x.Maturity.Value.Year == month_.Year + yearsMaturity_);

      var ctcontract = new CTBond { Ric = "CT" + yearsMaturity_, Series = yearsMaturity_ };
      var ctlogic = new CTRollLogic(ctcontract);
      var bond = ctlogic.GetCTBond(currDate, nthAuction);
      if(bond != null)
        Logger.InfoFormat(typeof(Generator), "CT bond found {0}: ", bond.SymmetryCode);
      return bond;
    }