Exemple #1
0
    private async Task populateDates(CarbonClient cc_)
    {
      var yesterday = await cc_.RollDateAsync(
  date: DateTime.Today.ToNodaLocalDate(),
  count: -1,
  unit: Symmetry.Carbon.Model.DateUnit.Bd,
  convention: Symmetry.Carbon.Model.BusinessDayConvention.Following,
  calendar: Market.HolidayCode());

      var spotSettle = await cc_.RollDateAsync(
  date: DateTime.Today.ToNodaLocalDate(),
  count: Market.DaysToSpot(),
  unit: Symmetry.Carbon.Model.DateUnit.Bd,
  convention: Symmetry.Carbon.Model.BusinessDayConvention.Following,
  calendar: Market.HolidayCode());

      var yesterdaySettle = await cc_.RollDateAsync(
        date: yesterday,
        count: Market.DaysToSpot(),
        unit: Symmetry.Carbon.Model.DateUnit.Bd,
        convention: Symmetry.Carbon.Model.BusinessDayConvention.Following,
        calendar: Market.HolidayCode());


      Today = new AsOfAndSpotSettle(DateTime.Today, spotSettle.ToDateTime());
      Yesterday = new AsOfAndSpotSettle(yesterday.ToDateTime(), yesterdaySettle.ToDateTime());


    }
 public void Dispose()
 {
   innerDispose();
   m_bond = null;
   m_context = null;
   m_measures = null;
 }
 protected BondMeasureCalcBase(Bond bond_, AsOfAndSpotSettle dateContext_, DateTime settleDate_, BondMeasures updateThis_)
 {
   m_measures = updateThis_;
   m_bond = bond_;
   m_context = dateContext_;
   SettleDate = settleDate_;
 }
    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);

    }
Exemple #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));
    }
 public CMTStructure(BondMarket market_, AsOfAndSpotSettle asOf_)
 {
   Market = market_;
   DateContext = asOf_;
   workOutSections();
 }
    public async Task<CMT> CreateCMTImpl(BondMeasure field_, AsOfAndSpotSettle asOfAndSpotSettle_, DateTime settleDate_, SwapCurve curve_, CarbonClient cc_)
    {
      var pricer = await BondMarketPricer.Create(Market, curve_, asOfAndSpotSettle_, settleDate_, cc_);

      return new CMT(
        structure_: this,
        initialField_: field_,
        curve_: curve_,
        pricer_: pricer
        );
    }
    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;
    }
 public static async Task<BondMarketPricer> Create(BondMarket market_, SwapCurve curve_, AsOfAndSpotSettle dateContext_, DateTime settleDate_, CarbonClient cc_)
 {
   var ret = new BondMarketPricer(dateContext_, settleDate_);
   await ret.initiate(market_, curve_, cc_);
   return ret;
 }
    private BondMarketPricer(AsOfAndSpotSettle dateContext_, DateTime settleDate_)
    {
      DateContext = dateContext_;
      SettleDate = settleDate_;

    }