danpaquin / coinbasepro-python

The unofficial Python client for the Coinbase Pro API
MIT License
1.82k stars 732 forks source link

Order Book gives wrong size #278

Open neilthefrobot opened 6 years ago

neilthefrobot commented 6 years ago

get_current_book seems to give the ask/bid prices just fine but I can't figure out what is up with the size. The value it returns for size does seem to change when it should while I watch what gdax.com shows, but it isn't the right value. It seems to be nonsense.
It's not clear to me if I'm doing any of this right because there is absolutely no documentation on how to do any of this... The one example for the live order book literally doesn't do anything but start and end a connection.

Here is what I'm trying

import gdax, time

order_book = gdax.OrderBook(product_id='BTC-USD')
order_book.start()
t = time.clock()
while (time.clock() - t < 99999):
    book = order_book.get_current_book()
    if (len(book['asks']) > 0):
        print(book['asks'][0][1])
    time.sleep(0.25)
order_book.close()

Edit: Without the websocket the size returned is correct but I know they don't want me doing it this way Edit2: Also should note this works when level = 1 or 2, but the issue comes back when you try level 3 which could explain why the above example doesn't work since it is also getting the whole order book.

import gdax
import time

public_client = gdax.PublicClient()
while(True):
    book = public_client.get_product_order_book('BTC-USD', level=1)
    print(book.values())
    time.sleep(1)