Exemple #1
0
        /// <summary>
        /// dispose API
        /// освободить апи
        /// </summary>
        public void Dispose()
        {
            if (_client != null)
            {
                _client.Dispose();

                _client.Connected         -= _client_Connected;
                _client.Disconnected      -= _client_Disconnected;
                _client.LogMessageEvent   -= SendLogMessage;
                _client.UpdatePairs       -= ClientOnUpdatePairs;
                _client.ClientsInfo       -= ClientsInfoUpdate;
                _client.UpdatePortfolio   -= ClientOnUpdatePortfolio;
                _client.NewTradesEvent    -= ClientOnNewTradesEvent;
                _client.UpdateMarketDepth -= ClientOnUpdateMarketDepth;
                _client.MyOrderEvent      -= ClientOnMyOrderEvent;
                _client.MyTradeEvent      -= ClientOnMyTradeEvent;
                _client.NewCandles        -= ClientOnNewCandles;
            }
            _depths?.Clear();
            _depths = null;
            _allCandleSeries?.Clear();
            _cancellationTokenSource?.Cancel();

            _client      = null;
            ServerStatus = ServerConnectStatus.Disconnect;
        }
Exemple #2
0
        /// <summary>
        /// connect to API
        /// подсоединиться к апи
        /// </summary>
        public void Connect()
        {
            _client = new TransaqClient(((ServerParameterString)ServerParameters[0]).Value,
                                        ((ServerParameterPassword)ServerParameters[1]).Value,
                                        ((ServerParameterString)ServerParameters[2]).Value,
                                        ((ServerParameterString)ServerParameters[3]).Value,
                                        _logPath);

            _client.Connected          += _client_Connected;
            _client.Disconnected       += _client_Disconnected;
            _client.LogMessageEvent    += SendLogMessage;
            _client.UpdatePairs        += ClientOnUpdatePairs;
            _client.ClientsInfo        += ClientsInfoUpdate;
            _client.UpdatePortfolio    += ClientOnUpdatePortfolio;
            _client.NewTradesEvent     += ClientOnNewTradesEvent;
            _client.UpdateMarketDepth  += ClientOnUpdateMarketDepth;
            _client.MyOrderEvent       += ClientOnMyOrderEvent;
            _client.MyTradeEvent       += ClientOnMyTradeEvent;
            _client.NewCandles         += ClientOnNewCandles;
            _client.NeedChangePassword += NeedChangePassword;

            _client.Connect();

            _cancellationTokenSource = new CancellationTokenSource();

            _cancellationToken = _cancellationTokenSource.Token;

            Task.Run(() => SessionTimeHandler(), _cancellationToken);
        }