// should only be called within write lock private void populateConstructWithDayAtIndex(Day day_, RollGeneration gen_) { if (day_ == null || day_.Lines == null) return; #if DEBUG var sw = new Stopwatch(); sw.Start(); #endif foreach (var line in day_.Lines) { var relativeDate = new RelativeDate(day_.Dates, line.GmtDateAsDate().ToTZfromGMT(day_.DispTimeZone)); if (relativeDate.Index == -1) // this shouldn't happen continue; m_data.SetValue(relativeDate, (int)gen_, line); } #if DEBUG sw.Stop(); Logger.Info(string.Format("Backfilling {0} took {1}ms (Lines={2})", day_, sw.ElapsedMilliseconds, day_.Lines.Count), typeof (LiveDayComparison)); #endif }
public async void Create(LiveDayComparison comp_, RollGeneration generation_) { var con = await Task.Run(() => comp_.GetMinuteFrontBackOpenInterestValues(generation_)); lineChartDataDisplay1.ClearSeries(); if (con == null || con.Keys.Count == 0) return; { var frontPct = new double[con.Keys.Count]; var backPct = new double[con.Keys.Count]; for (int i = 0; i < con.Keys.Count; ++i) { var vals = con.GetValues(con.Keys[i]); frontPct[i] = vals[0]/(vals[0] + vals[1]); backPct[i] = vals[1] / (vals[0] + vals[1]); } var labels = con.Keys.Select(x => x.ToString()).ToArray(); var chart = lineChartDataDisplay1.AddSeries( xAxisValues_: labels, values_: frontPct, desc_: "Front", yAxisExtent_: 40, yLabelFormat_: "##0.0%", color_:Color.White ); chart.AxisX.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart; chart.AxisX.Extent = 60; chart.AxisX.TickmarkInterval = 10; chart.AxisX.TickmarkPercentage = 0.1; chart.AxisX.MajorGridLines.Visible = false; chart= lineChartDataDisplay1.AddSeries( xAxisValues_: labels, values_: backPct, desc_: "Back", yAxisExtent_: 40, yLabelFormat_: "##0.0%", color_: Color.Yellow ); chart.AxisX.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart; chart.AxisX.Extent = 60; chart.AxisX.TickmarkInterval = 10; chart.AxisX.TickmarkPercentage = 0.1; chart.AxisX.MajorGridLines.Visible = false; } }
public ConstructGenGen<RelativeDate,double> GetMinuteFrontBackOpenInterestValues(RollGeneration generation_) { var day = GetDay(generation_); var hour = day.DispTimeZone == DisplayTimeZone.NYK ? 15 : 16; var oiDates = day.Dates.Select(x => new Tuple<DateTime, RelativeDate>(x, new RelativeDate(day.Dates, x.AddHours(hour)))); var ret = new ConstructGenGen<RelativeDate, double>(new[] {"Front", "Back"}); try { m_lock.EnterReadLock(); var startDate = day.Dates.Min(); var frontStartingValue = day.OI_From.ValueOnDate(startDate, -1); var backStartingValue = day.OI_To.ValueOnDate(startDate, -1); double priorValueFront = frontStartingValue; double priorValueBack = backStartingValue; for (int i = 0; i < m_data.Keys.Count; ++i) { var key = m_data.Keys[i]; if (i == 0) { ret.SetValue(key, 0, frontStartingValue, ConstructGenGen<RelativeDate, double>.KeyOptionsWhenAdding.AddEveryTime); ret.SetValue(key, 1, backStartingValue, ConstructGenGen<RelativeDate, double>.KeyOptionsWhenAdding.AssumeKeyAlreadyThere); continue; } var matchOnExactOI = oiDates.FirstOrDefault(x => x.Item2 == key); bool handled = false; if (matchOnExactOI!=null) { var frontOI = priorValueFront = day.OI_From.ValueOnExactDate(matchOnExactOI.Item1); var backOI = priorValueBack = day.OI_To.ValueOnExactDate(matchOnExactOI.Item1); if (!frontOI.IsZero() || !backOI.IsZero()) { ret.SetValue(key, 0, frontOI, ConstructGenGen<RelativeDate, double>.KeyOptionsWhenAdding.AddEveryTime); ret.SetValue(key, 1, backOI, ConstructGenGen<RelativeDate, double>.KeyOptionsWhenAdding.AssumeKeyAlreadyThere); handled = true; } } if(!handled) { var line = m_data.GetValue(key, (int)generation_); double increment = line == null ? 0d : line.SpreadVolume; ret.SetValue(key, 0, priorValueFront - increment, ConstructGenGen<RelativeDate, double>.KeyOptionsWhenAdding.AddEveryTime); ret.SetValue(key, 1, priorValueBack + increment, ConstructGenGen<RelativeDate, double>.KeyOptionsWhenAdding.AssumeKeyAlreadyThere); priorValueFront -= increment; priorValueBack += increment; } } } finally { m_lock.ExitReadLock(); } return ret; }
public ConstructGenGen<RelativeDate, double> GetOIFrontBackOpenInterestValues(RollGeneration generation_) { if (m_oiInterestValues != null) return m_oiInterestValues; var day = GetDay(generation_); var hour = day.DispTimeZone == DisplayTimeZone.NYK ? 15 : 16; var ret = new ConstructGenGen<RelativeDate, double>(new[] { "Front", "Back" }); foreach (var date in day.Dates) { var relDate = new RelativeDate(day.Dates, date.AddHours(hour)); ret.SetValue(relDate, 0, day.OI_From.ValueOnDate(date)); ret.SetValue(relDate, 1, day.OI_To.ValueOnDate(date)); } return m_oiInterestValues = ret; }
public Day GetDay(RollGeneration generation_) { return generation_ == RollGeneration.Current ? m_currentRoll : m_priorRoll; }
public Tuple<RelativeDate[],Line[]> GetGenerationData(RollGeneration generation_) { Tuple<RelativeDate[], Line[]> ret = null; try { m_lock.EnterReadLock(); ret = new Tuple<RelativeDate[], Line[]>( m_data.Keys.ToArray(), m_data.GetColumnValues((int)generation_)); } finally { m_lock.ExitReadLock(); } return ret; }
public IDoubleMonitor GetLiveSpreadOnHourVolumeMonitor(RollGeneration generation_, bool forceRegeneration_=false) { var key = getMonitorKey("LiveDaysSpreadVolume", generation_); return getorCreateMonitor(key, () => { var startKey = new RelativeDate(GetDay(generation_).Dates, DateTime.Today); return new CumulativeSinceTimeMonitor(startKey, this, generation_, DayField.SpreadVolume); }, forceRegeneration_); }
public IDoubleMonitor GetLiveSpreadOnDayVolumeMonitor(RollGeneration generation_, bool forceRegeneration_ = false) { var key = getMonitorKey("LiveDaysSpreadVolume", generation_); return getorCreateMonitor(key, () => { // index of current day in current set var index = RelativeDate.FindIndex(GetDay(RollGeneration.Current).Dates, DateTime.Today); if (index < 0) return null; var startKey = new RelativeDate(GetDay(generation_).Dates, GetDay(generation_).Dates[index]); return new CumulativeSinceTimeMonitor(startKey, this, generation_, DayField.SpreadVolume); }, forceRegeneration_); }
private static string getMonitorKey(string type_, RollGeneration generation_) { return string.Format("{0}_{1}", type_, generation_); }