0

So I'm a newer beginning program in Python. I've been trying to piece together a program and I'm using the Python-Binance wrapper, but I can't figure out how to exactly enter in this parameter to get me return information in here.

I'm trying to get information for a coin pairing called ADAETH for an example. this is the line, but I can't figure the syntax for calling this. I feel like I'm missing something obvious here.

get_order_book(**params) Get the Order Book for the market

https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#order-book

Parameters: •symbol (str) – required •limit (int) – Default 100; max 1000

Returns:

API response

"lastUpdateId": 1027024,
"bids": [
    [
        "4.00000000",     # PRICE
        "431.00000000",   # QTY
        []                # Can be ignored
    ]
],
"asks": [
    [
        "4.00000200",
        "12.00000000",
        []
    ]
]
Liamdaniel
  • 11
  • 3
  • you forgot the {} but you can use it as dictionary so you can access ["lastUpdateId"] and give you 1027024 but in case of ["bids"] it return all the list [["4.00000000","431.00000000",......],[]] so in this case it will work as list, for example ["bids"][0][0] is returning "4.00000000" – Carlo 1585 Jul 31 '18 at 16:27
  • Sorry I deleted the {} because it distorted the info below. My issue is what to put in the (**params) above that will give me the information that is listed below. – Liamdaniel Jul 31 '18 at 16:29
  • I can't say you that, I'm not sure what the API does, so you know that the parameter are 2, one of them is mandatory, the parameter name is symbol and have to be a string (I suppose whatever you want), the second parameter is called limit is an integer and it's not mandatory, the default value if you don't configure it is 100 and the accepted values are 5, 10, 20, 50, 100, 500, 1000 but I can't say to you which of those values gave you that specific result, you should know what the API does, so read all the documentation – Carlo 1585 Jul 31 '18 at 16:37
  • Frustrating. I have read the documentation. ALL of it. I don't understand the syntax of what to put in there. such as how to identify what symbol it is an such get_order_book(???????????) – Liamdaniel Jul 31 '18 at 16:42
  • symbol is just the key of the parameter (how the parameter is called), but your input can be any string for my understanding.... have a further look, in case just write me back and I'll see if I can help u more tomorrow ;) – Carlo 1585 Jul 31 '18 at 18:09
  • Please take a look at how functions using ** as arguments: https://stackoverflow.com/questions/36901/what-does-double-star-asterisk-and-star-asterisk-do-for-parameters – jackisdesigning Aug 28 '21 at 18:38

1 Answers1

0

If you are new in python I'm sure you'll appreciate this advice: Install Anaconda it comes with and IDE called Spyder that is really useful. I'm not sure why you are using that Library, but i recommend using this one instead https://github.com/sammchardy/python-binance this one is the official. To install the binance library use this command in the conda promt

pip install python-binance

then you can use this code in a .py file (use spyder to create that)

from binance.client import Client
api_key = 
api_secret = 
client = Client(api_key, api_secret)
orders=client.get_order_book(symbol='ADAETH') #This will give you a dict with current orders (bids and ask) and a an integer that represent the last updated ID.

Source: https://python-binance.readthedocs.io/en/latest/index.html

Chuox
  • 643
  • 1
  • 7
  • 20