Ejemplo n.º 1
0
        /// <summary>
        /// подключение
        /// </summary>
        public void Connect()
        {
            if (_client == null)
            {
                _client                        = new BitMexClient();
                _client.Connected             += _client_Connected;
                _client.Disconnected          += _client_Disconnected;
                _client.UpdatePortfolio       += _client_UpdatePortfolio;
                _client.UpdateMarketDepth     += _client_UpdateMarketDepth;
                _client.NewTradesEvent        += _client_NewTrades;
                _client.MyTradeEvent          += _client_NewMyTrades;
                _client.MyOrderEvent          += _client_BitMexUpdateOrder;
                _client.UpdateSecurity        += _client_UpdateSecurity;
                _client.BitMexLogMessageEvent += _client_SendLogMessage;
                _client.ErrorEvent            += _client_ErrorEvent;
            }

            _lastStartServerTime = DateTime.Now;

            if (((ServerParameterBool)ServerParameters[2]).Value)
            {
                _client.Domain      = "https://testnet.bitmex.com";
                _client.ServerAdres = "wss://testnet.bitmex.com/realtime";
            }
            else
            {
                _client.Domain      = "https://www.bitmex.com";
                _client.ServerAdres = "wss://www.bitmex.com/realtime";
            }
            _client.Id     = ((ServerParameterString)ServerParameters[0]).Value;
            _client.SecKey = ((ServerParameterPassword)ServerParameters[1]).Value;

            _client.Connect();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// осыободить апи
        /// </summary>
        public void Dispose()
        {
            if (_client != null)
            {
                _client.Disconnect();

                _client.Connected             -= _client_Connected;
                _client.Disconnected          -= _client_Disconnected;
                _client.UpdatePortfolio       -= _client_UpdatePortfolio;
                _client.UpdateMarketDepth     -= _client_UpdateMarketDepth;
                _client.NewTradesEvent        -= _client_NewTrades;
                _client.MyTradeEvent          -= _client_NewMyTrades;
                _client.MyOrderEvent          -= _client_BitMexUpdateOrder;
                _client.UpdateSecurity        -= _client_UpdateSecurity;
                _client.BitMexLogMessageEvent -= _client_SendLogMessage;
                _client.ErrorEvent            -= _client_ErrorEvent;
            }

            _client      = null;
            ServerStatus = ServerConnectStatus.Disconnect;
        }