2018-02-04 00:04:26 +00:00
|
|
|
# pragma pylint: disable=too-few-public-methods
|
|
|
|
|
|
|
|
"""
|
2018-04-02 14:42:53 +00:00
|
|
|
bot constants
|
2018-02-04 00:04:26 +00:00
|
|
|
"""
|
2024-05-15 15:09:32 +00:00
|
|
|
|
2024-02-06 19:35:16 +00:00
|
|
|
from typing import Any, Dict, List, Literal, Optional, Tuple
|
2020-05-22 18:56:34 +00:00
|
|
|
|
2024-07-23 16:14:31 +00:00
|
|
|
from freqtrade.enums import CandleType, PriceType
|
2021-12-03 14:20:18 +00:00
|
|
|
|
2020-05-22 18:56:34 +00:00
|
|
|
|
2023-06-16 11:06:21 +00:00
|
|
|
DOCS_LINK = "https://www.freqtrade.io/en/stable"
|
2024-05-12 14:27:46 +00:00
|
|
|
DEFAULT_CONFIG = "config.json"
|
2018-04-02 14:42:53 +00:00
|
|
|
PROCESS_THROTTLE_SECS = 5 # sec
|
|
|
|
HYPEROPT_EPOCH = 100 # epochs
|
|
|
|
RETRY_TIMEOUT = 30 # sec
|
2024-05-12 14:27:46 +00:00
|
|
|
TIMEOUT_UNITS = ["minutes", "seconds"]
|
|
|
|
EXPORT_OPTIONS = ["none", "trades", "signals"]
|
|
|
|
DEFAULT_DB_PROD_URL = "sqlite:///tradesv3.sqlite"
|
|
|
|
DEFAULT_DB_DRYRUN_URL = "sqlite:///tradesv3.dryrun.sqlite"
|
|
|
|
UNLIMITED_STAKE_AMOUNT = "unlimited"
|
2019-02-19 08:45:19 +00:00
|
|
|
DEFAULT_AMOUNT_RESERVE_PERCENT = 0.05
|
2024-05-12 14:27:46 +00:00
|
|
|
REQUIRED_ORDERTIF = ["entry", "exit"]
|
|
|
|
REQUIRED_ORDERTYPES = ["entry", "exit", "stoploss", "stoploss_on_exchange"]
|
|
|
|
PRICING_SIDES = ["ask", "bid", "same", "other"]
|
|
|
|
ORDERTYPE_POSSIBILITIES = ["limit", "market"]
|
|
|
|
_ORDERTIF_POSSIBILITIES = ["GTC", "FOK", "IOC", "PO"]
|
2022-08-27 08:24:56 +00:00
|
|
|
ORDERTIF_POSSIBILITIES = _ORDERTIF_POSSIBILITIES + [t.lower() for t in _ORDERTIF_POSSIBILITIES]
|
2023-02-04 20:08:41 +00:00
|
|
|
STOPLOSS_PRICE_TYPES = [p for p in PriceType]
|
2024-05-12 14:27:46 +00:00
|
|
|
HYPEROPT_LOSS_BUILTIN = [
|
|
|
|
"ShortTradeDurHyperOptLoss",
|
|
|
|
"OnlyProfitHyperOptLoss",
|
|
|
|
"SharpeHyperOptLoss",
|
|
|
|
"SharpeHyperOptLossDaily",
|
|
|
|
"SortinoHyperOptLoss",
|
|
|
|
"SortinoHyperOptLossDaily",
|
|
|
|
"CalmarHyperOptLoss",
|
|
|
|
"MaxDrawDownHyperOptLoss",
|
|
|
|
"MaxDrawDownRelativeHyperOptLoss",
|
|
|
|
"ProfitDrawDownHyperOptLoss",
|
|
|
|
]
|
|
|
|
AVAILABLE_PAIRLISTS = [
|
|
|
|
"StaticPairList",
|
|
|
|
"VolumePairList",
|
|
|
|
"ProducerPairList",
|
|
|
|
"RemotePairList",
|
|
|
|
"MarketCapPairList",
|
|
|
|
"AgeFilter",
|
|
|
|
"FullTradesFilter",
|
|
|
|
"OffsetFilter",
|
|
|
|
"PerformanceFilter",
|
|
|
|
"PrecisionFilter",
|
|
|
|
"PriceFilter",
|
|
|
|
"RangeStabilityFilter",
|
|
|
|
"ShuffleFilter",
|
|
|
|
"SpreadFilter",
|
|
|
|
"VolatilityFilter",
|
|
|
|
]
|
|
|
|
AVAILABLE_PROTECTIONS = ["CooldownPeriod", "LowProfitPairs", "MaxDrawdown", "StoplossGuard"]
|
|
|
|
AVAILABLE_DATAHANDLERS = ["json", "jsongz", "hdf5", "feather", "parquet"]
|
|
|
|
BACKTEST_BREAKDOWNS = ["day", "week", "month"]
|
|
|
|
BACKTEST_CACHE_AGE = ["none", "day", "week", "month"]
|
|
|
|
BACKTEST_CACHE_DEFAULT = "day"
|
2019-12-15 08:22:15 +00:00
|
|
|
DRY_RUN_WALLET = 1000
|
2024-05-12 14:27:46 +00:00
|
|
|
DATETIME_PRINT_FORMAT = "%Y-%m-%d %H:%M:%S"
|
2019-09-26 04:48:46 +00:00
|
|
|
MATH_CLOSE_PREC = 1e-14 # Precision used for float comparisons
|
2024-05-12 14:27:46 +00:00
|
|
|
DEFAULT_DATAFRAME_COLUMNS = ["date", "open", "high", "low", "close", "volume"]
|
2020-03-31 18:12:01 +00:00
|
|
|
# Don't modify sequence of DEFAULT_TRADES_COLUMNS
|
|
|
|
# it has wide consequences for stored trades files
|
2024-05-12 14:27:46 +00:00
|
|
|
DEFAULT_TRADES_COLUMNS = ["timestamp", "id", "type", "side", "price", "amount", "cost"]
|
2024-05-15 12:33:41 +00:00
|
|
|
DEFAULT_ORDERFLOW_COLUMNS = ["level", "bid", "ask", "delta"]
|
2023-08-18 05:25:51 +00:00
|
|
|
TRADES_DTYPES = {
|
2024-05-12 14:27:46 +00:00
|
|
|
"timestamp": "int64",
|
|
|
|
"id": "str",
|
|
|
|
"type": "str",
|
|
|
|
"side": "str",
|
|
|
|
"price": "float64",
|
|
|
|
"amount": "float64",
|
|
|
|
"cost": "float64",
|
2023-08-18 05:25:51 +00:00
|
|
|
}
|
2024-05-12 14:27:46 +00:00
|
|
|
TRADING_MODES = ["spot", "margin", "futures"]
|
|
|
|
MARGIN_MODES = ["cross", "isolated", ""]
|
2018-02-04 00:04:26 +00:00
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
LAST_BT_RESULT_FN = ".last_result.json"
|
|
|
|
FTHYPT_FILEVERSION = "fthypt_fileversion"
|
2020-06-28 07:27:19 +00:00
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
USERPATH_HYPEROPTS = "hyperopts"
|
|
|
|
USERPATH_STRATEGIES = "strategies"
|
|
|
|
USERPATH_NOTEBOOKS = "notebooks"
|
|
|
|
USERPATH_FREQAIMODELS = "freqaimodels"
|
2019-11-16 21:00:50 +00:00
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
TELEGRAM_SETTING_OPTIONS = ["on", "off", "silent"]
|
|
|
|
WEBHOOK_FORMAT_OPTIONS = ["form", "json", "raw"]
|
2022-12-14 18:56:54 +00:00
|
|
|
FULL_DATAFRAME_THRESHOLD = 100
|
2023-04-12 04:59:05 +00:00
|
|
|
CUSTOM_TAG_MAX_LENGTH = 255
|
2024-05-12 14:27:46 +00:00
|
|
|
DL_DATA_TIMEFRAMES = ["1m", "5m"]
|
2021-11-29 07:17:59 +00:00
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
ENV_VAR_PREFIX = "FREQTRADE__"
|
2020-09-19 17:38:33 +00:00
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
CANCELED_EXCHANGE_STATES = ("cancelled", "canceled", "expired")
|
|
|
|
NON_OPEN_EXCHANGE_STATES = CANCELED_EXCHANGE_STATES + ("closed",)
|
2021-08-27 17:54:53 +00:00
|
|
|
|
2021-02-12 19:32:41 +00:00
|
|
|
# Define decimals per coin for outputs
|
|
|
|
# Only used for outputs.
|
|
|
|
DECIMAL_PER_COIN_FALLBACK = 3 # Should be low to avoid listing all possible FIAT's
|
|
|
|
DECIMALS_PER_COIN = {
|
2024-05-12 14:27:46 +00:00
|
|
|
"BTC": 8,
|
|
|
|
"ETH": 5,
|
2021-02-12 19:32:41 +00:00
|
|
|
}
|
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
DUST_PER_COIN = {"BTC": 0.0001, "ETH": 0.01}
|
2021-02-28 08:03:27 +00:00
|
|
|
|
2021-06-25 13:45:49 +00:00
|
|
|
# Source files with destination directories within user-directory
|
2019-11-01 12:28:35 +00:00
|
|
|
USER_DATA_FILES = {
|
2024-05-12 14:27:46 +00:00
|
|
|
"sample_strategy.py": USERPATH_STRATEGIES,
|
|
|
|
"sample_hyperopt_loss.py": USERPATH_HYPEROPTS,
|
|
|
|
"strategy_analysis_example.ipynb": USERPATH_NOTEBOOKS,
|
2019-11-01 12:28:35 +00:00
|
|
|
}
|
|
|
|
|
2018-06-03 11:47:36 +00:00
|
|
|
SUPPORTED_FIAT = [
|
2024-05-12 14:27:46 +00:00
|
|
|
"AUD",
|
|
|
|
"BRL",
|
|
|
|
"CAD",
|
|
|
|
"CHF",
|
|
|
|
"CLP",
|
|
|
|
"CNY",
|
|
|
|
"CZK",
|
|
|
|
"DKK",
|
|
|
|
"EUR",
|
|
|
|
"GBP",
|
|
|
|
"HKD",
|
|
|
|
"HUF",
|
|
|
|
"IDR",
|
|
|
|
"ILS",
|
|
|
|
"INR",
|
|
|
|
"JPY",
|
|
|
|
"KRW",
|
|
|
|
"MXN",
|
|
|
|
"MYR",
|
|
|
|
"NOK",
|
|
|
|
"NZD",
|
|
|
|
"PHP",
|
|
|
|
"PKR",
|
|
|
|
"PLN",
|
|
|
|
"RUB",
|
|
|
|
"UAH",
|
|
|
|
"SEK",
|
|
|
|
"SGD",
|
|
|
|
"THB",
|
|
|
|
"TRY",
|
|
|
|
"TWD",
|
|
|
|
"ZAR",
|
|
|
|
"USD",
|
|
|
|
"BTC",
|
|
|
|
"ETH",
|
|
|
|
"XRP",
|
|
|
|
"LTC",
|
|
|
|
"BCH",
|
|
|
|
"BNB",
|
2024-05-22 18:30:35 +00:00
|
|
|
"", # Allow empty field in config.
|
2018-10-02 10:42:59 +00:00
|
|
|
]
|
2018-02-04 00:04:26 +00:00
|
|
|
|
2019-08-16 12:56:38 +00:00
|
|
|
MINIMAL_CONFIG = {
|
2022-04-08 14:04:54 +00:00
|
|
|
"stake_currency": "",
|
|
|
|
"dry_run": True,
|
|
|
|
"exchange": {
|
|
|
|
"name": "",
|
|
|
|
"key": "",
|
|
|
|
"secret": "",
|
|
|
|
"pair_whitelist": [],
|
2024-05-12 14:27:46 +00:00
|
|
|
"ccxt_async_config": {},
|
|
|
|
},
|
2019-08-16 12:56:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 22:16:52 +00:00
|
|
|
|
|
|
|
CANCEL_REASON = {
|
|
|
|
"TIMEOUT": "cancelled due to timeout",
|
2020-08-26 20:17:43 +00:00
|
|
|
"PARTIALLY_FILLED_KEEP_OPEN": "partially filled - keeping order open",
|
|
|
|
"PARTIALLY_FILLED": "partially filled",
|
|
|
|
"FULLY_CANCELLED": "fully cancelled",
|
2020-05-16 18:28:54 +00:00
|
|
|
"ALL_CANCELLED": "cancelled (all unfilled and partially filled open orders cancelled)",
|
2020-04-24 22:16:52 +00:00
|
|
|
"CANCELLED_ON_EXCHANGE": "cancelled on exchange",
|
2022-04-04 14:59:27 +00:00
|
|
|
"FORCE_EXIT": "forcesold",
|
2022-04-16 11:44:41 +00:00
|
|
|
"REPLACE": "cancelled to be replaced by new limit order",
|
2023-09-02 14:49:12 +00:00
|
|
|
"REPLACE_FAILED": "failed to replace order, deleting Trade",
|
2024-05-12 14:27:46 +00:00
|
|
|
"USER_CANCEL": "user requested order cancel",
|
2020-04-24 22:16:52 +00:00
|
|
|
}
|
2020-05-22 18:56:34 +00:00
|
|
|
|
|
|
|
# List of pairs with their timeframes
|
2021-12-03 14:20:18 +00:00
|
|
|
PairWithTimeframe = Tuple[str, str, CandleType]
|
2020-06-12 12:12:33 +00:00
|
|
|
ListPairsWithTimeframes = List[PairWithTimeframe]
|
2020-11-21 09:52:15 +00:00
|
|
|
|
|
|
|
# Type for trades list
|
|
|
|
TradeList = List[List]
|
2023-04-26 13:14:45 +00:00
|
|
|
# ticks, pair, timeframe, CandleType
|
|
|
|
TickWithTimeframe = Tuple[str, str, CandleType, Optional[int], Optional[int]]
|
|
|
|
ListTicksWithTimeframes = List[TickWithTimeframe]
|
2022-04-04 14:51:57 +00:00
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
LongShort = Literal["long", "short"]
|
|
|
|
EntryExit = Literal["entry", "exit"]
|
|
|
|
BuySell = Literal["buy", "sell"]
|
|
|
|
MakerTaker = Literal["maker", "taker"]
|
|
|
|
BidAsk = Literal["bid", "ask"]
|
|
|
|
OBLiteral = Literal["asks", "bids"]
|
2022-09-18 11:20:36 +00:00
|
|
|
|
|
|
|
Config = Dict[str, Any]
|
2023-05-13 13:38:40 +00:00
|
|
|
# Exchange part of the configuration.
|
|
|
|
ExchangeConfig = Dict[str, Any]
|
2023-01-15 10:44:10 +00:00
|
|
|
IntOrInf = float
|
2023-09-21 04:19:36 +00:00
|
|
|
|
|
|
|
|
2024-05-12 14:27:46 +00:00
|
|
|
EntryExecuteMode = Literal["initial", "pos_adjust", "replace"]
|