示例#1
0
        private async Task SendClientOrder(Core.Model.OrderSide orderSide)
        {
            try
            {
                var clientOrder = new Core.Model.ClientOrder
                {
                    Symbol              = SelectedSymbol?.ExchangeSymbol,
                    Type                = SelectedOrderType.GetOrderType(),
                    Side                = orderSide,
                    Quantity            = Quantity,
                    Price               = Price,
                    StopPrice           = StopPrice,
                    BaseAccountBalance  = BaseAccountBalance?.GetCoreAccountBalance(),
                    QuoteAccountBalance = QuoteAccountBalance?.GetCoreAccountBalance()
                };

                SelectedSymbol.GetCoreSymbol().ValidateClientOrder(clientOrder);

                await ExchangeService.PlaceOrder(Account.AccountInfo.User.Exchange, Account.AccountInfo.User, clientOrder).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                OnException($"{nameof(TradePanelViewModel)} - {ex.Message}", ex);
            }
        }
示例#2
0
        private async void SendClientOrder(Interface.OrderSide orderSide)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(selectedOrderType))
                {
                    throw new Exception("Order not valid: No order type.");
                }

                var clientOrder = new Interface.ClientOrder
                {
                    Symbol              = SelectedSymbol?.Name,
                    Type                = SelectedOrderType.GetOrderType(),
                    Side                = orderSide,
                    Quantity            = Quantity,
                    Price               = Price,
                    StopPrice           = StopPrice,
                    BaseAccountBalance  = BaseAccountBalance?.GetInterfaceAccountBalance(),
                    QuoteAccountBalance = QuoteAccountBalance?.GetInterfaceAccountBalance()
                };

                SelectedSymbol.GetInterfaceSymbol().ValidateClientOrder(clientOrder);

                await ExchangeService.PlaceOrder(Account.AccountInfo.User, clientOrder).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                OnException("TradeViewModel.SendClientOrder", e);
            }
        }
示例#3
0
        /// <summary>
        /// Send a new Order Request
        /// </summary>
        /// <param name="orderSide">Order Side 'BUY/SELL'</param>
        /// <param name="orderPrice">limit price at which to send the order</param>
        private void SendOrder(string orderSide, decimal orderPrice)
        {
            // Create a new Object which will be used across the application
            OrderDetails orderDetails = new OrderDetails(SelectedOrderExecutionProvider.ProviderName);

            orderDetails.Price     = SelectedOrderType.Equals(OrderType.Market) ? 0 : orderPrice;
            orderDetails.StopPrice = OrderModel.TriggerPrice;
            orderDetails.Quantity  = OrderModel.Size;
            orderDetails.Side      = orderSide;
            orderDetails.Type      = SelectedOrderType;
            orderDetails.Security  = OrderModel.Security;

            // Add to selected provider collection for future reference and updates
            SelectedOrderExecutionProvider.AddOrder(orderDetails);

            // Create new order request
            OrderRequest orderRequest = new OrderRequest(orderDetails, OrderRequestType.New);

            // Raise event to notify listener
            EventSystem.Publish <OrderRequest>(orderRequest);
        }