Update documentation

This commit is contained in:
Gerald Lonlas
2018-01-17 23:06:37 -08:00
parent be75522507
commit a5853681e3
5 changed files with 297 additions and 71 deletions

View File

@@ -3,21 +3,55 @@ This page explains where to customize your strategies, and add new
indicators.
## Table of Contents
- [Change your strategy](#change-your-strategy)
- [Install a custom strategy file](#install-a-custom-strategy-file)
- [Customize your strategy](#change-your-strategy)
- [Add more Indicator](#add-more-indicator)
- [Where is the default strategy](#where-is-the-default-strategy)
Since the version `0.16.0` the bot allows using custom strategy file.
## Install a custom strategy file
This is very simple. Copy paste your strategy file into the folder
`user_data/strategies`.
Let guess you have a strategy file `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 awesome-strategy` (the parameter is the name of the file without '.py')
```bash
python3 ./freqtrade/main.py --strategy awesome_strategy
```
## Change your strategy
The bot is using buy and sell strategies to buy and sell your trades.
Both are customizable.
The bot includes a default strategy file. However, we recommend you to
use your own file to not have to lose your parameters everytime the default
strategy file will be updated on Github. Put your custom strategy file
into the folder `user_data/strategies`.
### Buy strategy
The default buy strategy is located in the file
[freqtrade/analyze.py](https://github.com/gcarq/freqtrade/blob/develop/freqtrade/analyze.py#L73-L92).
Edit the function `populate_buy_trend()` to update your buy strategy.
A strategy file contains all the information needed to build a good strategy:
- Buy strategy rules
- Sell strategy rules
- Minimal ROI recommended
- Stoploss recommended
- Hyperopt parameter
Sample:
The bot also include a sample strategy you can update: `user_data/strategies/test_strategy.py`.
You can test it with the parameter: `--strategy test_strategy`
```bash
python3 ./freqtrade/main.py --strategy awesome_strategy
```
**For the following section we will use the [user_data/strategies/test_strategy.py](https://github.com/gcarq/freqtrade/blob/develop/user_data/strategies/test_strategy.py)
file as reference.**
### Buy strategy
Edit the method `populate_buy_trend()` into your strategy file to
update your buy strategy.
Sample from `user_data/strategies/test_strategy.py`:
```python
def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
"""
Based on TA indicators, populates the buy signal for the given dataframe
:param dataframe: DataFrame
@@ -25,14 +59,9 @@ def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
"""
dataframe.loc[
(
(dataframe['rsi'] < 35) &
(dataframe['fastd'] < 35) &
(dataframe['adx'] > 30) &
(dataframe['plus_di'] > 0.5)
) |
(
(dataframe['adx'] > 65) &
(dataframe['plus_di'] > 0.5)
(dataframe['tema'] <= dataframe['blower']) &
(dataframe['tema'] > dataframe['tema'].shift(1))
),
'buy'] = 1
@@ -40,41 +69,31 @@ def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
```
### Sell strategy
The default buy strategy is located in the file
[freqtrade/analyze.py](https://github.com/gcarq/freqtrade/blob/develop/freqtrade/analyze.py#L95-L115)
Edit the function `populate_sell_trend()` to update your buy strategy.
Edit the method `populate_sell_trend()` into your strategy file to
update your sell strategy.
Sample:
Sample from `user_data/strategies/test_strategy.py`:
```python
def populate_sell_trend(dataframe: DataFrame) -> DataFrame:
def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame:
"""
Based on TA indicators, populates the sell signal for the given dataframe
:param dataframe: DataFrame
:return: DataFrame with buy column
"""
dataframe.loc[
(
(
(crossed_above(dataframe['rsi'], 70)) |
(crossed_above(dataframe['fastd'], 70))
) &
(dataframe['adx'] > 10) &
(dataframe['minus_di'] > 0)
) |
(
(dataframe['adx'] > 70) &
(dataframe['minus_di'] > 0.5)
(dataframe['tema'] > dataframe['blower']) &
(dataframe['tema'] < dataframe['tema'].shift(1))
),
'sell'] = 1
return dataframe
```
## Add more Indicator
As you have seen, buy and sell strategies need indicators. You can see
the indicators in the file
[freqtrade/analyze.py](https://github.com/gcarq/freqtrade/blob/develop/freqtrade/analyze.py#L95-L115).
Of course you can add more indicators by extending the list contained in
the function `populate_indicators()`.
As you have seen, buy and sell strategies need indicators. You can add
more indicators by extending the list contained in
the method `populate_indicators()` from your strategy file.
Sample:
```python
@@ -111,6 +130,15 @@ def populate_indicators(dataframe: DataFrame) -> DataFrame:
return dataframe
```
**Want more indicators example?**
Look into the [user_data/strategies/test_strategy.py](https://github.com/gcarq/freqtrade/blob/develop/user_data/strategies/test_strategy.py).
Then uncomment indicateur you need.
### Where is the default strategy?
The default buy strategy is located in the file
[freqtrade/default_strategy.py](https://github.com/gcarq/freqtrade/blob/develop/freqtrade/strategy/default_strategy.py).
## Next step
Now you have a perfect strategy you probably want to backtesting it.