跳至内容

已成交订单延迟

默认情况下,Hummingbot 会在没有活跃订单时立即挂单;也就是说,当一个订单成交后,Hummingbot 会立刻挂出新的订单进行替换。如果市场在某一方向持续运动一段时间,则存在继续沿该方向交易的风险:例如,在长期下跌行情中持续买入并累积基础代币,或在长期上涨行情中持续卖出。

filled_order_delay 参数允许在订单成交后延迟挂出新订单,从而有助于缓解上述情况。

filled_order_delay

当至少有一个订单被成交时,等待多久再放置下一组订单。

例如,当 filled_order_delay 设置为 300 时,若机器人挂出的订单被成交,则下一组订单将在 300 秒后才被创建。

**提示:**

How long do you want to wait before placing the next order if your order gets filled (in seconds)?
>>> 300

工作原理

这有助于在价格趋势明显时进行管理。例如,在下图中,当价格呈下跌趋势时,买盘订单在每次刷新后都会被持续成交。

如果这种情况反复持续,做市商可能在仅数次订单刷新周期内迅速累积大量资产。在上述示例中,交易者已买入了五次资产。

通过在已成交订单与新订单之间引入延迟,可以分散订单的挂出时间,减缓资产的潜在累积,为价格趋势的稳定留出时间。

如上图所示,由于第一阶段的买盘订单被成交,机器人在第二、三、四阶段均未挂单。因此,在此下跌趋势中,机器人仅在第一和第五阶段买入两次;而若未启用已成交订单延迟,则机器人会在全部五个阶段都买入。

举例而言,我们的买入和卖出订单均在 00:00:00 精确创建。

00:00:00 - (BTCUSDT) Creating 1 bid order at ['0.005 BTC, 9026.63 USDT']
00:00:00 - (BTCUSDT) Creating 1 ask order at ['0.005 BTC, 9072.081 USDT']
Markets:
  Exchange   Market  Best Bid Price  Best Ask Price  Mid Price
   binance  BTCUSDT         9071.79         9072.13    9071.9

Assets:
                            BTC     USDT
   Total Balance           0.05      500
   Available Balance      0.045 454.8668
   Current Value (USDT) 453.598      500
   Current %              47.6%    52.4%

Orders:
   Level  Type    Price Spread Amount (Orig)  Amount (Adj)       Age
       1  sell 9072.081  0.01%         0.005         0.005  00:00:01
       1   buy  9026.63  0.50%         0.005         0.005  00:00:01

当一个订单成交后,系统将等待 filled_order_delay 时间后再创建新的一组订单。另一侧未成交的订单将根据订单刷新时间被取消。详见下一节示例。

较短订单刷新时间下的已成交订单延迟

- order_refresh_time: 30.0
- filled_order_delay: 60.0

假设我们的卖单在 00:00:10 被成交。

00:00:10 - (BTCUSDT) Maker sell order of 0.0050000 BTC filled.
00:00:10 - (BTCUSDT) Maker sell order (0.0050000 BTC @ 9072.0810000000 USDT)
                     has been completely filled.

未成交的订单将在创建后 30 秒被取消,这意味着从 00:00:3000:01:09 期间将没有任何活跃订单。

00:00:30 - (BTCUSDT) Cancelling the buy limit order
Markets:
  Exchange   Market  Best Bid Price  Best Ask Price  Mid Price
   binance  BTCUSDT         9073.91         9074.37    9074.14

Assets:
                             BTC     USDT
   Total Balance           0.045 545.3783
   Available Balance       0.045 545.3783
   Current Value (USDT) 408.3363 545.3783
   Current %               42.8%    57.2%

No active maker orders.
00:01:10 - (BTCUSDT) Creating 1 bid order at ['0.005 BTC, 9047.709 USDT']
00:01:10 - (BTCUSDT) Creating 1 ask order at ['0.005 BTC, 9093.266 USDT']

较长订单刷新时间下的已成交订单延迟

- order_refresh_time: 120.0
- filled_order_delay: 60.0

使用相同场景,我们的卖单在 00:00:10 被成交,而买单保持活跃。

00:00:10 - (BTCUSDT) Maker sell order of 0.0050000 BTC filled.
00:00:10 - (BTCUSDT) Maker sell order (0.0050000 BTC @ 9072.0810000000 USDT)
                     has been completely filled.
Markets:
  Exchange   Market  Best Bid Price  Best Ask Price  Mid Price
   binance  BTCUSDT          9071.8         9072.83   9072.315

Assets:
                             BTC     USDT
   Total Balance           0.045 545.3604
   Available Balance       0.045 500.2273
   Current Value (USDT) 408.2542 545.3604
   Current %               42.8%    57.2%

Orders:
   Level Type   Price Spread Amount (Orig)  Amount (Adj)       Age
       1  buy 9026.63  0.50%         0.005         0.005  00:00:11

请注意时间戳。由于刷新时间长于已成交订单延迟,未成交订单将保持活跃,直至需要创建新的一组订单为止。

00:01:09 - (BTCUSDT) Cancelling the buy limit order
00:01:10 - (BTCUSDT) Creating 1 bid order at ['0.005 BTC, 9047.709 USDT']
00:01:10 - (BTCUSDT) Creating 1 ask order at ['0.005 BTC, 9093.266 USDT']