public CurrencyPairCollection GetCurrencyPairs() { var currencyPairsCollection = new CurrencyPairCollection(); foreach (CurrencyPairs currencyPairValue in Enum.GetValues(typeof(CurrencyPairs))) currencyPairsCollection.Add(new CurrencyPair(currencyPairValue)); return currencyPairsCollection; }
public async Task GetTrades() { _fakeHttpMessageHandler.HandleRequestAsync = TestHelper.HandleContent(form => Assert.Equal("BTC_USD,ETH_USD", form["pair"])); _fakeHttpMessageHandler.ResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{\"BTC_USD\":[{\"trade_id\":158710427,\"type\":\"sell\",\"quantity\":\"0.0831\",\"price\":\"6653.1417\",\"amount\":\"552.87607527\",\"date\":1584995002}],\"ETH_USD\":[{\"trade_id\":158710264,\"type\":\"buy\",\"quantity\":\"2.3\",\"price\":\"137.56743\",\"amount\":\"316.405089\",\"date\":1584994920}]}") }; var pairs = new CurrencyPairCollection("BTC_USD", "ETH_USD"); var trades = await _publicApi.GetTradesAsync(pairs); Assert.Equal(new CurrencyPair[] { "BTC_USD", "ETH_USD" }, trades.Keys); var btcUsd = trades["BTC_USD"]; Assert.Equal(158710427, btcUsd[0].TradeId); Assert.Equal(TradeType.Sell, btcUsd[0].Type); Assert.Equal(0.0831m, btcUsd[0].Quantity); Assert.Equal(6653.1417m, btcUsd[0].Price); Assert.Equal(552.87607527m, btcUsd[0].Amount); Assert.Equal(1584995002, btcUsd[0].Date.ToUnixTimeSeconds()); var ethUsd = trades["ETH_USD"]; Assert.Equal(158710264, ethUsd[0].TradeId); Assert.Equal(TradeType.Buy, ethUsd[0].Type); Assert.Equal(2.3m, ethUsd[0].Quantity); Assert.Equal(137.56743m, ethUsd[0].Price); Assert.Equal(316.405089m, ethUsd[0].Amount); Assert.Equal(1584994920, ethUsd[0].Date.ToUnixTimeSeconds()); }
public Task <CurrencyPairDictionary <Trade[]> > GetTradesAsync(CurrencyPairCollection pairs, CancellationToken cancellationToken = default) { var request = new TradesRequest { Pairs = pairs }; return(_client.PostAsync <CurrencyPairDictionary <Trade[]> >("trades", request, cancellationToken)); }
public void DefaultCostructor_CreatesEmptyPairCollection() { var pairs = new CurrencyPairCollection(); Assert.Empty(pairs); }
public void ToString_ReturnsPairsString() { var pairs = new CurrencyPairCollection("BTC_USD", "ETH_USD"); Assert.Equal("BTC_USD,ETH_USD", pairs.ToString()); }
public TradingDao(ICurrencyPairsDao currencyPairsDao) { _currencyPair = currencyPairsDao.GetCurrencyPairs(); }