2024-08-17 14:24:50 +00:00
|
|
|
## 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
|
2024-08-18 06:38:59 +00:00
|
|
|
from datetime import datetime, timedelta, timezone
|
2024-08-17 14:24:50 +00:00
|
|
|
from pandas import DataFrame
|
2024-08-18 06:38:59 +00:00
|
|
|
from typing import Dict, Optional, Union, Tuple
|
2024-08-17 14:24:50 +00:00
|
|
|
|
|
|
|
from freqtrade.strategy import (
|
|
|
|
IStrategy,
|
|
|
|
Trade,
|
|
|
|
Order,
|
|
|
|
PairLocks,
|
|
|
|
informative, # @informative decorator
|
|
|
|
# Hyperopt Parameters
|
|
|
|
BooleanParameter,
|
|
|
|
CategoricalParameter,
|
|
|
|
DecimalParameter,
|
|
|
|
IntParameter,
|
|
|
|
RealParameter,
|
2024-08-18 06:38:59 +00:00
|
|
|
# timeframe helpers
|
|
|
|
timeframe_to_minutes,
|
|
|
|
timeframe_to_next_date,
|
|
|
|
timeframe_to_prev_date,
|
2024-08-17 14:24:50 +00:00
|
|
|
# Strategy helper functions
|
|
|
|
merge_informative_pair,
|
|
|
|
stoploss_from_absolute,
|
|
|
|
stoploss_from_open,
|
|
|
|
)
|
|
|
|
|
|
|
|
# --------------------------------
|
|
|
|
# Add your lib to import here
|
|
|
|
import talib.abstract as ta
|
2024-08-17 14:28:56 +00:00
|
|
|
from technical import qtpylib
|
2024-08-17 14:24:50 +00:00
|
|
|
```
|