diff --git a/config_examples/config_full.example.json b/config_examples/config_full.example.json index 1fb2817b8..7f1f92dfe 100644 --- a/config_examples/config_full.example.json +++ b/config_examples/config_full.example.json @@ -51,11 +51,11 @@ "order_book_top": 1 }, "order_types": { - "buy": "limit", - "sell": "limit", - "emergencysell": "market", - "forcesell": "market", - "forcebuy": "market", + "entry": "limit", + "exit": "limit", + "emergencyexit": "market", + "forceexit": "market", + "forceentry": "market", "stoploss": "market", "stoploss_on_exchange": false, "stoploss_on_exchange_interval": 60 diff --git a/docs/configuration.md b/docs/configuration.md index 99c13ca5a..f514e695a 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -392,11 +392,11 @@ Syntax for Strategy: ```python order_types = { - "buy": "limit", - "sell": "limit", - "emergencysell": "market", - "forcebuy": "market", - "forcesell": "market", + "entry": "limit", + "exit": "limit", + "emergencyexit": "market", + "forceentry": "market", + "forceexit": "market", "stoploss": "market", "stoploss_on_exchange": False, "stoploss_on_exchange_interval": 60, diff --git a/freqtrade/constants.py b/freqtrade/constants.py index bafda93db..fabac5830 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -20,7 +20,7 @@ DEFAULT_DB_DRYRUN_URL = 'sqlite:///tradesv3.dryrun.sqlite' UNLIMITED_STAKE_AMOUNT = 'unlimited' DEFAULT_AMOUNT_RESERVE_PERCENT = 0.05 REQUIRED_ORDERTIF = ['entry', 'exit'] -REQUIRED_ORDERTYPES = ['buy', 'sell', 'stoploss', 'stoploss_on_exchange'] +REQUIRED_ORDERTYPES = ['entry', 'exit', 'stoploss', 'stoploss_on_exchange'] ORDERBOOK_SIDES = ['ask', 'bid'] ORDERTYPE_POSSIBILITIES = ['limit', 'market'] ORDERTIF_POSSIBILITIES = ['gtc', 'fok', 'ioc'] @@ -214,11 +214,11 @@ CONF_SCHEMA = { 'order_types': { 'type': 'object', 'properties': { - 'buy': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, - 'sell': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, - 'forcesell': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, - 'forcebuy': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, - 'emergencysell': { + 'entry': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, + 'exit': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, + 'forceexit': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, + 'forceentry': {'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES}, + 'emergencyexit': { 'type': 'string', 'enum': ORDERTYPE_POSSIBILITIES, 'default': 'market'}, @@ -228,7 +228,7 @@ CONF_SCHEMA = { 'stoploss_on_exchange_limit_ratio': {'type': 'number', 'minimum': 0.0, 'maximum': 1.0} }, - 'required': ['buy', 'sell', 'stoploss', 'stoploss_on_exchange'] + 'required': ['entry', 'exit', 'stoploss', 'stoploss_on_exchange'] }, 'order_time_in_force': { 'type': 'object', diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 4f3f723c0..03c1c4eaf 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -630,7 +630,7 @@ class FreqtradeBot(LoggingMixin): f"{stake_amount} ...") amount = (stake_amount / enter_limit_requested) * leverage - order_type = ordertype or self.strategy.order_types['buy'] + order_type = ordertype or self.strategy.order_types['entry'] if not pos_adjust and not strategy_safe_wrapper( self.strategy.confirm_trade_entry, default_retval=True)( @@ -1247,11 +1247,11 @@ class FreqtradeBot(LoggingMixin): self.update_trade_state(trade, trade.open_order_id, corder) trade.open_order_id = None - logger.info('Partial %s order timeout for %s.', trade.enter_side, trade) + logger.info(f'Partial {trade.enter_side} order timeout for {trade}.') reason += f", {constants.CANCEL_REASON['PARTIALLY_FILLED']}" self.wallets.update() - self._notify_enter_cancel(trade, order_type=self.strategy.order_types[trade.enter_side], + self._notify_enter_cancel(trade, order_type=self.strategy.order_types['entry'], reason=reason) return was_trade_fully_canceled @@ -1296,7 +1296,7 @@ class FreqtradeBot(LoggingMixin): self.wallets.update() self._notify_exit_cancel( trade, - order_type=self.strategy.order_types[trade.exit_side], + order_type=self.strategy.order_types['exit'], reason=reason ) return cancelled @@ -1376,10 +1376,10 @@ class FreqtradeBot(LoggingMixin): # First cancelling stoploss on exchange ... trade = self.cancel_stoploss_on_exchange(trade) - order_type = ordertype or self.strategy.order_types[exit_type] + order_type = ordertype or self.strategy.order_types['exit'] if sell_reason.sell_type == SellType.EMERGENCY_SELL: # Emergency sells (default to market!) - order_type = self.strategy.order_types.get("emergencysell", "market") + order_type = self.strategy.order_types.get("emergencyexit", "market") amount = self._safe_exit_amount(trade.pair, trade.amount) time_in_force = self.strategy.order_time_in_force['exit'] diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 744c77844..8e189b2b0 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -491,7 +491,7 @@ class Backtesting: return None # call the custom exit price,with default value as previous closerate current_profit = trade.calc_profit_ratio(closerate) - order_type = self.strategy.order_types['sell'] + order_type = self.strategy.order_types['exit'] if sell.sell_type in (SellType.SELL_SIGNAL, SellType.CUSTOM_SELL): # Custom exit pricing only for sell-signals if order_type == 'limit': @@ -599,7 +599,7 @@ class Backtesting: current_time = row[DATE_IDX].to_pydatetime() entry_tag = row[ENTER_TAG_IDX] if len(row) >= ENTER_TAG_IDX + 1 else None # let's call the custom entry price, using the open price as default price - order_type = self.strategy.order_types['buy'] + order_type = self.strategy.order_types['entry'] propose_rate = row[OPEN_IDX] if order_type == 'limit': propose_rate = strategy_safe_wrapper(self.strategy.custom_entry_price, @@ -639,7 +639,7 @@ class Backtesting: # In case of pos adjust, still return the original trade # If not pos adjust, trade is None return trade - order_type = self.strategy.order_types['buy'] + order_type = self.strategy.order_types['entry'] time_in_force = self.strategy.order_time_in_force['entry'] if not pos_adjust: diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index 548362bf5..b6d175c0f 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -138,11 +138,11 @@ class UnfilledTimeout(BaseModel): class OrderTypes(BaseModel): - buy: OrderTypeValues - sell: OrderTypeValues - emergencysell: Optional[OrderTypeValues] - forcesell: Optional[OrderTypeValues] - forcebuy: Optional[OrderTypeValues] + entry: OrderTypeValues + exit: OrderTypeValues + emergencyexit: Optional[OrderTypeValues] + forceexit: Optional[OrderTypeValues] + forceentry: Optional[OrderTypeValues] stoploss: OrderTypeValues stoploss_on_exchange: bool stoploss_on_exchange_interval: Optional[int] diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index a77f6f69c..45e76d0c3 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -708,7 +708,7 @@ class RPC: trade.pair, refresh=False, side=trade.exit_side) sell_reason = SellCheckTuple(sell_type=SellType.FORCE_SELL) order_type = ordertype or self._freqtrade.strategy.order_types.get( - "forcesell", self._freqtrade.strategy.order_types["sell"]) + "forceexit", self._freqtrade.strategy.order_types["exit"]) self._freqtrade.execute_trade_exit( trade, current_rate, sell_reason, ordertype=order_type) @@ -731,7 +731,7 @@ class RPC: trade_filter=[Trade.id == trade_id, Trade.is_open.is_(True), ] ).first() if not trade: - logger.warning('forcesell: Invalid argument received') + logger.warning('forceexit: Invalid argument received') raise RPCException('invalid argument') _exec_forcesell(trade) @@ -780,7 +780,7 @@ class RPC: # execute buy if not order_type: order_type = self._freqtrade.strategy.order_types.get( - 'forcebuy', self._freqtrade.strategy.order_types['buy']) + 'forceentry', self._freqtrade.strategy.order_types['entry']) if self._freqtrade.execute_entry(pair, stake_amount, price, ordertype=order_type, trade=trade, is_short=is_short, diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 90a602ef8..29f63215d 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -944,7 +944,7 @@ class Telegram(RPCHandler): return try: msg = self._rpc._rpc_forceexit(trade_id) - self._send_msg('Forcesell Result: `{result}`'.format(**msg)) + self._send_msg('Forceexit Result: `{result}`'.format(**msg)) except RPCException as e: self._send_msg(str(e)) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index e5b583a9e..adf2e3d84 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -87,8 +87,8 @@ class IStrategy(ABC, HyperStrategyMixin): # Optional order types order_types: Dict = { - 'buy': 'limit', - 'sell': 'limit', + 'entry': 'limit', + 'exit': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False, 'stoploss_on_exchange_interval': 60, diff --git a/freqtrade/templates/sample_short_strategy.py b/freqtrade/templates/sample_short_strategy.py index c33327715..beb0706d8 100644 --- a/freqtrade/templates/sample_short_strategy.py +++ b/freqtrade/templates/sample_short_strategy.py @@ -76,8 +76,8 @@ class SampleShortStrategy(IStrategy): # Optional order type mapping. order_types = { - 'buy': 'limit', - 'sell': 'limit', + 'entry': 'limit', + 'exit': 'limit', 'stoploss': 'market', 'stoploss_on_exchange': False } diff --git a/freqtrade/templates/sample_strategy.py b/freqtrade/templates/sample_strategy.py index b3f1ae1c8..6f2b431dd 100644 --- a/freqtrade/templates/sample_strategy.py +++ b/freqtrade/templates/sample_strategy.py @@ -77,8 +77,8 @@ class SampleStrategy(IStrategy): # Optional order type mapping. order_types = { - 'buy': 'limit', - 'sell': 'limit', + 'entry': 'limit', + 'exit': 'limit', 'stoploss': 'market', 'stoploss_on_exchange': False }