Binance_interface APP U本位合约行情-交易规则信息
- Github地址
- PyTed量化交易研究院
量化交易研究群(VX) = py_ted
目录
- Binance_interface APP U本位合约行情-交易规则信息
- 1. APP U本位合约行情-交易规则信息函数总览
- 2. 模型实例化
- 3. 以缓存的方式获取一个产品的交易规则与交易对 get_exchangeInfo
- 4. 以缓存的方式获取全部产品的交易规则与交易对 get_exchangeInfos
- 5. 获取可以交易的产品列表 get_symbols_trading_on
- 6. 获取不可交易的产品列表 get_symbols_trading_off
- 7. 获取全部的产品列表 get_symbols_all
1. APP U本位合约行情-交易规则信息函数总览
方法 | 解释 |
---|---|
get_exchangeInfo | 以缓存的方式获取一个产品的交易规则与交易对 |
get_exchangeInfos | 以缓存的方式获取全部产品的交易规则与交易对 |
get_symbols_trading_on | 获取可以交易的产品列表 |
get_symbols_trading_off | 获取不可交易的产品列表 |
get_symbols_all | 获取全部的产品列表 |
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_exchangeInfo
exchangeInfo_result = market.get_exchangeInfo(symbol='BTCUSDT')
eprint(exchangeInfo_result)
输出:
>>> {'code': 200,
>>> 'data': {'symbol': 'BTCUSDT',
>>> 'pair': 'BTCUSDT',
>>> 'contractType': 'PERPETUAL',
>>> 'deliveryDate': 4133404800000,
>>> 'onboardDate': 1569398400000,
>>> 'status': 'TRADING',
>>> 'maintMarginPercent': '2.5000',
>>> 'requiredMarginPercent': '5.0000',
>>> 'baseAsset': 'BTC',
>>> 'quoteAsset': 'USDT',
>>> 'marginAsset': 'USDT',
>>> 'pricePrecision': 2,
>>> 'quantityPrecision': 3,
>>> 'baseAssetPrecision': 8,
>>> 'quotePrecision': 8,
>>> 'underlyingType': 'COIN',
>>> 'underlyingSubType': ['PoW'],
>>> 'settlePlan': 0,
>>> 'triggerProtect': '0.0500',
>>> 'liquidationFee': '0.012500',
>>> 'marketTakeBound': '0.05',
>>> 'maxMoveOrderLimit': 10000,
>>> 'filters': [{'maxPrice': '4529764', 'tickSize': '0.10', 'filterType': 'PRICE_FILTER', 'minPrice': '556.80'},
>>> {'stepSize': '0.001', 'minQty': '0.001', 'filterType': 'LOT_SIZE', 'maxQty': '1000'},
>>> {'maxQty': '120', 'minQty': '0.001', 'stepSize': '0.001', 'filterType': 'MARKET_LOT_SIZE'},
>>> {'limit': 200, 'filterType': 'MAX_NUM_ORDERS'},
>>> {'limit': 10, 'filterType': 'MAX_NUM_ALGO_ORDERS'},
>>> '......'],
>>> 'orderTypes': ['LIMIT', 'MARKET', 'STOP', 'STOP_MARKET', 'TAKE_PROFIT', '......'],
>>> 'timeInForce': ['GTC', 'IOC', 'FOK', 'GTX', 'GTD'],
>>> 'filter': {'PRICE_FILTER': {'maxPrice': '4529764',
>>> 'tickSize': '0.10',
>>> 'filterType': 'PRICE_FILTER',
>>> 'minPrice': '556.80'},
>>> 'LOT_SIZE': {'stepSize': '0.001', 'minQty': '0.001', 'filterType': 'LOT_SIZE', 'maxQty': '1000'},
>>> 'MARKET_LOT_SIZE': {'maxQty': '120',
>>> 'minQty': '0.001',
>>> 'stepSize': '0.001',
>>> 'filterType': 'MARKET_LOT_SIZE'},
>>> 'MAX_NUM_ORDERS': {'limit': 200, 'filterType': 'MAX_NUM_ORDERS'},
>>> 'MAX_NUM_ALGO_ORDERS': {'limit': 10, 'filterType': 'MAX_NUM_ALGO_ORDERS'},
>>> '...': '......'}},
>>> 'msg': ''}
4. 以缓存的方式获取全部产品的交易规则与交易对 get_exchangeInfos
exchangeInfos_result = market.get_exchangeInfos()
eprint(exchangeInfos_result)
输出:
>>> {'code': 200,
>>> 'data': {'timezone': 'UTC',
>>> 'serverTime': 1706112011203,
>>> 'futuresType': 'U_MARGINED',
>>> 'rateLimits': [{'rateLimitType': 'REQUEST_WEIGHT', 'interval': 'MINUTE', 'intervalNum': 1, 'limit': 2400},
>>> {'rateLimitType': 'ORDERS', 'interval': 'MINUTE', 'intervalNum': 1, 'limit': 1200},
>>> {'rateLimitType': 'ORDERS', 'interval': 'SECOND', 'intervalNum': 10, 'limit': 300}],
>>> 'exchangeFilters': [],
>>> 'assets': [{'asset': 'USDT', 'marginAvailable': True, 'autoAssetExchange': '-10000'},
>>> {'asset': 'BTC', 'marginAvailable': True, 'autoAssetExchange': '-0.10000000'},
>>> {'asset': 'BNB', 'marginAvailable': True, 'autoAssetExchange': '-10'},
>>> {'asset': 'ETH', 'marginAvailable': True, 'autoAssetExchange': '-5'},
>>> {'asset': 'XRP', 'marginAvailable': True, 'autoAssetExchange': '0'},
>>> '......'],
>>> 'symbols': [{'symbol': 'BTCUSDT',
>>> 'pair': 'BTCUSDT',
>>> 'contractType': 'PERPETUAL',
>>> 'deliveryDate': 4133404800000,
>>> 'onboardDate': 1569398400000,
>>> '...': '......'},
>>> {'symbol': 'ETHUSDT',
>>> 'pair': 'ETHUSDT',
>>> 'contractType': 'PERPETUAL',
>>> 'deliveryDate': 4133404800000,
>>> 'onboardDate': 1569398400000,
>>> '...': '......'},
>>> {'symbol': 'BCHUSDT',
>>> 'pair': 'BCHUSDT',
>>> 'contractType': 'PERPETUAL',
>>> 'deliveryDate': 4133404800000,
>>> 'onboardDate': 1569398400000,
>>> '...': '......'},
>>> {'symbol': 'XRPUSDT',
>>> 'pair': 'XRPUSDT',
>>> 'contractType': 'PERPETUAL',
>>> 'deliveryDate': 4133404800000,
>>> 'onboardDate': 1569398400000,
>>> '...': '......'},
>>> {'symbol': 'EOSUSDT',
>>> 'pair': 'EOSUSDT',
>>> 'contractType': 'PERPETUAL',
>>> 'deliveryDate': 4133404800000,
>>> 'onboardDate': 1569398400000,
>>> '...': '......'},
>>> '......']},
>>> 'msg': ''}
5. 获取可以交易的产品列表 get_symbols_trading_on
symbols_trading_on_result = market.get_symbols_trading_on()
eprint(symbols_trading_on_result)
输出:
>>> {'code': 200,
>>> 'data': ['BTCUSDT',
>>> 'ETHUSDT',
>>> 'BCHUSDT',
>>> 'XRPUSDT',
>>> 'EOSUSDT',
>>> 'LTCUSDT',
>>> 'TRXUSDT',
>>> 'ETCUSDT',
>>> 'LINKUSDT',
>>> 'XLMUSDT',
>>> 'ADAUSDT',
>>> 'XMRUSDT',
>>> 'DASHUSDT',
>>> 'ZECUSDT',
>>> 'XTZUSDT',
>>> 'BNBUSDT',
>>> 'ATOMUSDT',
>>> 'ONTUSDT',
>>> 'IOTAUSDT',
>>> 'BATUSDT',
>>> 'VETUSDT',
>>> 'NEOUSDT',
>>> 'QTUMUSDT',
>>> 'IOSTUSDT',
>>> 'THETAUSDT',
>>> 'ALGOUSDT',
>>> 'ZILUSDT',
>>> 'KNCUSDT',
>>> 'ZRXUSDT',
>>> 'COMPUSDT',
>>> '......'],
>>> 'msg': ''}
6. 获取不可交易的产品列表 get_symbols_trading_off
symbols_trading_off_result = market.get_symbols_trading_off()
eprint(symbols_trading_off_result)
输出:
>>> {'code': 200,
>>> 'data': ['SRMUSDT',
>>> 'HNTUSDT',
>>> 'TOMOUSDT',
>>> 'CVCUSDT',
>>> 'BTSUSDT',
>>> 'BTCSTUSDT',
>>> 'SCUSDT',
>>> 'RAYUSDT',
>>> 'FTTUSDT',
>>> 'COCOSUSDT'],
>>> 'msg': ''}
7. 获取全部的产品列表 get_symbols_all
symbols_all_result = market.get_symbols_all()
eprint(symbols_all_result)
输出:
>>> {'code': 200,
>>> 'data': ['BTCUSDT',
>>> 'ETHUSDT',
>>> 'BCHUSDT',
>>> 'XRPUSDT',
>>> 'EOSUSDT',
>>> 'LTCUSDT',
>>> 'TRXUSDT',
>>> 'ETCUSDT',
>>> 'LINKUSDT',
>>> 'XLMUSDT',
>>> 'ADAUSDT',
>>> 'XMRUSDT',
>>> 'DASHUSDT',
>>> 'ZECUSDT',
>>> 'XTZUSDT',
>>> 'BNBUSDT',
>>> 'ATOMUSDT',
>>> 'ONTUSDT',
>>> 'IOTAUSDT',
>>> 'BATUSDT',
>>> 'VETUSDT',
>>> 'NEOUSDT',
>>> 'QTUMUSDT',
>>> 'IOSTUSDT',
>>> 'THETAUSDT',
>>> 'ALGOUSDT',
>>> 'ZILUSDT',
>>> 'KNCUSDT',
>>> 'ZRXUSDT',
>>> 'COMPUSDT',
>>> '......'],
>>> 'msg': ''}