Ejemplo n.º 1
0
 public void Dispose()
 {
   innerDispose();
   m_bond = null;
   m_context = null;
   m_measures = null;
 }
Ejemplo n.º 2
0
 protected BondMeasureCalcBase(Bond bond_, AsOfAndSpotSettle dateContext_, DateTime settleDate_, BondMeasures updateThis_)
 {
   m_measures = updateThis_;
   m_bond = bond_;
   m_context = dateContext_;
   SettleDate = settleDate_;
 }
    private async Task initiate(CarbonClient cc_, BondMeasures listenToThis_)
    {
      m_fcsCurve = await IRCurveImpl.Get(SwapCurve.GetForecastCurve(), DateContext, cc_);

      // if we're doing calcs on the forwards, then don't need to listen to the curve directly
      // as the forward price will be updated as a result of a change in curve and will trickle
      // through to us as a price update
      if (SettleDate == DateContext.SpotSettle)
        m_fcsCurveDisp = m_fcsCurve.GetMonitor()/*.Throttle(TimeSpan.FromSeconds(10),Scheduler.Default)*/.Subscribe(handleFcstCurveUpdate);

      if (SwapCurve.GetForecastCurve() == SwapCurve.GetDiscountCurve())
      {
        m_disCurve = m_fcsCurve;
      }
      else
      {
        m_disCurve = await IRCurveImpl.Get(SwapCurve.GetForecastCurve(), DateContext, cc_);
        if (SettleDate == DateContext.SpotSettle)
          m_disCurveDisp = m_disCurve.GetMonitor()/*.Throttle(TimeSpan.FromSeconds(10), Scheduler.Default)*/.Subscribe(handleDiscCurveUpdate);
      }

      // 
      var flds = new[] { BondMeasure.Price, BondMeasure.Yield };
      Array.ForEach(flds, fld =>
      {
        var d = listenToThis_.GetValue(fld);
        if (d.HasValue)
          m_measures.SetValue(fld, d.Value);
      });

      calcMMS();
      calcZSpread();

    }
    public BondMeasureCalcPriceYield(Bond bond_, AsOfAndSpotSettle context_, DateTime settleDate_, BondMeasures measures_)
      : base (bond_, context_, settleDate_, measures_)
    {
      m_measuresDisp = measures_.Subscribe(handleUpdate);

      {
        var px = measures_.GetValue(BondMeasure.Price);
        if (px.HasValue)
          handleUpdate(Tuple.Create(BondMeasure.Price, px.Value));
      }
    }
    public BondMeasureCalcFwdPriceYield(Bond bond_, AsOfAndSpotSettle dateContext_,  DateTime settlDate_, BondMeasures spotMeasures_, BondMeasures measures_)
      : base(bond_, dateContext_, settlDate_,measures_)
    {

      m_spotMeasureDisp = spotMeasures_.Subscribe(handleSpotMeasureUpdated);

      {
        var px = spotMeasures_.GetValue(BondMeasure.Price);
        if (px.HasValue)
          handleSpotMeasureUpdated(Tuple.Create(BondMeasure.Price, px.Value));
      }

    }
    private BondMeasureCalcSpreadsOverCurve(
      Bond bond_, 
      SwapCurve swapcurve_, 
      AsOfAndSpotSettle dateContext_, 
      DateTime settleDate_,
      BondMeasures updateThis_, 
      BondMeasures listenToThis_
      ) : base(bond_,dateContext_,settleDate_,updateThis_)
    {
      SwapCurve = swapcurve_;

      m_listenToThisDisp = listenToThis_.Subscribe(listenToUpdated);
      m_myMeasuresDisp = updateThis_.Subscribe(myMeasuresUpdated);

    }
Ejemplo n.º 7
0
    internal BondMeasureCalcPriceYield CreatePriceYield(AsOfAndSpotSettle aass_, DateTime fwdDate_)
    {
      // if we're after the spot measures for today, then send back the one that's being maintained via the price subscription
      if (aass_.AsOf == OwningMarket.Today.AsOf && fwdDate_==OwningMarket.Today.SpotSettle)
        return GetLiveSpotPriceYield();

      // if the desired spotsettle is equal to the fwddate, then we're being asked for a spot date on (likely) an historic date.
      // so, need to populate the historic price to allow the calc to be done
      if (aass_.SpotSettle == fwdDate_)
      {
        var measures = new BondMeasures(this);
        if (HistoricPrices.HasDate(aass_.AsOf))
          measures.SetValue(BondMeasure.Price, HistoricPrices.ValueOnDateExact(aass_.AsOf));

        return new BondMeasureCalcPriceYield(this, aass_, fwdDate_, measures);
      }

      return new BondMeasureCalcFwdPriceYield(this, aass_, fwdDate_, CreatePriceYield(aass_,aass_.SpotSettle).Measures,  new BondMeasures(this));
    }
Ejemplo n.º 8
0
 public BondAddedEventArgs(BondMeasures bond_)
 {
   BondOverCurve = bond_;
 }
    public static async Task<BondMeasureCalcSpreadsOverCurve> Create(
            Bond bond_,
      SwapCurve swapcurve_,
      AsOfAndSpotSettle dateContext_,
      DateTime settleDate_,
      BondMeasures updateThis_,
      BondMeasures listenToThis_,
      CarbonClient cc_
)
    {
      var impl = new BondMeasureCalcSpreadsOverCurve(bond_, swapcurve_, dateContext_, settleDate_, updateThis_,
        listenToThis_);

      await impl.initiate(cc_,listenToThis_);

      return impl;
    }