Updated requested changes in PR #6545
This commit is contained in:
parent
3607538287
commit
b5f6f919b6
@ -542,6 +542,13 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
|
|
||||||
if stake_amount is not None and stake_amount > 0.0:
|
if stake_amount is not None and stake_amount > 0.0:
|
||||||
# We should increase our position
|
# We should increase our position
|
||||||
|
if self.strategy.max_entry_position_adjustment > -1:
|
||||||
|
count_of_entries = trade.nr_of_successful_entries
|
||||||
|
if count_of_entries > self.strategy.max_entry_position_adjustment:
|
||||||
|
logger.debug(f"Max adjustment entries for {trade.pair} has been reached.")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
logger.debug("Max adjustment entries is set to unlimited.")
|
||||||
self.execute_entry(trade.pair, stake_amount, price=current_entry_rate,
|
self.execute_entry(trade.pair, stake_amount, price=current_entry_rate,
|
||||||
trade=trade, is_short=trade.is_short)
|
trade=trade, is_short=trade.is_short)
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ def migrate_trades_and_orders_table(
|
|||||||
exit_reason = get_column_def(cols, 'sell_reason', get_column_def(cols, 'exit_reason', 'null'))
|
exit_reason = get_column_def(cols, 'sell_reason', get_column_def(cols, 'exit_reason', 'null'))
|
||||||
strategy = get_column_def(cols, 'strategy', 'null')
|
strategy = get_column_def(cols, 'strategy', 'null')
|
||||||
enter_tag = get_column_def(cols, 'buy_tag', get_column_def(cols, 'enter_tag', 'null'))
|
enter_tag = get_column_def(cols, 'buy_tag', get_column_def(cols, 'enter_tag', 'null'))
|
||||||
|
realized_profit = get_column_def(cols, 'realized_profit', '0.0')
|
||||||
|
|
||||||
trading_mode = get_column_def(cols, 'trading_mode', 'null')
|
trading_mode = get_column_def(cols, 'trading_mode', 'null')
|
||||||
|
|
||||||
@ -154,7 +155,7 @@ def migrate_trades_and_orders_table(
|
|||||||
max_rate, min_rate, exit_reason, exit_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, realized_profit
|
||||||
)
|
)
|
||||||
select id, lower(exchange), pair, {base_currency} base_currency,
|
select id, lower(exchange), pair, {base_currency} base_currency,
|
||||||
{stake_currency} stake_currency,
|
{stake_currency} stake_currency,
|
||||||
@ -180,7 +181,7 @@ def migrate_trades_and_orders_table(
|
|||||||
{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,
|
||||||
{is_short} is_short, {interest_rate} interest_rate,
|
{is_short} is_short, {interest_rate} interest_rate,
|
||||||
{funding_fees} funding_fees
|
{funding_fees} funding_fees, {realized_profit} realized_profit
|
||||||
from {trade_back_name}
|
from {trade_back_name}
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
@ -267,7 +268,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_trades, 'base_currency'):
|
if not has_column(cols_trades, 'realized_profit'):
|
||||||
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(
|
||||||
|
@ -5854,3 +5854,7 @@ def test_check_and_call_adjust_trade_position(mocker, default_conf_usdt, fee, ca
|
|||||||
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=10)
|
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=10)
|
||||||
freqtrade.process_open_trade_positions()
|
freqtrade.process_open_trade_positions()
|
||||||
assert log_has_re(r"Max adjustment entries for .* has been reached\.", caplog)
|
assert log_has_re(r"Max adjustment entries for .* has been reached\.", caplog)
|
||||||
|
|
||||||
|
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=-10)
|
||||||
|
freqtrade.process_open_trade_positions()
|
||||||
|
assert log_has_re(r"Processed exit sub trade for .*", caplog)
|
||||||
|
Loading…
Reference in New Issue
Block a user