Exemple #1
0
        protected override void PlaceLimitStopOrder(Order order)
        {
            ThreadPool.QueueUserWorkItem(_ =>
            {
                var qty = order.Quantity;
                if (qty > 0 && order.OrderSide == Side.Sell)
                {
                    qty = -qty;
                }

                var security = Securities.First(i => i.Symbol.Equals(order.Symbol, IgnoreCase));
                if (security == null || _session == null)
                {
                    return;
                }

                if (order.OrderType == CommonObjects.OrderType.Limit)
                {
                    _session.PlaceLimitOrder(new LimitOrderSpecification(order.UserID, security.SecurityId,
                                                                         order.Price, qty, Converter.ToTIF(order.TimeInForce), order.SLOffset, order.TPOffset),
                                             id => OnOrderPlaced(order), this.GeneralFailureCallback);
                }
                else if (order.OrderType == CommonObjects.OrderType.Stop)
                {
                    _session.PlaceStopOrder(new StopOrderSpecification(order.UserID, security.SecurityId,
                                                                       order.Price, qty, Converter.ToTIF(order.TimeInForce), order.SLOffset, order.TPOffset),
                                            id => OnOrderPlaced(order), this.GeneralFailureCallback);
                }
            });
        }
Exemple #2
0
        protected override void PlaceMarketOrder(Order order)
        {
            ThreadPool.QueueUserWorkItem(_ =>
            {
                var qty = order.Quantity;
                if (qty > 0 && order.OrderSide == Side.Sell)
                {
                    qty = -qty;
                }

                var security = Securities.First(i => i.Symbol.Equals(order.Symbol, IgnoreCase));
                if (security == null || _session == null)
                {
                    OnOrderRejected(order, "Broker API error");
                    return;
                }

                _session.PlaceMarketOrder(new MarketOrderSpecification(order.UserID, security.SecurityId,
                                                                       qty, Converter.ToTIF(order.TimeInForce), order.SLOffset, order.TPOffset),
                                          id => OnOrderPlaced(order), GeneralFailureCallback);
            });
        }