@@ -107,7 +107,7 @@ class RetryException(PoloniexError):
107107 pass
108108
109109
110- class Poloniex (object ):
110+ class PoloniexBase (object ):
111111 """The Poloniex Object!"""
112112
113113 def __init__ (
@@ -293,6 +293,28 @@ def _handleReturned(self, data):
293293 raise PoloniexError (out ['error' ])
294294 return out
295295
296+ @_retry
297+ def marketTradeHist (self , currencyPair , start = False , end = False ):
298+ """ Returns the past 200 trades for a given market, or up to 50,000
299+ trades between a range specified in UNIX timestamps by the "start" and
300+ "end" parameters. """
301+ if self .coach :
302+ self .coach .wait ()
303+ args = {'command' : 'returnTradeHistory' ,
304+ 'currencyPair' : str (currencyPair ).upper ()}
305+ if start :
306+ args ['start' ] = start
307+ if end :
308+ args ['end' ] = end
309+ ret = self .session .get (
310+ 'https://poloniex.com/public?' + _urlencode (args ),
311+ timeout = self .timeout )
312+ # decode json
313+ return self ._handleReturned (ret )
314+
315+
316+ class PoloniexHelper (PoloniexBase ):
317+
296318 # --PUBLIC COMMANDS-------------------------------------------------------
297319 def returnTicker (self ):
298320 """ Returns the ticker for all markets. """
@@ -313,25 +335,6 @@ def returnOrderBook(self, currencyPair='all', depth=20):
313335 'depth' : str (depth )
314336 })
315337
316- @_retry
317- def marketTradeHist (self , currencyPair , start = False , end = False ):
318- """ Returns the past 200 trades for a given market, or up to 50,000
319- trades between a range specified in UNIX timestamps by the "start" and
320- "end" parameters. """
321- if self .coach :
322- self .coach .wait ()
323- args = {'command' : 'returnTradeHistory' ,
324- 'currencyPair' : str (currencyPair ).upper ()}
325- if start :
326- args ['start' ] = start
327- if end :
328- args ['end' ] = end
329- ret = self .session .get (
330- 'https://poloniex.com/public?' + _urlencode (args ),
331- timeout = self .timeout )
332- # decode json
333- return self ._handleReturned (ret )
334-
335338 def returnChartData (self , currencyPair , period = False ,
336339 start = False , end = False ):
337340 """ Returns candlestick chart data. Parameters are "currencyPair",
@@ -663,10 +666,10 @@ def toggleAutoRenew(self, orderNumber):
663666 'toggleAutoRenew' , {'orderNumber' : str (orderNumber )})
664667
665668
666- class PoloniexSocketed ( Poloniex ):
669+ class Poloniex ( PoloniexHelper ):
667670 """ Child class of Poloniex with support for the websocket api """
668671 def __init__ (self , * args , ** kwargs ):
669- super (PoloniexSocketed , self ).__init__ (* args , ** kwargs )
672+ super (Poloniex , self ).__init__ (* args , ** kwargs )
670673 self .socket = WebSocketApp (url = "wss://api2.poloniex.com/" ,
671674 on_open = self .on_open ,
672675 on_message = self .on_message ,
0 commit comments