九、区块量化 binance 合约操作文件续

def create_limit_order(symbol='EOSUSDT', side='BUY', positionside='LONG', ordtype='LIMIT', price=0, quantity='1',
message=''):""" 全仓合约市价下单 @param symbol: 产品ID EOSUSDT @param side: 订单方向:BUY:买, SELL:卖 @param positionside: 持仓方向:LONG 或 SHORT @param ordtype: 订单类型:MARKET:市价单、LIMIT:限价单 @param price: 委托价格 @param quantity: 委托数量 @param message: 判断依据 @return: """ quantitys = float(quantity)
result = client.futures_create_order(symbol=symbol, side=side, positionSide=positionside, type=ordtype, price=price,quantity=quantitys, timeInForce='GTC')if side == 'SELL':
sides = '卖出' else:
sides = '买入' if positionside == 'SHORT':
possides = '做空' else:
possides = '做多' weixin.senddata('@all', 'Binance 限价单委托下单成功,\n 订单ID:' + str(result["orderId"]) + '\n 交易对:' + symbol +'\n 买卖方式:' + sides + '\n 购买方向:' + possides + '\n 购买价格:' + str(
price) + '\n 购买数量:' + str(quantity) + '\n 判断依据:' + message)def create_market_order(symbol='EOSUSDT', side='BUY', positionside='LONG', ordtype='MARKET', quantity='1', message=''):""" 全仓合约市价下单 @param symbol: 产品ID EOSUSDT @param side: 订单方向:BUY:买, SELL:卖 @param positionside: 持仓方向:LONG 或 SHORT @param ordtype: 订单类型:MARKET:市价单、LIMIT:限价单 @param quantity: 委托数量 @param message: 判断依据 @return: """ quantitys = float(quantity)
result = client.futures_create_order(symbol=symbol, side=side, positionSide=positionside,type=ordtype, quantity=quantitys)if side == 'SELL':
sides = '卖出' else:
sides = '买入' if positionside == 'SHORT':
possides = '做空' else:
possides = '做多' weixin.senddata('@all', 'Binance 市价单下单成功,\n 订单ID:' + str(result["orderId"]) + '\n 交易对:' + symbol +'\n 买卖方式:' + sides + '\n 购买方向:' + possides + '\n 购买数量:' + str(quantity) +'\n 判断依据:' + message)'''开平仓模式下,side和posSide需要进行组合开多:买入开多(side 填写 buy; posSide 填写 long )开空:卖出开空(side 填写 sell; posSide 填写 short )平多:卖出平多(
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值