diff --git a/docs/includes/strategy-imports.md b/docs/includes/strategy-imports.md new file mode 100644 index 000000000..818af3a52 --- /dev/null +++ b/docs/includes/strategy-imports.md @@ -0,0 +1,41 @@ +## Imports necessary for a strategy + +When creating a strategy, you will need to import the necessary modules and classes. The following imports are required for a strategy: + +By default, we recommend the following imports as a base line for your strategy: +This will cover all imports necessary for freqtrade functions to work. +Obviously you can add more imports as needed for your strategy. + +``` python +# flake8: noqa: F401 +# isort: skip_file +# --- Do not remove these imports --- +import numpy as np +import pandas as pd +from datetime import datetime +from pandas import DataFrame +from typing import Optional, Union + +from freqtrade.strategy import ( + IStrategy, + Trade, + Order, + PairLocks, + informative, # @informative decorator + # Hyperopt Parameters + BooleanParameter, + CategoricalParameter, + DecimalParameter, + IntParameter, + RealParameter, + # Strategy helper functions + merge_informative_pair, + stoploss_from_absolute, + stoploss_from_open, +) + +# -------------------------------- +# Add your lib to import here +import talib.abstract as ta +import freqtrade.vendor.qtpylib.indicators as qtpylib +``` diff --git a/docs/strategy-callbacks.md b/docs/strategy-callbacks.md index 74eef53c1..a090749cc 100644 --- a/docs/strategy-callbacks.md +++ b/docs/strategy-callbacks.md @@ -24,6 +24,8 @@ Currently available callbacks: !!! Tip "Callback calling sequence" You can find the callback calling sequence in [bot-basics](bot-basics.md#bot-execution-logic) +--8<-- "includes/strategy-imports.md" + ## Bot start A simple callback which is called once when the strategy is loaded. diff --git a/docs/strategy-customization.md b/docs/strategy-customization.md index 98d7ae9d2..a8b9dcb4c 100644 --- a/docs/strategy-customization.md +++ b/docs/strategy-customization.md @@ -407,6 +407,8 @@ Currently this is `pair`, which can be accessed using `metadata['pair']` - and w The Metadata-dict should not be modified and does not persist information across multiple calls. Instead, have a look at the [Storing information](strategy-advanced.md#storing-information-persistent) section. +--8<-- "includes/strategy-imports.md" + ## Strategy file loading By default, freqtrade will attempt to load strategies from all `.py` files within `user_data/strategies`.