Beispiel #1
0
        /// <summary>
        /// Helper method to send orders
        /// </summary>
        /// <param name="point"></param>
        /// <param name="side"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        protected ITransactionOrderModel CreateOrder(IPointModel point, OrderSideEnum side, double size)
        {
            var gateway    = point.Account.Gateway;
            var instrument = point.Account.Instruments[_asset];
            var order      = new TransactionOrderModel
            {
                Size       = size,
                Side       = side,
                Instrument = instrument,
                Type       = OrderTypeEnum.Market
            };

            gateway.OrderSenderStream.OnNext(new TransactionMessage <ITransactionOrderModel>
            {
                Action = ActionEnum.Create,
                Next   = order
            });

            return(order);
        }
Beispiel #2
0
        /// <summary>
        /// Get orders by criteria
        /// </summary>
        /// <param name="inputs"></param>
        /// <returns></returns>
        protected async Task <IndexCollection <ITransactionOrderModel> > GetGenericOrders(dynamic inputs)
        {
            var orders   = new IndexCollection <ITransactionOrderModel>();
            var response = await GetResponse <InputOrderListModel>($"/v3/accounts/{ Account.Id }/orders");

            foreach (var inputOrder in response.Orders)
            {
                var orderModel = new TransactionOrderModel
                {
                    Id       = $"{ inputOrder.Id }",
                    Size     = inputOrder.Size,
                    Price    = inputOrder.Price,
                    Time     = inputOrder.CreationTime,
                    Type     = OrderTypeMap.Input(inputOrder.Type),
                    Status   = OrderStatusMap.Input(inputOrder.Status),
                    TimeSpan = OrderTimeSpanMap.Input(inputOrder.TimeSpan),
                    DealTime = inputOrder.FillTime ?? inputOrder.CancellationTime ?? inputOrder.TriggerTime
                };

                orders.Add(orderModel);
            }

            return(orders);
        }
Beispiel #3
0
        /// <summary>
        /// Helper method to send orders
        /// </summary>
        /// <param name="point"></param>
        /// <param name="side"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        protected ITransactionOrderModel CreateOrder(IPointModel point, OrderSideEnum side, double size)
        {
            var gateway    = point.Account.Gateway;
            var instrument = point.Account.Instruments[_asset];
            var order      = new TransactionOrderModel
            {
                Size       = size,
                Side       = side,
                Instrument = instrument,
                Type       = OrderTypeEnum.Market
            };

            switch (side)
            {
            case OrderSideEnum.Buy:

                order.Orders.Add(new TransactionOrderModel
                {
                    Size       = size,
                    Side       = OrderSideEnum.Sell,
                    Type       = OrderTypeEnum.Limit,
                    Price      = point.Ask + 2,
                    Instrument = instrument,
                    Container  = order
                });

                order.Orders.Add(new TransactionOrderModel
                {
                    Size       = size,
                    Side       = OrderSideEnum.Sell,
                    Type       = OrderTypeEnum.Stop,
                    Price      = point.Bid - 2,
                    Instrument = instrument,
                    Container  = order
                });

                break;

            case OrderSideEnum.Sell:

                order.Orders.Add(new TransactionOrderModel
                {
                    Size       = size,
                    Side       = OrderSideEnum.Buy,
                    Type       = OrderTypeEnum.Stop,
                    Price      = point.Bid + 2,
                    Instrument = instrument,
                    Container  = order
                });

                order.Orders.Add(new TransactionOrderModel
                {
                    Size       = size,
                    Side       = OrderSideEnum.Buy,
                    Type       = OrderTypeEnum.Limit,
                    Price      = point.Ask - 2,
                    Instrument = instrument,
                    Container  = order
                });

                break;
            }

            gateway.OrderSenderStream.OnNext(new TransactionMessage <ITransactionOrderModel>
            {
                Action = ActionEnum.Create,
                Next   = order
            });

            _date = point.Time;

            return(order);
        }