示例#1
0
 public SpreadViewModel(string board, string seccode)
 {
     Board   = board;
     Seccode = seccode;
     Level2DataHandler.AddLevel2Subscribtion(board, seccode);
     Level2DataHandler.NewBestBuySell += OnNewBestBuySell;
 }
示例#2
0
 public void SetSecurity(string board, string seccode)
 {
     Level2DataHandler.Level2ColChanged -= OnLevel2ColChanged;
     Board   = board;
     Seccode = seccode;
     Level2DataHandler.AddLevel2Subscribtion(Board, Seccode);
     Level2DataHandler.Level2ColChanged += OnLevel2ColChanged;
 }
示例#3
0
 public void SetSecurity(string board, string seccode)
 {
     Task.Run(() => {
         Board       = board;
         Seccode     = seccode;
         Level2Items = Level2DataHandler.AddLevel2Subscribtion(Board, Seccode);
         _dispatcher.Invoke(() =>
         {
             IsUsaChanged?.Invoke(Board == "MCT");
             OnIntsrumentChanged();
         });
         UpdateWindowInstrument();
     });
 }
示例#4
0
 public void SetSecurity(string board, string seccode)
 {
     if (board == Board && seccode == Seccode)
     {
         return;
     }
     Board   = board;
     Seccode = seccode;
     if (Board == "MCT")
     {
         Level2DataHandler.AddLevel2Subscribtion(Board, Seccode);
     }
     AllTrades = TickDataHandler.AddAllTradesSubsribtion(Board, Seccode);
     UpdateWindowInstrument();
 }
示例#5
0
 public AllTradesSimpleViewModel(string board, string seccode, Window window, int id = 0)
 {
     Window  = window;
     Closing = new Command(arg => WindowClosing());
     Board   = board;
     Seccode = seccode;
     if (Board == "MCT")
     {
         Level2DataHandler.AddLevel2Subscribtion(Board, Seccode);
     }
     AllTrades = TickDataHandler.AddAllTradesSubsribtion(Board, Seccode);
     Id        = id;
     if (Id == 0)
     {
         SaveWindow();
     }
     SubscribeToWindowEvents();
 }
示例#6
0
 public FastOrderViewModel(string board, string seccode, Window window, int id = 0)
 {
     Window    = window;
     Board     = board;
     Seccode   = seccode;
     Size      = Settings.Default.FastOrderSize;
     SendOrder = new Command(PlaceOrder);
     Closing   = new Command(arg => WindowClosing());
     Level2DataHandler.AddLevel2Subscribtion(Board, Seccode);
     Level2DataHandler.Level2ColChanged += OnLevel2ColChanged;
     Id = id;
     if (Id == 0)
     {
         SaveWindow();
     }
     SubscribeToWindowEvents();
     IsAnchorEnabled  = true;
     _timer           = new Timer(GetBalance, null, 0, 500);
     ActiveOrders     = MainWindowViewModel.ClientOrdersViewModel.ActiveOrders;
     ActiveStoporders = MainWindowViewModel.ClientOrdersViewModel.ActiveStoporders;
     SubscriveToOrderCountUpdates();
 }
示例#7
0
        public LogBookViewModel(string board, string seccode, Window window, int id = 0)
        {
            Window         = window;
            ClosingCommand = new Command(arg => Closing());
            ResetCommand   = new Command(arg => Reset());
            Board          = board;
            Seccode        = seccode;
            _level2Items   = Level2DataHandler.AddLevel2Subscribtion(Board, Seccode);
            TXmlConnector.SendNewQuotes += XmlConnector_OnSendNewQuotes;
            Level2Subs.Add(new Security {
                Board = Board, Seccode = Seccode
            });
            TXmlConnector.ConnectorSendCommand(
                ConnectorCommands.SubUnsubCommand("subscribe", "alltrades", Board, Seccode));
            TXmlConnector.SendNewAllTrades += XmlConnector_OnSendNewTrades;
            AllTradesSubs.Add(new Security {
                Board = Board, Seccode = Seccode
            });
            Id = id;
            if (Id == 0)
            {
                SaveWindow();
            }
            SubscribeToWindowEvents();
            var args = GetWindowArgs() as LogBookArgs;

            if (args == null)
            {
                UpdateWindowArgs(new LogBookArgs {
                    Alert = false, Ratio = 2, Size = 1, TriggerDelta = 0.5
                });
                return;
            }
            Coef         = args.Ratio;
            Size         = args.Size;
            IsAlerting   = args.Alert;
            TriggerDelta = args.TriggerDelta;
        }
示例#8
0
 public Level2ViewModel(string board, string seccode, Window window, int id = 0)
 {
     Window                = window;
     Closing               = new Command(arg => WindowClosing());
     PlaceOrderCommand     = new Command(PlaceOrder);
     PlaceStoporderCommand = new Command(PlaceStopOrder);
     Board       = board;
     Seccode     = seccode;
     Level2Items = Level2DataHandler.AddLevel2Subscribtion(Board, Seccode);
     if (Board == "MCT")
     {
         IsUSA = true;
     }
     Id = id;
     if (Id == 0)
     {
         SaveWindow();
     }
     SubscribeToWindowEvents();
     //sub for settings changes
     UseCredit = Level2Settings.Default.UseCredit;
     TradeSize = Level2Settings.Default.Size;
     Level2Settings.Default.PropertyChanged += SettingsChanged;
 }
示例#9
0
        private void XmlConnector_OnSendNewStatus(string data)
        {
            var status = (ServerStatus)_statusXml.Deserialize(new StringReader(data));

            if (status.Recover == "true")
            {
                Status         = "Status: Reconnecting...";
                IsReconnecting = true;
                Animate        = false;
                return;
            }
            if (status.Connected != "true")
            {
                if (IsShuttingDown)
                {
                    //TXmlConnector.ConnectorUnInitialize();
                    //Application.Current.Shutdown();
                    return;
                }
                MenuItemConnectCommand = new Command(arg => Show_LoginForm()); //set command to open LoginForm
                MenuItemConnectText    = "Connect";                            //change text
                Status = "Status: Disconnected";                               //change status string

                //_dialogCoordinator.ShowMessageAsync(this, "Connection status", "Connection lost");
                //disable menu buttons
                InfoEnabled           = false;
                TradeEnabled          = false;
                Animate               = false;
                SecVm                 = new SecuritiesViewModel();
                ClientTradesViewModel = new ClientTradesViewModel();
                ClientOrdersViewModel = new ClientOrdersViewModel();
                //close windows
                Application.Current.Dispatcher.Invoke(() => {
                    foreach (Window window in Application.Current.Windows)
                    {
                        if (window.GetType() != typeof(MainWindow) && window.GetType().Namespace.Split('.')[0] != "Microsoft")
                        {
                            window.Close();
                        }
                    }
                });
                //clear clients
                ClientsViewModel.Clients.Clear();
                //clear subs
                Level2DataHandler.UnsubAll();
                TickDataHandler.UnsubAll();
            }
            else
            {
                MenuItemConnectCommand = new Command(arg => Disconnect()); //set command to disconnect
                Status = "Status: Connected";                              //change text
                MenuItemConnectText = "Disconnect";                        //change status string
                //enable menu buttons
                InfoEnabled  = true;
                TradeEnabled = true;
                Animate      = true;
                //Application.Current.Dispatcher.Invoke(() => {
                //    if (!CheckIfWindowIsOpened(typeof(Clients)))
                //        {
                //            _clientsViewModel.Timer.Start();
                //            new Clients { DataContext = _clientsViewModel }.Show();
                //        }
                //    });
                //if reconnecting, do not restore windows
                if (!IsReconnecting)
                {
                    OpenSavedWindows();
                }
                ClientsViewModel.GetInfo();
                IsReconnecting = false; //reconnected at this point
            }

            IsConnected            = status.Connected == "true";
            MenuItemConnectEnabled = true; //enable it after status change
            IsActive = false;
        }