/
Launch Hummingbot Miner

Perpetual Market Making

Learn how to use Perpetual market making strategy


How it Works

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.

Creating the Strategy

  1. In Hummingbot, enter create.
  2. Enter [perpetual_connector_name]_testnet or [perpetual_connector_name].
  3. Enter the trading pair, for example, BTC-USDT.
  4. Follow on-screen prompts and info for Perpetual parameters.
  5. Enter start to 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. conf/perpetual_market_making_[#].yml).

leverage

Enter the leverage you would like to use.

Prompt:

How much leverage do you want to use? (Binance Perpetual supports up to 75X for most pairs) >>>
>>>


position_mode

Generally, the Perpetual market making strategy can manage two different types of position modes :

  NOTE:
Some perpetual connectors may offer either of the modes or both.

Prompt:

Which position mode do you want to use? (One-way/Hedge) >>>
>>> Hedge



One-way

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.

In 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

Hedge

Unlike one-way mode, it is possible to have a long and short position open concurrently without affecting the size of the contract.

In 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.

order_amount

The order amount for the short or long position of the base asset for the trading pair.

Prompt:

What is the amount of [trading pair] per order? >>> 3


position_management

Two available features for position management. Profit_taking and Trailing_stop are the currently available features.

Prompt:

How would you like to manage your positions? (Profit_taking/Trailing_stop) >>>
>>> Profit_taking


Profit_taking

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 long_profit_taking_spread and short_profit_taking_spread.


long_profit_taking_spread

It is the spread above the entry price at which a short limit order is placed to close the position.

Prompt:

At what spread from the entry price do you want to place a short order to reduce position? (Enter 1 for 1%) >>>
>>> 1


short_profit_taking_spread

It is the spread below the entry price at which a long limit order is placed to close the position.

Prompt:

At what spread from the entry price do you want to place a long order to reduce position? (Enter 1 for 1%) >>>
>>> 1


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 long_profit_taking_spread and short_profit_taking_spread that is set. The position will be closed once the orders are filled, depending on the spreads.

Trailing_stop

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.

ts_activation_spread

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.

Prompt:

At what spread from the position entry price do you want the bot to start trailing? (Enter 1 for 1%) >>>
>>> 1


ts_callback_rate

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.

Prompt:

At what spread away from the trailing peak price do you want positions to remain open before they're closed? (Enter 1 for 1%) >>>
>>> 1


close_position_order_type

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.

Prompt:

What order type do you want to use for closing positions? (LIMIT/MARKET) >>>
>>> LIMIT


Source: https://www.binance.com/en/support/faq/360042299292

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 ts_activation_spread.

Trailing began when the ts_activation_spread was met, then the position eventually closed because it reached the percentage we set as ts_callback_rate.

stop_loss_spread

Stop_loss works with both Profit_taking and Trailing_stop features and would only place a stop loss order if loss has reached the limit set by the stop loss spread.

At what spread from position entry price do you want to place stop_loss order? (Enter 1 for 1%) >>>
>>> 1


stop_loss_spread with Profit_taking

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.

stop_loss_spread with Trailing_stop

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.

  INFO:
Price NILL means the market is yet to move enough to have a peak price that'll give a profitable exit price according to the configured parameters for the feature.
Edit on GitHub