示例#1
0
        public static IEnumerable <LimitOrder> GetAsks(OrderBook orderBook, AssetPair target)
        {
            Debug.Assert(orderBook != null);
            Debug.Assert(target != null && target.IsValid());
            Debug.Assert(target.EqualOrInverted(orderBook.AssetPair));

            var bids = orderBook.Bids;
            var asks = orderBook.Asks;

            // Streight
            if (orderBook.AssetPair.Base.Id == target.Base.Id &&
                orderBook.AssetPair.Quote.Id == target.Quote.Id)
            {
                foreach (var ask in asks)
                {
                    yield return(ask);
                }
            }

            // Inverted
            if (orderBook.AssetPair.Base.Id == target.Quote.Id &&
                orderBook.AssetPair.Quote.Id == target.Base.Id)
            {
                foreach (var bid in bids)
                {
                    var ask = bid.Reciprocal();
                    yield return(ask);
                }
            }
        }
示例#2
0
        public static SynthOrderBook FromOrderBook(OrderBook orderBook, AssetPair target)
        {
            Debug.Assert(orderBook != null);
            Debug.Assert(target != null && target.IsValid());
            Debug.Assert(target.EqualOrInverted(orderBook.AssetPair));

            var result = new SynthOrderBook(target, new List <OrderBook> {
                orderBook
            });

            return(result);
        }