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); }
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)); }
public virtual bool CanUpdateOrder(Security security, Order order, UpdateOrderRequest request, out BrokerageMessageEvent message) { message = null; return(true); }
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); }
public virtual bool CanSubmitOrder(Security security, Order order, out BrokerageMessageEvent message) { message = null; return(true); }