示例#1
0
        private void HandlePriceChange(List <PricePoint> prices, OrderTracker orderTracker, decimal quantity,
                                       decimal priceDelta)
        {
            decimal mostRecentOrderPrice = orderTracker.Price;

            if (prices.Count == 0)
            {
                //if there's no best price, we can't decide what price to place, so exit
                return;
            }
            PricePoint bestPriceInTheMarket = prices[0];

            // Make sure we have a best bid price, and it's not the same as the order we just placed
            // and place similar to the ask price change.
            if (mostRecentOrderPrice == 0 || mostRecentOrderPrice != bestPriceInTheMarket.Price)
            {
                switch (orderTracker.OrderState)
                {
                // Place an order inside the spread if there isn't one currently in the market
                case OrderState.None:
                    orderTracker.Price = bestPriceInTheMarket.Price + priceDelta;

                    orderTracker.InstructionId = NextInstructionId();
                    LimitOrderSpecification order =
                        new LimitOrderSpecification(orderTracker.InstructionId, _instrumentId, orderTracker.Price,
                                                    quantity, TimeInForce.GoodForDay);

                    _session.PlaceLimitOrder(order,
                                             OrderSuccessCallback(orderTracker),
                                             FailureCallback("Place order failed for instruction ID " +
                                                             orderTracker.InstructionId));
                    break;

                // Cancel a working order on a price change.
                case OrderState.Working:
                    CancelOrder(orderTracker);
                    break;
                }
            }
        }
示例#2
0
        public void PlaceLimitOrder(LimitOrderSpecification limitOrderSpecification, OnInstructionResponse instructionCallback, OnFailure failureCallback)
        {
            OrderResponseHandler handler = new OrderResponseHandler();

            SendRequest(limitOrderSpecification, handler, delegate() { instructionCallback(handler.InstructionId); }, failureCallback);
        }
示例#3
0
        public void PlaceLimitOrder(LimitOrderSpecification limitOrderSpecification, OnInstructionResponse instructionCallback, OnFailure failureCallback)
        {
            OrderResponseHandler handler = new OrderResponseHandler();

            this.SendRequest((IRequest)limitOrderSpecification, (Handler)handler, (Session.OnSucessfulRequest)(() => instructionCallback(handler.InstructionId)), failureCallback);
        }