1- /*
1+ /*
22MIT LICENSE
33
44Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com
@@ -292,53 +292,11 @@ protected override async Task<IEnumerable<ExchangeTransaction>> OnGetDepositHist
292292 return transactions ;
293293 }
294294
295- protected override async Task OnGetHistoricalTradesAsync ( Func < IEnumerable < ExchangeTrade > , bool > callback , string marketSymbol , DateTime ? startDate = null , DateTime ? endDate = null )
295+ protected override async Task OnGetHistoricalTradesAsync ( Func < IEnumerable < ExchangeTrade > , bool > callback , string marketSymbol ,
296+ DateTime ? startDate = null , DateTime ? endDate = null )
296297 {
297- // TODO: sinceDateTime is ignored
298- // https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-WAVES&tickInterval=oneMin&_=1499127220008
299- string baseUrl = "/pub/market/GetTicks?marketName=" + marketSymbol + "&tickInterval=oneMin" ;
300- string url ;
301- List < ExchangeTrade > trades = new List < ExchangeTrade > ( ) ;
302- while ( true )
303- {
304- url = baseUrl ;
305- if ( startDate != null )
306- {
307- url += "&_=" + CryptoUtility . UtcNow . Ticks ;
308- }
309- JToken array = await MakeJsonRequestAsync < JToken > ( url , BaseUrl2 ) ;
310- if ( array == null || array . Count ( ) == 0 )
311- {
312- break ;
313- }
314- if ( startDate != null )
315- {
316- startDate = array . Last [ "T" ] . ToDateTimeInvariant ( ) ;
317- }
318- foreach ( JToken trade in array )
319- {
320- // {"O":0.00106302,"H":0.00106302,"L":0.00106302,"C":0.00106302,"V":80.58638589,"T":"2017-08-18T17:48:00","BV":0.08566493}
321- trades . Add ( new ExchangeTrade
322- {
323- Amount = trade [ "V" ] . ConvertInvariant < decimal > ( ) ,
324- Price = trade [ "C" ] . ConvertInvariant < decimal > ( ) ,
325- Timestamp = trade [ "T" ] . ToDateTimeInvariant ( ) ,
326- Id = trade [ "T" ] . ToStringInvariant ( ) ,
327- IsBuy = true
328- } ) ;
329- }
330- trades . Sort ( ( t1 , t2 ) => t1 . Timestamp . CompareTo ( t2 . Timestamp ) ) ;
331- if ( ! callback ( trades ) )
332- {
333- break ;
334- }
335- trades . Clear ( ) ;
336- if ( startDate == null )
337- {
338- break ;
339- }
340- Task . Delay ( 1000 ) . Wait ( ) ;
341- }
298+ throw new APIException (
299+ "Bittrex does not allow querying trades by dates. Consider using either GetRecentTradesAsync() or GetCandlesAsync() w/ a period of 1 min. See issue #508." ) ;
342300 }
343301
344302 protected override async Task < IEnumerable < ExchangeTrade > > OnGetRecentTradesAsync ( string marketSymbol )
@@ -353,11 +311,12 @@ protected override async Task<IEnumerable<ExchangeTrade>> OnGetRecentTradesAsync
353311 return trades ;
354312 }
355313
356- protected override async Task < IEnumerable < MarketCandle > > OnGetCandlesAsync ( string marketSymbol , int periodSeconds , DateTime ? startDate = null , DateTime ? endDate = null , int ? limit = null )
314+ protected override async Task < IEnumerable < MarketCandle > > OnGetCandlesAsync ( string marketSymbol , int periodSeconds ,
315+ DateTime ? startDate = null , DateTime ? endDate = null , int ? limit = null )
357316 {
358317 if ( limit != null )
359318 {
360- throw new APIException ( "Limit parameter not supported" ) ;
319+ throw new APIException ( "Limit parameter not supported in Bittrex " ) ;
361320 }
362321
363322 // https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-WAVES&tickInterval=day
@@ -372,7 +331,9 @@ protected override async Task<IEnumerable<MarketCandle>> OnGetCandlesAsync(strin
372331 foreach ( JToken jsonCandle in array )
373332 {
374333 //NOTE: Bittrex uses the term "BaseVolume" when referring to the QuoteCurrencyVolume
375- MarketCandle candle = this . ParseCandle ( jsonCandle , marketSymbol , periodSeconds , "O" , "H" , "L" , "C" , "T" , TimestampType . Iso8601 , "V" , "BV" ) ;
334+ MarketCandle candle = this . ParseCandle ( token : jsonCandle , marketSymbol : marketSymbol , periodSeconds : periodSeconds ,
335+ openKey : "O" , highKey : "H" , lowKey : "L" , closeKey : "C" , timestampKey : "T" , timestampType : TimestampType . Iso8601 ,
336+ baseVolumeKey : "V" , quoteVolumeKey : "BV" ) ;
376337 if ( candle . Timestamp >= startDate && candle . Timestamp <= endDate )
377338 {
378339 candles . Add ( candle ) ;
0 commit comments