Hummingbot Academy

Advanced TWAP Strategy

Advanced TWAP (2) Strategy

https://github.com/CoinAlpha/hummingbot-rfox.git

Summary

The “twap_plus” strategy highly involves the Relative Strength Indicator (RSI) trend of a certain trading pair to execute trades. This way users can setup bots to match whenever the RSI levels are theoretically giving “Buy” signals or “Sell” signals and decide potential entry and exit points.

Brief overview of RSI

(RSI) is a momentum indicator that evaluates overbought or oversold conditions by measuring the magnitude of recent price changes for various assets. It is displayed as an oscillator (a line graph that moves between two extremes) and can have a reading from 0 to 100.

Traditional interpretation and usage of the RSI are:

  • 70 or above - (SELL) Indicates that an asset is becoming overbought or overvalued and may be primed for a trend reversal or corrective pullback in price.
  • 30 or below - (BUY) Indicates an oversold or undervalued condition and may be poised for a rebound.

For more info about RSI click the link below.

Relative Strength Index (RSI)

Where to find the RSI in the exchange?

The RSI Graph is available as a custom view in most exchanges. A view on how it looks like is seen below.

Untitled (6)

Strategy Config Map

The table below reflects the config settings that comes after strategy; connector and trading_pair setup.

KeyDefault ValueOther ValuesOn SelectOrderPrompt
price_sourcecurrent marketcurrent_marke external_market or custom_apiN/A1Which price source to use?
external_exchangeadd connector
external_trading_pairtrading pair
price_custom_api-
custom_api_intervalURLEnter external pricing API URL
price_type
price_indicatorsRSIEnter the indicator based on which order sizes are adjusted (RSI)
indicator_candle1m1s;1m;5m;10m;30m;1h;1d3Enter the size of candles used for indicator calculatio
rsi_length144What history length should be used in the RSI?
order_sidebuybuy/sell5What operation will be executed?
target_asset_amount16What is the total amount of "trading_pair" to be traded?
order_amount_min17What is the minimum amount of each individual order (denominated in the base as set)?
order_amount_max18What is the maximum amount of each individual order (denominated in the base as set)?
order_spreads-9What is the size of the limit orders from the price_type (denominated as a% of the asset price)?
order_level1
order_level_amount0
order_level_spread0
price_floorNone
price_ceilingNone
is_delayed_start_executionNoYes/No10Do you want to specify a start time for the execution?
is_time_span_execution(MM:DD:YYY - HH:MM:SS)
end_timeNoYes/No11Do you want to specify an end time for the execution?
order_delay_time(MM:DD:YYY - HH:MM:SS)
cancel_order_wait_time6012How long do you want to wait before cancelling your limit order (in seconds)?

Config Description

price_source - Gets where the price of the subject asset/token is from

  • current_market - Trades to where the initial exchange was set
  • external_exchange - Changes the exchange on which transactions will be made
    • external_trading_pair - Changes the token to trade
  • custom_api - Select custom API to where trade will take place
    • price_custom_api - Adds API and will prompt for the URL source of price
    • custom_api_interval - Set interval in seconds

price_indicator - RSI based trading

indicator_candle - Similar to the Timeframe of the desired trade view on an exchange trading block

rsi_length - RSI level of entry (14 as the default undervalued Buy signal)

order_side - Select which action to execute (buy/sell)

target_asset_amount - Amount of set asset/token to be traded.

order_amount_min - Set minimum base asset/token order.

order_amount_max - Set maximum base asset/token order.

is_delayed_start_execution - Activate the option of starting trade.

is_time_span_execution - Set time of start if is_delayed_start_execution = "yes"

end_time - Activate the option of ending trade.

order_delay_time - Set time of end if end_time = "yes”

cancel_order_wait_time - ****Activate the option of ending trade.

Sample Config

Untitled (3)

See details below:

  • target_asset_amount - The goal is to trade a total of 30 ADA.
  • order_amount_min - The minimum amount of ADA to bid is 6
  • order_amount_max - The maximum amount of ADA to bid is 8
  • rsi_length - The RSI Length to base orders to be placed is 14
  • indicator_candle_size - Orders will be placed every 1s based on the RSI 14 graph
  • order_side - The only action to be done is to “Buy”

When Started

Untitled (4)

With the configuration above:

  • 4 ADA bid orders were made on a indicator_candle_size (1s) which was based on the rsi_length (14)
  • The bot tried to fill orders until the target_asset_amount (30) was filled by the frequent orders indicated by order_amount_min (6) up to order_amount_max (8)

Untitled (5)

  • “twap_plus - Not possible to break the order into the desired number of segments”
    Message appeared. This means that the bot has stopped creating orders.
  • “twap_plus - [time stamp] is now greater than Previous time [time stamp]. Trying to place orders now. -Message appeared. This means that it will still try to place an order even if the bid order target_asset_amount (30) - At this point there will be no more orders reflecting in the exchange’s open orders.

Conclusion:

The twap_plus strategy’s ultimate goal is to fill the asset value indicated in the target_asset_amount. In order to do this, once the bot has started, it will create either a bid or an ask order based on the value assigned on the order_side which will be buying or selling. If buying, make sure to have enough Quote currency. On the other hand, to sell, make sure Base currency is available. The asset order volume to be placed will use the values indicated on the order_amount_min and order_amount_max. Remember that the bot uses the Base currency as the indicator on all order fields. And the frequency of the order will be depending on the graph of the rsi_length and selected timeframe in the indicator_candle_size. The bot will stop making orders when the target_asset_amount has been reached or if: (x + y) > target_asset_amount. Where:

  • x = Current asset amount
  • y= order_amount_min or order_amount_max

For more info about RFOX see link below:

RFOX

DISCLAIMER: The websites located at https://hummingbot.io, https://docs.hummingbot.io, https://miners.hummingbot.io (collectively, the "Site") are copyrighted works belonging to CoinAlpha, Inc. ("Company", "us", "our", and "we"). Certain features of the Site may be subject to additional guidelines, terms, or rules, which will be posted on the Site in connection with such features. All such additional terms, guidelines, and rules are incorporated by reference into these Terms. These terms of use (these "Terms") set forth the legally binding terms and conditions that govern your use of the Site. By accessing or using the Site, you are accepting these Terms (on behalf of yourself or the entity that you represent), and you represent and warrant that you have the right, authority, and capacity to enter into these terms (on behalf of yourself or the entity that you represent). You may not access or use the Site or accept the terms if you are not at least 18 years old. If you do not agree with all of the provisions of these terms, do not access and/or use the Site.