public BitfinexVendor() { this.restApi = new BitfinexRestApi(BitfinexConsts.API_BASE_ENDPOINT); this.socketApi = new BitfinexSocketApi(); this.socketApi.NewData += this.SocketApi_NewData; this.symbolsCache = new Dictionary <string, BitfinexSymbol>(); this.lastTradeTimeCache = new Dictionary <string, long>(); this.aggressorFlagCalculator = new AggressorFlagCalculator(); this.ping = new Ping(); this.pingUri = new Uri(BitfinexConsts.API_BASE_ENDPOINT); }
public MarketDataVendor() { this.restApi = new HitRestApi(); this.socketApi = new HitSocketApi(); this.socketApi.ConnectionStateChanged += this.SocketApi_ConnectionStateChanged; this.socketApi.Notification += this.SocketApi_Notification; this.currenciesCache = new Dictionary <string, HitCurrency>(); this.symbolsCache = new Dictionary <string, HitSymbol>(); this.ping = new Ping(); this.pingUri = new Uri("https://api.hitbtc.com/api/2"); this.lastsTimeCache = new Dictionary <string, long>(); this.aggressorFlagCalculator = new AggressorFlagCalculator(); }
public override ConnectionResult Connect(ConnectRequestParameters connectRequestParameters) { // Initialize var config = this.HitConfig; this.restApi = new HitRestApi(config); this.socketApi = new HitSocketApi(config); this.socketApi.ConnectionStateChanged += this.SocketApi_ConnectionStateChanged; this.socketApi.Notification += this.SocketApi_Notification; this.currenciesCache = new Dictionary <string, HitCurrency>(); this.symbolsCache = new Dictionary <string, HitSymbol>(); this.ping = new Ping(); this.pingUri = new Uri("https://api.hitbtc.com/api/2"); this.lastsTimeCache = new Dictionary <string, long>(); this.aggressorFlagCalculator = new AggressorFlagCalculator(); // Connect var token = connectRequestParameters.CancellationToken; this.socketApi.ConnectAsync().Wait(token); if (token.IsCancellationRequested) { return(ConnectionResult.CreateCancelled()); } if (this.socketApi.ConnectionState != HitConnectionState.Connected) { return(ConnectionResult.CreateFail("Can't connect to socket API")); } var currencies = this.CheckHitResponse(this.restApi.GetCurrenciesAsync(token).Result, out HitError hitError); if (hitError != null) { return(ConnectionResult.CreateFail(hitError.Format())); } foreach (var currency in currencies) { this.currenciesCache.Add(currency.Id, currency); } var symbols = this.CheckHitResponse(this.restApi.GetSymbolsAsync(token).Result, out hitError); if (hitError != null) { return(ConnectionResult.CreateFail(hitError.Format())); } foreach (var symbol in symbols) { this.symbolsCache.Add(symbol.Id, symbol); } return(ConnectionResult.CreateSuccess()); }