public AveragePrice CombineIntoOne(DateTime start, DateTime end) { var complete = new AveragePrice(); var matchingSelection = Prices .Where(p => p.Date >= start && p.Date <= end && p.Avg > 0) .OrderBy(p => p.Date); if (matchingSelection.Count() == 0 || matchingSelection.First().Date.Ticks == 0) { return(complete); } complete.Min = Int32.MaxValue; foreach (var item in matchingSelection) { complete.Avg += item.Avg; complete.Volume += item.Volume; if (complete.Max < item.Max) { complete.Max = item.Max; } if (complete.Min > item.Min) { complete.Min = item.Min; } } complete.Avg /= Prices.Count(); complete.Date = matchingSelection.Where(p => p.Date.Ticks > 0).First().Date; return(complete); }
public AveragePriceSync(AveragePrice price) { this.SId = price.Id; this.SItemId = price.ItemId; this.Max = price.Max; this.Avg = price.Avg; this.Min = price.Min; this.Date = price.Date; this.Volume = price.Volume; }
public void AddNew(AveragePrice price) { // only add if the date is newer if (Youngest == null || Youngest.Date < price.Date) { Prices.Add(price); } else { throw new Exception("to early");//Console.Write("ta - " + price.ItemId); } }
private Resonse FromItemLookup(ItemLookup value, string itemTag, AveragePrice additional = null) { return(FromList(additional == null || additional.Volume == 0 ? value.Prices : value.Prices.Append(additional), itemTag)); }