中英切换的网站咋做,网络舆情监测适合女生嘛,群晖套件做网站,创建自己的博客网站吗Binance_interface APP 币本位合约交易-基础订单
Github地址PyTed量化交易研究院
量化交易研究群(VX) py_ted目录 Binance_interface APP 币本位合约交易-基础订单1. APP 币本位合约交易-基础订单函数总览2. 模型实例化3. 下单#xff08;API原始接口#xff09; set_orde…Binance_interface APP 币本位合约交易-基础订单
Github地址PyTed量化交易研究院
量化交易研究群(VX) py_ted目录 Binance_interface APP 币本位合约交易-基础订单1. APP 币本位合约交易-基础订单函数总览2. 模型实例化3. 下单API原始接口 set_order4. 查询订单API原始接口 get_order5. 查看当前挂单 get_orders_pending6. 查看当前开仓挂单 get_orders_pending_open7. 查看当前平仓挂单 get_orders_pending_close8. 等待订单成交 wait_order_FILLED9. 撤销订单API原始接口 cancel_order 1. APP 币本位合约交易-基础订单函数总览
方法解释set_order下单API原始接口get_order查询订单API原始接口get_orders_pending查看当前挂单get_orders_pending_open查看当前开仓挂单get_orders_pending_close查看当前平仓挂单wait_order_FILLED等待订单成交cancel_order撤销订单API原始接口
2. 模型实例化
from binance_interface.app import BinanceCM
from binance_interface.app.utils import eprint
import paux.date# 转发需搭建转发服务器可参考https://github.com/pyted/binance_resender
proxy_host None
key xxxx
secret xxxxbinanceCM BinanceCM(keykey,secretsecret,proxy_hostproxy_host,timezoneAsia/Shanghai,
)
trade binanceCM.trade3. 下单API原始接口 set_order
set_order_result trade.set_order(symbolDOTUSD_PERP,sideBUY,typeLIMIT,price6.1,quantity1,positionSideLONG,timeInForceGTC,
)
eprint(set_order_result)输出 {code: 200,data: {orderId: 7108734736,symbol: DOTUSD_PERP,pair: DOTUSD,status: NEW,clientOrderId: pPO9llcY29tIyoWJT3fYnS,price: 6.100,avgPrice: 0.000,origQty: 1,executedQty: 0,cumQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,updateTime: 1706193909383},msg: }4. 查询订单API原始接口 get_order
orderId set_order_result[data][orderId]
order_result trade.get_order(symbolDOTUSD_PERP,orderIdorderId,
)
eprint(order_result)输出 {code: 200,data: {orderId: 7108734736,symbol: DOTUSD_PERP,pair: DOTUSD,status: NEW,clientOrderId: pPO9llcY29tIyoWJT3fYnS,price: 6.100,avgPrice: 0.000,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193909383,updateTime: 1706193909383},msg: }5. 查看当前挂单 get_orders_pending
# 查询symbol 从start到end全部未成交订单
orders_pending_result trade.get_orders_pending(symbol, # 默认为空表示全部产品start2024-01-01 10:00:00, # 默认为空表示不限定订单的起始时间end2024-12-26, # 默认为空表示不限定订单的终止时间
)
eprint(orders_pending_result, length30)输出 {code: 200,data: [{orderId: 7108734736,symbol: DOTUSD_PERP,pair: DOTUSD,status: NEW,clientOrderId: pPO9llcY29tIyoWJT3fYnS,price: 6.100,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193909383,updateTime: 1706193909383},{orderId: 70547715976,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_xAkWbFbtGfP3W6nRPI3J,price: 2400,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: SELL,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193177536,updateTime: 1706193177536},{orderId: 70548864413,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_H29bLqhYVMPyLC2k9tVt,price: 2100,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: True,closePosition: False,side: BUY,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193876902,updateTime: 1706193876902},{orderId: 70547694568,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_Qf3K1XXNtOayzl3M05Ek,price: 2000,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193160778,updateTime: 1706193160778},{orderId: 70548673979,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_NsHOBwSq1znyGgs0TDBz,price: 2400,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: True,closePosition: False,side: SELL,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193739701,updateTime: 1706193739701}],msg: }# 查询symbol 从start到end全部未成交订单
orders_pending_result trade.get_orders_pending(symbolETHUSD_PERP, # 默认为空表示全部产品start2024-01-01 10:00:00, # 默认为空表示不限定订单的起始时间end2024-12-26, # 默认为空表示不限定订单的终止时间
)
eprint(orders_pending_result, length30)输出 {code: 200,data: [{orderId: 70547715976,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_xAkWbFbtGfP3W6nRPI3J,price: 2400,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: SELL,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193177536,updateTime: 1706193177536},{orderId: 70548673979,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_NsHOBwSq1znyGgs0TDBz,price: 2400,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: True,closePosition: False,side: SELL,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193739701,updateTime: 1706193739701},{orderId: 70547694568,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_Qf3K1XXNtOayzl3M05Ek,price: 2000,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193160778,updateTime: 1706193160778},{orderId: 70548864413,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_H29bLqhYVMPyLC2k9tVt,price: 2100,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: True,closePosition: False,side: BUY,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193876902,updateTime: 1706193876902}],msg: }6. 查看当前开仓挂单 get_orders_pending_open
# 参数positionSide默认值为表示全部多单和空单
orders_pending_open_result trade.get_orders_pending_open(symbolETHUSD_PERP,
)
eprint(orders_pending_open_result, length30)输出 {code: 200,data: [{orderId: 70547715976,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_xAkWbFbtGfP3W6nRPI3J,price: 2400,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: SELL,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193177536,updateTime: 1706193177536},{orderId: 70547694568,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_Qf3K1XXNtOayzl3M05Ek,price: 2000,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193160778,updateTime: 1706193160778}],msg: }# positionSideSHORT 限制结果为空单
orders_pending_open_result trade.get_orders_pending_open(symbolETHUSD_PERP,positionSideSHORT,
)
eprint(orders_pending_open_result, length30)输出 {code: 200,data: [{orderId: 70547715976,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_xAkWbFbtGfP3W6nRPI3J,price: 2400,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: SELL,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193177536,updateTime: 1706193177536}],msg: }7. 查看当前平仓挂单 get_orders_pending_close
# 参数positionSide默认值为表示全部多单和空单
orders_pending_close_result trade.get_orders_pending_close(symbolETHUSD_PERP,
)
eprint(orders_pending_close_result, length30)输出 {code: 200,data: [{orderId: 70548673979,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_NsHOBwSq1znyGgs0TDBz,price: 2400,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: True,closePosition: False,side: SELL,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193739701,updateTime: 1706193739701},{orderId: 70548864413,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_H29bLqhYVMPyLC2k9tVt,price: 2100,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: True,closePosition: False,side: BUY,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193876902,updateTime: 1706193876902}],msg: }# positionSideSHORT 限制结果为空单
orders_pending_close_result trade.get_orders_pending_close(symbolETHUSD_PERP,positionSideSHORT,
)
eprint(orders_pending_close_result, length30)输出 {code: 200,data: [{orderId: 70548864413,symbol: ETHUSD_PERP,pair: ETHUSD,status: NEW,clientOrderId: ios_H29bLqhYVMPyLC2k9tVt,price: 2100,avgPrice: 0,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: True,closePosition: False,side: BUY,positionSide: SHORT,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193876902,updateTime: 1706193876902}],msg: }8. 等待订单成交 wait_order_FILLED
orderId set_order_result[data][orderId]
symbol set_order_result[data][symbol]
# 堵塞等待订单完全成交如果超时后仍未成交返回订单数据
wait_order_filled_result trade.wait_order_FILLED(symbolsymbol,orderIdorderId,timeout5,
)
eprint(wait_order_filled_result, length30)输出 {code: 200,data: {orderId: 7108734736,symbol: DOTUSD_PERP,pair: DOTUSD,status: NEW,clientOrderId: pPO9llcY29tIyoWJT3fYnS,price: 6.100,avgPrice: 0.000,origQty: 1,executedQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,time: 1706193909383,updateTime: 1706193909383},msg: }9. 撤销订单API原始接口 cancel_order
orderId set_order_result[data][orderId]
symbol set_order_result[data][symbol]cancel_order_result trade.cancel_order(symbolsymbol,orderIdorderId,
)
eprint(cancel_order_result, length30)输出 {code: 200,data: {orderId: 7108734736,symbol: DOTUSD_PERP,pair: DOTUSD,status: CANCELED,clientOrderId: pPO9llcY29tIyoWJT3fYnS,price: 6.100,avgPrice: 0.000,origQty: 1,executedQty: 0,cumQty: 0,cumBase: 0,timeInForce: GTC,type: LIMIT,reduceOnly: False,closePosition: False,side: BUY,positionSide: LONG,stopPrice: 0,workingType: CONTRACT_PRICE,priceProtect: False,origType: LIMIT,updateTime: 1706193919012},msg: }