コード例 #1
0
    public SmoothCurveAndSettingsGroup(FitPhases phases_, CountryBondSource source_, BondField timeToMaturity_, Focus focus_, int recalcNumber_, bool fitOnEvent_=true)
    {
      m_settings = new SmoothCurveSettings(phases_);

      LiveCMT = new CMTLine(source_.Market,focus_);

      DateTime thirtyYearsTime = DateTime.Today.AddYears(34);

      LiveCalculator = new SmoothCurveCalculator(
        cml_: LiveCMT,
        cmlStartTenor_: 1,
        cmlEndTenor_: 34,
        list_: source_.Lines.Where(x => x.Maturity <= thirtyYearsTime).ToList(),
        timeToMaturityField_: timeToMaturity_,
        valueField_: BondAnalysisLineHelper.GetFieldForFocusAndType(focus_,FieldType.Live),
        fittedValueField_: BondAnalysisLineHelper.GetFieldForFocusAndType(focus_,FieldType.FittedLive),
        recalcNumber_: recalcNumber_,
        updateOnCalcEvent_: fitOnEvent_,
        settings_: Settings);
    }
コード例 #2
0
    public SmoothCurveCalculator(
      CMTLine cml_,
      int cmlStartTenor_,
      int cmlEndTenor_,
      IList<BondAnalysisLine> list_, 
      BondField timeToMaturityField_, 
      BondField valueField_, 
      BondField fittedValueField_, 
      SmoothCurveSettings settings_, 
      int recalcNumber_,
      bool updateOnCalcEvent_=true, 
      bool updateOnMinusOffsetChange_=false)
    {
      m_bondList = list_;
      m_timeToMaturityField = timeToMaturityField_;
      m_valueField = valueField_;
      m_fittedValueField = fittedValueField_;
      m_settings = settings_;
      m_cmlStartTenor = cmlStartTenor_;
      m_cmlEndTenor = cmlEndTenor_;
      m_fitter = new Symmetry.Analytics.NelsonSiegelFunctions();

      m_cml = cml_;

      //m_settings.PropertyChanged += (a, b) => RebuildCurve(reReadSetup_: true);

      reReadSetup();

      m_applyCycleNumber = recalcNumber_;

#if DEBUG
      Logger.Debug(string.Format("{0} fit will be generated on cycle {1}", m_cml.Market, m_applyCycleNumber), typeof(SmoothCurveCalculator));
#endif 

      m_updateOnCalcEvent = updateOnCalcEvent_;
      subscribeToCentralEvent();

      // if the curve build settings change then want to recalc everything
      settings_.PropertyChanged += (a, b) =>
      {
        Logger.Debug(string.Format("Args changed - recalcing {0} fit", m_valueField), typeof (SmoothCurveCalculator));
        RebuildCurveAndApplyResults();
      };

      if (updateOnMinusOffsetChange_)
      {
        m_updateOnMinusOffsetChange = true;
        GlobalSettings.Instance().PropertyChanged += (a, b) =>
        {
          if (String.Compare(b.PropertyName, "MinusOffset", StringComparison.OrdinalIgnoreCase) == 0)
          {
            // this will mean this will get updated on the next cycle
            subscribeToCentralEvent(true);
          }
        };
      }

      foreach (var bond in m_bondList)
        bond.PropertyChanged += (x, y) =>
        {
          if (String.Compare("IncludeInFit", y.PropertyName, StringComparison.OrdinalIgnoreCase) == 0)
          {
            RebuildCurve(reReadSetup_: true);
            ApplyBuildResults();
          }
        };
      ;
    }