Skip to content

Sample Scripts

The sample scripts below can be found in the /scripts folder in the Hummingbot codebase.

In the Hummingbot client, run a script with:

start --script [SCRIPT NAME]

Simple Strategies

Simple PMM

  • Code: simple_pmm_example
  • Author: cardosofede
  • Release Added: 1.9.0
  • Description: The bot will place two orders around the price_source (mid price or last traded price) in a trading_pair on exchange, with a distance defined by the ask_spread and bid_spread. Every order_refresh_time in seconds, the bot will cancel and replace the orders.

Simple XEMM

  • Code: simple_xemm_example
  • Author: fengtality
  • Release Added: 1.10.0
  • Description: A simplified version of Hummingbot cross-exchange market making strategy, this bot makes a market on the maker pair and hedges any filled trades in the taker pair. If the spread (difference between maker order price and taker hedge price) dips below min_spread, the bot refreshes the order

Simple Arbitrage

  • Code: simple_arbitrage_example
  • Author: fengtality
  • Release Added: 1.20.0
  • Description: A simplified version of Hummingbot arbitrage strategy, this bot checks the Volume Weighted Average Price for bid and ask in two exchanges and if it finds a profitable opportunity, it will trade the tokens.

Simple Directional

Simple VWAP

  • Code: simple_vwap_example
  • Author: cardosofede
  • Release Added: 1.7.0
  • Description: This example lets you create one VWAP in a market using a percentage of the sum volume of the order book until a spread from the mid price. This example demonstrates:
    • How to get the account balance
    • How to get the bids and asks of a market
    • How to code a "utility" strategy

Fixed Grid

  • Code: fixed_grid
  • Author: rkc2000
  • Release Added: 1.15.0
  • Description: The script implements a fixed grid trading strategy, placing buy and sell orders at predetermined price levels, rebalancing assets if required, and providing status updates on trades and balances.

V2 Strategies

Directional-MACD-BB

  • Code: v2_directional-trading_macd_bb_v1
  • Author: cardosofede
  • Release Added: 1.20.0
  • Description: This script is a customized market-making script which operates using multiple trading pairs and uses a combination of MACD and Bollinger Bands indicators for each trading pair.

DMan-Composed

  • Code: v2_market-making_dman_composed
  • Author: cardosofede
  • Release Added: 1.20.0
  • Description: This script is an advanced market-making strategy, designed to execute trades on a single trading pair, with a sophisticated setup that includes two different market-making controllers: DManV1 and DManV2. Each controller has its own configuration and set of rules for trade execution.

DMan-V1

DMan-V2

DMan-V3

Download Data

Download Candles

  • Code: download_candles
  • Author: cardosofede
  • Release Added: 1.15.0
  • Description: This script provides an example of how to use the Candles Feed to download and store historical data. It downloads 3-minute candles for 3 Binance trading pairs ["APE-USDT", "BTC-USDT", "BNB-USDT"] and stores them in CSV files in the /data directory. The script stops after it has downloaded 175,000 max_records records for each pair

Download Order Book and Trades

  • Code: download_order_book_and_trades
  • Author: cardosofede
  • Release Added: 1.15.0
  • Description: This script provides an example of how to download trades and order book snapshots for specified trading pairs from an exchange into a text file in the data folder.

Archived Scripts

These are a collection of older scripts which are moved over to the archived_scripts folder in the Github repo.

1-N Portfolio

  • Code: 1overN_portfolio
  • Author: rolandkofler
  • Release Added: 1.16.0
  • Description: This strategy aims to create a 1/N cryptocurrency portfolio, providing perfect diversification without parametrization and giving a reasonable baseline performance.

Adjusted Mid Price

  • Code: adjusted_mid_price
  • Author: cmichaeltimmons
  • Release Added: 1.9.0
  • Description: This is an example of a pure market making strategy with an adjusted mid price. The mid price is adjusted to the midpoint of a hypothetical buy and sell of a user defined {test_volume}.

Advanced Directional

  • Code: advanced_directional_strategy_example
  • Author: cardosofede
  • Release Added: 1.13.0
  • Description: A directional trading strategy that uses two timeframes of the same trading pair (ETH-USDT) and based on the RSI and Bollinger Bands is going long or short. The weigths of the indicators are the same, that means that 0.5 * RSI + 0.5 * BBANDS = signal_value, but we are going to prioritize 1m timeframe so after calculating the signal for 1m and 3m, we are going to multiply the value of 1m by 0.7 and 3m by 0.3.

AMM Price

  • Code: amm_price_example
  • Author: fengtality
  • Release Added: 1.13.0
  • Description: This example shows how to call the /amm/price Gateway endpoint to fetch price for a swap

AMM Trade

  • Code: amm_trade_example
  • Author: fengtality
  • Release Added: 1.13.0
  • Description: This example shows how to call the /amm/trade Gateway endpoint to execute a swap transaction

Buy dip

  • Code: buy_dip_example
  • Author: aarmoa
  • Release Added: 1.4.0
  • Description: This strategy buys ETH (with BTC) when the ETH-BTC drops 5% below 50 days moving average (of a previous candle) This example demonstrates:
    • How to call Binance REST API for candle stick data
    • How to incorporate external pricing source (Coingecko) into the strategy
    • How to listen to order filled event
    • How to structure order execution on a more complex strategy

Buy low sell high

  • Code: buy_low_sell_high
  • Author: Alkhalifah-blockchain
  • Release Added: 1.9.0
  • Description: The script will be calculating the MA for a certain pair, and will execute a buy_order at the golden cross and a sell_order at the death cross.

Buy only three times

  • Code: buy_only_three_times_example
  • Author: cardosofede
  • Release Added: 1.7.0
  • Description: This example places shows how to add a logic to only place three buy orders in the market, use an event to increase the counter and stop the strategy once the task is done.

Candles Example

  • Code: candles_example
  • Author: cardosofede
  • Release Added: 1.13.0
  • Description: This is a strategy that shows how to use the new Candlestick component. It acquires data from both Binance spot and Binance perpetuals to initialize three different timeframes of candlesticks. The candlesticks are then displayed in the status, which is coded using a custom format status that includes technical indicators.

DCA Example

  • Code: dca_example
  • Author: aarmoa
  • Release Added: 1.4.0
  • Description: This example shows how to set up a simple strategy to buy a token on fixed (dollar) amount on a regular basis

Format Status

Log Price

Microprice Calculator

  • Code: microprice_calculator
  • Author: ntnle
  • Release Added: 1.13.0
  • Description: A script that can compute the microprice adjusted midprice of token pairs and display that midprice adjusted for the imbalance of the order book, and other information.

PMM with shifted mid dynamic spreads

  • Code: pmm_with_shifted_mid_dynamic_spreads
  • Author: cardosofede
  • Release Added: 1.15.0
  • Description: This script will demonstrate how to extend the simple mmm example to shift the mid-price and make the spreads dynamic by using the candles component and applying technical indicators.

Simple RSI

Spot Perp Arbitrage

  • Code: spot_perp_arb
  • Author: riven314
  • Release Added: 1.16.0
  • Description: This script improves upon and addresses problems with the current spot perp arbitrage strategy. It is designed to simultaneously initiate a long position in the spot market and a short position in the perpetual market when the opening signal is triggered. These positions are then closed upon receiving the closing signal. The profit is generated from the corrective motion between the spot price and the perpetual price.

Triangular Arbitrage

  • Code: triangular_arbitrage
  • Author: supervik
  • Release Added: 1.10.0
  • Description: This script executes arbitrage trades on 3 markets of the same exchange when a price discrepancy among those markets is found.