MCPcopy Create free account
hub / github.com/danpaquin/coinbasepro-python / get_current_book

Method get_current_book

cbpro/order_book.py:180–205  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

178 return self._current_ticker
179
180 def get_current_book(self):
181 result = {
182 'sequence': self._sequence,
183 'asks': [],
184 'bids': [],
185 }
186 for ask in self._asks:
187 try:
188 # There can be a race condition here, where a price point is removed
189 # between these two ops
190 this_ask = self._asks[ask]
191 except KeyError:
192 continue
193 for order in this_ask:
194 result['asks'].append([order['price'], order['size'], order['id']])
195 for bid in self._bids:
196 try:
197 # There can be a race condition here, where a price point is removed
198 # between these two ops
199 this_bid = self._bids[bid]
200 except KeyError:
201 continue
202
203 for order in this_bid:
204 result['bids'].append([order['price'], order['size'], order['id']])
205 return result
206
207 def get_ask(self):
208 return self._asks.peekitem(0)[0]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected