docs: Add section explaining strategy imports
This commit is contained in:
@@ -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
|
||||||
|
```
|
||||||
@@ -24,6 +24,8 @@ Currently available callbacks:
|
|||||||
!!! Tip "Callback calling sequence"
|
!!! Tip "Callback calling sequence"
|
||||||
You can find the callback calling sequence in [bot-basics](bot-basics.md#bot-execution-logic)
|
You can find the callback calling sequence in [bot-basics](bot-basics.md#bot-execution-logic)
|
||||||
|
|
||||||
|
--8<-- "includes/strategy-imports.md"
|
||||||
|
|
||||||
## Bot start
|
## Bot start
|
||||||
|
|
||||||
A simple callback which is called once when the strategy is loaded.
|
A simple callback which is called once when the strategy is loaded.
|
||||||
|
|||||||
@@ -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.
|
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.
|
Instead, have a look at the [Storing information](strategy-advanced.md#storing-information-persistent) section.
|
||||||
|
|
||||||
|
--8<-- "includes/strategy-imports.md"
|
||||||
|
|
||||||
## Strategy file loading
|
## Strategy file loading
|
||||||
|
|
||||||
By default, freqtrade will attempt to load strategies from all `.py` files within `user_data/strategies`.
|
By default, freqtrade will attempt to load strategies from all `.py` files within `user_data/strategies`.
|
||||||
|
|||||||
Reference in New Issue
Block a user