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
|
|
|
"""
|
2022-04-04 14:51:57 +00:00
|
|
|
from typing import List, Literal, Tuple
|
2020-05-22 18:56:34 +00:00
|
|
|
|
2021-12-03 14:20:18 +00:00
|
|
|
from freqtrade.enums import CandleType
|
|
|
|
|
2020-05-22 18:56:34 +00:00
|
|
|
|
2019-02-19 12:14:47 +00:00
|
|
|
DEFAULT_CONFIG = 'config.json'
|
2019-06-22 20:51:29 +00:00
|
|
|
DEFAULT_EXCHANGE = 'bittrex'
|
2018-04-02 14:42:53 +00:00
|
|
|
PROCESS_THROTTLE_SECS = 5 # sec
|
|
|
|
HYPEROPT_EPOCH = 100 # epochs
|
|
|
|
RETRY_TIMEOUT = 30 # sec
|
2021-05-18 23:30:36 +00:00
|
|
|
TIMEOUT_UNITS = ['minutes', 'seconds']
|
2022-04-22 17:46:12 +00:00
|
|
|
EXPORT_OPTIONS = ['none', 'trades', 'signals']
|
2018-06-07 15:29:43 +00:00
|
|
|
DEFAULT_DB_PROD_URL = 'sqlite:///tradesv3.sqlite'
|
2019-12-22 09:16:16 +00:00
|
|
|
DEFAULT_DB_DRYRUN_URL = 'sqlite:///tradesv3.dryrun.sqlite'
|
2018-05-25 14:04:08 +00:00
|
|
|
UNLIMITED_STAKE_AMOUNT = 'unlimited'
|
2019-02-19 08:45:19 +00:00
|
|
|
DEFAULT_AMOUNT_RESERVE_PERCENT = 0.05
|
2022-03-07 06:09:01 +00:00
|
|
|
REQUIRED_ORDERTIF = ['entry', 'exit']
|
2022-03-07 19:32:16 +00:00
|
|
|
REQUIRED_ORDERTYPES = ['entry', 'exit', 'stoploss', 'stoploss_on_exchange']
|
2022-03-27 16:03:49 +00:00
|
|
|
PRICING_SIDES = ['ask', 'bid', 'same', 'other']
|
2018-11-17 12:05:35 +00:00
|
|
|
ORDERTYPE_POSSIBILITIES = ['limit', 'market']
|
2018-12-04 19:36:44 +00:00
|
|
|
ORDERTIF_POSSIBILITIES = ['gtc', 'fok', 'ioc']
|
2020-10-28 06:58:55 +00:00
|
|
|
HYPEROPT_LOSS_BUILTIN = ['ShortTradeDurHyperOptLoss', 'OnlyProfitHyperOptLoss',
|
|
|
|
'SharpeHyperOptLoss', 'SharpeHyperOptLossDaily',
|
2021-10-07 05:12:45 +00:00
|
|
|
'SortinoHyperOptLoss', 'SortinoHyperOptLossDaily',
|
2021-10-29 04:42:17 +00:00
|
|
|
'CalmarHyperOptLoss',
|
2022-04-10 15:53:47 +00:00
|
|
|
'MaxDrawDownHyperOptLoss', 'MaxDrawDownRelativeHyperOptLoss',
|
|
|
|
'ProfitDrawDownHyperOptLoss']
|
2020-02-03 06:44:17 +00:00
|
|
|
AVAILABLE_PAIRLISTS = ['StaticPairList', 'VolumePairList',
|
2021-07-05 10:50:56 +00:00
|
|
|
'AgeFilter', 'OffsetFilter', 'PerformanceFilter',
|
|
|
|
'PrecisionFilter', 'PriceFilter', 'RangeStabilityFilter',
|
|
|
|
'ShuffleFilter', 'SpreadFilter', 'VolatilityFilter']
|
2020-11-30 07:05:48 +00:00
|
|
|
AVAILABLE_PROTECTIONS = ['CooldownPeriod', 'LowProfitPairs', 'MaxDrawdown', 'StoplossGuard']
|
2020-07-12 18:06:59 +00:00
|
|
|
AVAILABLE_DATAHANDLERS = ['json', 'jsongz', 'hdf5']
|
2021-10-21 04:58:40 +00:00
|
|
|
BACKTEST_BREAKDOWNS = ['day', 'week', 'month']
|
2022-01-18 09:00:51 +00:00
|
|
|
BACKTEST_CACHE_AGE = ['none', 'day', 'week', 'month']
|
|
|
|
BACKTEST_CACHE_DEFAULT = 'day'
|
2019-12-15 08:22:15 +00:00
|
|
|
DRY_RUN_WALLET = 1000
|
2020-06-09 06:07:34 +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
|
2019-12-26 18:52:08 +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
|
|
|
|
DEFAULT_TRADES_COLUMNS = ['timestamp', 'id', 'type', 'side', 'price', 'amount', 'cost']
|
2021-10-18 07:15:44 +00:00
|
|
|
TRADING_MODES = ['spot', 'margin', 'futures']
|
2022-02-02 19:18:42 +00:00
|
|
|
MARGIN_MODES = ['cross', 'isolated', '']
|
2018-02-04 00:04:26 +00:00
|
|
|
|
2020-06-28 07:27:19 +00:00
|
|
|
LAST_BT_RESULT_FN = '.last_result.json'
|
2021-06-15 18:27:46 +00:00
|
|
|
FTHYPT_FILEVERSION = 'fthypt_fileversion'
|
2020-06-28 07:27:19 +00:00
|
|
|
|
2019-11-16 21:00:50 +00:00
|
|
|
USERPATH_HYPEROPTS = 'hyperopts'
|
2020-02-02 15:12:23 +00:00
|
|
|
USERPATH_STRATEGIES = 'strategies'
|
2020-02-02 15:07:21 +00:00
|
|
|
USERPATH_NOTEBOOKS = 'notebooks'
|
2022-05-06 11:35:01 +00:00
|
|
|
USERPATH_FREQAIMODELS = 'freqaimodels'
|
2019-11-16 21:00:50 +00:00
|
|
|
|
2020-09-19 17:38:33 +00:00
|
|
|
TELEGRAM_SETTING_OPTIONS = ['on', 'off', 'silent']
|
2021-11-29 07:17:59 +00:00
|
|
|
WEBHOOK_FORMAT_OPTIONS = ['form', 'json', 'raw']
|
|
|
|
|
2021-07-31 15:43:10 +00:00
|
|
|
ENV_VAR_PREFIX = 'FREQTRADE__'
|
2020-09-19 17:38:33 +00:00
|
|
|
|
2021-08-27 17:54:53 +00:00
|
|
|
NON_OPEN_EXCHANGE_STATES = ('cancelled', 'canceled', 'closed', 'expired')
|
|
|
|
|
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 = {
|
|
|
|
'BTC': 8,
|
|
|
|
'ETH': 5,
|
|
|
|
}
|
|
|
|
|
2021-02-28 08:03:27 +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 = {
|
2020-02-02 15:12:23 +00:00
|
|
|
'sample_strategy.py': USERPATH_STRATEGIES,
|
2019-11-16 21:00:50 +00:00
|
|
|
'sample_hyperopt_loss.py': USERPATH_HYPEROPTS,
|
2020-02-02 15:07:21 +00:00
|
|
|
'strategy_analysis_example.ipynb': USERPATH_NOTEBOOKS,
|
2019-11-01 12:28:35 +00:00
|
|
|
}
|
|
|
|
|
2018-06-03 11:47:36 +00:00
|
|
|
SUPPORTED_FIAT = [
|
|
|
|
"AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK",
|
|
|
|
"EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY",
|
|
|
|
"KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN",
|
2022-04-06 04:43:06 +00:00
|
|
|
"RUB", "UAH", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR",
|
|
|
|
"USD", "BTC", "ETH", "XRP", "LTC", "BCH"
|
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": [],
|
|
|
|
"ccxt_async_config": {
|
2019-08-16 12:56:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-02 14:42:53 +00:00
|
|
|
# Required json-schema for user specified config
|
|
|
|
CONF_SCHEMA = {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2019-11-25 06:05:18 +00:00
|
|
|
'max_open_trades': {'type': ['integer', 'number'], 'minimum': -1},
|
2021-04-22 17:41:01 +00:00
|
|
|
'new_pairs_days': {'type': 'integer', 'default': 30},
|
2020-06-01 18:33:26 +00:00
|
|
|
'timeframe': {'type': 'string'},
|
2020-01-11 10:53:44 +00:00
|
|
|
'stake_currency': {'type': 'string'},
|
2018-06-03 22:48:26 +00:00
|
|
|
'stake_amount': {
|
2019-11-25 06:06:55 +00:00
|
|
|
'type': ['number', 'string'],
|
|
|
|
'minimum': 0.0001,
|
|
|
|
'pattern': UNLIMITED_STAKE_AMOUNT
|
2018-06-03 22:48:26 +00:00
|
|
|
},
|
2020-01-02 09:59:10 +00:00
|
|
|
'tradable_balance_ratio': {
|
2020-01-02 13:41:28 +00:00
|
|
|
'type': 'number',
|
2021-09-24 17:24:33 +00:00
|
|
|
'minimum': 0.0,
|
2020-01-02 09:59:10 +00:00
|
|
|
'maximum': 1,
|
|
|
|
'default': 0.99
|
|
|
|
},
|
2021-07-10 10:30:00 +00:00
|
|
|
'available_capital': {
|
|
|
|
'type': 'number',
|
|
|
|
'minimum': 0,
|
|
|
|
},
|
2020-01-05 12:25:11 +00:00
|
|
|
'amend_last_stake_amount': {'type': 'boolean', 'default': False},
|
2020-01-10 05:36:28 +00:00
|
|
|
'last_stake_amount_min_ratio': {
|
|
|
|
'type': 'number', 'minimum': 0.0, 'maximum': 1.0, 'default': 0.5
|
2020-02-08 20:02:52 +00:00
|
|
|
},
|
2018-06-03 11:47:36 +00:00
|
|
|
'fiat_display_currency': {'type': 'string', 'enum': SUPPORTED_FIAT},
|
2018-04-02 14:42:53 +00:00
|
|
|
'dry_run': {'type': 'boolean'},
|
2019-12-15 08:22:15 +00:00
|
|
|
'dry_run_wallet': {'type': 'number', 'default': DRY_RUN_WALLET},
|
2020-04-24 22:16:52 +00:00
|
|
|
'cancel_open_orders_on_exit': {'type': 'boolean', 'default': False},
|
2018-09-01 17:52:40 +00:00
|
|
|
'process_only_new_candles': {'type': 'boolean'},
|
2018-04-02 14:42:53 +00:00
|
|
|
'minimal_roi': {
|
|
|
|
'type': 'object',
|
|
|
|
'patternProperties': {
|
|
|
|
'^[0-9.]+$': {'type': 'number'}
|
2018-02-04 00:04:26 +00:00
|
|
|
},
|
2018-04-02 14:42:53 +00:00
|
|
|
'minProperties': 1
|
|
|
|
},
|
2019-02-20 21:26:02 +00:00
|
|
|
'amount_reserve_percent': {'type': 'number', 'minimum': 0.0, 'maximum': 0.5},
|
2022-03-05 13:11:21 +00:00
|
|
|
'stoploss': {'type': 'number', 'maximum': 0, 'exclusiveMaximum': True, 'minimum': -1},
|
2018-06-26 21:06:27 +00:00
|
|
|
'trailing_stop': {'type': 'boolean'},
|
2018-07-01 17:54:26 +00:00
|
|
|
'trailing_stop_positive': {'type': 'number', 'minimum': 0, 'maximum': 1},
|
2018-07-16 19:23:35 +00:00
|
|
|
'trailing_stop_positive_offset': {'type': 'number', 'minimum': 0, 'maximum': 1},
|
2019-03-12 14:43:53 +00:00
|
|
|
'trailing_only_offset_is_reached': {'type': 'boolean'},
|
2022-04-05 18:07:58 +00:00
|
|
|
'use_exit_signal': {'type': 'boolean'},
|
2022-04-05 18:00:35 +00:00
|
|
|
'exit_profit_only': {'type': 'boolean'},
|
2022-04-05 18:03:20 +00:00
|
|
|
'exit_profit_offset': {'type': 'number'},
|
2022-04-05 18:20:51 +00:00
|
|
|
'ignore_roi_if_entry_signal': {'type': 'boolean'},
|
2021-06-26 14:06:09 +00:00
|
|
|
'ignore_buying_expired_candle_after': {'type': 'number'},
|
2021-10-18 07:15:44 +00:00
|
|
|
'trading_mode': {'type': 'string', 'enum': TRADING_MODES},
|
2022-02-02 05:41:42 +00:00
|
|
|
'margin_mode': {'type': 'string', 'enum': MARGIN_MODES},
|
2022-02-11 06:43:45 +00:00
|
|
|
'liquidation_buffer': {'type': 'number', 'minimum': 0.0, 'maximum': 0.99},
|
2021-10-21 04:58:40 +00:00
|
|
|
'backtest_breakdown': {
|
|
|
|
'type': 'array',
|
|
|
|
'items': {'type': 'string', 'enum': BACKTEST_BREAKDOWNS}
|
|
|
|
},
|
2021-01-16 15:19:49 +00:00
|
|
|
'bot_name': {'type': 'string'},
|
2018-06-14 01:32:52 +00:00
|
|
|
'unfilledtimeout': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2022-03-26 10:55:11 +00:00
|
|
|
'entry': {'type': 'number', 'minimum': 1},
|
|
|
|
'exit': {'type': 'number', 'minimum': 1},
|
2021-11-06 10:48:49 +00:00
|
|
|
'exit_timeout_count': {'type': 'number', 'minimum': 0, 'default': 0},
|
2021-05-18 23:30:36 +00:00
|
|
|
'unit': {'type': 'string', 'enum': TIMEOUT_UNITS, 'default': 'minutes'}
|
2018-06-14 01:32:52 +00:00
|
|
|
}
|
|
|
|
},
|
2022-03-27 16:03:49 +00:00
|
|
|
'entry_pricing': {
|
2018-04-02 14:42:53 +00:00
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2022-03-28 17:48:45 +00:00
|
|
|
'price_last_balance': {
|
2018-04-02 14:42:53 +00:00
|
|
|
'type': 'number',
|
|
|
|
'minimum': 0,
|
|
|
|
'maximum': 1,
|
2018-08-29 09:38:43 +00:00
|
|
|
'exclusiveMaximum': False,
|
2020-02-23 12:51:16 +00:00
|
|
|
},
|
2022-03-28 17:16:12 +00:00
|
|
|
'price_side': {'type': 'string', 'enum': PRICING_SIDES, 'default': 'same'},
|
2020-02-23 12:51:16 +00:00
|
|
|
'use_order_book': {'type': 'boolean'},
|
2021-06-25 18:36:39 +00:00
|
|
|
'order_book_top': {'type': 'integer', 'minimum': 1, 'maximum': 50, },
|
2020-02-23 12:51:16 +00:00
|
|
|
'check_depth_of_market': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
|
|
|
'enabled': {'type': 'boolean'},
|
|
|
|
'bids_to_ask_delta': {'type': 'number', 'minimum': 0},
|
|
|
|
}
|
2018-02-04 00:04:26 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-26 06:19:37 +00:00
|
|
|
'required': ['price_side']
|
2018-04-02 14:42:53 +00:00
|
|
|
},
|
2022-03-27 16:03:49 +00:00
|
|
|
'exit_pricing': {
|
2018-08-29 09:38:43 +00:00
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2022-03-28 17:16:12 +00:00
|
|
|
'price_side': {'type': 'string', 'enum': PRICING_SIDES, 'default': 'same'},
|
2022-03-28 17:48:45 +00:00
|
|
|
'price_last_balance': {
|
2021-03-20 13:38:26 +00:00
|
|
|
'type': 'number',
|
|
|
|
'minimum': 0,
|
|
|
|
'maximum': 1,
|
|
|
|
'exclusiveMaximum': False,
|
|
|
|
},
|
2018-08-29 09:38:43 +00:00
|
|
|
'use_order_book': {'type': 'boolean'},
|
2021-06-25 18:36:39 +00:00
|
|
|
'order_book_top': {'type': 'integer', 'minimum': 1, 'maximum': 50, },
|
2021-06-26 06:19:37 +00:00
|
|
|
},
|
|
|
|
'required': ['price_side']
|
2018-08-29 09:38:43 +00:00
|
|
|
},
|
2021-08-18 09:07:37 +00:00
|
|
|
'custom_price_max_distance_ratio': {
|
2021-10-18 07:15:44 +00:00
|
|
|
'type': 'number', 'minimum': 0.0
|
2021-08-17 03:09:30 +00:00
|
|
|
},
|
2018-11-17 12:05:35 +00:00
|
|
|
'order_types': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2022-03-07 19:32:16 +00:00
|
|
|
'entry': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES},
|
|
|
|
'exit': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES},
|
2022-04-05 10:31:53 +00:00
|
|
|
'force_exit': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES},
|
|
|
|
'force_entry': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES},
|
|
|
|
'emergency_exit': {
|
2021-11-06 15:12:25 +00:00
|
|
|
'type': 'string',
|
|
|
|
'enum': ORDERTYPE_POSSIBILITIES,
|
|
|
|
'default': 'market'},
|
2018-11-25 16:22:56 +00:00
|
|
|
'stoploss': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES},
|
2019-01-16 18:04:43 +00:00
|
|
|
'stoploss_on_exchange': {'type': 'boolean'},
|
2020-07-13 17:48:21 +00:00
|
|
|
'stoploss_on_exchange_interval': {'type': 'number'},
|
|
|
|
'stoploss_on_exchange_limit_ratio': {'type': 'number', 'minimum': 0.0,
|
|
|
|
'maximum': 1.0}
|
2018-11-17 12:05:35 +00:00
|
|
|
},
|
2022-03-07 19:32:16 +00:00
|
|
|
'required': ['entry', 'exit', 'stoploss', 'stoploss_on_exchange']
|
2018-11-17 12:05:35 +00:00
|
|
|
},
|
2018-11-25 20:05:25 +00:00
|
|
|
'order_time_in_force': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2022-03-07 06:09:01 +00:00
|
|
|
'entry': {'type': 'string', 'enum': ORDERTIF_POSSIBILITIES},
|
|
|
|
'exit': {'type': 'string', 'enum': ORDERTIF_POSSIBILITIES}
|
2018-11-25 20:05:25 +00:00
|
|
|
},
|
2022-03-07 06:09:01 +00:00
|
|
|
'required': REQUIRED_ORDERTIF
|
2018-11-25 20:05:25 +00:00
|
|
|
},
|
2018-04-02 14:42:53 +00:00
|
|
|
'exchange': {'$ref': '#/definitions/exchange'},
|
2018-10-02 10:42:59 +00:00
|
|
|
'edge': {'$ref': '#/definitions/edge'},
|
2022-07-31 13:23:27 +00:00
|
|
|
'freqai': {'$ref': '#/definitions/freqai'},
|
2018-04-02 14:42:53 +00:00
|
|
|
'experimental': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2019-10-05 10:29:59 +00:00
|
|
|
'block_bad_exchanges': {'type': 'boolean'}
|
2018-02-04 00:04:26 +00:00
|
|
|
}
|
|
|
|
},
|
2019-11-09 13:16:11 +00:00
|
|
|
'pairlists': {
|
|
|
|
'type': 'array',
|
|
|
|
'items': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
|
|
|
'method': {'type': 'string', 'enum': AVAILABLE_PAIRLISTS},
|
2020-10-15 05:38:00 +00:00
|
|
|
},
|
|
|
|
'required': ['method'],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'protections': {
|
|
|
|
'type': 'array',
|
|
|
|
'items': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
|
|
|
'method': {'type': 'string', 'enum': AVAILABLE_PROTECTIONS},
|
2020-11-11 06:48:27 +00:00
|
|
|
'stop_duration': {'type': 'number', 'minimum': 0.0},
|
2020-12-07 09:21:03 +00:00
|
|
|
'stop_duration_candles': {'type': 'number', 'minimum': 0},
|
2020-11-29 10:36:16 +00:00
|
|
|
'trade_limit': {'type': 'number', 'minimum': 1},
|
|
|
|
'lookback_period': {'type': 'number', 'minimum': 1},
|
2020-12-07 09:21:03 +00:00
|
|
|
'lookback_period_candles': {'type': 'number', 'minimum': 1},
|
2019-11-09 13:16:11 +00:00
|
|
|
},
|
2020-11-11 07:00:10 +00:00
|
|
|
'required': ['method'],
|
2019-11-09 13:16:11 +00:00
|
|
|
}
|
2018-12-03 19:00:18 +00:00
|
|
|
},
|
2018-04-02 14:42:53 +00:00
|
|
|
'telegram': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
|
|
|
'enabled': {'type': 'boolean'},
|
|
|
|
'token': {'type': 'string'},
|
|
|
|
'chat_id': {'type': 'string'},
|
2021-02-28 08:03:27 +00:00
|
|
|
'balance_dust_level': {'type': 'number', 'minimum': 0.0},
|
2020-09-19 17:38:33 +00:00
|
|
|
'notification_settings': {
|
|
|
|
'type': 'object',
|
2021-04-20 04:49:29 +00:00
|
|
|
'default': {},
|
2020-09-19 17:38:33 +00:00
|
|
|
'properties': {
|
|
|
|
'status': {'type': 'string', 'enum': TELEGRAM_SETTING_OPTIONS},
|
|
|
|
'warning': {'type': 'string', 'enum': TELEGRAM_SETTING_OPTIONS},
|
|
|
|
'startup': {'type': 'string', 'enum': TELEGRAM_SETTING_OPTIONS},
|
2022-04-04 17:29:15 +00:00
|
|
|
'entry': {'type': 'string', 'enum': TELEGRAM_SETTING_OPTIONS},
|
|
|
|
'entry_cancel': {'type': 'string', 'enum': TELEGRAM_SETTING_OPTIONS},
|
|
|
|
'entry_fill': {'type': 'string',
|
|
|
|
'enum': TELEGRAM_SETTING_OPTIONS,
|
|
|
|
'default': 'off'
|
|
|
|
},
|
2022-04-04 17:10:44 +00:00
|
|
|
'exit': {
|
2021-05-27 11:00:05 +00:00
|
|
|
'type': ['string', 'object'],
|
2021-05-27 09:35:27 +00:00
|
|
|
'additionalProperties': {
|
|
|
|
'type': 'string',
|
|
|
|
'enum': TELEGRAM_SETTING_OPTIONS
|
|
|
|
}
|
|
|
|
},
|
2022-04-04 17:07:20 +00:00
|
|
|
'exit_cancel': {'type': 'string', 'enum': TELEGRAM_SETTING_OPTIONS},
|
2022-04-04 17:08:31 +00:00
|
|
|
'exit_fill': {
|
2021-04-20 04:49:29 +00:00
|
|
|
'type': 'string',
|
|
|
|
'enum': TELEGRAM_SETTING_OPTIONS,
|
2022-05-22 17:16:31 +00:00
|
|
|
'default': 'on'
|
2021-08-06 22:19:36 +00:00
|
|
|
},
|
2021-09-20 18:08:48 +00:00
|
|
|
'protection_trigger': {
|
|
|
|
'type': 'string',
|
|
|
|
'enum': TELEGRAM_SETTING_OPTIONS,
|
2022-05-22 17:16:31 +00:00
|
|
|
'default': 'on'
|
2021-09-20 18:08:48 +00:00
|
|
|
},
|
|
|
|
'protection_trigger_global': {
|
|
|
|
'type': 'string',
|
|
|
|
'enum': TELEGRAM_SETTING_OPTIONS,
|
|
|
|
},
|
2022-07-11 10:10:29 +00:00
|
|
|
'show_candle': {
|
|
|
|
'type': 'string',
|
|
|
|
'enum': ['off', 'ohlc'],
|
|
|
|
},
|
2020-09-19 17:38:33 +00:00
|
|
|
}
|
2021-06-19 14:49:54 +00:00
|
|
|
},
|
|
|
|
'reload': {'type': 'boolean'},
|
2018-04-02 14:42:53 +00:00
|
|
|
},
|
2021-02-17 22:09:39 +00:00
|
|
|
'required': ['enabled', 'token', 'chat_id'],
|
2018-04-02 14:42:53 +00:00
|
|
|
},
|
2018-07-07 11:39:21 +00:00
|
|
|
'webhook': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
|
|
|
'enabled': {'type': 'boolean'},
|
2021-11-29 07:17:59 +00:00
|
|
|
'url': {'type': 'string'},
|
|
|
|
'format': {'type': 'string', 'enum': WEBHOOK_FORMAT_OPTIONS, 'default': 'form'},
|
2021-11-28 23:48:35 +00:00
|
|
|
'retries': {'type': 'integer', 'minimum': 0},
|
|
|
|
'retry_delay': {'type': 'number', 'minimum': 0},
|
2022-04-04 17:32:27 +00:00
|
|
|
'webhookentry': {'type': 'object'},
|
|
|
|
'webhookentrycancel': {'type': 'object'},
|
|
|
|
'webhookentryfill': {'type': 'object'},
|
2022-04-04 17:05:36 +00:00
|
|
|
'webhookexit': {'type': 'object'},
|
|
|
|
'webhookexitcancel': {'type': 'object'},
|
|
|
|
'webhookexitfill': {'type': 'object'},
|
2018-07-07 11:39:21 +00:00
|
|
|
'webhookstatus': {'type': 'object'},
|
|
|
|
},
|
|
|
|
},
|
2022-06-11 15:30:56 +00:00
|
|
|
'discord': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
|
|
|
'enabled': {'type': 'boolean'},
|
|
|
|
'webhook_url': {'type': 'string'},
|
|
|
|
"exit_fill": {
|
|
|
|
'type': 'array', 'items': {'type': 'object'},
|
|
|
|
'default': [
|
|
|
|
{"Trade ID": "{trade_id}"},
|
|
|
|
{"Exchange": "{exchange}"},
|
|
|
|
{"Pair": "{pair}"},
|
|
|
|
{"Direction": "{direction}"},
|
|
|
|
{"Open rate": "{open_rate}"},
|
|
|
|
{"Close rate": "{close_rate}"},
|
|
|
|
{"Amount": "{amount}"},
|
|
|
|
{"Open date": "{open_date:%Y-%m-%d %H:%M:%S}"},
|
|
|
|
{"Close date": "{close_date:%Y-%m-%d %H:%M:%S}"},
|
|
|
|
{"Profit": "{profit_amount} {stake_currency}"},
|
|
|
|
{"Profitability": "{profit_ratio:.2%}"},
|
|
|
|
{"Enter tag": "{enter_tag}"},
|
|
|
|
{"Exit Reason": "{exit_reason}"},
|
|
|
|
{"Strategy": "{strategy}"},
|
|
|
|
{"Timeframe": "{timeframe}"},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"entry_fill": {
|
|
|
|
'type': 'array', 'items': {'type': 'object'},
|
|
|
|
'default': [
|
|
|
|
{"Trade ID": "{trade_id}"},
|
|
|
|
{"Exchange": "{exchange}"},
|
|
|
|
{"Pair": "{pair}"},
|
|
|
|
{"Direction": "{direction}"},
|
|
|
|
{"Open rate": "{open_rate}"},
|
|
|
|
{"Amount": "{amount}"},
|
|
|
|
{"Open date": "{open_date:%Y-%m-%d %H:%M:%S}"},
|
|
|
|
{"Enter tag": "{enter_tag}"},
|
|
|
|
{"Strategy": "{strategy} {timeframe}"},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2019-04-04 05:13:14 +00:00
|
|
|
'api_server': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
|
|
|
'enabled': {'type': 'boolean'},
|
|
|
|
'listen_ip_address': {'format': 'ipv4'},
|
|
|
|
'listen_port': {
|
|
|
|
'type': 'integer',
|
2019-11-25 06:06:55 +00:00
|
|
|
'minimum': 1024,
|
|
|
|
'maximum': 65535
|
2019-04-04 05:13:14 +00:00
|
|
|
},
|
2019-05-25 12:42:13 +00:00
|
|
|
'username': {'type': 'string'},
|
|
|
|
'password': {'type': 'string'},
|
2020-06-24 18:32:19 +00:00
|
|
|
'jwt_secret_key': {'type': 'string'},
|
|
|
|
'CORS_origins': {'type': 'array', 'items': {'type': 'string'}},
|
2020-05-31 07:51:45 +00:00
|
|
|
'verbosity': {'type': 'string', 'enum': ['error', 'info']},
|
2019-04-04 05:13:14 +00:00
|
|
|
},
|
2019-05-25 12:42:13 +00:00
|
|
|
'required': ['enabled', 'listen_ip_address', 'listen_port', 'username', 'password']
|
2019-04-04 05:13:14 +00:00
|
|
|
},
|
2018-06-07 03:26:39 +00:00
|
|
|
'db_url': {'type': 'string'},
|
2021-06-14 17:57:24 +00:00
|
|
|
'export': {'type': 'string', 'enum': EXPORT_OPTIONS, 'default': 'trades'},
|
2021-06-29 18:38:14 +00:00
|
|
|
'disableparamexport': {'type': 'boolean'},
|
2018-04-02 14:42:53 +00:00
|
|
|
'initial_state': {'type': 'string', 'enum': ['running', 'stopped']},
|
2022-04-08 11:39:41 +00:00
|
|
|
'force_entry_enable': {'type': 'boolean'},
|
2020-05-29 17:37:18 +00:00
|
|
|
'disable_dataframe_checks': {'type': 'boolean'},
|
2018-04-02 14:42:53 +00:00
|
|
|
'internals': {
|
|
|
|
'type': 'object',
|
2019-12-25 09:41:04 +00:00
|
|
|
'default': {},
|
2018-04-02 14:42:53 +00:00
|
|
|
'properties': {
|
2019-11-27 13:46:09 +00:00
|
|
|
'process_throttle_secs': {'type': 'integer'},
|
2019-03-10 17:05:33 +00:00
|
|
|
'interval': {'type': 'integer'},
|
|
|
|
'sd_notify': {'type': 'boolean'},
|
2019-12-27 12:46:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
'dataformat_ohlcv': {
|
|
|
|
'type': 'string',
|
2021-09-27 16:47:03 +00:00
|
|
|
'enum': AVAILABLE_DATAHANDLERS,
|
|
|
|
'default': 'json'
|
2019-12-27 12:46:25 +00:00
|
|
|
},
|
|
|
|
'dataformat_trades': {
|
|
|
|
'type': 'string',
|
2021-09-27 16:47:03 +00:00
|
|
|
'enum': AVAILABLE_DATAHANDLERS,
|
|
|
|
'default': 'jsongz'
|
2022-01-23 03:54:58 +00:00
|
|
|
},
|
2022-01-28 18:21:31 +00:00
|
|
|
'position_adjustment_enable': {'type': 'boolean'},
|
2022-01-27 15:57:50 +00:00
|
|
|
'max_entry_position_adjustment': {'type': ['integer', 'number'], 'minimum': -1},
|
2018-04-02 14:42:53 +00:00
|
|
|
},
|
|
|
|
'definitions': {
|
|
|
|
'exchange': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2019-04-08 08:19:45 +00:00
|
|
|
'name': {'type': 'string'},
|
2019-04-08 01:42:28 +00:00
|
|
|
'sandbox': {'type': 'boolean', 'default': False},
|
|
|
|
'key': {'type': 'string', 'default': ''},
|
|
|
|
'secret': {'type': 'string', 'default': ''},
|
|
|
|
'password': {'type': 'string', 'default': ''},
|
2018-07-27 12:19:01 +00:00
|
|
|
'uid': {'type': 'string'},
|
2018-04-02 14:42:53 +00:00
|
|
|
'pair_whitelist': {
|
|
|
|
'type': 'array',
|
|
|
|
'items': {
|
|
|
|
'type': 'string',
|
2018-02-04 00:04:26 +00:00
|
|
|
},
|
2018-04-02 14:42:53 +00:00
|
|
|
'uniqueItems': True
|
2018-02-04 00:04:26 +00:00
|
|
|
},
|
2018-04-02 14:42:53 +00:00
|
|
|
'pair_blacklist': {
|
|
|
|
'type': 'array',
|
|
|
|
'items': {
|
|
|
|
'type': 'string',
|
|
|
|
},
|
|
|
|
'uniqueItems': True
|
2018-08-07 07:25:21 +00:00
|
|
|
},
|
2021-12-11 14:26:08 +00:00
|
|
|
'unknown_fee_rate': {'type': 'number'},
|
2018-10-04 18:34:48 +00:00
|
|
|
'outdated_offset': {'type': 'integer', 'minimum': 1},
|
2019-03-12 15:54:59 +00:00
|
|
|
'markets_refresh_interval': {'type': 'integer'},
|
2018-10-04 18:34:48 +00:00
|
|
|
'ccxt_config': {'type': 'object'},
|
|
|
|
'ccxt_async_config': {'type': 'object'}
|
2018-04-02 14:42:53 +00:00
|
|
|
},
|
2019-10-25 05:07:01 +00:00
|
|
|
'required': ['name']
|
2018-10-02 10:42:59 +00:00
|
|
|
},
|
|
|
|
'edge': {
|
|
|
|
'type': 'object',
|
|
|
|
'properties': {
|
2019-11-25 06:06:55 +00:00
|
|
|
'enabled': {'type': 'boolean'},
|
|
|
|
'process_throttle_secs': {'type': 'integer', 'minimum': 600},
|
|
|
|
'calculate_since_number_of_days': {'type': 'integer'},
|
|
|
|
'allowed_risk': {'type': 'number'},
|
|
|
|
'stoploss_range_min': {'type': 'number'},
|
|
|
|
'stoploss_range_max': {'type': 'number'},
|
|
|
|
'stoploss_range_step': {'type': 'number'},
|
|
|
|
'minimum_winrate': {'type': 'number'},
|
|
|
|
'minimum_expectancy': {'type': 'number'},
|
|
|
|
'min_trade_number': {'type': 'number'},
|
|
|
|
'max_trade_duration_minute': {'type': 'integer'},
|
|
|
|
'remove_pumps': {'type': 'boolean'}
|
2018-12-01 10:08:18 +00:00
|
|
|
},
|
2020-01-03 09:58:31 +00:00
|
|
|
'required': ['process_throttle_secs', 'allowed_risk']
|
2018-10-02 10:42:59 +00:00
|
|
|
},
|
2022-05-05 12:37:37 +00:00
|
|
|
"freqai": {
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
2022-07-29 06:49:35 +00:00
|
|
|
"keras": {"type": "boolean", "default": False},
|
|
|
|
"conv_width": {"type": "integer", "default": 2},
|
2022-07-10 10:34:09 +00:00
|
|
|
"train_period_days": {"type": "integer", "default": 0},
|
2022-07-31 13:23:27 +00:00
|
|
|
"backtest_period_days": {"type": "number", "default": 7},
|
|
|
|
"identifier": {"type": "string", "default": "example"},
|
2022-05-05 12:37:37 +00:00
|
|
|
"feature_parameters": {
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
2022-07-31 13:23:27 +00:00
|
|
|
"include_corr_pairlist": {"type": "array"},
|
|
|
|
"include_timeframes": {"type": "array"},
|
2022-07-10 10:34:09 +00:00
|
|
|
"label_period_candles": {"type": "integer"},
|
|
|
|
"include_shifted_candles": {"type": "integer", "default": 0},
|
2022-07-31 13:23:27 +00:00
|
|
|
"DI_threshold": {"type": "number", "default": 0},
|
2022-05-05 12:37:37 +00:00
|
|
|
"weight_factor": {"type": "number", "default": 0},
|
|
|
|
"principal_component_analysis": {"type": "boolean", "default": False},
|
2022-05-22 22:06:26 +00:00
|
|
|
"use_SVM_to_remove_outliers": {"type": "boolean", "default": False},
|
2022-05-05 12:37:37 +00:00
|
|
|
},
|
2022-07-31 13:23:27 +00:00
|
|
|
"required": ["include_timeframes", "include_corr_pairlist", ]
|
2022-05-05 12:37:37 +00:00
|
|
|
},
|
|
|
|
"data_split_parameters": {
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"test_size": {"type": "number"},
|
|
|
|
"random_state": {"type": "integer"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"model_training_parameters": {
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"n_estimators": {"type": "integer", "default": 2000},
|
|
|
|
"random_state": {"type": "integer", "default": 1},
|
|
|
|
"learning_rate": {"type": "number", "default": 0.02},
|
|
|
|
"task_type": {"type": "string", "default": "CPU"},
|
|
|
|
},
|
|
|
|
},
|
2018-12-01 10:08:18 +00:00
|
|
|
},
|
2022-07-31 13:23:27 +00:00
|
|
|
"required": ["train_period_days",
|
|
|
|
"backtest_period_days",
|
|
|
|
"identifier",
|
|
|
|
"feature_parameters",
|
|
|
|
"data_split_parameters",
|
|
|
|
"model_training_parameters"]
|
2022-05-05 12:37:37 +00:00
|
|
|
},
|
2018-04-02 14:42:53 +00:00
|
|
|
},
|
|
|
|
}
|
2020-01-02 09:38:59 +00:00
|
|
|
|
|
|
|
SCHEMA_TRADE_REQUIRED = [
|
|
|
|
'exchange',
|
2020-06-01 18:33:26 +00:00
|
|
|
'timeframe',
|
2020-01-02 09:38:59 +00:00
|
|
|
'max_open_trades',
|
|
|
|
'stake_currency',
|
|
|
|
'stake_amount',
|
2020-01-05 12:25:11 +00:00
|
|
|
'tradable_balance_ratio',
|
2020-01-10 05:36:28 +00:00
|
|
|
'last_stake_amount_min_ratio',
|
2020-01-02 09:38:59 +00:00
|
|
|
'dry_run',
|
|
|
|
'dry_run_wallet',
|
2022-03-27 16:03:49 +00:00
|
|
|
'exit_pricing',
|
|
|
|
'entry_pricing',
|
2020-01-02 09:38:59 +00:00
|
|
|
'stoploss',
|
|
|
|
'minimal_roi',
|
2020-01-04 10:36:27 +00:00
|
|
|
'internals',
|
|
|
|
'dataformat_ohlcv',
|
|
|
|
'dataformat_trades',
|
2020-01-02 09:38:59 +00:00
|
|
|
]
|
|
|
|
|
2021-03-10 09:43:44 +00:00
|
|
|
SCHEMA_BACKTEST_REQUIRED = [
|
|
|
|
'exchange',
|
|
|
|
'max_open_trades',
|
|
|
|
'stake_currency',
|
|
|
|
'stake_amount',
|
|
|
|
'dry_run_wallet',
|
|
|
|
'dataformat_ohlcv',
|
|
|
|
'dataformat_trades',
|
|
|
|
]
|
2022-05-01 07:53:34 +00:00
|
|
|
SCHEMA_BACKTEST_REQUIRED_FINAL = SCHEMA_BACKTEST_REQUIRED + [
|
|
|
|
'stoploss',
|
|
|
|
'minimal_roi',
|
|
|
|
]
|
2021-03-10 09:43:44 +00:00
|
|
|
|
2020-01-02 09:38:59 +00:00
|
|
|
SCHEMA_MINIMAL_REQUIRED = [
|
|
|
|
'exchange',
|
|
|
|
'dry_run',
|
2020-01-04 10:36:27 +00:00
|
|
|
'dataformat_ohlcv',
|
|
|
|
'dataformat_trades',
|
2020-01-02 09:38:59 +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",
|
2022-04-18 18:14:35 +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]
|
2022-04-04 14:51:57 +00:00
|
|
|
|
|
|
|
LongShort = Literal['long', 'short']
|
|
|
|
EntryExit = Literal['entry', 'exit']
|
2022-05-07 06:45:37 +00:00
|
|
|
BuySell = Literal['buy', 'sell']
|
2022-07-16 13:42:17 +00:00
|
|
|
MakerTaker = Literal['maker', 'taker']
|