コード例 #1
0
        public Orderbook GetOrderbookUpdates(Orderbook oldOrderbook, Orderbook newOrderbook)
        {
            var result = JsonConvert.DeserializeObject <Orderbook>(newOrderbook.ToJson());

            var asks = MergeLevels(oldOrderbook.Asks.Select(x =>
                                                            new VolumePriceModel {
                Volume = Convert.ToDecimal(x.V), Price = Convert.ToDecimal(x.P)
            }).ToList(),
                                   newOrderbook.Asks.Select(x =>
                                                            new VolumePriceModel {
                Volume = Convert.ToDecimal(x.V), Price = Convert.ToDecimal(x.P)
            }).ToList()).OrderBy(x => x.Price).ToList();
            var bids = MergeLevels(oldOrderbook.Bids.Select(x =>
                                                            new VolumePriceModel {
                Volume = Convert.ToDecimal(x.V), Price = Convert.ToDecimal(x.P)
            }).ToList(),
                                   newOrderbook.Bids.Select(x =>
                                                            new VolumePriceModel {
                Volume = Convert.ToDecimal(x.V), Price = Convert.ToDecimal(x.P)
            }).ToList()).OrderByDescending(x => x.Price).ToList();

            result.Asks.Clear();
            result.Bids.Clear();

            result.Asks.AddRange(asks.Select(x => new Orderbook.Types.PriceVolume {
                P = x.Price.ToString(CultureInfo.InvariantCulture), V = x.Volume.ToString(CultureInfo.InvariantCulture)
            }));
            result.Bids.AddRange(bids.Select(x => new Orderbook.Types.PriceVolume {
                P = x.Price.ToString(CultureInfo.InvariantCulture), V = x.Volume.ToString(CultureInfo.InvariantCulture)
            }));

            return(result);
        }
コード例 #2
0
        public Orderbook GetOrderbookUpdates(Orderbook oldOrderbook, Orderbook newOrderbook)
        {
            var result = JsonConvert.DeserializeObject <Orderbook>(newOrderbook.ToJson());

            result.Asks = MergeLevels(oldOrderbook.Asks.ToList(), newOrderbook.Asks.ToList()).OrderBy(x => x.Price).ToList();
            result.Bids = MergeLevels(oldOrderbook.Bids.ToList(), newOrderbook.Bids.ToList()).OrderByDescending(x => x.Price).ToList();

            return(result);
        }