s4w3d0ff / python-poloniex

Poloniex API wrapper for Python 2.7 & 3
https://poloniex.com/support/api
GNU General Public License v2.0
568 stars 166 forks source link

amount of lowest ask and highest bid #186

Closed oldriverno1 closed 5 years ago

oldriverno1 commented 6 years ago

Hi, really appreciate the work. I have a question, is there any way to get the amount for lowest ask and highest bid ? can't find these information from the ticker. Sorry if this is a very simple question, still learning here.

FlamingLasrSwrd commented 6 years ago
from poloniex import Poloniex

polo = Poloniex()

# Returns a dictionary like this
# bid_ask = {
#       "trading_pair" = {
#               "asks": ['price','volume'], #sorted low to high
#               "bids": ['price','volume'], #sorted high to low
#               "isFrozen": '0',
#               "seq": type(int) }}
bid_ask = polo.returnOrderBook()

# For a specific pair
trading_pair = "BTC_ETH"

high_bid_price = float(bid_ask[trading_pair]['bids'][0][0])
low_ask_price = float(bid_ask[trading_pair]['asks'][0][0])

print(trading_pair)
print(f'Highest bid price: {high_bid_price}')
print(f'Lowest ask price: {low_ask_price}')
oldriverno1 commented 6 years ago

Thank you for the help, really appreciate it !