public RampingStrategySummary( IPriceImpactSummary priceImpact, ITimeSeriesTrendClassification trendClassification, RampingStrategy rampingStrategy, TimeSegment timeSegment) { this.PriceImpact = priceImpact ?? throw new ArgumentNullException(nameof(priceImpact)); this.TrendClassification = trendClassification ?? throw new ArgumentNullException(nameof(trendClassification)); this.RampingStrategy = rampingStrategy; this.TimeSegment = timeSegment; }
public TimeSeriesTrendClassification( IFinancialInstrument instrument, TimeSeriesTrend trend, DateTime commencementUtc, DateTime terminationUtc, TimeSegment timeSegment) { this.Instrument = instrument ?? throw new ArgumentNullException(nameof(instrument)); this.Trend = trend; this.CommencementUtc = commencementUtc; this.TerminationUtc = terminationUtc; this.TimeSegment = timeSegment; }
public void CanFormatTimeSegment() { var segment = new TimeSegment { Start = new DateTime(2016, 8, 30, 23, 44, 08), End = new DateTime(2016, 8, 30, 23, 59, 59) }; var json = new BsonDocument { { "start", segment.Start.ToString("HH:mm:ss") }, { "end", segment.End.ToString("HH:mm:ss") }, { "diration", segment.Span.Hours + "h " + segment.Span.Minutes + "m " + segment.Span.Seconds + "s" }, { "minutes", segment.Span.TotalMinutes.Round(2) }, { "hours", segment.Span.TotalHours.Round(2) }, { "task_id", segment.Id }, { "task_comment", segment.Comment } }; Console.WriteLine(json); }
void timer1_Tick(object sender, EventArgs e) { if (Status == TimerStatus.Running) { int h = NowTimerValue.Hours; int m = NowTimerValue.Minutes; int s = NowTimerValue.Seconds; if (s > 0) { s--; } else if (m > 0) { m--; s = 59; } else if (h > 0) { h--; m = 59; s = 59; } else { OnTimeIsOver(); } if (h <= 0 && m <= 0 && s <= 0) { OnTimeIsOver(); } else { NowTimerValue = new TimeSegment(h, m, s); } } else { timer1.Enabled = false; } }
// POST api/customers public HttpResponseMessage Post([FromBody] TimeSegment timeSegmentDto) { return(ActionWarpper.Process(timeSegmentDto, OperationCodes.ATMSGM, () => { var repo = RepositoryManager.GetRepository <ITimeSegmentRepository>(); if (repo.Query(new Hashtable() { { "TimeSegmentCode", timeSegmentDto.TimeSegmentCode } }).Any()) { return new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(string.Format("系统中已经存在编号为{0}的时间段", timeSegmentDto.TimeSegmentCode)), ReasonPhrase = ConstStrings.BusinessLogicError, }; } var timeSegment = repo.Insert(timeSegmentDto); return Request.CreateResponse(HttpStatusCode.OK, timeSegment); }, this)); }
public void StartNewSegment(string key) { if (!Enabled) { return; } if (m_stopwatch.IsRunning) { CloseSegment(); } if (!m_segments.Contains(key)) { m_segments.Add(key, new TimeSegment(key)); } m_lastSegmentRef = m_segments[key] as TimeSegment; m_stopwatch.Restart(); }
public void DeleteTimeSegment(TimeSegment ts) { _context.Remove(ts); _context.SaveChanges(); }
public void AddTimeSgment(TimeSegment ts) { _context.Add(ts); }
public IPriceImpactSummary ClassifyByWeightedVolume(IReadOnlyCollection <Order> orders, TimeSegment segment) { if (!orders.Any()) { return(new PriceImpactSummary(PriceImpactClassification.Unknown, segment)); } var buySide = orders .Where(_ => _.OrderDirection == OrderDirections.BUY || _.OrderDirection == OrderDirections.COVER) .Sum(_ => _.OrderFilledVolume ?? 0); var sellSide = orders .Where(_ => _.OrderDirection == OrderDirections.SELL || _.OrderDirection == OrderDirections.SHORT) .Sum(_ => _.OrderFilledVolume ?? 0); if (buySide == 0) { var impact = sellSide == 0 ? PriceImpactClassification.Unknown : PriceImpactClassification.Negative; return(new PriceImpactSummary(impact, segment)); } var totalVolume = orders.Sum(_ => _.OrderFilledVolume ?? 0); if (totalVolume == 0) { return(new PriceImpactSummary(PriceImpactClassification.Unknown, segment)); } var proportionBuySide = buySide / totalVolume; if (proportionBuySide >= 0.66m) { return(new PriceImpactSummary(PriceImpactClassification.Positive, segment)); } if (proportionBuySide <= 0.33m) { return(new PriceImpactSummary(PriceImpactClassification.Negative, segment)); } return(new PriceImpactSummary(PriceImpactClassification.Unknown, segment)); }
public TimerDialog(int hour, int minute, int second) : this() { TimerValue = new TimeSegment(hour, minute, second); Status = TimerStatus.Paused; }
public void Add(TimeSegment segment) { if (segment != null && segment.BeginTime <= segment.EndTime) { if (TimeSegments.Count == 0) { TimeSegments.Add(segment); } else { int leftIndex = -1; int rightIndex = -1; bool handled = false; for (int i = 0; i < TimeSegments.Count; i++) { if (TimeSegments[i].Equals(segment)) { handled = true; break; } if (IsSurrounding(TimeSegments[i], segment)) { TimeSegments[i].BeginTime = segment.BeginTime; TimeSegments[i].EndTime = segment.EndTime; CollapseLeft(i); CollapseRight(i); handled = true; break; } if (IsWithin(TimeSegments[i], segment.BeginTime)) { if (segment.EndTime > TimeSegments[i].EndTime) { TimeSegments[i].EndTime = segment.EndTime; CollapseRight(i); } handled = true; break; } if (IsWithin(TimeSegments[i], segment.EndTime)) { if (segment.BeginTime < TimeSegments[i].BeginTime) { TimeSegments[i].BeginTime = segment.BeginTime; CollapseLeft(i); } handled = true; break; } if (IsLeftOf(segment, TimeSegments[i].BeginTime)) { leftIndex = i; break; } else if (IsRightOf(segment, TimeSegments[i].EndTime)) { rightIndex = i; } } if (!handled) { if (rightIndex + 1 is int newIndex && newIndex >= 1) { if (TimeSegments.Count > newIndex) { TimeSegments.Insert(newIndex, segment); } else { TimeSegments.Add(segment); } } else if (leftIndex >= 0) { TimeSegments.Insert(leftIndex, segment); } } } }
public TimeRange(TimeSegment segment) { TimeSegments.Add(segment); }
public PriceImpactSummary(PriceImpactClassification classification, TimeSegment timeSegment) { this.Classification = classification; this.TimeSegment = timeSegment; }
public ITimeSeriesTrendClassification Classify( List <EquityInstrumentIntraDayTimeBar> timeBars, IFinancialInstrument financialInstrument, DateTime commencement, DateTime termination, TimeSegment timeSegment) { if (timeBars == null || !timeBars.Any()) { this._logger?.LogWarning("Received an empty or null time bars collection"); return(new TimeSeriesTrendClassification( financialInstrument, TimeSeriesTrend.Unclassified, commencement, termination, timeSegment)); } var orderedTimeBars = timeBars.OrderBy(_ => _.TimeStamp).ToList(); // basic implementation for initial work - we will make this more sophisticated in response to tests var initial = orderedTimeBars.FirstOrDefault(); var final = orderedTimeBars.LastOrDefault(); if (initial == null || final == null) { return(new TimeSeriesTrendClassification( financialInstrument, TimeSeriesTrend.Unclassified, commencement, termination, timeSegment)); } // TODO take a volatiltiy measure and return chaotic if volatiltiy is high if (final.SpreadTimeBar.Price.Value > initial.SpreadTimeBar.Price.Value) { return(new TimeSeriesTrendClassification( financialInstrument, TimeSeriesTrend.Increasing, commencement, termination, timeSegment)); } if (final.SpreadTimeBar.Price.Value < initial.SpreadTimeBar.Price.Value) { return(new TimeSeriesTrendClassification( financialInstrument, TimeSeriesTrend.Decreasing, commencement, termination, timeSegment)); } return(new TimeSeriesTrendClassification( financialInstrument, TimeSeriesTrend.Unclassified, commencement, termination, timeSegment)); }
public TimerDialog(TimeSegment timerValue) : this() { TimerValue = new TimeSegment(timerValue.Hours, timerValue.Minutes, timerValue.Seconds); Status = TimerStatus.Paused; }
public Trun(Stream fs, ulong maximumLength) { Samples = new List <TimeSegment>(); if (maximumLength <= 4) { return; } Buffer = new byte[maximumLength - 4]; var readCount = fs.Read(Buffer, 0, Buffer.Length); if (readCount < (int)maximumLength - 4) { return; } var versionAndFlags = GetUInt(0); var version = versionAndFlags >> 24; var flags = versionAndFlags & 0xFFFFFF; var sampleCount = GetUInt(4); int pos = 8; if ((flags & 0x000001) > 0) { pos += 4; } // skip "first_sample_flags" if present if ((flags & 0x000004) > 0) { pos += 4; } for (var sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++) { var sample = new TimeSegment(); if (pos > Buffer.Length - 4) { return; } // read "sample duration" if present if ((flags & 0x000100) > 0) { sample.Duration = GetUInt(pos); pos += 4; } if (pos > Buffer.Length - 4) { return; } // skip "sample_size" if present if ((flags & 0x000200) > 0) { pos += 4; } if (pos > Buffer.Length - 4) { return; } // skip "sample_flags" if present if ((flags & 0x000400) > 0) { pos += 4; } if (pos > Buffer.Length - 4) { return; } // read "sample_time_offset" if present if ((flags & 0x000800) > 0) { sample.TimeOffset = version == 0 ? GetUInt(pos) : (uint)GetUInt(pos); pos += 4; } Samples.Add(sample); } }
public IPriceImpactSummary ClassifyByTradeCount(IReadOnlyCollection <Order> orders, TimeSegment segment) { if (!orders.Any()) { return(new PriceImpactSummary(PriceImpactClassification.Unknown, segment)); } var buySide = orders.Count( _ => _.OrderDirection == OrderDirections.BUY || _.OrderDirection == OrderDirections.COVER); if (buySide == 0) { return(new PriceImpactSummary(PriceImpactClassification.Negative, segment)); } var proportionBuySide = buySide / (decimal)orders.Count; if (proportionBuySide >= 0.66m) { return(new PriceImpactSummary(PriceImpactClassification.Positive, segment)); } if (proportionBuySide <= 0.33m) { return(new PriceImpactSummary(PriceImpactClassification.Negative, segment)); } return(new PriceImpactSummary(PriceImpactClassification.Unknown, segment)); }