Skip to content

Commit 7ac4a31

Browse files
committed
hold-trades only for live/dry runmodes.
1 parent 18ced08 commit 7ac4a31

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

NostalgiaForInfinityNext.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,8 @@ def bot_loop_start(self, **kwargs) -> None:
22422242
(e.g. gather some remote resource for comparison)
22432243
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
22442244
"""
2245-
self.load_hold_trades_config()
2245+
if self.config['runmode'].value in ('live', 'dry_run'):
2246+
self.load_hold_trades_config()
22462247
return super().bot_loop_start(**kwargs)
22472248

22482249
def get_ticker_indicator(self):
@@ -4090,34 +4091,36 @@ def confirm_trade_exit(self, pair: str, trade: "Trade", order_type: str, amount:
40904091
False aborts the process
40914092
"""
40924093
# Just to be sure our hold data is loaded, should be a no-op call after the first bot loop
4093-
self.load_hold_trades_config()
4094-
4095-
if not self.hold_trade_ids:
4096-
# We have no pairs we want to hold until profit, sell
4097-
return True
4098-
4099-
if trade.id not in self.hold_trade_ids:
4100-
# This pair is not on the list to hold until profit, sell
4101-
return True
4102-
4103-
trade_profit_ratio = self.hold_trade_ids[trade.id]
4104-
current_profit_ratio = trade.calc_profit_ratio(rate)
4105-
if sell_reason == "force_sell":
4106-
formatted_profit_ratio = "{}%".format(trade_profit_ratio * 100)
4107-
formatted_current_profit_ratio = "{}%".format(current_profit_ratio * 100)
4108-
log.warning(
4109-
"Force selling %s even though the current profit of %s < %s",
4110-
trade, formatted_current_profit_ratio, formatted_profit_ratio
4111-
)
4112-
return True
4113-
elif current_profit_ratio >= trade_profit_ratio:
4114-
# This pair is on the list to hold, and we reached minimum profit, sell
4094+
if self.config['runmode'].value in ('live', 'dry_run'):
4095+
self.load_hold_trades_config()
4096+
4097+
if not self.hold_trade_ids:
4098+
# We have no pairs we want to hold until profit, sell
4099+
return True
4100+
4101+
if trade.id not in self.hold_trade_ids:
4102+
# This pair is not on the list to hold until profit, sell
4103+
return True
4104+
4105+
trade_profit_ratio = self.hold_trade_ids[trade.id]
4106+
current_profit_ratio = trade.calc_profit_ratio(rate)
4107+
if sell_reason == "force_sell":
4108+
formatted_profit_ratio = "{}%".format(trade_profit_ratio * 100)
4109+
formatted_current_profit_ratio = "{}%".format(current_profit_ratio * 100)
4110+
log.warning(
4111+
"Force selling %s even though the current profit of %s < %s",
4112+
trade, formatted_current_profit_ratio, formatted_profit_ratio
4113+
)
4114+
return True
4115+
elif current_profit_ratio >= trade_profit_ratio:
4116+
# This pair is on the list to hold, and we reached minimum profit, sell
4117+
return True
4118+
4119+
# This pair is on the list to hold, and we haven't reached minimum profit, hold
4120+
return False
4121+
else:
41154122
return True
41164123

4117-
# This pair is on the list to hold, and we haven't reached minimum profit, hold
4118-
return False
4119-
4120-
41214124
# Elliot Wave Oscillator
41224125
def ewo(dataframe, sma1_length=5, sma2_length=35):
41234126
df = dataframe.copy()

0 commit comments

Comments
 (0)