Exemple #1
0
        private TradeResult MakeMatch(AskOrder ask, List <BidOrder> bids)
        {
            bids = bids.OrderByDescending(e => e.Price).ThenBy(e => e.Date).ToList();

            var items = new List <TradeLog>();

            foreach (var bid in bids)
            {
                if (ask.Remain() == 0)
                {
                    break;
                }

                var item = MakeMatch(bid, ask);

                items.Add(item);
            }

            return(items.Count > 0 ? TradeResult.Success(items) : TradeResult.None());
        }
Exemple #2
0
        private TradeResult MakeMatch(BidOrder bid, List <AskOrder> asks)
        {
            asks = asks.OrderBy(e => e.Price).ThenBy(e => e.Date).ToList();

            var items = new List <TradeLog>();

            foreach (var ask in asks)
            {
                if (bid.Remain() == 0)
                {
                    break;
                }

                var item = MakeMatch(bid, ask);

                items.Add(item);
            }

            return(items.Count > 0 ? TradeResult.Success(items) : TradeResult.None());
        }