Esempio n. 1
0
        private static decimal?MatchBestPriceForOrder(ExternalOrderBook externalOrderbook, IOrder order, bool isOpening)
        {
            var direction = isOpening ? order.GetOrderType() : order.GetCloseType();
            var volume    = Math.Abs(order.Volume);

            return(externalOrderbook.GetMatchedPrice(volume, direction));
        }
Esempio n. 2
0
        private static decimal?MatchBestPriceForOrderExecution(ExternalOrderBook externalOrderBook, decimal volume,
                                                               bool validateOppositeDirectionVolume)
        {
            var direction = volume.GetOrderDirection();

            var price = externalOrderBook.GetMatchedPrice(volume, direction);

            if (price != null && validateOppositeDirectionVolume)
            {
                var closePrice = externalOrderBook.GetMatchedPrice(volume, direction.GetOpositeDirection());

                //if no liquidity for close, should not use price for open
                if (closePrice == null)
                {
                    return(null);
                }
            }

            return(price);
        }
Esempio n. 3
0
        private static decimal?MatchBestPriceForPositionClose(ExternalOrderBook externalOrderBook, decimal volume)
        {
            var direction = volume.GetClosePositionOrderDirection();

            return(externalOrderBook.GetMatchedPrice(Math.Abs(volume), direction));
        }
Esempio n. 4
0
 public decimal?TestExternalOrderBook_GetMatchedPrice(int volumeToMatch, OrderDirection direction)
 {
     return(_orderBook1.GetMatchedPrice(volumeToMatch, direction));
 }