示例#1
0
 public override bool CanUpdateOrder(Security security, Order order, UpdateOrderRequest request, out BrokerageMessageEvent message)
 {
     message = null;
     if (order.SecurityType == SecurityType.Forex && request.Quantity != null)
     {
         return(IsForexWithinOrderSizeLimits(order.Symbol.Value, request.Quantity.Value, out message));
     }
     return(true);
 }
示例#2
0
        public override bool CanUpdateOrder(Security security, Order order, UpdateOrderRequest request, out BrokerageMessageEvent message)
        {
            message = null;
            if (request.Quantity != null && request.Quantity % 1000 != 0)
            {
                message = new BrokerageMessageEvent(BrokerageMessageType.Warning, "NotSupported",
                                                    "The order quantity must be a multiple of 1000."
                                                    );
                return(false);
            }
            var newQuantity = request.Quantity ?? order.Quantity;
            var direction   = newQuantity > 0 ? OrderDirection.Buy : OrderDirection.Sell;
            var stopPrice   = request.StopPrice ?? security.Price;
            var limitPrice  = request.LimitPrice ?? security.Price;

            return(IsValidOrderPrices(security, order.Type, direction, stopPrice, limitPrice, ref message));
        }
示例#3
0
 public virtual bool CanUpdateOrder(Security security, Order order, UpdateOrderRequest request, out BrokerageMessageEvent message)
 {
     message = null;
     return(true);
 }
示例#4
0
        private static bool IsValidOrderPrices(Security security, OrderType orderType, OrderDirection orderDirection, decimal stopPrice, decimal limitPrice, ref BrokerageMessageEvent message)
        {
            var invalidPrice = orderType == OrderType.Limit && orderDirection == OrderDirection.Buy && limitPrice > security.Price ||
                               orderType == OrderType.Limit && orderDirection == OrderDirection.Sell && limitPrice < security.Price ||
                               orderType == OrderType.StopMarket && orderDirection == OrderDirection.Buy && stopPrice <security.Price ||
                                                                                                                       orderType == OrderType.StopMarket && orderDirection == OrderDirection.Sell && stopPrice> security.Price;

            if (invalidPrice)
            {
                message = new BrokerageMessageEvent(BrokerageMessageType.Warning, "NotSupported",
                                                    "Limit Buy orders and Stop Sell orders must be below market, Limit Sell orders and Stop Buy orders must be above market."
                                                    );
                return(false);
            }
            return(true);
        }
示例#5
0
 public virtual bool CanSubmitOrder(Security security, Order order, out BrokerageMessageEvent message)
 {
     message = null;
     return(true);
 }