Exemple #1
0
        /// <summary>
        /// release API
        /// освободить апи
        /// </summary>
        public void Dispose()
        {
            if (_client != null)
            {
                _client.ConnectionFail       -= _ibClient_ConnectionFail;
                _client.ConnectionSucsess    -= _ibClient_ConnectionSucsess;
                _client.LogMessageEvent      -= SendLogMessage;
                _client.NewAccauntValue      -= _ibClient_NewAccauntValue;
                _client.NewPortfolioPosition -= _ibClient_NewPortfolioPosition;
                _client.NewContractEvent     -= _ibClient_NewContractEvent;
                _client.NewMarketDepth       -= _ibClient_NewMarketDepth;
                _client.NewMyTradeEvent      -= _ibClient_NewMyTradeEvent;
                _client.NewOrderEvent        -= _ibClient_NewOrderEvent;
                _client.NewTradeEvent        -= AddTick;
                _client.CandlesUpdateEvent   -= _client_CandlesUpdateEvent;
                _client.Disconnect();
            }

            _client             = null;
            _connectedContracts = new List <string>();

            ServerStatus = ServerConnectStatus.Disconnect;

            if (DisconnectEvent != null)
            {
                DisconnectEvent();
            }
        }
Exemple #2
0
        /// <summary>
        /// connect to API
        /// подсоединиться к апи
        /// </summary>
        public void Connect()
        {
            if (_client == null)
            {
                _client = new IbClient();
                _client.ConnectionFail       += _ibClient_ConnectionFail;
                _client.ConnectionSucsess    += _ibClient_ConnectionSucsess;
                _client.LogMessageEvent      += SendLogMessage;
                _client.NewAccauntValue      += _ibClient_NewAccauntValue;
                _client.NewPortfolioPosition += _ibClient_NewPortfolioPosition;
                _client.NewContractEvent     += _ibClient_NewContractEvent;
                _client.NewMarketDepth       += _ibClient_NewMarketDepth;
                _client.NewMyTradeEvent      += _ibClient_NewMyTradeEvent;
                _client.NewOrderEvent        += _ibClient_NewOrderEvent;
                _client.NewTradeEvent        += AddTick;
                _client.CandlesUpdateEvent   += _client_CandlesUpdateEvent;
            }

            _client.Connect(
                ((ServerParameterString)ServerParameters[0]).Value,
                ((ServerParameterInt)ServerParameters[1]).Value);
        }