public void GetTickersAsyncTest() { var client = new HitRestApi(); var response = client.GetTickersAsync().Result; ResponseBasicCheck(response); Assert.AreNotEqual(0, response.Result.Length); }
public void GetSymbolAsyncTest() { var client = new HitRestApi(); var symbol = "ETHBTC"; var response = client.GetSymbolAsync(symbol).Result; ResponseBasicCheck(response); Assert.AreEqual(symbol, response.Result.Id); }
public void GetTickerAsyncTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var response = client.GetTickerAsync(symbol).Result; ResponseBasicCheck(response); Assert.AreEqual(symbol, response.Result.Symbol); }
public void GetCandlesAsyncTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var response = client.GetCandlesAsync(symbol).Result; ResponseBasicCheck(response); Assert.AreEqual(DEFAULT_CONTENT_LENGTH, response.Result.Length); }
public void GetCurrencyAsyncTest() { var client = new HitRestApi(); var currency = "BTC"; var response = client.GetCurrencyAsync(currency).Result; ResponseBasicCheck(response); Assert.AreEqual(currency, response.Result.Id); }
public void GetTradesByTimestampAsyncTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var response = client.GetTradesByTimestampAsync(symbol).Result; ResponseBasicCheck(response); Assert.AreNotEqual(0, response.Result.Length); }
public void GetOrderBookAsyncWithNullLimitTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var response = client.GetOrderBookAsync(symbol, null).Result; ResponseBasicCheck(response); Assert.AreEqual(DEFAULT_CONTENT_LENGTH, response.Result.Asks.Length); Assert.AreEqual(DEFAULT_CONTENT_LENGTH, response.Result.Bids.Length); }
public void GetOrderBookAsyncWithZeroLimitTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var response = client.GetOrderBookAsync(symbol, 0).Result; ResponseBasicCheck(response); Assert.AreNotEqual(0, response.Result.Asks.Length); Assert.AreNotEqual(0, response.Result.Bids.Length); }
public void GetCandlesAsyncLimitTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var limit = 555; var response = client.GetCandlesAsync(symbol, limit: limit).Result; ResponseBasicCheck(response); Assert.AreEqual(limit, response.Result.Length); }
public void GetTradesByIdsAsyncAscSortingTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var sort = HitSort.Asc; var response = client.GetTradesByIdsAsync(symbol, sort).Result; ResponseBasicCheck(response); Assert.IsTrue(response.Result.Length >= 2); Assert.IsTrue(response.Result[0].Timestamp < response.Result[1].Timestamp); }
public void GetCandlesAsyncMinute1Test() { var client = new HitRestApi(); var symbol = "BTCUSD"; var period = HitPeriod.Minute1; var response = client.GetCandlesAsync(symbol, period).Result; ResponseBasicCheck(response); Assert.AreEqual(DEFAULT_CONTENT_LENGTH, response.Result.Length); Assert.AreEqual(response.Result[0].Timestamp - response.Result[1].Timestamp, TimeSpan.FromMinutes(1)); }
public void GetTradesByTimestampAsyncFromTimestampTillTimestampTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var from = new DateTime(2018, 5, 5, 12, 59, 0, DateTimeKind.Utc); var till = new DateTime(2018, 5, 5, 13, 0, 0, DateTimeKind.Utc); var expectedTradesCount = 19; // tested experimentally var response = client.GetTradesByTimestampAsync(symbol, from: from, till: till).Result; ResponseBasicCheck(response); Assert.AreEqual(expectedTradesCount, response.Result.Length); }
public void GetTradesByIdsAsyncFromIdTillIdTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; long fromId = 287719394; long tillId = 287720650; var response = client.GetTradesByIdsAsync(symbol, from: fromId, till: tillId).Result; ResponseBasicCheck(response); Assert.IsTrue(response.Result.Length >= 2); Assert.AreEqual(tillId, response.Result.First().Id); Assert.AreEqual(fromId, response.Result.Last().Id); }
public void GetCandlesAsyncFromTillTest() { var client = new HitRestApi(); var symbol = "BTCUSD"; var period = HitPeriod.Hour1; var from = new DateTime(2020, 4, 5); var till = new DateTime(2020, 4, 6); var response = client.GetCandlesAsync(symbol, from, till, period).Result; ResponseBasicCheck(response); Assert.AreEqual(24, response.Result.Length); Assert.AreEqual(response.Result[1].Timestamp - response.Result[0].Timestamp, TimeSpan.FromHours(1)); }
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 HitBTCClient(string startCoin, decimal waitingTime = 0, string key = "xxx", string sign = "xxx", decimal feeSell = 0.00054m, decimal feeBuy = 0.00054m) : base(startCoin: startCoin, feeBuy: feeBuy, feeSell: feeSell) { _hitbtcRestClient = new HitRestApi(new HitConfig { ApiKey = key, Secret = sign }); _hitbctSocketApi = new HitSocketApi(new HitConfig { ApiKey = key, Secret = sign, }); _currentAmount = UpdatedAmount; _lstMarket = _hitbtcRestClient.GetSymbolsAsync().Result.Result.ToList(); _waitingTime = waitingTime; }
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()); }