INNER CODE UNIT · Python
get_bid_size
5ymph0en1x/SyDOM · sydom.py:118
def get_bid_size(k):
list_buy = []
data = ws_bmex.market_depth()
for batch in data:
if batch['symbol'] == instrument_bmex:
if batch['side'] == 'Buy':
list_buy.append(batch)
list_buy.sort(key=lambda i: i['id'])
if len(list_buy) > k:
return list_buy[k]['size']
else:
return 0
def get_all_bid_size(k):
size_total = 0
for i in range(0, k):
size_total += get_bid_size(i)