@@ -24,6 +24,7 @@ def createSignature(timestamp, method, url, body, APISECRET):
2424 return signature
2525
2626def createPostfix (options ):
27+ options = _default (options , {})
2728 params = []
2829 for key in options :
2930 params .append (key + '=' + str (options [key ]))
@@ -32,6 +33,9 @@ def createPostfix(options):
3233 postfix = '?' + postfix
3334 return postfix
3435
36+ def _default (value , fallback ):
37+ return value if value is not None else fallback
38+
3539def asksCompare (a , b ):
3640 if (a < b ):
3741 return True
@@ -225,43 +229,44 @@ def time(self):
225229 return self .publicRequest ((self .base + '/time' ))
226230
227231 # options: market
228- def markets (self , options ):
232+ def markets (self , options = None ):
229233 postfix = createPostfix (options )
230234 return self .publicRequest ((self .base + '/markets' + postfix ))
231235
232236 # options: symbol
233- def assets (self , options ):
237+ def assets (self , options = None ):
234238 postfix = createPostfix (options )
235239 return self .publicRequest ((self .base + '/assets' + postfix ))
236240
237241 # options: depth
238- def book (self , symbol , options ):
242+ def book (self , symbol , options = None ):
239243 postfix = createPostfix (options )
240244 return self .publicRequest ((self .base + '/' + symbol + '/book' + postfix ))
241245
242246 # options: limit, start, end, tradeIdFrom, tradeIdTo
243- def publicTrades (self , symbol , options ):
247+ def publicTrades (self , symbol , options = None ):
244248 postfix = createPostfix (options )
245249 return self .publicRequest ((self .base + '/' + symbol + '/trades' + postfix ))
246250
247251 # options: limit, start, end
248- def candles (self , symbol , interval , options ):
252+ def candles (self , symbol , interval , options = None ):
253+ options = _default (options , {})
249254 options ['interval' ] = interval
250255 postfix = createPostfix (options )
251256 return self .publicRequest ((self .base + '/' + symbol + '/candles' + postfix ))
252257
253258 # options: market
254- def tickerPrice (self , options ):
259+ def tickerPrice (self , options = None ):
255260 postfix = createPostfix (options )
256261 return self .publicRequest ((self .base + '/ticker/price' + postfix ))
257262
258263 # options: market
259- def tickerBook (self , options ):
264+ def tickerBook (self , options = None ):
260265 postfix = createPostfix (options )
261266 return self .publicRequest ((self .base + '/ticker/book' + postfix ))
262267
263268 # options: market
264- def ticker24h (self , options ):
269+ def ticker24h (self , options = None ):
265270 postfix = createPostfix (options )
266271 return self .publicRequest ((self .base + '/ticker/24h' + postfix ))
267272
@@ -292,23 +297,25 @@ def cancelOrder(self, market, orderId):
292297 return self .privateRequest ('/order' , postfix , {}, 'DELETE' )
293298
294299 # options: limit, start, end, orderIdFrom, orderIdTo
295- def getOrders (self , market , options ):
300+ def getOrders (self , market , options = None ):
301+ options = _default (options , {})
296302 options ['market' ] = market
297303 postfix = createPostfix (options )
298304 return self .privateRequest ('/orders' , postfix , {}, 'GET' )
299305
300306 # options: market
301- def cancelOrders (self , options ):
307+ def cancelOrders (self , options = None ):
302308 postfix = createPostfix (options )
303309 return self .privateRequest ('/orders' , postfix , {}, 'DELETE' )
304310
305311 # options: market
306- def ordersOpen (self , options ):
312+ def ordersOpen (self , options = None ):
307313 postfix = createPostfix (options )
308314 return self .privateRequest ('/ordersOpen' , postfix , {}, 'GET' )
309315
310316 # options: limit, start, end, tradeIdFrom, tradeIdTo
311- def trades (self , market , options ):
317+ def trades (self , market , options = None ):
318+ options = _default (options , {})
312319 options ['market' ] = market
313320 postfix = createPostfix (options )
314321 return self .privateRequest ('/trades' , postfix , {}, 'GET' )
@@ -317,7 +324,7 @@ def account(self):
317324 return self .privateRequest ('/account' , '' , {}, 'GET' )
318325
319326 # options: symbol
320- def balance (self , options ):
327+ def balance (self , options = None ):
321328 postfix = createPostfix (options )
322329 return self .privateRequest ('/balance' , postfix , {}, 'GET' )
323330
@@ -333,12 +340,12 @@ def withdrawAssets(self, symbol, amount, address, body):
333340 return self .privateRequest ('/withdrawal' , '' , body , 'POST' )
334341
335342 # options: symbol, limit, start, end
336- def depositHistory (self , options ):
343+ def depositHistory (self , options = None ):
337344 postfix = createPostfix (options )
338345 return self .privateRequest ('/depositHistory' , postfix , {}, 'GET' )
339346
340347 # options: symbol, limit, start, end
341- def withdrawalHistory (self , options ):
348+ def withdrawalHistory (self , options = None ):
342349 postfix = createPostfix (options )
343350 return self .privateRequest ('/withdrawalHistory' , postfix , {}, 'GET' )
344351
0 commit comments