示例#1
0
        private void Dispose()
        {
            if (_Client != null)
            {
                _Client.ConnectionFail         -= _ibClient_ConnectionFail;
                _Client.ConnectionSucsess      -= _ibClient_ConnectionSucsess;
                _Client.LogMessageEvent        -= SendLogMessage;
                _Client.NewMyTradeEvent        -= _ibClient_NewMyTradeEvent;
                _Client.NewOrderEvent          -= _ibClient_NewOrderEvent;
                _Client.NewTradeEvent          -= AddTick;
                _Client.PortfolioChangeEvent   -= _Client_PortfolioChangeEvent;
                _Client.NewSecurityEvent       -= _Client_NewSecurityEvent;
                _Client.MarketDepthChangeEvent -= _Client_MarketDepthChangeEvent;
            }

            try
            {
                if (_Client != null && ServerStatus == ServerConnectStatus.Connect)
                {
                    _Client.Disconnect();
                }
            }
            catch (Exception error)
            {
                SendLogMessage(error.ToString(), LogMessageType.Error);
            }

            _Client = null;
        }
示例#2
0
        public void Dispose()
        {
            if (_client != null)
            {
                _client.ConnectionFail         -= ClientOnConnectionFail;
                _client.ConnectionSucsess      -= ClientOnConnectionSucsess;
                _client.LogMessageEvent        -= ClientOnLogMessageEvent;
                _client.NewMyTradeEvent        -= ClientOnNewMyTradeEvent;
                _client.NewOrderEvent          -= ClientOnNewOrderEvent;
                _client.NewTradeEvent          -= ClientOnNewTradeEvent;
                _client.PortfolioChangeEvent   -= ClientOnPortfolioChangeEvent;
                _client.NewSecurityEvent       -= ClientOnNewSecurityEvent;
                _client.MarketDepthChangeEvent -= ClientOnMarketDepthChangeEvent;
            }

            try
            {
                if (_client != null && ServerStatus == ServerConnectStatus.Connect)
                {
                    _client.Disconnect();
                }
            }
            catch (Exception error)
            {
                SendLogMessage(error.ToString(), LogMessageType.Error);
            }

            _client      = null;
            ServerStatus = ServerConnectStatus.Disconnect;
        }
示例#3
0
 /// <summary>
 /// создать новое подключение
 /// </summary>
 private void CreateNewServer()
 {
     if (_Client == null)
     {
         _Client = new OandaClient();
         _Client.ConnectionFail         += _ibClient_ConnectionFail;
         _Client.ConnectionSucsess      += _ibClient_ConnectionSucsess;
         _Client.LogMessageEvent        += SendLogMessage;
         _Client.NewMyTradeEvent        += _ibClient_NewMyTradeEvent;
         _Client.NewOrderEvent          += _ibClient_NewOrderEvent;
         _Client.NewTradeEvent          += AddTick;
         _Client.PortfolioChangeEvent   += _Client_PortfolioChangeEvent;
         _Client.NewSecurityEvent       += _Client_NewSecurityEvent;
         _Client.MarketDepthChangeEvent += _Client_MarketDepthChangeEvent;
     }
 }
示例#4
0
        public void Connect()
        {
            if (_client == null)
            {
                _client = new OandaClient();

                _client.ConnectionFail         += ClientOnConnectionFail;
                _client.ConnectionSucsess      += ClientOnConnectionSucsess;
                _client.LogMessageEvent        += ClientOnLogMessageEvent;
                _client.NewMyTradeEvent        += ClientOnNewMyTradeEvent;
                _client.NewOrderEvent          += ClientOnNewOrderEvent;
                _client.NewTradeEvent          += ClientOnNewTradeEvent;
                _client.PortfolioChangeEvent   += ClientOnPortfolioChangeEvent;
                _client.NewSecurityEvent       += ClientOnNewSecurityEvent;
                _client.MarketDepthChangeEvent += ClientOnMarketDepthChangeEvent;
            }
            _client.Connect(((ServerParameterString)ServerParameters[0]).Value, ((ServerParameterPassword)ServerParameters[1]).Value,
                            ((ServerParameterBool)ServerParameters[2]).Value);
        }