Exemple #1
0
        /// <summary>
        /// Creates a new <see cref="OrderTicket"/> that is invalidated because the algorithm was in the middle of warm up still
        /// </summary>
        public static OrderTicket InvalidWarmingUp(SecurityTransactionManager transactionManager, SubmitOrderRequest submit)
        {
            submit.SetResponse(OrderResponse.WarmingUp(submit));
            var ticket = new OrderTicket(transactionManager, submit);

            ticket._orderStatusOverride = OrderStatus.Invalid;
            return(ticket);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new <see cref="OrderTicket"/> tht represents trying to update an order for which no ticket exists
        /// </summary>
        public static OrderTicket InvalidUpdateOrderId(SecurityTransactionManager transactionManager, UpdateOrderRequest request)
        {
            var submit = new SubmitOrderRequest(OrderType.Market, SecurityType.Base, string.Empty, 0, 0, 0, DateTime.MaxValue, string.Empty);

            submit.SetResponse(OrderResponse.UnableToFindOrder(request));
            var ticket = new OrderTicket(transactionManager, submit);

            request.SetResponse(OrderResponse.UnableToFindOrder(request));
            ticket.AddUpdateRequest(request);
            ticket._orderStatusOverride = OrderStatus.Invalid;
            return(ticket);
        }
Exemple #3
0
        /// <summary>
        /// Creates a new <see cref="OrderTicket"/> that represents trying to cancel an order for which no ticket exists
        /// </summary>
        public static OrderTicket InvalidCancelOrderId(SecurityTransactionManager transactionManager, CancelOrderRequest request)
        {
            var submit = new SubmitOrderRequest(OrderType.Market, SecurityType.Base, Symbol.Empty, 0, 0, 0, DateTime.MaxValue, request.Tag);

            submit.SetResponse(OrderResponse.UnableToFindOrder(request));
            submit.SetOrderId(request.OrderId);
            var ticket = new OrderTicket(transactionManager, submit);

            request.SetResponse(OrderResponse.UnableToFindOrder(request));
            ticket.TrySetCancelRequest(request);
            ticket._orderStatusOverride = OrderStatus.Invalid;
            return(ticket);
        }
Exemple #4
0
        private static decimal AccessOrder <T>(OrderTicket ticket, OrderField field, Func <T, decimal> orderSelector, Func <SubmitOrderRequest, decimal> requestSelector)
            where T : Order
        {
            var order = ticket._order;

            if (order == null)
            {
                return(requestSelector(ticket._submitRequest));
            }
            var typedOrder = order as T;

            if (typedOrder != null)
            {
                return(orderSelector(typedOrder));
            }
            throw new ArgumentException(string.Format("Unable to access property {0} on order of type {1}", field, order.Type));
        }