freqtrade_origin/freqtrade/constants.py

214 lines
5.7 KiB
Python
Raw Normal View History

# pragma pylint: disable=too-few-public-methods
"""
bot constants
"""
2024-05-12 14:27:46 +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
from freqtrade.enums import CandleType, PriceType
2020-05-22 18:56:34 +00:00
DOCS_LINK = "https://www.freqtrade.io/en/stable"
2024-05-12 14:27:46 +00:00
DEFAULT_CONFIG = "config.json"
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"
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"]
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",
"PercentChangePairList",
2024-05-12 14:27:46 +00:00
"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"
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"]
# 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"]
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", ""]
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"
2024-05-12 14:27:46 +00:00
TELEGRAM_SETTING_OPTIONS = ["on", "off", "silent"]
WEBHOOK_FORMAT_OPTIONS = ["form", "json", "raw"]
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"]
2024-05-12 14:27:46 +00:00
ENV_VAR_PREFIX = "FREQTRADE__"
2024-05-12 14:27:46 +00:00
CANCELED_EXCHANGE_STATES = ("cancelled", "canceled", "expired")
NON_OPEN_EXCHANGE_STATES = CANCELED_EXCHANGE_STATES + ("closed",)
# 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,
}
2024-05-12 14:27:46 +00:00
DUST_PER_COIN = {"BTC": 0.0001, "ETH": 0.01}
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",
"", # Allow empty field in config.
]
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
}
CANCEL_REASON = {
"TIMEOUT": "cancelled due to timeout",
"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)",
"CANCELLED_ON_EXCHANGE": "cancelled on exchange",
2022-04-04 14:59:27 +00:00
"FORCE_EXIT": "forcesold",
"REPLACE": "cancelled to be replaced by new limit order",
"REPLACE_FAILED": "failed to replace order, deleting Trade",
2024-05-12 14:27:46 +00:00
"USER_CANCEL": "user requested order cancel",
}
2020-05-22 18:56:34 +00:00
# List of pairs with their timeframes
PairWithTimeframe = Tuple[str, str, CandleType]
2020-06-12 12:12:33 +00:00
ListPairsWithTimeframes = List[PairWithTimeframe]
# Type for trades list
TradeList = List[List]
# ticks, pair, timeframe, CandleType
TickWithTimeframe = Tuple[str, str, CandleType, Optional[int], Optional[int]]
ListTicksWithTimeframes = List[TickWithTimeframe]
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]
IntOrInf = float
2023-09-21 04:19:36 +00:00
2024-05-12 14:27:46 +00:00
EntryExecuteMode = Literal["initial", "pos_adjust", "replace"]