protected override async Task OnGetHistoricalTradesAsync(Func <IEnumerable <ExchangeTrade>, bool> callback, string symbol, DateTime?startDate = null, DateTime?endDate = null) { HistoricalTradeHelperState state = new HistoricalTradeHelperState(this) { Callback = callback, DirectionIsBackwards = false, EndDate = endDate, ParseFunction = (JToken token) => { return(new ExchangeTrade { Amount = token["amount"].ConvertInvariant <decimal>(), Price = token["price"].ConvertInvariant <decimal>(), Timestamp = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(token["timestampms"].ConvertInvariant <long>()), Id = token["tid"].ConvertInvariant <long>(), IsBuy = token["type"].ToStringInvariant() == "buy" }); }, StartDate = startDate, Symbol = symbol, TimestampFunction = (DateTime dt) => ((long)CryptoUtility.UnixTimestampFromDateTimeMilliseconds(dt)).ToStringInvariant(), Url = "/trades/[symbol]?limit_trades=100×tamp={0}" }; await state.ProcessHistoricalTrades(); }
protected override async Task OnGetHistoricalTradesAsync(Func <IEnumerable <ExchangeTrade>, bool> callback, string symbol, DateTime?startDate = null, DateTime?endDate = null) { /* * [{ * "time": "2014-11-07T22:19:28.578544Z", * "trade_id": 74, * "price": "10.00000000", * "size": "0.01000000", * "side": "buy" * }, { * "time": "2014-11-07T01:08:43.642366Z", * "trade_id": 73, * "price": "100.00000000", * "size": "0.01000000", * "side": "sell" * }] */ HistoricalTradeHelperState state = new HistoricalTradeHelperState(this) { Callback = callback, EndDate = endDate, ParseFunction = (JToken token) => { return(new ExchangeTrade { Amount = token["size"].ConvertInvariant <decimal>(), Id = token["trade_id"].ConvertInvariant <long>(), IsBuy = token["side"].ToStringInvariant() == "buy", Price = token["price"].ConvertInvariant <decimal>(), Timestamp = ConvertDateTimeInvariant(token["time"]) }); }, StartDate = startDate, Symbol = symbol, Url = "/products/[symbol]/trades", UrlFunction = (HistoricalTradeHelperState _state) => { return(_state.Url + (string.IsNullOrWhiteSpace(cursorBefore) ? string.Empty : "?before=" + cursorBefore.ToStringInvariant())); } }; await state.ProcessHistoricalTrades(); }
protected override async Task OnGetHistoricalTradesAsync(Func <IEnumerable <ExchangeTrade>, bool> callback, string symbol, DateTime?startDate = null, DateTime?endDate = null) { /* [ { * "a": 26129, // Aggregate tradeId * "p": "0.01633102", // Price * "q": "4.70443515", // Quantity * "f": 27781, // First tradeId * "l": 27781, // Last tradeId * "T": 1498793709153, // Timestamp * "m": true, // Was the buyer the maker? * "M": true // Was the trade the best price match? * } ] */ HistoricalTradeHelperState state = new HistoricalTradeHelperState(this) { Callback = callback, EndDate = endDate, ParseFunction = (JToken token) => { DateTime timestamp = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(token["T"].ConvertInvariant <long>()); return(new ExchangeTrade { Amount = token["q"].ConvertInvariant <decimal>(), Price = token["p"].ConvertInvariant <decimal>(), Timestamp = timestamp, Id = token["a"].ConvertInvariant <long>(), IsBuy = token["m"].ConvertInvariant <bool>() }); }, StartDate = startDate, Symbol = symbol, TimestampFunction = (DateTime dt) => ((long)CryptoUtility.UnixTimestampFromDateTimeMilliseconds(dt)).ToStringInvariant(), Url = "/aggTrades?symbol=[symbol]&startTime={0}&endTime={1}", }; await state.ProcessHistoricalTrades(); }