Skip to content

Instantly share code, notes, and snippets.

@devster31
Created January 6, 2018 20:43
Show Gist options
  • Save devster31/f088d3d5d1bf3af42641a5a63be66749 to your computer and use it in GitHub Desktop.
Save devster31/f088d3d5d1bf3af42641a5a63be66749 to your computer and use it in GitHub Desktop.

Strategies

The trend_ema strategy (default)

  • The default strategy is called trend_ema and resides at ./extensions/strategies/trend_ema.
  • Defaults to using a 2m period, but you can override this with adding e.g. --period=5m to the sim or trade commands.
  • Computes the 26-period EMA of the current price, and calculates the percent change from the last period's EMA to get the trend_ema_rate
  • Considers trend_ema_rate >= 0 an upwards trend and trend_ema_rate < 0 a downwards trend
  • Filters out low values (whipsaws) by neutral_rate, which when set to auto, uses the standard deviation of the trend_ema_rate as a variable noise filter.
  • Buys at the beginning of upwards trend, sells at the beginning of downwards trend
  • If oversold_rsi is set, tries to buy when the RSI dips below that value, and then starts to recover (a counterpart to --profit_stop_enable_pct, which sells when a percent of profit is reached, and then dips)
  • The bot will always try to avoid trade fees, by using post-only orders and thus being a market "maker" instead of a "taker". Some exchanges will, however, not offer maker discounts.

The macd strategy

The moving average convergence divergence calculation is a lagging indicator, used to follow trends.

  • Can be very effective for trading periods of 1h, with a shorter period like 15m it seems too erratic and the Moving Averages are kind of lost.
  • It's not firing multiple 'buy' or 'sold' signals, only one per trend, which seems to lead to a better quality trading scheme.
  • Especially when the bot will enter in the middle of a trend, it avoids buying unless it's the beginning of the trend.

The rsi strategy

Attempts to buy low and sell high by tracking RSI high-water readings.

  • Effective in sideways markets or markets that tend to recover after price drops.
  • Risky to use in bear markets, since the algorithm depends on price recovery.
  • If the other strategies are losing you money, this strategy may perform better, since it basically "reverses the signals" and anticipates a reversal instead of expecting the trend to continue.

The sar strategy

Uses a Parabolic SAR indicator to trade when SAR trend reverses.

  • Tends to generate earlier signals than EMA-based strategies, resulting in better capture of highs and lows, and better protection against quick price drops.
  • Does not perform well in sideways (non-trending) markets, generating more whipsaws than EMA-based strategies.
  • Most effective with short period (default is 2m), which means it generates 50-100 trades/day, so only usable on GDAX (with 0% maker fee) at the moment.
  • Tested live, results here

The speed strategy

Trade when % change from last two 1m periods is higher than average.

This strategy is experimental and has WILDLY varying sim results. NOT RECOMMENDED YET.

  • Like the sar strategy, this generates early signals and can be effective in volatile markets and for sudden price drop protection.
  • Its weakness is that it performs very poorly in low-volatility situations and misses signals from gradually developing trends.

Tips for tweaking options

  • Trade frequency is adjusted with a combination of --period and --trend_ema. For example, if you want more frequent trading, try --period=5m or --trend_ema=15 or both. If you get too many ping-pong trades or losses from fees, try increasing period or trend_ema or increasing neutral_rate.
  • Sometimes it's tempting to tell the bot trade very often. Try to resist this urge, and go for quality over quantity, since each trade comes with a decent amount of slippage and whipsaw risk.
  • --oversold_rsi=<rsi> will try to buy when the price dives. This is one of the ways to get profit above buy/hold, but setting it too high might result in a loss of the price continues to fall.
  • In a market with predictable price surges and corrections, --profit_stop_enable_pct=10 will try to sell when the last buy hits 10% profit and then drops to 9% (the drop % is set with --profit_stop_pct). However in strong, long uptrends this option may end up causing a sell too early.
  • For Kraken and GDAX you may wish to use --order_type="taker", this uses market orders instead of limit orders. You usually pay a higher fee, but you can be sure that your order is filled instantly. This means that the sim will more closely match your live trading. Please note that GDAX does not charge maker fees (limit orders), so you will need to choose between not paying fees and running the risk orders do not get filled on time, or paying somewhat high % of fees and making sure your orders are always filled on time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment