Example #1
0
        public async void CloseBalanceMethod()
        {
            MessageDialogResult result = await _dialogCoordinator.ShowMessageAsync(this,
                                                                                   "Are you sure?", "Are you sure you want to close all positions?",
                                                                                   MessageDialogStyle.AffirmativeAndNegative);

            if (result == MessageDialogResult.Affirmative)
            {
                foreach (var row in UnitedPortfolioSecurityDataGridRowses)
                {
                    string res;
                    var    security = MainWindowViewModel.SecVm.SecList
                                      .First(x => x.Secid == row.Secid);
                    var client = ClientSelector.GetClient(security.Board);
                    if (row.Balance > 0)
                    {
                        res = ConnectorCommands.PlaceMktOrder(security.Board, security.Seccode, client[0], client[1],
                                                              row.Balance / security.Lotsize, "S", false);
                    }
                    if (row.Balance < 0)
                    {
                        res = ConnectorCommands.PlaceMktOrder(security.Board, security.Seccode, client[0], client[1],
                                                              Math.Abs(row.Balance / security.Lotsize), "B", false);
                    }
                }
            }
        }
Example #2
0
        private async void PlaceOrder(object param)
        {
            var client    = ClientSelector.GetClient(Board);
            var usecredit = UseCredit ? "<usecredit/>" : "";
            var res1      = TXmlConnector.ConnectorSendCommand("<command id=\"neworder\"><security><board>" + Board +
                                                               "</board><seccode>" + Seccode +
                                                               "</seccode></security><client>" + client[0] + "</client>" +
                                                               "<union>" + client[1] + "</union>" +
                                                               "<quantity>" + Size + "</quantity>" +
                                                               "<buysell>" + param + "</buysell>" +
                                                               "<bymarket/>" + usecredit + "</command>");

            OpenTradingWindows();
            var res2         = string.Empty;
            var orderResult1 = (OrderResult)_serializer.Deserialize(new StringReader(res1));

            if (StopType == "Stop spread")
            {
                var direction       = param.ToString() == "B" ? "S" : "B";
                var activationPrice = direction == "B" ? _bestBuy + StoporderSpread : _bestSell - StoporderSpread;
                res2 = TXmlConnector.ConnectorSendCommand(
                    $"<command id=\"newstoporder\"><security><board>{Board}</board><seccode>{Seccode}</seccode></security><client>{client[0]}</client><union>{client[1]}</union><buysell>{direction}</buysell><stoploss><activationprice>{activationPrice}</activationprice><bymarket/><quantity>{Size}</quantity>{usecredit}</stoploss></command>");
            }
            if (StopType == "Manual stop")
            {
                var direction       = param.ToString() == "B" ? "S" : "B";
                var activationPrice = direction == "B" ? BuyPrice : SellPrice;
                res2 = TXmlConnector.ConnectorSendCommand(
                    $"<command id=\"newstoporder\"><security><board>{Board}</board><seccode>{Seccode}</seccode></security><client>{client[0]}</client><union>{client[1]}</union><buysell>{direction}</buysell><stoploss><activationprice>{activationPrice}</activationprice><bymarket/><quantity>{Size}</quantity>{usecredit}</stoploss></command>");
            }
            if (orderResult1.Success == "true")
            {
                await Dialog.ShowMessageAsync(this, "Message", $"Success. Transaction ID - {orderResult1.TransactionId}");
            }
            else
            {
                await Dialog.ShowMessageAsync(this, "Warning", orderResult1.Message);
            }
            if (res2.IsNullOrEmpty())
            {
                return;
            }
            var orderResult2 = (OrderResult)_serializer.Deserialize(new StringReader(res2));

            if (orderResult2.Success == "true")
            {
                await Dialog.ShowMessageAsync(this, "Message", $"Success. Transaction ID - {orderResult2.TransactionId}");
            }
            else
            {
                await Dialog.ShowMessageAsync(this, "Warning", orderResult2.Message);
            }
        }
Example #3
0
        public async void ShiftLeftClickStopOrder()
        {
            if (SelectedData == null)
            {
                return;
            }
            var price      = SelectedData.Price;
            var buysell    = SelectedData.BuySell == "buy" ? "S" : "B";
            var clientInfo = ClientSelector.GetClient(Board);
            var clientId   = clientInfo == null ? "-" : clientInfo[0];
            var size       = Level2Settings.Default.Size;
            var res        = await Dialog.ShowMessageAsync(this, "Stoporder", $"{Board} {Seccode}\r\nActivation price: {price}\r\nSize: {size}\r\nType: {buysell}\r\nClient: {clientId}",
                                                           MessageDialogStyle.AffirmativeAndNegative);

            if (res == MessageDialogResult.Negative)
            {
                return;
            }
            var str = TXmlConnector.ConnectorSendCommand($"<command id=\"newstoporder\"><security><board>{Board}</board><seccode>{Seccode}</seccode></security><client>{clientInfo[0]}</client><union>{clientInfo[1]}</union><buysell>{buysell}</buysell><stoploss><activationprice>{price}</activationprice><bymarket/><quantity>{size}</quantity>{UseCreditString}</stoploss></command>");
        }
 public AccountController(
     UserManager <ApplicationUser> userManager,
     IPersistedGrantService persistedGrantService,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender,
     ISmsSender smsSender,
     ILoggerFactory loggerFactory,
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     ClientSelector clientSelector)
 {
     _userManager           = userManager;
     _persistedGrantService = persistedGrantService;
     _signInManager         = signInManager;
     _emailSender           = emailSender;
     _smsSender             = smsSender;
     _logger         = loggerFactory.CreateLogger <AccountController>();
     _interaction    = interaction;
     _clientStore    = clientStore;
     _clientSelector = clientSelector;
 }
Example #5
0
        private async void Confirm()
        {
            var client = ClientSelector.GetClient(Board);

            if (IsSmartStoporder && !CheckStoplossPrice())
            {
                return;
            }
            string stoploss   = $"<stoploss>{StopLossActivationPriceString}{StopLossOrderPrice}{_stopLossByMarketString}{StopLossQuantity}{_stopLossUseCreditString}{StopLossGuardTime}</stoploss>";
            string takeprofit = $"<takeprofit>{TakeProfitActivationPrice}{TakeProfitQuantity}{_takeProfitUseCreditString}{TakeProfitGuardTime}{TakeProfitCorrection}{TakeProfitSpread}<bymarket/></takeprofit>";

            if (stoploss == "<stoploss></stoploss>")
            {
                stoploss = string.Empty;
            }
            if (takeprofit == "<takeprofit><bymarket/></takeprofit>")
            {
                takeprofit = string.Empty;
            }
            var cmd =
                $"<command id=\"newstoporder\"><security>{BoardString}{SeccodeString}</security><client>{client[0]}</client><union>{client[1]}</union>{BuySell}{stoploss}{takeprofit}</command>";
            var orderResult = (OrderResult)_serializer.Deserialize(new StringReader(TXmlConnector.ConnectorSendCommand(cmd)));

            if (orderResult.Success == "true")
            {
                await Dialog.ShowMessageAsync(this, "Message", $"Success. Transaction ID - {orderResult.TransactionId}");

                OpenTradingWindows();
                if (!KeepOpen)
                {
                    Close();
                }
            }
            else
            {
                await Dialog.ShowMessageAsync(this, "Warning", orderResult.Message);
            }
        }
Example #6
0
        public async void LeftClickMktOrder()
        {
            if (SelectedData == null)
            {
                return;
            }
            var buysell    = SelectedData.BuySell == "buy" ? "S" : "B";
            var clientInfo = ClientSelector.GetClient(Board);
            var clientId   = clientInfo == null ? "-" : clientInfo[0];
            var size       = Level2Settings.Default.Size;
            var res        = await Dialog.ShowMessageAsync(this, "MKT order", $"{Board} {Seccode}\r\nPrice: MKT\r\nSize: {size}\r\nType: {buysell}\r\nClient: {clientId}",
                                                           MessageDialogStyle.AffirmativeAndNegative);

            if (res == MessageDialogResult.Negative)
            {
                return;
            }
            TXmlConnector.ConnectorSendCommand("<command id=\"neworder\"><security><board>" + Board +
                                               "</board><seccode>" + Seccode +
                                               "</seccode></security><client>" + clientInfo[0] + "</client><union>" + clientInfo[1] + "</union><quantity>" +
                                               size + "</quantity><buysell>" + buysell +
                                               "</buysell><bymarket/>" + UseCreditString + "</command>");
        }
Example #7
0
        private async void Confirm()
        {
            var    client = ClientSelector.GetClient(Board);
            string res;
            var    useCredit = _useCredit ? "<usecredit/>" : "";

            if (Visibility)
            {
                res = TXmlConnector.ConnectorSendCommand(
                    $"<command id=\"neworder\"><security><board>{_board}</board><seccode>{_seccode}</seccode></security><client>{client[0]}</client><union>{client[1]}</union><price>{ _price }</price><quantity>{ _quantity }</quantity><buysell>{ _buySell }</buysell>{useCredit}</command>");
            }
            else
            {
                res = TXmlConnector.ConnectorSendCommand("<command id=\"neworder\"><security><board>" + _board +
                                                         "</board><seccode>" + _seccode +
                                                         "</seccode></security><client>" + client[0] + "</client><union>" + client[1] + "</union><quantity>" +
                                                         _quantity + "</quantity><buysell>" + _buySell +
                                                         "</buysell><bymarket/>" + useCredit + "</command>");
            }
            var orderResult = (OrderResult)_serializer.Deserialize(new StringReader(res));

            if (orderResult.Success == "true")
            {
                await Dialog.ShowMessageAsync(this, "Message", $"Success. Transaction ID - {orderResult.TransactionId}");

                OpenTradingWindows();
                if (!KeepOpen)
                {
                    Close();
                }
            }
            else
            {
                await Dialog.ShowMessageAsync(this, "Warning", orderResult.Message);
            }
        }
Example #8
0
        public static void EditStoporder(string id, double price)
        {
            var editedStoporder = _stoporders.First(s => s.Transactionid == id);

            TXmlConnector.ConnectorSendCommand(
                $"<command id=\"cancelstoporder\"><transactionid>{editedStoporder.Transactionid}</transactionid></command>");
            var res = TXmlConnector.ConnectorSendCommand(ConnectorCommands.NewStopLoss(editedStoporder.Board,
                                                                                       editedStoporder.Seccode, editedStoporder.Client,
                                                                                       ClientSelector.GetClient(editedStoporder.Board)[1], editedStoporder.Buysell,
                                                                                       price.ToString(), editedStoporder.Stoploss[0].Orderprice ?? "",
                                                                                       editedStoporder.Stoploss[0].Quantity, editedStoporder.Stoploss[0].IsByMarket,
                                                                                       editedStoporder.Stoploss[0].Usecredit != "no"));
        }