示例#1
0
        /// <summary>
        /// Creates a deep-copy clone of this order
        /// </summary>
        /// <returns>A copy of this order</returns>
        public override Order Clone()
        {
            var order = new OptionExerciseOrder();

            CopyTo(order);
            return(order);
        }
示例#2
0
        /// <summary>
        /// Creates an order of the correct type
        /// </summary>
        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"] == null ? default(decimal) : jObject["LimitPrice"].Value <decimal>()
                };
                break;

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

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

            case OrderType.LimitIfTouched:
                order = new LimitIfTouchedOrder
                {
                    LimitPrice   = jObject["LimitPrice"] == null ? default(decimal) : jObject["LimitPrice"].Value <decimal>(),
                    TriggerPrice = jObject["TriggerPrice"] == null ? default(decimal) : jObject["TriggerPrice"].Value <decimal>()
                };
                break;

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

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

            case OrderType.OptionExercise:
                order = new OptionExerciseOrder();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(order);
        }
示例#3
0
        private static Order CreateOrder(int orderId, OrderType type, Symbol symbol, decimal quantity, DateTime time,
                                         string tag, IOrderProperties properties, decimal limitPrice, decimal stopPrice, decimal triggerPrice)
        {
            Order order;

            switch (type)
            {
            case OrderType.Market:
                order = new MarketOrder(symbol, quantity, time, tag, properties);
                break;

            case OrderType.Limit:
                order = new LimitOrder(symbol, quantity, limitPrice, time, tag, properties);
                break;

            case OrderType.StopMarket:
                order = new StopMarketOrder(symbol, quantity, stopPrice, time, tag, properties);
                break;

            case OrderType.StopLimit:
                order = new StopLimitOrder(symbol, quantity, stopPrice, limitPrice, time, tag, properties);
                break;

            case OrderType.LimitIfTouched:
                order = new LimitIfTouchedOrder(symbol, quantity, triggerPrice, limitPrice, time, tag, properties);
                break;

            case OrderType.MarketOnOpen:
                order = new MarketOnOpenOrder(symbol, quantity, time, tag, properties);
                break;

            case OrderType.MarketOnClose:
                order = new MarketOnCloseOrder(symbol, quantity, time, tag, properties);
                break;

            case OrderType.OptionExercise:
                order = new OptionExerciseOrder(symbol, quantity, time, tag, properties);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            order.Status = OrderStatus.New;
            order.Id     = orderId;
            return(order);
        }
示例#4
0
        /// <summary>
        /// Creates an <see cref="Order"/> to match the specified <paramref name="request"/>
        /// </summary>
        /// <param name="request">The <see cref="SubmitOrderRequest"/> to create an order for</param>
        /// <returns>The <see cref="Order"/> that matches the request</returns>
        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, request.OrderProperties);
                break;

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

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

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

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

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

            case OrderType.OptionExercise:
                order = new OptionExerciseOrder(request.Symbol, request.Quantity, request.Time, request.Tag, request.OrderProperties);
                break;

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