本文主要是介绍3.3 Binance_interface APP U本位合约行情-实时行情,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Binance_interface APP U本位合约行情-实时行情
- Github地址
- PyTed量化交易研究院
量化交易研究群(VX) = py_ted
目录
- Binance_interface APP U本位合约行情-实时行情
- 1. APP U本位合约行情-实时行情函数总览
- 2. 模型实例化
- 3. 获取一个产品的最优挂单 get_bookTicker
- 4. 获取全部产品的最优挂单(列表格式)get_bookTickers
- 5. 获取全部产品的最优挂单 (字典格式)get_bookTickersMap
- 6. 获取一个产品的最新价格 get_tickerPrice
- 7. 获取全部产品的最新价格(列表格式) get_tickerPrices
- 8. 获取全部产品的最新价格 (字典格式) get_tickerPricesMap
- 9. 获取深度信息 get_depth
1. APP U本位合约行情-实时行情函数总览
方法 | 解释 |
---|---|
get_bookTicker | 获取一个产品的最优挂单 |
get_bookTickers | 获取全部产品的最优挂单(列表格式) |
get_bookTickersMap | 获取全部产品的最优挂单 (字典格式) |
get_tickerPrice | 获取一个产品的最新价格 |
get_tickerPrices | 获取全部产品的最新价格(列表格式) |
get_tickerPricesMap | 获取全部产品的最新价格 (字典格式) |
get_depth | 获取深度信息 |
2. 模型实例化
from binance_interface.app import BinanceUM
from binance_interface.app.utils import eprint
# 转发:需搭建转发服务器,可参考:https://github.com/pyted/binance_resender
proxy_host = None
key = 'xxxx'
secret = 'xxxx'binanceUM = BinanceUM(key=key, secret=secret,proxy_host=proxy_host
)
market = binanceUM.market
3. 获取一个产品的最优挂单 get_bookTicker
bookTicker_result = market.get_bookTicker(symbol='BTCUSDT')
eprint(bookTicker_result)
输出:
>>> {'code': 200,
>>> 'data': {'symbol': 'BTCUSDT',
>>> 'bidPrice': '39980.80',
>>> 'bidQty': '0.223',
>>> 'askPrice': '39980.90',
>>> 'askQty': '9.638',
>>> 'time': 1706192853095,
>>> 'lastUpdateId': 3886059539004},
>>> 'msg': ''}
4. 获取全部产品的最优挂单(列表格式)get_bookTickers
# 参数symbols默认为[],表示全部产品
bookTickers_result = market.get_bookTickers()
eprint(bookTickers_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': [{'symbol': 'BTCUSDT',
>>> 'bidPrice': '39980.80',
>>> 'bidQty': '0.293',
>>> 'askPrice': '39980.90',
>>> 'askQty': '7.874',
>>> '...': '......'},
>>> {'symbol': 'ETHUSDT',
>>> 'bidPrice': '2207.40',
>>> 'bidQty': '8.099',
>>> 'askPrice': '2207.41',
>>> 'askQty': '47.500',
>>> '...': '......'},
>>> {'symbol': 'BCHUSDT',
>>> 'bidPrice': '237.14',
>>> 'bidQty': '4.087',
>>> 'askPrice': '237.15',
>>> 'askQty': '1.500',
>>> '...': '......'},
>>> {'symbol': 'XRPUSDT',
>>> 'bidPrice': '0.5091',
>>> 'bidQty': '27610.6',
>>> 'askPrice': '0.5092',
>>> 'askQty': '50550.5',
>>> '...': '......'},
>>> {'symbol': 'EOSUSDT',
>>> 'bidPrice': '0.679',
>>> 'bidQty': '40474.3',
>>> 'askPrice': '0.680',
>>> 'askQty': '282807.7',
>>> '...': '......'},
>>> '......'],
>>> 'msg': ''}
# 指定多个产品
bookTickers_result = market.get_bookTickers(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(bookTickers_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': [{'symbol': 'BTCUSDT',
>>> 'bidPrice': '39980.80',
>>> 'bidQty': '4.276',
>>> 'askPrice': '39980.90',
>>> 'askQty': '1.229',
>>> '...': '......'},
>>> {'symbol': 'ETHUSDT',
>>> 'bidPrice': '2207.81',
>>> 'bidQty': '36.656',
>>> 'askPrice': '2207.82',
>>> 'askQty': '2.740',
>>> '...': '......'}],
>>> 'msg': ''}
5. 获取全部产品的最优挂单 (字典格式)get_bookTickersMap
# 参数symbols默认为[],表示全部产品
bookTickersMap_result = market.get_bookTickersMap()
eprint(bookTickersMap_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': {'BTCUSDT': {'symbol': 'BTCUSDT',
>>> 'bidPrice': '39980.90',
>>> 'bidQty': '11.650',
>>> 'askPrice': '39981.00',
>>> 'askQty': '0.901',
>>> '...': '......'},
>>> 'ETHUSDT': {'symbol': 'ETHUSDT',
>>> 'bidPrice': '2207.99',
>>> 'bidQty': '75.316',
>>> 'askPrice': '2208.00',
>>> 'askQty': '12.926',
>>> '...': '......'},
>>> 'BCHUSDT': {'symbol': 'BCHUSDT',
>>> 'bidPrice': '237.18',
>>> 'bidQty': '8.734',
>>> 'askPrice': '237.19',
>>> 'askQty': '0.759',
>>> '...': '......'},
>>> 'XRPUSDT': {'symbol': 'XRPUSDT',
>>> 'bidPrice': '0.5091',
>>> 'bidQty': '55089.9',
>>> 'askPrice': '0.5092',
>>> 'askQty': '46667.9',
>>> '...': '......'},
>>> 'EOSUSDT': {'symbol': 'EOSUSDT',
>>> 'bidPrice': '0.679',
>>> 'bidQty': '56550.5',
>>> 'askPrice': '0.680',
>>> 'askQty': '272375.7',
>>> '...': '......'},
>>> 'LTCUSDT': {'symbol': 'LTCUSDT',
>>> 'bidPrice': '65.24',
>>> 'bidQty': '168.506',
>>> 'askPrice': '65.25',
>>> 'askQty': '48.750',
>>> '...': '......'},
>>> '...': '......'},
>>> 'msg': ''}
# 指定多个产品
bookTickersMap_result = market.get_bookTickersMap(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(bookTickersMap_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': {'BTCUSDT': {'symbol': 'BTCUSDT',
>>> 'bidPrice': '39984.60',
>>> 'bidQty': '5.123',
>>> 'askPrice': '39984.70',
>>> 'askQty': '0.982',
>>> '...': '......'},
>>> 'ETHUSDT': {'symbol': 'ETHUSDT',
>>> 'bidPrice': '2208.35',
>>> 'bidQty': '13.595',
>>> 'askPrice': '2208.36',
>>> 'askQty': '27.052',
>>> '...': '......'}},
>>> 'msg': ''}
6. 获取一个产品的最新价格 get_tickerPrice
tickerPrice_result = market.get_tickerPrice(symbol='BTCUSDT')
eprint(tickerPrice_result, data_length=5)
输出:
>>> {'code': 200, 'data': {'symbol': 'BTCUSDT', 'price': '39984.60', 'time': 1706192863131}, 'msg': ''}
7. 获取全部产品的最新价格(列表格式) get_tickerPrices
# 参数symbols默认为[],表示全部产品
tickerPrices_result = market.get_tickerPrices()
eprint(tickerPrices_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': [{'symbol': 'CFXUSDT', 'price': '0.1774000', 'time': 1706192858797},
>>> {'symbol': 'BALUSDT', 'price': '3.542', 'time': 1706192858970},
>>> {'symbol': 'STEEMUSDT', 'price': '0.215700', 'time': 1706192863909},
>>> {'symbol': 'RNDRUSDT', 'price': '3.733300', 'time': 1706192864007},
>>> {'symbol': 'CYBERUSDT', 'price': '6.814000', 'time': 1706192863855},
>>> '......'],
>>> 'msg': ''}
# 指定多个产品
tickerPrices_result = market.get_tickerPrices(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(tickerPrices_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': [{'symbol': 'ETHUSDT', 'price': '2208.68', 'time': 1706192865251},
>>> {'symbol': 'BTCUSDT', 'price': '39990.80', 'time': 1706192865193}],
>>> 'msg': ''}
8. 获取全部产品的最新价格 (字典格式) get_tickerPricesMap
# 参数symbols默认为[],表示全部产品
tickerPricesMap_result = market.get_tickerPricesMap()
eprint(tickerPricesMap_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': {'TLMUSDT': {'symbol': 'TLMUSDT', 'price': '0.0133500', 'time': 1706192856376},
>>> 'ICXUSDT': {'symbol': 'ICXUSDT', 'price': '0.2186', 'time': 1706192864162},
>>> 'TRUUSDT': {'symbol': 'TRUUSDT', 'price': '0.0442200', 'time': 1706192850693},
>>> 'KASUSDT': {'symbol': 'KASUSDT', 'price': '0.0976400', 'time': 1706192865635},
>>> 'STMXUSDT': {'symbol': 'STMXUSDT', 'price': '0.00694', 'time': 1706192836836},
>>> 'BNXUSDT': {'symbol': 'BNXUSDT', 'price': '0.285600', 'time': 1706192859765},
>>> '...': '......'},
>>> 'msg': ''}
# 指定多个产品
tickerPricesMap_result = market.get_tickerPricesMap(symbols=['BTCUSDT', 'ETHUSDT'])
eprint(tickerPricesMap_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': {'ETHUSDT': {'symbol': 'ETHUSDT', 'price': '2208.68', 'time': 1706192867298},
>>> 'BTCUSDT': {'symbol': 'BTCUSDT', 'price': '39990.70', 'time': 1706192866967}},
>>> 'msg': ''}
9. 获取深度信息 get_depth
depth_result = market.get_depth(symbol='BTCUSDT')
eprint(depth_result, data_length=5)
输出:
>>> {'code': 200,
>>> 'data': {'lastUpdateId': 3886060389175,
>>> 'E': 1706192868070,
>>> 'T': 1706192868014,
>>> 'bids': [['39985.10', '2.376'],
>>> ['39985.00', '0.003'],
>>> ['39983.40', '1.600'],
>>> ['39983.10', '0.240'],
>>> ['39982.70', '0.783'],
>>> '......'],
>>> 'asks': [['39985.20', '0.951'],
>>> ['39985.30', '0.009'],
>>> ['39986.00', '0.050'],
>>> ['39986.90', '0.005'],
>>> ['39987.20', '0.003'],
>>> '......']},
>>> 'msg': ''}
这篇关于3.3 Binance_interface APP U本位合约行情-实时行情的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!