Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
[DOCS] add docs on papertrader, tradebot rewrite simulation explanati…
Browse files Browse the repository at this point in the history
…on in backtester
  • Loading branch information
askmike committed Aug 12, 2018
1 parent dccab50 commit 6f49c72
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/features/backtesting.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Backtesting

Gekko supports backtesting strategies over historical data. This means that Gekko will simulate running a strategy in realtime against a live market. Backtesting requires having data locally available already. After a backtest Gekko will provide statistics about the market and the strategy's performance.
Gekko supports backtesting strategies over historical data. A Backtest is a simulation where you simulate running a strategy over a long time (such as the last 30 days) in a matter of seconds. Backtesting requires having market data locally available already. After a backtest Gekko will provide statistics about the market and the strategy's performance.

![screen shot of gekko backtesting](https://cloud.githubusercontent.com/assets/969743/24838718/8c790a86-1d45-11e7-99ae-e7e551cb40cb.png)

**Important things to remember:**

- Just because a strategy performed well in the past, does not mean it will perform well in the future.
- Be careful of overfitting, in other words: don't simply tweak a strategy until you get high profit and assume that will be as profitable when going live. Read more about overfitting in [this article](https://laplaceinsights.com/backtesting-strategies-and-overfitting/).
- The backtest simulation is limited, this is not really a problem on bigger markets (such as BTC/USD) but the differences between backtests and live traders on very low volume markets might be big. Read more about this below in the simplified simulation below.

## Simplified simulation

Gekko backtests using a very limited datasource (only OHCL candles). This means that Gekko estimates trades (and thus profits), which depending on the liquidity and market depth might be estimated very wrong. By configuring the paper trader's fee and slippage you can better mimic trading at the real market.
Simulating trades is done through a module called the paper trader. This module will use market candles together with fee, slippage and spread numbers to estimate trade executions costs. While the default settings work great for most big markets (USD/BTC or BTC/ETH), it becomes a lot less acurate on smaller markets with low volume and liquidity.

In order to backtest with 100% accuracy one would need the exact state of the orderbook (spread and depth) as well as information about orders happening around the time of each advice. With Gekko we made the decision to not store all this information (to simplify importing and storing market data). In voluminous and liquid markets this shouldn't be too much of a problem, but if you are backtesting over a small market (like some altcoins) the estimation will be of poor accuracy.
In live trading the notion of the "price" is more complicated than a single number. Both `spread` and `slippage` will effect your trade prices: these numbers describe your desired trades in relation to what people are currently offering in the market (this is called the orderbook). Read more about this in [this explanation](https://github.com/askmike/gekko/issues/2380#issuecomment-408744682).

If you look at the following backtest result:

Expand Down
7 changes: 7 additions & 0 deletions docs/features/paper_trading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Paper trading

Gekko can automatically run a strategy over the live markets and simulate in realtime what happen if you would have traded on its signals. Paper trading and [backtesting](../backtesting.md) are the two simulation modes that come with Gekko. It's a great way to experiment with strategies without putting your money on the line.

You can start a paper trader by going to live gekkos and clicking on "Start a new live Gekko".

Keep in mind that a paper trader is a simulation, and the accuracy depends on the market you decide to run it on (you'll get pretty accurate results on big markets like USD/BTC). You can read more about the details and limitations of the simulation on [the backtesting page](../backtesting.md#Simplified-simulation).
22 changes: 22 additions & 0 deletions docs/features/trading_bot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Trading bot

Once you have run enough simulations (using [backtesting](./hacktesting.md) and [paper trading](./paper_trading.md)) and you are confident in your strategy you can use Gekko as a trading bot.

Gekko will run your strategy on the live market and automatically trade on your exchange account when trade signals come out of your strategy.

## Preparation

1. Make sure you are fully confident in your strategy! If you want to play around use either the [paper trader](./paper_trader.md) or the [backtester](./backtesting.md). Once you are confident continue with this list.
2. Gekko will need to have API keys to your exchange account that have permissions to view balances and orders and create new orders. Keep in mind:
- Gekko does NOT need withdrawal access, for your safety DO NOT create API keys that can withdraw.
- Make sure you only use the API key for Gekko, and for nothing else.
- If possible try to restrict the API key to the IP address you will run Gekko from (this makes moest sense in server environments)
3. Start your gekko through either the UI or the commandline interface!

## Notes

Gekko will trade on the market you configured that consists of two currencies (for example USD/BTC):
- Try to not trade either of these currencies on the account you use with Gekko. (in the example above: don't trade any USD nor any BTC).
- Try to not withdraw or deposit more of either of these currencies.

While Gekko will handle the situations above, all the profit calculations will be incorrect since your balances are taken into account while calculating profits.

0 comments on commit 6f49c72

Please sign in to comment.