2.3 Binance_interface APP 现货行情-实时行情

Binance_interface APP 现货行情-实时行情

  • Github地址
  • PyTed量化交易研究院

目录

  • Binance_interface APP 现货行情-实时行情
    • 1. APP 现货行情-实时行情函数总览
    • 2. 模型实例化
    • 3. 获取一个产品的最优挂单 get_bookTicker
    • 4. 获取全部产品的最优挂单(列表格式)get_bookTickers
    • 5. 获取全部产品的最优挂单 (字典格式)get_bookTickersMap
    • 6. 获取一个产品的最新价格 get_tickerPrice
    • 7. 获取全部产品的最新价格(列表格式) get_tickerPrices
    • 8. 获取全部产品的最新价格 (字典格式) get_tickerPricesMap
    • 9. 获取深度信息 get_depth

1. APP 现货行情-实时行情函数总览

方法 解释
get_bookTicker 获取一个产品的最优挂单
get_bookTickers 获取全部产品的最优挂单(列表格式)
get_bookTickersMap 获取全部产品的最优挂单 (字典格式)
get_tickerPrice 获取一个产品的最新价格
get_tickerPrices 获取全部产品的最新价格(列表格式)
get_tickerPricesMap 获取全部产品的最新价格 (字典格式)
get_depth 获取深度信息

2. 模型实例化

from binance_interface.app import BinanceSPOT
from binance_interface.app.utils import eprint
# 转发:需搭建转发服务器,可参考:https://github.com/pyted/binance_resender
proxy_host = None
key = 'xxxx'
secret = 'xxxx'

binanceSPOT = BinanceSPOT(
    key=key, secret=secret,
    proxy_host=proxy_host
)
market = binanceSPOT.market

3. 获取一个产品的最优挂单 get_bookTicker

bookTicker_result = market.get_bookTicker(symbol='BTCUSDT')
eprint(bookTicker_result)

输出:

>>> {'code': 200,
>>>  'data': {'symbol': 'BTCUSDT',
>>>           'bidPrice': '40059.99000000',
>>>           'bidQty': '7.90103000',
>>>           'askPrice': '40060.00000000',
>>>           'askQty': '2.29840000'},
>>>  'msg': ''}

4. 获取全部产品的最优挂单(列表格式)get_bookTickers

# 参数symbols默认为[],表示全部产品
bookTickers_result = market.get_bookTickers()
eprint(bookTickers_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': [{'symbol': 'ETHBTC',
>>>            'bidPrice': '0.05594000',
>>>            'bidQty': '4.35300000',
>>>            'askPrice': '0.05595000',
>>>            'askQty': '27.14070000'},
>>>           {'symbol': 'LTCBTC',
>>>            'bidPrice': '0.00164000',
>>>            'bidQty': '29.84500000',
>>>            'askPrice': '0.00164100',
>>>            'askQty': '45.26200000'},
>>>           {'symbol': 'BNBBTC',
>>>            'bidPrice': '0.00734300',
>>>            'bidQty': '3.71100000',
>>>            'askPrice': '0.00734400',
>>>            'askQty': '6.96100000'},
>>>           {'symbol': 'NEOBTC',
>>>            'bidPrice': '0.00026060',
>>>            'bidQty': '9.69000000',
>>>            'askPrice': '0.00026100',
>>>            'askQty': '5.80000000'},
>>>           {'symbol': 'QTUMETH',
>>>            'bidPrice': '0.00126800',
>>>            'bidQty': '638.00000000',
>>>            'askPrice': '0.00127300',
>>>            'askQty': '21.00000000'},
>>>           '......'],
>>>  'msg': ''}
# 指定多个产品
bookTickers_result = market.get_bookTickers(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(bookTickers_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': [{'symbol': 'BTCUSDT',
>>>            'bidPrice': '40062.06000000',
>>>            'bidQty': '1.67129000',
>>>            'askPrice': '40062.07000000',
>>>            'askQty': '5.59147000'},
>>>           {'symbol': 'ETHUSDT',
>>>            'bidPrice': '2241.25000000',
>>>            'bidQty': '63.64610000',
>>>            'askPrice': '2241.26000000',
>>>            'askQty': '70.79630000'}],
>>>  'msg': ''}

5. 获取全部产品的最优挂单 (字典格式)get_bookTickersMap

# 参数symbols默认为[],表示全部产品
bookTickersMap_result = market.get_bookTickersMap()
eprint(bookTickersMap_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': {'ETHBTC': {'symbol': 'ETHBTC',
>>>                      'bidPrice': '0.05593000',
>>>                      'bidQty': '20.92610000',
>>>                      'askPrice': '0.05594000',
>>>                      'askQty': '21.05760000'},
>>>           'LTCBTC': {'symbol': 'LTCBTC',
>>>                      'bidPrice': '0.00164000',
>>>                      'bidQty': '74.73600000',
>>>                      'askPrice': '0.00164200',
>>>                      'askQty': '388.14800000'},
>>>           'BNBBTC': {'symbol': 'BNBBTC',
>>>                      'bidPrice': '0.00734200',
>>>                      'bidQty': '4.53500000',
>>>                      'askPrice': '0.00734300',
>>>                      'askQty': '5.71400000'},
>>>           'NEOBTC': {'symbol': 'NEOBTC',
>>>                      'bidPrice': '0.00026060',
>>>                      'bidQty': '9.69000000',
>>>                      'askPrice': '0.00026100',
>>>                      'askQty': '5.80000000'},
>>>           'QTUMETH': {'symbol': 'QTUMETH',
>>>                       'bidPrice': '0.00126800',
>>>                       'bidQty': '1165.60000000',
>>>                       'askPrice': '0.00127300',
>>>                       'askQty': '21.00000000'},
>>>           'EOSETH': {'symbol': 'EOSETH',
>>>                      'bidPrice': '0.00030350',
>>>                      'bidQty': '2490.90000000',
>>>                      'askPrice': '0.00030480',
>>>                      'askQty': '406.80000000'},
>>>           '...': '......'},
>>>  'msg': ''}
# 指定多个产品
bookTickersMap_result = market.get_bookTickersMap(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(bookTickersMap_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': {'BTCUSDT': {'symbol': 'BTCUSDT',
>>>                       'bidPrice': '40072.30000000',
>>>                       'bidQty': '9.14236000',
>>>                       'askPrice': '40072.31000000',
>>>                       'askQty': '1.19617000'},
>>>           'ETHUSDT': {'symbol': 'ETHUSDT',
>>>                       'bidPrice': '2242.69000000',
>>>                       'bidQty': '39.63170000',
>>>                       'askPrice': '2242.70000000',
>>>                       'askQty': '36.98430000'}},
>>>  'msg': ''}

6. 获取一个产品的最新价格 get_tickerPrice

tickerPrice_result = market.get_tickerPrice(symbol='BTCUSDT')
eprint(tickerPrice_result, data_length=5)

输出:

>>> {'code': 200, 'data': {'symbol': 'BTCUSDT', 'price': '40077.30000000'}, 'msg': ''}

7. 获取全部产品的最新价格(列表格式) get_tickerPrices

# 参数symbols默认为[],表示全部产品
tickerPrices_result = market.get_tickerPrices()
eprint(tickerPrices_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': [{'symbol': 'ETHBTC', 'price': '0.05595000'},
>>>           {'symbol': 'LTCBTC', 'price': '0.00164000'},
>>>           {'symbol': 'BNBBTC', 'price': '0.00734200'},
>>>           {'symbol': 'NEOBTC', 'price': '0.00026090'},
>>>           {'symbol': 'QTUMETH', 'price': '0.00127200'},
>>>           '......'],
>>>  'msg': ''}
# 指定多个产品
tickerPrices_result = market.get_tickerPrices(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(tickerPrices_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': [{'symbol': 'BTCUSDT', 'price': '40066.02000000'}, {'symbol': 'ETHUSDT', 'price': '2242.38000000'}],
>>>  'msg': ''}

8. 获取全部产品的最新价格 (字典格式) get_tickerPricesMap

# 参数symbols默认为[],表示全部产品
tickerPricesMap_result = market.get_tickerPricesMap()
eprint(tickerPricesMap_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': {'ETHBTC': {'symbol': 'ETHBTC', 'price': '0.05596000'},
>>>           'LTCBTC': {'symbol': 'LTCBTC', 'price': '0.00164000'},
>>>           'BNBBTC': {'symbol': 'BNBBTC', 'price': '0.00734300'},
>>>           'NEOBTC': {'symbol': 'NEOBTC', 'price': '0.00026090'},
>>>           'QTUMETH': {'symbol': 'QTUMETH', 'price': '0.00127200'},
>>>           'EOSETH': {'symbol': 'EOSETH', 'price': '0.00030480'},
>>>           '...': '......'},
>>>  'msg': ''}
# 指定多个产品
tickerPricesMap_result = market.get_tickerPricesMap(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(tickerPricesMap_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': {'BTCUSDT': {'symbol': 'BTCUSDT', 'price': '40059.59000000'},
>>>           'ETHUSDT': {'symbol': 'ETHUSDT', 'price': '2241.78000000'}},
>>>  'msg': ''}

9. 获取深度信息 get_depth

depth_result = market.get_depth(symbol='BTCUSDT')
eprint(depth_result, data_length=5)

输出:

>>> {'code': 200,
>>>  'data': {'lastUpdateId': 42417598490,
>>>           'bids': [['40067.99000000', '6.41848000'],
>>>                    ['40067.98000000', '3.41816000'],
>>>                    ['40067.75000000', '0.00021000'],
>>>                    ['40067.51000000', '0.00021000'],
>>>                    ['40067.27000000', '0.00021000'],
>>>                    '......'],
>>>           'asks': [['40068.00000000', '0.77779000'],
>>>                    ['40068.15000000', '0.03249000'],
>>>                    ['40068.19000000', '0.01972000'],
>>>                    ['40068.23000000', '0.00021000'],
>>>                    ['40068.33000000', '0.16291000'],
>>>                    '......']},
>>>  'msg': ''}

你可能感兴趣的:(Binance量化交易,区块链,Python,量化交易,实盘交易)