sell_order_status -> exit_order_status
This commit is contained in:
parent
d054916439
commit
2d2bea17e7
@ -1414,7 +1414,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
trade.orders.append(order_obj)
|
trade.orders.append(order_obj)
|
||||||
|
|
||||||
trade.open_order_id = order['id']
|
trade.open_order_id = order['id']
|
||||||
trade.sell_order_status = ''
|
trade.exit_order_status = ''
|
||||||
trade.close_rate_requested = limit
|
trade.close_rate_requested = limit
|
||||||
trade.exit_reason = exit_tag or exit_check.exit_reason
|
trade.exit_reason = exit_tag or exit_check.exit_reason
|
||||||
|
|
||||||
@ -1481,10 +1481,10 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
"""
|
"""
|
||||||
Sends rpc notification when a sell cancel occurred.
|
Sends rpc notification when a sell cancel occurred.
|
||||||
"""
|
"""
|
||||||
if trade.sell_order_status == reason:
|
if trade.exit_order_status == reason:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
trade.sell_order_status = reason
|
trade.exit_order_status = reason
|
||||||
|
|
||||||
profit_rate = trade.close_rate if trade.close_rate else trade.close_rate_requested
|
profit_rate = trade.close_rate if trade.close_rate else trade.close_rate_requested
|
||||||
profit_trade = trade.calc_profit(rate=profit_rate)
|
profit_trade = trade.calc_profit(rate=profit_rate)
|
||||||
|
@ -104,7 +104,8 @@ def migrate_trades_and_orders_table(
|
|||||||
close_profit_abs = get_column_def(
|
close_profit_abs = get_column_def(
|
||||||
cols, 'close_profit_abs',
|
cols, 'close_profit_abs',
|
||||||
f"(amount * close_rate * (1 - {fee_close})) - {open_trade_value}")
|
f"(amount * close_rate * (1 - {fee_close})) - {open_trade_value}")
|
||||||
sell_order_status = get_column_def(cols, 'sell_order_status', 'null')
|
exit_order_status = get_column_def(cols, 'exit_order_status',
|
||||||
|
get_column_def(cols, 'sell_order_status', 'null'))
|
||||||
amount_requested = get_column_def(cols, 'amount_requested', 'amount')
|
amount_requested = get_column_def(cols, 'amount_requested', 'amount')
|
||||||
|
|
||||||
# Schema migration necessary
|
# Schema migration necessary
|
||||||
@ -136,7 +137,7 @@ def migrate_trades_and_orders_table(
|
|||||||
stake_amount, amount, amount_requested, open_date, close_date, open_order_id,
|
stake_amount, amount, amount_requested, open_date, close_date, open_order_id,
|
||||||
stop_loss, stop_loss_pct, initial_stop_loss, initial_stop_loss_pct,
|
stop_loss, stop_loss_pct, initial_stop_loss, initial_stop_loss_pct,
|
||||||
stoploss_order_id, stoploss_last_update,
|
stoploss_order_id, stoploss_last_update,
|
||||||
max_rate, min_rate, exit_reason, sell_order_status, strategy, enter_tag,
|
max_rate, min_rate, exit_reason, exit_order_status, strategy, enter_tag,
|
||||||
timeframe, open_trade_value, close_profit_abs,
|
timeframe, open_trade_value, close_profit_abs,
|
||||||
trading_mode, leverage, liquidation_price, is_short,
|
trading_mode, leverage, liquidation_price, is_short,
|
||||||
interest_rate, funding_fees
|
interest_rate, funding_fees
|
||||||
@ -153,7 +154,7 @@ def migrate_trades_and_orders_table(
|
|||||||
{initial_stop_loss_pct} initial_stop_loss_pct,
|
{initial_stop_loss_pct} initial_stop_loss_pct,
|
||||||
{stoploss_order_id} stoploss_order_id, {stoploss_last_update} stoploss_last_update,
|
{stoploss_order_id} stoploss_order_id, {stoploss_last_update} stoploss_last_update,
|
||||||
{max_rate} max_rate, {min_rate} min_rate, {exit_reason} exit_reason,
|
{max_rate} max_rate, {min_rate} min_rate, {exit_reason} exit_reason,
|
||||||
{sell_order_status} sell_order_status,
|
{exit_order_status} exit_order_status,
|
||||||
{strategy} strategy, {enter_tag} enter_tag, {timeframe} timeframe,
|
{strategy} strategy, {enter_tag} enter_tag, {timeframe} timeframe,
|
||||||
{open_trade_value} open_trade_value, {close_profit_abs} close_profit_abs,
|
{open_trade_value} open_trade_value, {close_profit_abs} close_profit_abs,
|
||||||
{trading_mode} trading_mode, {leverage} leverage, {liquidation_price} liquidation_price,
|
{trading_mode} trading_mode, {leverage} leverage, {liquidation_price} liquidation_price,
|
||||||
@ -234,7 +235,7 @@ def check_migrate(engine, decl_base, previous_tables) -> None:
|
|||||||
# Migrates both trades and orders table!
|
# Migrates both trades and orders table!
|
||||||
# if ('orders' not in previous_tables
|
# if ('orders' not in previous_tables
|
||||||
# or not has_column(cols_orders, 'leverage')):
|
# or not has_column(cols_orders, 'leverage')):
|
||||||
if not has_column(cols, 'exit_reason'):
|
if not has_column(cols, 'exit_order_status'):
|
||||||
logger.info(f"Running database migration for trades - "
|
logger.info(f"Running database migration for trades - "
|
||||||
f"backup: {table_back_name}, {order_table_bak_name}")
|
f"backup: {table_back_name}, {order_table_bak_name}")
|
||||||
migrate_trades_and_orders_table(
|
migrate_trades_and_orders_table(
|
||||||
|
@ -317,7 +317,7 @@ class LocalTrade():
|
|||||||
# Lowest price reached
|
# Lowest price reached
|
||||||
min_rate: float = 0.0
|
min_rate: float = 0.0
|
||||||
exit_reason: str = ''
|
exit_reason: str = ''
|
||||||
sell_order_status: str = ''
|
exit_order_status: str = ''
|
||||||
strategy: str = ''
|
strategy: str = ''
|
||||||
enter_tag: Optional[str] = None
|
enter_tag: Optional[str] = None
|
||||||
timeframe: Optional[int] = None
|
timeframe: Optional[int] = None
|
||||||
@ -461,7 +461,7 @@ class LocalTrade():
|
|||||||
|
|
||||||
'sell_reason': self.exit_reason, # Deprecated
|
'sell_reason': self.exit_reason, # Deprecated
|
||||||
'exit_reason': self.exit_reason,
|
'exit_reason': self.exit_reason,
|
||||||
'sell_order_status': self.sell_order_status,
|
'exit_order_status': self.exit_order_status,
|
||||||
'stop_loss_abs': self.stop_loss,
|
'stop_loss_abs': self.stop_loss,
|
||||||
'stop_loss_ratio': self.stop_loss_pct if self.stop_loss_pct else None,
|
'stop_loss_ratio': self.stop_loss_pct if self.stop_loss_pct else None,
|
||||||
'stop_loss_pct': (self.stop_loss_pct * 100) if self.stop_loss_pct else None,
|
'stop_loss_pct': (self.stop_loss_pct * 100) if self.stop_loss_pct else None,
|
||||||
@ -637,7 +637,7 @@ class LocalTrade():
|
|||||||
self.close_profit = self.calc_profit_ratio()
|
self.close_profit = self.calc_profit_ratio()
|
||||||
self.close_profit_abs = self.calc_profit()
|
self.close_profit_abs = self.calc_profit()
|
||||||
self.is_open = False
|
self.is_open = False
|
||||||
self.sell_order_status = 'closed'
|
self.exit_order_status = 'closed'
|
||||||
self.open_order_id = None
|
self.open_order_id = None
|
||||||
if show_msg:
|
if show_msg:
|
||||||
logger.info(
|
logger.info(
|
||||||
@ -1083,7 +1083,7 @@ class Trade(_DECL_BASE, LocalTrade):
|
|||||||
# Lowest price reached
|
# Lowest price reached
|
||||||
min_rate = Column(Float, nullable=True)
|
min_rate = Column(Float, nullable=True)
|
||||||
exit_reason = Column(String(100), nullable=True)
|
exit_reason = Column(String(100), nullable=True)
|
||||||
sell_order_status = Column(String(100), nullable=True)
|
exit_order_status = Column(String(100), nullable=True)
|
||||||
strategy = Column(String(100), nullable=True)
|
strategy = Column(String(100), nullable=True)
|
||||||
enter_tag = Column(String(100), nullable=True)
|
enter_tag = Column(String(100), nullable=True)
|
||||||
timeframe = Column(Integer, nullable=True)
|
timeframe = Column(Integer, nullable=True)
|
||||||
|
@ -237,7 +237,7 @@ class TradeSchema(BaseModel):
|
|||||||
profit_fiat: Optional[float]
|
profit_fiat: Optional[float]
|
||||||
sell_reason: Optional[str] # Deprecated
|
sell_reason: Optional[str] # Deprecated
|
||||||
exit_reason: Optional[str]
|
exit_reason: Optional[str]
|
||||||
sell_order_status: Optional[str]
|
exit_order_status: Optional[str]
|
||||||
stop_loss_abs: Optional[float]
|
stop_loss_abs: Optional[float]
|
||||||
stop_loss_ratio: Optional[float]
|
stop_loss_ratio: Optional[float]
|
||||||
stop_loss_pct: Optional[float]
|
stop_loss_pct: Optional[float]
|
||||||
|
@ -506,8 +506,8 @@ class Telegram(RPCHandler):
|
|||||||
lines.append("*Stoploss distance:* `{stoploss_current_dist:.8f}` "
|
lines.append("*Stoploss distance:* `{stoploss_current_dist:.8f}` "
|
||||||
"`({stoploss_current_dist_ratio:.2%})`")
|
"`({stoploss_current_dist_ratio:.2%})`")
|
||||||
if r['open_order']:
|
if r['open_order']:
|
||||||
if r['sell_order_status']:
|
if r['exit_order_status']:
|
||||||
lines.append("*Open Order:* `{open_order}` - `{sell_order_status}`")
|
lines.append("*Open Order:* `{open_order}` - `{exit_order_status}`")
|
||||||
else:
|
else:
|
||||||
lines.append("*Open Order:* `{open_order}`")
|
lines.append("*Open Order:* `{open_order}`")
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'close_rate_requested': ANY,
|
'close_rate_requested': ANY,
|
||||||
'sell_reason': ANY,
|
'sell_reason': ANY,
|
||||||
'exit_reason': ANY,
|
'exit_reason': ANY,
|
||||||
'sell_order_status': ANY,
|
'exit_order_status': ANY,
|
||||||
'min_rate': ANY,
|
'min_rate': ANY,
|
||||||
'max_rate': ANY,
|
'max_rate': ANY,
|
||||||
'strategy': ANY,
|
'strategy': ANY,
|
||||||
@ -150,7 +150,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'close_rate_requested': ANY,
|
'close_rate_requested': ANY,
|
||||||
'sell_reason': ANY,
|
'sell_reason': ANY,
|
||||||
'exit_reason': ANY,
|
'exit_reason': ANY,
|
||||||
'sell_order_status': ANY,
|
'exit_order_status': ANY,
|
||||||
'min_rate': ANY,
|
'min_rate': ANY,
|
||||||
'max_rate': ANY,
|
'max_rate': ANY,
|
||||||
'strategy': ANY,
|
'strategy': ANY,
|
||||||
|
@ -963,7 +963,7 @@ def test_api_status(botclient, mocker, ticker, fee, markets, is_short,
|
|||||||
'open_trade_value': open_trade_value,
|
'open_trade_value': open_trade_value,
|
||||||
'sell_reason': None,
|
'sell_reason': None,
|
||||||
'exit_reason': None,
|
'exit_reason': None,
|
||||||
'sell_order_status': None,
|
'exit_order_status': None,
|
||||||
'strategy': CURRENT_TEST_STRATEGY,
|
'strategy': CURRENT_TEST_STRATEGY,
|
||||||
'buy_tag': None,
|
'buy_tag': None,
|
||||||
'enter_tag': None,
|
'enter_tag': None,
|
||||||
@ -1164,7 +1164,7 @@ def test_api_forceentry(botclient, mocker, fee, endpoint):
|
|||||||
'open_trade_value': 0.24605460,
|
'open_trade_value': 0.24605460,
|
||||||
'sell_reason': None,
|
'sell_reason': None,
|
||||||
'exit_reason': None,
|
'exit_reason': None,
|
||||||
'sell_order_status': None,
|
'exit_order_status': None,
|
||||||
'strategy': CURRENT_TEST_STRATEGY,
|
'strategy': CURRENT_TEST_STRATEGY,
|
||||||
'buy_tag': None,
|
'buy_tag': None,
|
||||||
'enter_tag': None,
|
'enter_tag': None,
|
||||||
|
@ -199,7 +199,7 @@ def test_telegram_status(default_conf, update, mocker) -> None:
|
|||||||
'profit_ratio': -0.0059,
|
'profit_ratio': -0.0059,
|
||||||
'initial_stop_loss_abs': 1.098e-05,
|
'initial_stop_loss_abs': 1.098e-05,
|
||||||
'stop_loss_abs': 1.099e-05,
|
'stop_loss_abs': 1.099e-05,
|
||||||
'sell_order_status': None,
|
'exit_order_status': None,
|
||||||
'initial_stop_loss_ratio': -0.0005,
|
'initial_stop_loss_ratio': -0.0005,
|
||||||
'stoploss_current_dist': 1e-08,
|
'stoploss_current_dist': 1e-08,
|
||||||
'stoploss_current_dist_ratio': -0.0002,
|
'stoploss_current_dist_ratio': -0.0002,
|
||||||
|
@ -3014,7 +3014,7 @@ def test_handle_cancel_exit_limit(mocker, default_conf_usdt, fee) -> None:
|
|||||||
send_msg_mock.call_args_list[0][0][0]['reason'] = CANCEL_REASON['PARTIALLY_FILLED_KEEP_OPEN']
|
send_msg_mock.call_args_list[0][0][0]['reason'] = CANCEL_REASON['PARTIALLY_FILLED_KEEP_OPEN']
|
||||||
|
|
||||||
# Message should not be iterated again
|
# Message should not be iterated again
|
||||||
assert trade.sell_order_status == CANCEL_REASON['PARTIALLY_FILLED_KEEP_OPEN']
|
assert trade.exit_order_status == CANCEL_REASON['PARTIALLY_FILLED_KEEP_OPEN']
|
||||||
assert send_msg_mock.call_count == 1
|
assert send_msg_mock.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -1591,7 +1591,7 @@ def test_to_json(fee):
|
|||||||
'profit_abs': None,
|
'profit_abs': None,
|
||||||
'sell_reason': None,
|
'sell_reason': None,
|
||||||
'exit_reason': None,
|
'exit_reason': None,
|
||||||
'sell_order_status': None,
|
'exit_order_status': None,
|
||||||
'stop_loss_abs': None,
|
'stop_loss_abs': None,
|
||||||
'stop_loss_ratio': None,
|
'stop_loss_ratio': None,
|
||||||
'stop_loss_pct': None,
|
'stop_loss_pct': None,
|
||||||
@ -1678,7 +1678,7 @@ def test_to_json(fee):
|
|||||||
'open_trade_value': 12.33075,
|
'open_trade_value': 12.33075,
|
||||||
'sell_reason': None,
|
'sell_reason': None,
|
||||||
'exit_reason': None,
|
'exit_reason': None,
|
||||||
'sell_order_status': None,
|
'exit_order_status': None,
|
||||||
'strategy': None,
|
'strategy': None,
|
||||||
'buy_tag': 'buys_signal_001',
|
'buy_tag': 'buys_signal_001',
|
||||||
'enter_tag': 'buys_signal_001',
|
'enter_tag': 'buys_signal_001',
|
||||||
|
Loading…
Reference in New Issue
Block a user