在Python中为Binance API输入参数

时间:2018-07-31 16:21:21

标签: python api binance

所以我是Python中较新的入门程序。我一直在尝试组装一个程序,并且正在使用Python-Binance包装器,但是我不知道如何准确地输入此参数以使我在这里返回信息。

我正在尝试获取有关名为ADAETH的硬币配对的信息。 这是一行,但是我不知道调用它的语法。我觉得这里缺少明显的东西。

get_order_book(** params) 获取市场的订单簿

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

参数: •符号(str)–必填 •limit(int)–默认值100;最多1000

返回:

API响应

"lastUpdateId": 1027024,
"bids": [
    [
        "4.00000000",     # PRICE
        "431.00000000",   # QTY
        []                # Can be ignored
    ]
],
"asks": [
    [
        "4.00000200",
        "12.00000000",
        []
    ]
]

1 个答案:

答案 0 :(得分:0)

如果您是python的新手,我相信您会喜欢以下建议: 安装Anaconda随附的工具,以及名为Spyder的IDE,它非常有用。 我不确定您为什么要使用该库,但是我建议使用此库而不是https://github.com/sammchardy/python-binance,这是官方的库。 要安装币安库,请在conda promt中使用此命令

pip install python-binance

然后您可以在.py文件中使用此代码(使用spyder创建该代码)

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.

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