public static ConstructGen<double> TestOnCT() { var str = KnownStructure.US_WN; var comps = new[] { new ChartComponent(), new ChartComponent(), new ChartComponent(), }; var bondsRollMonthly = Generator.Go(cashBondRollOption_: Generator.CashBondRolling.Monthly); var spreadsRollMonthly = new Dictionary<BondCurves, List<CTDLine<BondSpreads>>>(); spreadsRollMonthly[BondCurves.USD3mLibor] = Generator.GetSpreads(bondsRollMonthly, BondCurves.USD3mLibor, Generator.CashBondRolling.Monthly); var cdRollMonthly = new ChartDataSource(comps, spreadsRollMonthly, bondsRollMonthly); var impl = StructureFactory.GetStructure(str); impl.Configure(comps); var data = cdRollMonthly.GetData().SmoothedData.GetEndValues(650); var con = new ConstructGen<double>(1); con.SetColumnValues(0, data); return con; }
public void Create(IDictionary<BondCurves,List<CTDLine<BondSpreads>>> spreads_, List<CTDLine<Bond>> bonds_) { m_editors = new[] { this.chartComp1, this.chartComp2, this.chartComp3 }; Array.ForEach(m_editors, (x) => x.Create()); m_data = new ChartDataSource(m_editors.Select(x => x.Component).ToArray(), spreads_, bonds_); cbHandleRoll.DataBindings.Add("Checked", m_data, "SmoothRolling", false, DataSourceUpdateMode.OnPropertyChanged); }
public HistSeriesChartViewModel() { var rollsetting = new RollSettings {DataSource = RollDataSource.CarbonLive}; futureRollCache = new FutureRollCache(rollsetting); // we use carbon live for this. futureContracts = FutureContractsFactory.CreateFutureContracts(); var task = new Task(() => { try { var bonds = Generator.Go(Generator.CashBondRolling.Monthly); var dictionary = new Dictionary<BondCurves, List<CTDLine<BondSpreads>>> { {BondCurves.USD3mLibor, Generator.GetSpreads(bonds, BondCurves.USD3mLibor)} }; m_cd = new ChartDataSource(chartComponents_: new[] { new ChartComponent(), new ChartComponent(), new ChartComponent() }, bonds_: bonds, spreads_: dictionary ); // subscribe to live curve and live bonds m_live = new LiveDataModel(bonds.Last()); } catch (Exception ex_) { Logger.Error("Error building CTD data for seasonality application", typeof(HistSeriesChartViewModel), ex_); } }); task.ContinueWith( t => { // hook up carbon and live data result m_live.SubscribeForLiveCurveAndBondPrices(); }); task.ContinueWith(t => m_live.BondSpreadModel().BondSpreadResultObservable().Where(b => b != null) .ObserveOn(SynchronizationContext.Current) .Subscribe(LiveChartUpdate), TaskScheduler.FromCurrentSynchronizationContext()); task.Start(); }
public void Create() { if (m_args != null) return; var task = new Task(() => { try { var bonds = Generator.Go(Generator.CashBondRolling.Monthly); var dictionary = new Dictionary<BondCurves, List<CTDLine<BondSpreads>>> { {BondCurves.USD3mLibor, Generator.GetSpreads(bonds, BondCurves.USD3mLibor)} }; m_cd = new ChartDataSource(chartComponents_: new[] { new ChartComponent(), new ChartComponent(), new ChartComponent() }, bonds_: bonds, spreads_: dictionary ); } catch (Exception ex_) { Logger.Error("Error building CTD data for seasonality application", typeof(CTSeasonalityComponent), ex_); } }); m_args = new Args(); boundComboBox1.AddItems(typeof(KnownStructure), true); boundComboBox1.Bind(m_args, "KnownStructure", new Validators.EnumDescValidator(KnownStructure.Basis10Y)); //lblEquation.Bind(m_args, "StructureEquation", null); TextBoxEquation.Bind(m_args, "StructureEquation", null); task.Start(); }
override public void Create() { base.Create(); var structures = new[] { KnownStructure.Basis5Y, KnownStructure.Basis7Y, KnownStructure.Basis10Y, KnownStructure.Basis30Y, KnownStructure.FV_3s, KnownStructure.TU_3s, KnownStructure.TY_US, KnownStructure.US_WN, KnownStructure.USASWFLY, KnownStructure.TYASWFLY }; var task = new Task(() => { try { var bonds = Generator.Go(Generator.CashBondRolling.Monthly); var dictionary = new Dictionary<BondCurves, List<CTDLine<BondSpreads>>> { {BondCurves.USD3mLibor, Generator.GetSpreads(bonds, BondCurves.USD3mLibor)} }; m_cd = new ChartDataSource(chartComponents_: new[] { new ChartComponent(), new ChartComponent(), new ChartComponent() }, bonds_: bonds, spreads_: dictionary ); } catch (Exception ex_) { Logger.Error("Error building CTD data for seasonality application", typeof(CTSeasonalityComponent), ex_); } }); foreach (var s in structures) { var button = new StructureButton(s); flowLayoutPanel1.Controls.Add(button); button.Click += (a_, b_) => { var b = (StructureButton)a_; try { if (m_cd == null) { displayMessage("Data is still being put together. Please try again in a sec.", "Data building...", MessageBoxIcon.Information); return; } var eventARgs = GiveMeEvents(); if (!canProcessArgs(eventARgs)) return; var o = Structures.StructureFactory.GetStructure(b.Structure); o.Configure(m_cd.Components); var data = m_cd.GetData(); var list = new List<SeasonalityAnalysis.DataAroundEvent>(); foreach (var v in eventARgs.Events) { list.Add(new SeasonalityAnalysis.DataAroundEvent(eventDate_: v.Date.Date, instrument_: o, data_: data.SmoothedData, numPointsAroundEvent_: eventARgs.NumberOfPointsAroundEvent, eventCode_: v.SourceEvent.EventCode)); } OnDataAroundEventsGenerated(new SeasonalityAnalysis.DataAroundEVentsGeneratedData() { DataAroundEvents = list.ToArray() }); } catch (Exception ex_) { Logger.Error("Error", typeof(CTSeasonalityComponent), ex_); } }; } task.Start(); }