Merge pull request #873 from freqtrade/feature/strat_repo_ref

add reference to strategy repository
This commit is contained in:
Janne Sinivirta 2018-06-08 12:53:40 +03:00 committed by GitHub
commit 867faf1c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,10 @@
# Bot Optimization # Bot Optimization
This page explains where to customize your strategies, and add new This page explains where to customize your strategies, and add new
indicators. indicators.
## Table of Contents ## Table of Contents
- [Install a custom strategy file](#install-a-custom-strategy-file) - [Install a custom strategy file](#install-a-custom-strategy-file)
- [Customize your strategy](#change-your-strategy) - [Customize your strategy](#change-your-strategy)
- [Add more Indicator](#add-more-indicator) - [Add more Indicator](#add-more-indicator)
@ -11,10 +13,12 @@ indicators.
Since the version `0.16.0` the bot allows using custom strategy file. Since the version `0.16.0` the bot allows using custom strategy file.
## Install a custom strategy file ## Install a custom strategy file
This is very simple. Copy paste your strategy file into the folder This is very simple. Copy paste your strategy file into the folder
`user_data/strategies`. `user_data/strategies`.
Let assume you have a class called `AwesomeStrategy` in the file `awesome-strategy.py`: Let assume you have a class called `AwesomeStrategy` in the file `awesome-strategy.py`:
1. Move your file into `user_data/strategies` (you should have `user_data/strategies/awesome-strategy.py` 1. Move your file into `user_data/strategies` (you should have `user_data/strategies/awesome-strategy.py`
2. Start the bot with the param `--strategy AwesomeStrategy` (the parameter is the class name) 2. Start the bot with the param `--strategy AwesomeStrategy` (the parameter is the class name)
@ -23,12 +27,14 @@ python3 ./freqtrade/main.py --strategy AwesomeStrategy
``` ```
## Change your strategy ## Change your strategy
The bot includes a default strategy file. However, we recommend you to The bot includes a default strategy file. However, we recommend you to
use your own file to not have to lose your parameters every time the default use your own file to not have to lose your parameters every time the default
strategy file will be updated on Github. Put your custom strategy file strategy file will be updated on Github. Put your custom strategy file
into the folder `user_data/strategies`. into the folder `user_data/strategies`.
A strategy file contains all the information needed to build a good strategy: A strategy file contains all the information needed to build a good strategy:
- Buy strategy rules - Buy strategy rules
- Sell strategy rules - Sell strategy rules
- Minimal ROI recommended - Minimal ROI recommended
@ -38,11 +44,12 @@ A strategy file contains all the information needed to build a good strategy:
The bot also include a sample strategy called `TestStrategy` you can update: `user_data/strategies/test_strategy.py`. The bot also include a sample strategy called `TestStrategy` you can update: `user_data/strategies/test_strategy.py`.
You can test it with the parameter: `--strategy TestStrategy` You can test it with the parameter: `--strategy TestStrategy`
```bash ``` bash
python3 ./freqtrade/main.py --strategy AwesomeStrategy python3 ./freqtrade/main.py --strategy AwesomeStrategy
``` ```
### Specify custom strategy location ### Specify custom strategy location
If you want to use a strategy from a different folder you can pass `--strategy-path` If you want to use a strategy from a different folder you can pass `--strategy-path`
```bash ```bash
@ -53,10 +60,12 @@ python3 ./freqtrade/main.py --strategy AwesomeStrategy --strategy-path /some/fol
file as reference.** file as reference.**
### Buy strategy ### Buy strategy
Edit the method `populate_buy_trend()` into your strategy file to Edit the method `populate_buy_trend()` into your strategy file to
update your buy strategy. update your buy strategy.
Sample from `user_data/strategies/test_strategy.py`: Sample from `user_data/strategies/test_strategy.py`:
```python ```python
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame: def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
""" """
@ -76,10 +85,11 @@ def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
``` ```
### Sell strategy ### Sell strategy
Edit the method `populate_sell_trend()` into your strategy file to
update your sell strategy. Edit the method `populate_sell_trend()` into your strategy file to update your sell strategy.
Sample from `user_data/strategies/test_strategy.py`: Sample from `user_data/strategies/test_strategy.py`:
```python ```python
def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame: def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame:
""" """
@ -98,11 +108,13 @@ def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame:
``` ```
## Add more Indicator ## Add more Indicator
As you have seen, buy and sell strategies need indicators. You can add As you have seen, buy and sell strategies need indicators. You can add
more indicators by extending the list contained in more indicators by extending the list contained in
the method `populate_indicators()` from your strategy file. the method `populate_indicators()` from your strategy file.
Sample: Sample:
```python ```python
def populate_indicators(dataframe: DataFrame) -> DataFrame: def populate_indicators(dataframe: DataFrame) -> DataFrame:
""" """
@ -137,16 +149,25 @@ def populate_indicators(dataframe: DataFrame) -> DataFrame:
return dataframe return dataframe
``` ```
**Want more indicators example?** ### Want more indicator examples
Look into the [user_data/strategies/test_strategy.py](https://github.com/freqtrade/freqtrade/blob/develop/user_data/strategies/test_strategy.py). Look into the [user_data/strategies/test_strategy.py](https://github.com/freqtrade/freqtrade/blob/develop/user_data/strategies/test_strategy.py).
Then uncomment indicators you need. Then uncomment indicators you need.
### Where is the default strategy? ### Where is the default strategy?
The default buy strategy is located in the file The default buy strategy is located in the file
[freqtrade/default_strategy.py](https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/strategy/default_strategy.py). [freqtrade/default_strategy.py](https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/strategy/default_strategy.py).
### Further strategy ideas
To get additional Ideas for strategies, head over to our [strategy repository](https://github.com/freqtrade/freqtrade-strategies). Feel free to use them as they are - but results will depend on the current market situation, pairs used etc. - therefore please backtest the strategy for your exchange/desired pairs first, evaluate carefully, use at your own risk.
Feel free to use any of them as inspiration for your own strategies.
We're happy to accept Pull Requests containing new Strategies to that repo.
We also got a *strategy-sharing* channel in our [Slack community](https://join.slack.com/t/highfrequencybot/shared_invite/enQtMjQ5NTM0OTYzMzY3LWMxYzE3M2MxNDdjMGM3ZTYwNzFjMGIwZGRjNTc3ZGU3MGE3NzdmZGMwNmU3NDM5ZTNmM2Y3NjRiNzk4NmM4OGE) which is a great place to get and/or share ideas.
## Next step ## Next step
Now you have a perfect strategy you probably want to backtesting it.
Now you have a perfect strategy you probably want to backtest it.
Your next step is to learn [How to use the Backtesting](https://github.com/freqtrade/freqtrade/blob/develop/docs/backtesting.md). Your next step is to learn [How to use the Backtesting](https://github.com/freqtrade/freqtrade/blob/develop/docs/backtesting.md).