Binance Futures如何以市场价格关闭头寸(与“按“关闭位置”下方“按下“市场”相同)通过API

发布于 2025-02-03 10:21:31 字数 1918 浏览 4 评论 0原文

这个问题是关于Binance Futures API(不是现货交换,而是期货)。

目标:具有与关闭位置的“紧密位置”下的按钮“市场”与“市场”相同的行为。

注意:请不要回复EndPoit:DELETE/FAPI/V1/ALLOPENORDERS ==>>这仅取消未填写 /(未打开)职位的订单。

我想关闭一个实际的打开位置。

(别忘了按钮购买/长而卖出/卖空是开放位置)期货,卖出与现货交易中的卖出不同。在期货中,卖出实际打开职位。要获利,我们必须关闭(不取消)职位。

我在论坛上进行搜索,很难找到正确的工作答案。

**我可以以市场价格开设一个职位: 符号= btcusdt& side = sell& positionside = short& type = market& dentity = 0.01

** **,但是当我尝试用这些参数关闭它时,我总是会遇到

错误代码>符号= btcusdt& side = sell& type = stop_market& closeposition = true 我得到的停止价格小于零。

符号= btcusdt& side = sell& type = stop_market& closeposition = true& stopprice = 30895.00 我得到订单的位置方面不符合用户的设置。

符号= btcusdt& side = sell& type = stop& closeposition = true& stopprice = 30895.00 profittArget策略无效订购量停止

符号= btcusdt& side = sell& dentity = 0.01& type = market
Order的位置侧不符合用户的设置。

符号= btcusdt& side = sell& type = market& closeposition = true
目标策略无效订购市场,关闭位置true

符号= btcusdt& side = sell& type = stop = stop& collectposition = true true 目标策略无效订购式停止,关闭位置true

符号= btcusdt& side = sell& type = stop_market& closeposite = true 停止价格小于零。

符号= btcusdt& side = sell& type = stop_market& closeposition = true& stopprice = 30158.30
Order的位置侧不符合用户的设置。

符号= btcusdt& side = sell& type = take_profit_market& closeposition = true& stopprice = 30131.30 Order的位置侧不符合用户的设置。

符号= btcusdt& side = sell& positionside = short& type = take_profit_market& closeposition& amp; amp; amp; amp; true& stopprice = 30271.60 可选参数的组合无效。

!!!!!!!!!!!我缺少什么问题或什么参数???

有点令人沮丧。...

有人知道正确的参数吗???

This question is about binance FUTURES api (not spot exchange, but futures).

GOAL : have the same behaviour that the button "market" under "close positions" that closes a position.

NOTE : please don't reply the endpoit : DELETE /fapi/v1/allOpenOrders ==>> this is CANCELLING only orders NOT FILLED / (not opened) positions.

I want to CLOSE a actual OPENED position.

(don't forget that the buttons buy/long and sell/short are opening positions) in futures, sell is not the same as a sell in spot trading. in futures, sell actually open a position. to take profit we have to close (not cancel) the position.

I search all over forums and it's very hard to find a correct working answer to this.

** I can OPEN a position at market price with this:
symbol=BTCUSDT&side=SELL&positionSide=SHORT&type=MARKET&quantity=0.01

** But when I try to CLOSE it with those parameters, I always get an error NOT matter what I try

symbol=BTCUSDT&side=SELL&type=STOP_MARKET&closePosition=true
I get Stop price less than zero.

symbol=BTCUSDT&side=SELL&type=STOP_MARKET&closePosition=true&stopPrice=30895.00
I get Order’s position side does not match user’s setting.

symbol=BTCUSDT&side=SELL&type=STOP&closePosition=true&stopPrice=30895.00
ProfitTarget strategy invalid for orderType STOP

symbol=BTCUSDT&side=SELL&quantity=0.01&type=MARKET
Order's position side does not match user's setting.

symbol=BTCUSDT&side=SELL&type=MARKET&closePosition=true
Target strategy invalid for orderType MARKET,closePosition true

symbol=BTCUSDT&side=SELL&type=STOP&closePosition=true
Target strategy invalid for orderType STOP,closePosition true

symbol=BTCUSDT&side=SELL&type=STOP_MARKET&closePosition=true
Stop price less than zero.

symbol=BTCUSDT&side=SELL&type=STOP_MARKET&closePosition=true&stopPrice=30158.30
Order's position side does not match user's setting.

symbol=BTCUSDT&side=SELL&type=TAKE_PROFIT_MARKET&closePosition=true&stopPrice=30131.30
Order's position side does not match user's setting.

symbol=BTCUSDT&side=SELL&positionSide=SHORT&type=TAKE_PROFIT_MARKET&closePosition=true&stopPrice=30271.60
Combination of optional parameters invalid.

!!!!!!!!!! what’s wrong or what parameter I’m missing ???

it's a bit frustrating....

does anyone know the correct parameters ???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埋葬我深情 2025-02-10 10:21:31

我混合了买东西的东西

打开短短
符号= btcusdt& side = sell& positionside = short& type = market& ventity = 0.01

关闭
符号= btcusdt& side =买& positionside = short& type = market& ventity = 0.01

long
符号= btcusdt& side =买& positionside = long& type = market& ventity = 0.01

close long long
符号= btcusdt& side = sell& positionside = long& type = market&数量= 0.01

I mixed the BUY SELL stuff

OPEN SHORT
symbol=BTCUSDT&side=SELL&positionSide=SHORT&type=MARKET&quantity=0.01

CLOSE SHORT
symbol=BTCUSDT&side=BUY&positionSide=SHORT&type=MARKET&quantity=0.01

OPEN LONG
symbol=BTCUSDT&side=BUY&positionSide=LONG&type=MARKET&quantity=0.01

CLOSE LONG
symbol=BTCUSDT&side=SELL&positionSide=LONG&type=MARKET&quantity=0.01

浴红衣 2025-02-10 10:21:31

我遇到了同一问题,并弄清楚它可以完成,而无需插座连接以监视是否填充了TP/SL之一以取消另一个TP/SL。

它确实需要对API的三个单独的呼叫才能创建每个呼叫,以创建每个呼叫,但是可以设置呼叫中发送的参数,以便如果执行执行,则可以取消其他两个。

例如,被击中的SL将取消原始订单,而TP和击中的TP将取消原始订单和SL等。以下是我在每个呼叫中​​使用的参数以实现此目的(示例值):

原始订单

symbol=BNBUSDT
side=BUY
positionSide=BOTH
type=MARKET
quantity=1
reduceOnly=false

-SL订单

symbol=BNBUSDT
side=SELL
positionSide=BOTH
type=STOP_MARKET
timeInForce= GTE_GTC
quantity=1
reduceOnly=true
stopPrice=(your stop price)
workingType= MARK_PRICE

-TP订单 -

symbol=BNBUSDT
side=SELL
positionSide=BOTH
type=TAKE_PROFIT_MARKET
timeInForce= GTE_GTC
quantity=1
reduceOnly=true
stopPrice=(your take profit price)
workingType= MARK_PRICE

希望这有助于其他任何遇到此问题的人

I was running into the same issue and worked out that it can be done without the need for a socket connection to monitor whether or not one of the TP/SL has been filled in order to cancel the other.

It does require three separate calls to the API to create each as the solved answer points out, but the parameters sent in the calls can be set such that one will cancel the other two if it executes.

For example, the SL being hit will cancel the original order and the TP and the TP being hit will cancel the original order and the SL, etc. Here are the parameters I used in each call to achieve this (with example values):

Original order -

symbol=BNBUSDT
side=BUY
positionSide=BOTH
type=MARKET
quantity=1
reduceOnly=false

SL Order -

symbol=BNBUSDT
side=SELL
positionSide=BOTH
type=STOP_MARKET
timeInForce= GTE_GTC
quantity=1
reduceOnly=true
stopPrice=(your stop price)
workingType= MARK_PRICE

TP Order -

symbol=BNBUSDT
side=SELL
positionSide=BOTH
type=TAKE_PROFIT_MARKET
timeInForce= GTE_GTC
quantity=1
reduceOnly=true
stopPrice=(your take profit price)
workingType= MARK_PRICE

Hopefully, this helps anyone else running into this issue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文