Script Walkthrough - Hummingbot
URL: https://hummingbot.org/v2-strategies/walkthrough/
Contents:
- Script Walkthrough
- What we'll cover¶
- Create script config¶
- Run the script¶
- Check status and performance¶
- Next steps¶
Below, we provide a walkthrough to illustrate the StrategyV2 framework, which we recommend for new users who want to understand how the framework works.
In this example, we'll show you how to configure and run a simple directional trading strategy using the v2_directional_rsi.py starter script.
This strategy executes trades on a spot or perpetual exchange based on the RSI signals from the Market Data Provider, creating buy actions when the RSI is below a low threshold (indicating oversold conditions) and sell actions when the RSI is above a high threshold (indicating overbought conditions).
After each trade, the strategy utilizes the Position Executor component, which uses a triple barrier configuration to manage the P&L of the position or filled order.
First, let's create a script config file that defines the key strategy parameters.
Launch Hummingbot and execute the command below to generate your script configuration:
This command auto-completes with the subset of configurable scripts from the local /scripts directory.
You'll be prompted to specify the strategy parameters, which are then saved in a YAML file within the conf/scripts directory:
Execute the command below to start the script:
The strategy makes a series of market checks and initializes the market data provider. Afterwards, it should start placing orders for both pairs.
Run the Status command to see the status (asset balances, active orders and positions) of the running strategy:
After there have been trades, you can use the History to see your bot's performance.
We encourage you check out Dashboard, the new entry point for Hummingbot users that will be officially launched at the Hummingbot 2.0 launch event.
Also, see Walkthrough - Controller to learn how to run scripts that deploy strategies as Controllers.
Examples:
Example 1 (unknown):
create --script-config v2_directional_rsiExample 2 (unknown):
Exchange where the bot will trade >> hyperliquid_perpetual
Trading pair where the bot will trade >> ETH-USD
Candles exchange used to calculate RSI >> binance_perpetual
Candles trading pair used to calculate RSI >> ETH-USDT
Candle interval (e.g. 1m for 1 minute) >> 1m
Number of candles used to calculate RSI (e.g. 60) >> 60
RSI lower bound to enter long position (e.g. 30) >> 30
RSI upper bound to enter short position (e.g. 70) >> 70
Order amount in quote asset >> 30
Leverage (e.g. 10 for 10x) >> 10
Position mode (HEDGE/ONEWAY) >> ONEWAY
Enter a new file name for your configuration >> conf_v2_directional_rsi_1.ymlExample 3 (unknown):
start --script v2_directional_rsi.py --conf conf_v2_directional_rsi_1.yml