private void Dispose() { if (_krakenClient != null) { _krakenClient.ConnectionFail -= ConnectionFail; _krakenClient.ConnectionSucsess -= ConnectionSucsess; _krakenClient.LogMessageEvent -= SendLogMessage; _krakenClient.NewPortfolio -= NewPortfolio; _krakenClient.NewMyTradeEvent -= _Client_NewMyTradeEvent; _krakenClient.NewOrderEvent -= _ibClient_NewOrderEvent; _krakenClient.NewTradeEvent -= AddTick; _krakenClient.NewSecuritiesEvent -= _krakenClient_NewSecuritiesEvent; _krakenClient.NewMarketDepthEvent -= _krakenClient_NewMarketDepthEvent; } try { if (_krakenClient != null && ServerStatus == ServerConnectStatus.Connect) { _krakenClient.Disconnect(); } } catch (Exception error) { SendLogMessage(error.ToString(), LogMessageType.Error); } _krakenClient = null; }
/// <summary> /// создать новое подключение /// </summary> private void CreateNewServer() { if (_krakenClient == null) { _krakenClient = new KrakenServerClient(); _krakenClient.ConnectionFail += ConnectionFail; _krakenClient.ConnectionSucsess += ConnectionSucsess; _krakenClient.LogMessageEvent += SendLogMessage; _krakenClient.NewPortfolio += NewPortfolio; _krakenClient.NewMyTradeEvent += _Client_NewMyTradeEvent; _krakenClient.NewOrderEvent += _ibClient_NewOrderEvent; _krakenClient.NewTradeEvent += AddTick; _krakenClient.NewSecuritiesEvent += _krakenClient_NewSecuritiesEvent; _krakenClient.NewMarketDepthEvent += _krakenClient_NewMarketDepthEvent; _krakenClient.DataType = _loadDateType; } }