def _orderbook_tag_frame(text):
# This function can be removed if this pandas feature request is implemented
# https://github.com/pandas-dev/pandas/issues/14608
table_str = _table_text(text)
root = etree.fromstring(table_str)
table_body = root.find('tbody')
index = []
data = defaultdict(list)
# Iterator of tr objects
qty_path = "td[@class='change-cell quantity']"
tr_iter = table_body.iter(tag='tr')
for tr in tr_iter:
index.append(tr.find(path='td').text.strip())
# Quantity Held
pos = pd.to_numeric(tr.find(path=qty_path).attrib['value'])
data[iem.QUANTITY_HELD].append(pos)
# Your Bids
data[iem.YOUR_BIDS].append(_num_open_orders(tr, 'yourBidsCell'))
# Your Asks
data[iem.YOUR_ASKS].append(_num_open_orders(tr, 'yourAsksCell'))
return pd.DataFrame(data=data, index=index)
评论列表
文章目录