Info on ping pong
Updated as of
This feature enables the ping pong strategy, in which Hummingbot alternates buy and sell orders.
Whether to alternate between buys and sells.
The ping pong strategy tries to keep buys and sells balanced by only creating orders on the opposite side of an order that is filled. It will keep on creating orders on the opposite side of the filled order as long as
ping_pong is set to enabled. For example:
Because the buy order from period 1 was filled, the bot stops placing buy orders and only places sell orders (periods 2-4). Only when a sell order is eventually filled (period 4) that's the time that it will resume creating both buy and sell orders (period 5).
By default, this parameter is set to
False. When enabled, after a filled order event on either side (buy/sell) it will only create orders on the opposite side on the next refresh.
For example, if your buy order is filled and the sell order was cancelled the bot will keep creating sell orders only until it gets filled.
Stopping the strategy using the
stop command breaks the current ping pong logic. Upon restarting the bot will initially create both buy and sell orders again assuming you have enough balance to place orders on each side.
The scenario below shows how ping pong balances trades when one side is filled.
- Buy order $b1$ and sell order $s1$ are created
- $b1$ gets filled and $s1$ is cancelled when not filled
- Sell order $s2$ is created
- $s2$ gets filled
- Buy order $b3$ and sell order $s3$ are created
Notice that the buy order $b2$ was not created in an attempt to offset the previous trade.
Let's say initially we have 2 orders on each side, buy orders $b1$, $b2$, and sell orders $s1$, $s2$.
- $b1$ gets filled and $b2$, $s1$, $s2$ are cancelled when not filled
- Buy order $b3$ and sell orders $s3$, $s4$ are created
- $s3$ gets filled and $b3$, $s4$ are cancelled when not filled
- Buy order $b4$ and sell order $s5$ are created
- $s5$ gets filled and $b4$ is cancelled when not filled
- Buy order $b5$ is created
- $b5$ gets filled
- Buy orders $b6$, $b7$ and sell orders $s6$, $s7$ are created