【问题标题】:Binance API Java - Stop-Limit Orders?Binance API Java - 止损限价单?
【发布时间】:2019-01-31 23:59:38
【问题描述】:

我已经下载了binance API for Java,我正在尝试弄清楚如何下一个新的止损限价单。我已经进入NewOrder 类并添加了一个构造函数,该构造函数采用止损价格参数和一个用于创建止损限价卖出订单的方法。

public NewOrder(String symbol, OrderSide side, OrderType type, TimeInForce timeInForce, String quantity, String Price, String stopPrice){
  this(symbol, side, type, timeInForce, quantity);
  this.price=price;
  this.stopPrice=stopPrice;
}

 public static NewOrder stopLimitSell(String symbol, TimeInForce timeInForce, String quantity, String price, String stopPrice){
  return new NewOrder(symbol, OrderSide.SELL, OrderType.STOP_LOSS_LIMIT, timeInForce, quantity, price, stopPrice);
}

这是应该创建止损限价单的代码行

client.newOrder(stopLimitBuy("BTCUSDT", TimeInForce.GTC, "0.035375", "5000","4999"));

出现以下错误:

线程“main”com.binance.api.client.exception.BinanceApiException 中的异常:未发送强制参数“price”、为空/null 或格式错误。

有人可以指导我正确的方向吗?在 Java 中为 binance 创建止损限价单的方法是什么?我找不到任何东西...

【问题讨论】:

  • 在第一段代码中显示stopLimitSell() 订单,然后在第二段代码中显示stopLimitBuy() 调用。这是正确的吗?
  • 应该是。 Binance 在其网站上具有止损限价买卖功能。似乎有可用于 python 和 php 的自定义订单我只是无法在任何地方找到它用于 Java ......
  • 我在 Java API 中找不到 stopLimitBuy() 方法。你知道在哪里吗?我们必须查看该代码并尝试了解它如何期望传递 price 参数。

标签: java api binance


【解决方案1】:

创建 NewOrder 对象作为默认限价卖单,然后使用 NewOrder.stopPrice() 添加止损价格(即触发值)。

【讨论】:

  • 你说的普通订单是指限价单吗?
  • 是的。刚刚根据您的评论改进了答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-22
  • 2023-01-10
  • 2022-08-24
  • 2022-08-04
  • 1970-01-01
相关资源
最近更新 更多