Perpetual Market Making
Learn how to use Perpetual market making strategy
Like pure market-making, Hummingbot continually posts limit bids and asks offers on the market, and waits for other participants "takers" to fill their orders. Position management features are introduced to configure the bot further to make managing positions easier and remove the need to interact with the derivative exchange manually.
This strategy has two position management features currently available which has different parameters that users can customize:
In addition to those two features, a stop_loss parameter is added to work with both features and would close any active position(s) as soon as loss reaches the limit set in the stop_loss_spread parameter.
Hummingbot uses these to logically determine when positions would be closed when using a particular feature.
- In Hummingbot, enter
- Enter the trading pair, for example,
- Follow on-screen prompts and info for Perpetual parameters.
startto run the strategy.
For details on each Perpetual parameters, see the following sections for details. These parameters are fields in Hummingbot configuration files (located in the
/conf folder, e.g.
Enter the leverage you would like to use.
Generally, the Perpetual market making strategy can manage two different types of position modes :
In this mode, only one active position(long or short) per trading pair is possible. Trying to open a second position would increase or decrease the position’s size depending on the second position’s side.
One-way mode, users can have only one active position in the direction of the order that opened the contract regardless of the
position_management being used. Refer to the example below:
position_mode: One-way bid_spread: 0.01 ask_spread: 0.01 order_refresh_time: 30 position_management: Profit_taking
Unlike one-way mode, it is possible to have a long and short position open concurrently without affecting the size of the contract.
Hedge mode, users can have two open positions.
position_mode: Hedge bid_spread: 0.01 ask_spread: 0.01 order_refresh_time: 30 position_management: Profit_taking
View the image here that if one order gets filled, it will close the long position. If the other order gets filled, it will open a short position.
The order amount for the short or long position of the base asset for the trading pair.
Two available features for position management.
Trailing_stop are the currently available features.
Places a short or long order to close a position from the position's entry price determined by the spreads set. After an order is filled, a position is opened immediately. The parameters under Profit taking are
It is the spread above the entry price at which a short limit order is placed to close the position.
It is the spread below the entry price at which a long limit order is placed to close the position.
Refer to the example below.
position_mode: Hedge bid_spread: 0.01 ask_spread: 0.01 order_refresh_time: 30 position_management: Profit_taking long_profit_taking_spread: 0.5% short_profit_taking_spread: 0.5%
A position is immediately opened when an order is filled.
After the position has been opened, it will create an order to take profit(and close position) provided there's no open loss on the active position.
If by chance, the order for
open long gets filled, it will now open a long position, and you now have two open orders to close the positions.
The bot will create orders depending on the
short_profit_taking_spread that is set. The position will be closed once the orders are filled, depending on the spreads.
Trailing would begin if the current price is beyond or equal to the set
ts_activation_spread. Setting this parameter to zero would start the trailing immediately the position is opened.
Traders can fill in the price level that triggers the trailing stop. If no activation price is being filled, the activation price will be the position entry price by default.
Callback rate determines the price away from peak maximum or peak minimum price when trailing, beyond which a long position or short position will be closed respectively.
This feature gives users the option to select the order type for closing positions which is used by the trailing stop and/or stop loss features.
Refer to the example below.
position_mode: Hedge bid_spread: 0.01 ask_spread: 0.01 order_refresh_time: 30 position_management: Trailing_stop ts_activation_spread: 0.01% ts_callback_rate: 0.5% close_position_order_type: LIMIT
The order was filled, but the position was immediately closed because the current price was above or not equal to
Trailing began when the
ts_activation_spread was met, then the position eventually closed because it reached the percentage we set as
Stop_loss works with both
Trailing_stop features and would only place a stop loss order if loss has reached the limit set by the stop loss spread.
A profit taking order would be placed immediately if the position has no opening loss, otherwise, it would monitor position and place a stop-loss order if loss increases to the set stop-loss spread. If a loss is detected, the
Profit_taking orders will be canceled, and a stop-loss order will be placed if loss rises to the set stop-loss spread.
Suppose stop-loss spread is set too low and LIMIT order is specified to close the position in an active market. In that case, there's a high probability that the take profit feature would cancel and replace a stop-loss order.
Once a profitable exit price is detected, no stop-loss order should be placed. An exception could arise in cases where the market swings swiftly to an unprofitable price within ticks or if the configured trailing stop parameters are too low.
If no exit price has been detected, a stop-loss order will be placed if loss increases to the set stop-loss spread.