Exemple #1
0
        private async void ExecuteTradeCommand()
        {
            TradeOrderWindow          tow        = new TradeOrderWindow();
            TradeOrderWindowViewModel towContext = tow.DataContext as TradeOrderWindowViewModel;

            towContext.View             = tow;
            towContext.OnTradeExecuted += TowContext_OnTradeExecuted;

            var quote = QuoteCollectionView.CurrentItem as SharedData.poco.Quote;

            if (null == quote)
            {
                return;
            }
            towContext.TradingSymbol = quote.Name;

            await ChildWindowManager.ShowChildWindowAsync(_mainWindow, tow, ChildWindowManager.OverlayFillBehavior.WindowContent);
        }
Exemple #2
0
        private void TowContext_OnTradeExecuted(TradeOrderWindowViewModel context)
        {
            context.View.Close();

            decimal requestedPrice = 0;
            Quote   searchKey      = new Quote()
            {
                Name = context.TradingSymbol
            };

            lock (lockQuotes)
            {
                int quoteIndex = Quotes.IndexOf(searchKey);

                if (context.IsBuy)
                {
                    requestedPrice = Quotes[quoteIndex].Ask;
                }
                else
                {
                    requestedPrice = Quotes[quoteIndex].Bid;
                }
            }

            TradeRequest request = new TradeRequest()
            {
                commodity      = context.TradingSymbol,
                requestedLot   = decimal.Parse(context.LotSize),
                requestTime    = DateTime.Now.ToString("MM/dd/yyyy HH:mm"),
                requestType    = context.IsBuy ? TradeRequest.REQUEST_TYPE_BUY : TradeRequest.REQUEST_TYPE_SELL,
                tradeId        = Guid.NewGuid(),
                requestedPrice = requestedPrice
            };

            ClientService.GetInstance().requestTrade(request);
        }