Binance_interface APP 现货交易-限单价平仓
量化交易研究群(VX) = py_ted
目录
1. APP 现货交易-限单价平仓函数总览
方法 | 解释 |
---|---|
close_limit | 限价单卖出 |
2. 模型实例化
from binance_interface.app import BinanceSPOT
from pprint import pprint
# 转发:需搭建转发服务器,可参考:https://github.com/pyted/binance_resender
proxy_host = None
key = 'xxxx'
secret = 'xxxx'
binanceSPOT = BinanceSPOT(
key=key, secret=secret,
proxy_host=proxy_host
)
trade = binanceSPOT.trade
3. 同步 非堵塞 固定价格平仓(卖出)
# block = False
close_limit3 = trade.close_limit(
symbol='MANAUSDT', # 产品
closePrice=1, # 平仓价格 closePrice 和 tpRate必须填写其中一个
# tpRate=0.1, # 挂单止盈率
quantity=5, # 平仓数量(交易货币)
block=False, # 是否以堵塞的模式
meta={
}, # 向回调函数中传递的参数字典
)
pprint(close_limit3)
输出:
>>> {'cancel_result': None,
>>> 'error_result': None,
>>> 'func_param': {'base_asset': None,
>>> 'block': False,
>>> 'callback': None,
>>> 'cancel': True,
>>> 'closePrice': 1,
>>> 'delay': 0.2,
>>> 'errorback': None,
>>> 'meta': {},
>>> 'newClientOrderId': '',
>>> 'newThread': False,
>>> 'quantity': 5,
>>> 'symbol': 'MANAUSDT',
>>> 'timeout': 60,
>>> 'tpRate': None},
>>> 'get_order_result': None,
>>> 'meta': {},
>>> 'request_param': {'newClientOrderId': '',
>>> 'price': '1.0000',
>>> 'quantity': '5',
>>> 'side': 'SELL',
>>> 'symbol': 'MANAUSDT',
>>> 'timeInForce': 'GTC',
>>> 'type': 'LIMIT'},
>>> 'set_order_result': {'code': 200,
>>> 'data': {'clientOrderId': 'm7UdoWyzjkl80q1rgzJ19U',
>>> 'cummulativeQuoteQty': '0.00000000',
>>> 'executedQty': '0.00000000',
>>> 'fills': [],
>>> 'orderId': 2207181640,
>>> 'orderListId': -1,
>>> 'origQty': '5.00000000',
>>> 'price': '1.00000000',
>>> 'selfTradePreventionMode': 'EXPIRE_MAKER',
>>> 'side': 'SELL',
>>> 'status': 'NEW',
>>> 'symbol': 'MANAUSDT',
>>> 'timeInForce': 'GTC',
>>> 'transactTime': 1706105539772,
>>> 'type': 'LIMIT',
>>> 'workingTime': 1706105539772},
>>> 'msg': ''},
>>> 'status': None,
>>> 'symbol': 'MANAUSDT'}
4. 同步 非堵塞 止盈价格平仓(卖出)
# 设置tpRate = 0.1,止盈率为10%,止盈率以当前最新价格为基准
close_limit4 = trade.close_limit(
symbol='MANAUSDT', # 产品
# closePrice=10, # 平仓价格 closePrice 和 tpRate必须填写其中一个
tpRate=0.1, # 挂单止盈率
quantity=15, # 平仓数量(交易货币)
block=False, # 是否以堵塞的模式
meta={
}