private PricePoints GetPricePoints(OrderBookDao.Entity orderBook) { if (pricePointsCache == null) { pricePointsCache = new Dictionary <string, Dictionary <OrderBookDao.Entity, PricePoints> >(); } if (pricePointsCache.ContainsKey(selectedInstrument.Name) == false) { pricePointsCache.Add(selectedInstrument.Name, new Dictionary <OrderBookDao.Entity, PricePoints>()); } var orderBookPricePoints = pricePointsCache[selectedInstrument.Name]; if (orderBookPricePoints.ContainsKey(orderBook)) { return(orderBookPricePoints[orderBook]); } PricePoints pricePoints = new PricePoints(); pricePoints.rate = orderBook.Rate; pricePoints.price_points = new Dictionary <float, PricePoint>(); foreach (var pp in orderBook.GetPricePointsOrderByPrice()) { pricePoints.price_points[pp.Price] = new PricePoint() { os = pp.Os, ol = pp.Ol, ps = pp.Ps, pl = pp.Pl }; } orderBookPricePoints[orderBook] = pricePoints; return(pricePoints); }
private static IEnumerable <OrderBookPricePointDao.Entity> GetRangePricePoint(OrderBookDao.Entity orderBook, float min, float max) { float start = GetRoundPrice(min); float end = GetRoundPrice(max); foreach (var pricePoint in orderBook.GetPricePointsOrderByPrice()) { if (start - 0.001f <= pricePoint.Price && pricePoint.Price <= end + 0.001f) { yield return(pricePoint); } } }
private static OrderBookPricePointDao.Entity GetRatePricePoint(OrderBookDao.Entity orderBook, float rate) { float min = float.MaxValue; OrderBookPricePointDao.Entity closedPricePoint = null; foreach (var pricePoint in orderBook.GetPricePointsOrderByPrice()) { float d = Math.Abs(rate - pricePoint.Price); if (d < min) { min = d; closedPricePoint = pricePoint; } } return(closedPricePoint); }
private void LoadChart(Chart chart, OrderBookDao.Entity orderBook) { PricePoints pricePoints = new PricePoints(); pricePoints.rate = orderBook.Rate; pricePoints.price_points = new Dictionary <float, PricePoint>(); foreach (var pp in orderBook.GetPricePointsOrderByPrice()) { pricePoints.price_points[pp.Price] = new PricePoint() { os = pp.Os, ol = pp.Ol, ps = pp.Ps, pl = pp.Pl }; } LoadChart(chart, orderBook.DateTime, pricePoints); }