-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow custom strategy files #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, one comment about the Strategy class wich seems to be implemented as a singleton. We could for example have a strategy to handle long uptrend or short uptrend, long downtrend or short downtrend to maximize the number of scenario we handle.
The bot ask each strategy to populates its indicators and select the first strategy who would buy and use it untill the trade is closed.
The bot would then ask the selected strategy wether to sell the position or not.
So each pair could have a different strategy according to a given scenario.
I think it could be possible, but it will add more changes in the Bot Core. This PR will not be easy to pass and convey everyone, so I will try to not add more logic for now. It could be part of another PR. |
cce96f9
to
6a4800c
Compare
docs/bot-optimization.md
Outdated
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`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"assume" instead of "guess"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for fixing my English.
This is fixed.
docs/bot-optimization.md
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"indicator"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My French accent ;)
Fixed as well.
d2027ac
to
13efe4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR causes running unit tests to take 93-112 seconds instead of 25-31seconds on my laptop. So over 3x increase. That is way too much.
Thank you @vertti, I this a great input to improve out bot. To see the difference and understand what makes this PR test slower, I have run the same test command in Note: This branch is up-to-date from yesterday (Last rebase from develop ~10h) From my laptop:
So I dived deep to see tests is slower in both branches: longest calls from
|
13efe4d
to
ef9f4ca
Compare
Seems this was more about network calls than changes in the PR
…fined in populate_buy_trend()
This commit is major core upgrade and introduce breaking change.
c93a570
to
fcb29c6
Compare
I have added the support of custom strategies into plot_dataframe.py and plot_profit.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running python freqtrade/main.py --strategy test_strategy hyperopt -e 3
throws a lot of errors because the guards use indicators that are commented out.
I'm merging this now, despite the hyperopt mistake in test_strategy. I think we should refactor the hyperopt part out from the strategy files but that can be done in following PR. |
Breaking change
This PR change where the indicators, buy strategy, sell strategy, hyperopt space, and hyperopt guards are defined. This PR regroup all these information into the same "Strategy" class.
Look into /user_data/strategies/test_strategy.py to move your bot strategies.
Summary
This PR is a major change that allows users to use custom strategy files.
With this PR, we will not update Core files of the bot to update strategies and hyperopt configuration.
Benefits
analyze.py
, andhyperopt.py
s files:
/user_data/` (can be used to store: config file, backtesting data sets, strategies, ...).hyperopt_conf.py
andhyperopt_trials.pickle
were moved into/user_data/
How to use it?
User can add customized strategy into
user_data/strategies
and ask the bot to use it.The bot is smart enough to find where can be the strategy file. If the strategy file is not found it will fallback to the default strategy included with the bot (located into
freqtrade/strategy/default_strategy.py
). All details are in the documentation included with this PR.Solve the issue: None
Quick changelog
/user_data/
and/user_data/strategies
to put custom strategiesfreqtrade/strategy/default_strategy.py
user_data/strategies/test_strategy.py
hyperopt_conf.py
andhyperopt_trials.pickle
to/user_data/
Tests
Dry-run, backtesting, and hyperopt, have been tested for a week. Any feedbacks are welcome.