Beispiel #1
0
        public void ShouldAggregateListOfOrderInfos()
        {
            var fullList = new List <IDepthOrderInfo>();

            fullList.Add(new DepthOrderInfo {
                Price = 12.0001m, Amount = 1
            });
            fullList.Add(new DepthOrderInfo {
                Price = 12.99999m, Amount = 1
            });
            fullList.Add(new DepthOrderInfo {
                Price = 13.499999m, Amount = 2
            });
            fullList.Add(new DepthOrderInfo {
                Price = 13.99999m, Amount = 3
            });
            fullList.Add(new DepthOrderInfo {
                Price = 13.79m, Amount = 0.5m
            });

            var aggregatedList = DepthHelper.GetAggregatedAskOrderList(fullList, 0.5m);

            Assert.AreEqual(1, aggregatedList.Find(a => a.Price == 12.0001m).Amount);
            Assert.AreEqual(1, aggregatedList.Find(a => a.Price == 12.5m).Amount);
            Assert.AreEqual(2, aggregatedList.Find(a => a.Price == 13).Amount);
            Assert.AreEqual(3.5, aggregatedList.Find(a => a.Price == 13.5m).Amount);

            Assert.AreEqual(fullList.Sum(a => a.Amount), aggregatedList.Sum(b => b.Amount));
        }
Beispiel #2
0
        void btceModels_DepthUpdated(object sender, System.EventArgs e)
        {
            UiThread.UiDispatcher.Invoke(() =>
            {
                Asks = btceModels.MarketDepths[CurrentPair].Asks.OrderBy(a => a.Price).Take(20).OrderByDescending(a => a.Price).ToList();
                Bids = btceModels.MarketDepths[CurrentPair].Bids.OrderByDescending(a => a.Price).Take(20).ToList();

                AggregatedAsks = DepthHelper.GetAggregatedAskOrderList(btceModels.MarketDepths[CurrentPair].Asks, configuration.PairAggregatorIncrement[CurrentPair]).OrderByDescending(a => a.Price).ToList();
                AggregatedBids = DepthHelper.GetAggregatedBidOrderList(btceModels.MarketDepths[CurrentPair].Bids, configuration.PairAggregatorIncrement[CurrentPair]).OrderByDescending(a => a.Price).ToList();

                foreach (var order in btceModels.ActiveOrders.FindAll(a => a.Pair == CurrentPair && a.Type == TradeTypeEnum.Sell))
                {
                    var ask = Asks.Find(a => a.Price == order.Rate);
                    if (ask != null)
                    {
                        ask.ActiveOrder = string.Format("Sell {0}", order.Amount);
                    }
                }

                foreach (var order in btceModels.ActiveOrders.FindAll(a => a.Pair == CurrentPair && a.Type == TradeTypeEnum.Buy))
                {
                    var bid = Bids.Find(a => a.Price == order.Rate);
                    if (bid != null)
                    {
                        bid.ActiveOrder = string.Format("Buy {0}", order.Amount);
                    }
                }

                spread = Asks[Asks.Count - 1].Price - Bids[0].Price;
                OnPropertyChanged("Asks");
                OnPropertyChanged("Bids");
                OnPropertyChanged("AggregatedAsks");
                OnPropertyChanged("AggregatedBids");
                OnPropertyChanged("Spread");
            });
        }
Beispiel #3
0
 public TileRenderSystem(SpriteBatch spriteBatch, OrthographicCamera camera, DepthHelper depthHelper) : base(Aspect.All(typeof(TilePosition)).One(typeof(Sprite), typeof(TileBorder)))
 {
     _depthHelper = depthHelper;
     _spriteBatch = spriteBatch;
     _camera      = camera;
 }