示例#1
0
        public override Order Clone()
        {
            var order = new MarketOnCloseOrder();

            CopyTo(order);
            return(order);
        }
示例#2
0
        private static Order CreateOrder(OrderType orderType, JObject jObject)
        {
            Order order;

            switch (orderType)
            {
            case OrderType.Market:
                order = new MarketOrder();
                break;

            case OrderType.Limit:
                order = new LimitOrder {
                    LimitPrice = jObject["LimitPrice"].Value <decimal>()
                };
                break;

            case OrderType.StopMarket:
                order = new StopMarketOrder
                {
                    StopPrice = jObject["StopPrice"].Value <decimal>()
                };
                break;

            case OrderType.StopLimit:
                order = new StopLimitOrder
                {
                    LimitPrice = jObject["LimitPrice"].Value <decimal>(),
                    StopPrice  = jObject["StopPrice"].Value <decimal>()
                };
                break;

            case OrderType.MarketOnOpen:
                order = new MarketOnOpenOrder();
                break;

            case OrderType.MarketOnClose:
                order = new MarketOnCloseOrder();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(order);
        }
示例#3
0
        public static Order CreateOrder(SubmitOrderRequest request)
        {
            Order order;

            switch (request.OrderType)
            {
            case OrderType.Market:
                order = new MarketOrder(request.Symbol, request.Quantity, request.Time, request.Tag);
                break;

            case OrderType.Limit:
                order = new LimitOrder(request.Symbol, request.Quantity, request.LimitPrice, request.Time, request.Tag);
                break;

            case OrderType.StopMarket:
                order = new StopMarketOrder(request.Symbol, request.Quantity, request.StopPrice, request.Time, request.Tag);
                break;

            case OrderType.StopLimit:
                order = new StopLimitOrder(request.Symbol, request.Quantity, request.StopPrice, request.LimitPrice, request.Time, request.Tag);
                break;

            case OrderType.MarketOnOpen:
                order = new MarketOnOpenOrder(request.Symbol, request.Quantity, request.Time, request.Tag);
                break;

            case OrderType.MarketOnClose:
                order = new MarketOnCloseOrder(request.Symbol, request.Quantity, request.Time, request.Tag);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            order.Status = OrderStatus.New;
            order.Id     = request.OrderId;
            if (request.Tag != null)
            {
                order.Tag = request.Tag;
            }
            return(order);
        }