Skip to content

Commit

Permalink
python orderbook parsing workaround for none values (kuna)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Dec 25, 2017
1 parent 5e6a93e commit d0fb9c5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/ccxt/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,19 @@ def parse_bid_ask(self, bidask, price_key=0, amount_key=0):
return [float(bidask[price_key]), float(bidask[amount_key])]

def parse_bids_asks(self, bidasks, price_key=0, amount_key=1):
return [self.parse_bid_ask(bidask, price_key, amount_key) for bidask in bidasks]
result = []
if len(bidasks):
if type(bidasks[0]) is list:
for bidask in bidasks:
if bidask[price_key] and bidask[amount_key]:
result.append(self.parse_bid_ask(bidask, price_key, amount_key))
elif type(bidasks[0]) is dict:
for bidask in bidasks:
if (price_key in bidask) and (amount_key in bidask) and (bidask[price_key] and bidask[amount_key]):
result.append(self.parse_bid_ask(bidask, price_key, amount_key))
else:
raise ExchangeError(self.id + ' unrecognized bidask format: ' + str(bidasks[0]))
return result

def fetch_l2_order_book(self, symbol, params={}):
orderbook = self.fetch_order_book(symbol, params)
Expand Down

0 comments on commit d0fb9c5

Please sign in to comment.