chore: remove bt_open_open_trade_count_candle
it's no longer necessary if we support in-candle entries
This commit is contained in:
@@ -1488,7 +1488,6 @@ class Backtesting:
|
|||||||
# Reset open trade count for this candle
|
# Reset open trade count for this candle
|
||||||
# Critical to avoid exceeding max_open_trades in backtesting
|
# Critical to avoid exceeding max_open_trades in backtesting
|
||||||
# when timeframe-detail is used and trades close within the opening candle.
|
# when timeframe-detail is used and trades close within the opening candle.
|
||||||
LocalTrade.bt_open_open_trade_count_candle = LocalTrade.bt_open_open_trade_count
|
|
||||||
strategy_safe_wrapper(self.strategy.bot_loop_start, supress_error=True)(
|
strategy_safe_wrapper(self.strategy.bot_loop_start, supress_error=True)(
|
||||||
current_time=current_time
|
current_time=current_time
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -391,7 +391,6 @@ class LocalTrade:
|
|||||||
# Copy of trades_open - but indexed by pair
|
# Copy of trades_open - but indexed by pair
|
||||||
bt_trades_open_pp: dict[str, list["LocalTrade"]] = defaultdict(list)
|
bt_trades_open_pp: dict[str, list["LocalTrade"]] = defaultdict(list)
|
||||||
bt_open_open_trade_count: int = 0
|
bt_open_open_trade_count: int = 0
|
||||||
bt_open_open_trade_count_candle: int = 0
|
|
||||||
bt_total_profit: float = 0
|
bt_total_profit: float = 0
|
||||||
realized_profit: float = 0
|
realized_profit: float = 0
|
||||||
|
|
||||||
@@ -760,7 +759,6 @@ class LocalTrade:
|
|||||||
LocalTrade.bt_trades_open = []
|
LocalTrade.bt_trades_open = []
|
||||||
LocalTrade.bt_trades_open_pp = defaultdict(list)
|
LocalTrade.bt_trades_open_pp = defaultdict(list)
|
||||||
LocalTrade.bt_open_open_trade_count = 0
|
LocalTrade.bt_open_open_trade_count = 0
|
||||||
LocalTrade.bt_open_open_trade_count_candle = 0
|
|
||||||
LocalTrade.bt_total_profit = 0
|
LocalTrade.bt_total_profit = 0
|
||||||
|
|
||||||
def adjust_min_max_rates(self, current_price: float, current_price_low: float) -> None:
|
def adjust_min_max_rates(self, current_price: float, current_price_low: float) -> None:
|
||||||
@@ -1462,11 +1460,6 @@ class LocalTrade:
|
|||||||
LocalTrade.bt_trades_open.remove(trade)
|
LocalTrade.bt_trades_open.remove(trade)
|
||||||
LocalTrade.bt_trades_open_pp[trade.pair].remove(trade)
|
LocalTrade.bt_trades_open_pp[trade.pair].remove(trade)
|
||||||
LocalTrade.bt_open_open_trade_count -= 1
|
LocalTrade.bt_open_open_trade_count -= 1
|
||||||
if (trade.close_date_utc - trade.open_date_utc) > timedelta(minutes=trade.timeframe):
|
|
||||||
# Only subtract trades that are open for more than 1 candle
|
|
||||||
# To avoid exceeding max_open_trades.
|
|
||||||
# Must be reset at the start of every candle during backesting.
|
|
||||||
LocalTrade.bt_open_open_trade_count_candle -= 1
|
|
||||||
LocalTrade.bt_trades.append(trade)
|
LocalTrade.bt_trades.append(trade)
|
||||||
LocalTrade.bt_total_profit += trade.close_profit_abs
|
LocalTrade.bt_total_profit += trade.close_profit_abs
|
||||||
|
|
||||||
@@ -1476,7 +1469,6 @@ class LocalTrade:
|
|||||||
LocalTrade.bt_trades_open.append(trade)
|
LocalTrade.bt_trades_open.append(trade)
|
||||||
LocalTrade.bt_trades_open_pp[trade.pair].append(trade)
|
LocalTrade.bt_trades_open_pp[trade.pair].append(trade)
|
||||||
LocalTrade.bt_open_open_trade_count += 1
|
LocalTrade.bt_open_open_trade_count += 1
|
||||||
LocalTrade.bt_open_open_trade_count_candle += 1
|
|
||||||
else:
|
else:
|
||||||
LocalTrade.bt_trades.append(trade)
|
LocalTrade.bt_trades.append(trade)
|
||||||
|
|
||||||
@@ -1485,9 +1477,6 @@ class LocalTrade:
|
|||||||
LocalTrade.bt_trades_open.remove(trade)
|
LocalTrade.bt_trades_open.remove(trade)
|
||||||
LocalTrade.bt_trades_open_pp[trade.pair].remove(trade)
|
LocalTrade.bt_trades_open_pp[trade.pair].remove(trade)
|
||||||
LocalTrade.bt_open_open_trade_count -= 1
|
LocalTrade.bt_open_open_trade_count -= 1
|
||||||
# TODO: The below may have odd behavior in case of canceled entries
|
|
||||||
# It might need to be removed so the trade "counts" as open for this candle.
|
|
||||||
LocalTrade.bt_open_open_trade_count_candle -= 1
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_open_trades() -> list[Any]:
|
def get_open_trades() -> list[Any]:
|
||||||
|
|||||||
@@ -2145,7 +2145,6 @@ def test_Trade_object_idem():
|
|||||||
"bt_trades_open",
|
"bt_trades_open",
|
||||||
"bt_trades_open_pp",
|
"bt_trades_open_pp",
|
||||||
"bt_open_open_trade_count",
|
"bt_open_open_trade_count",
|
||||||
"bt_open_open_trade_count_candle",
|
|
||||||
"bt_total_profit",
|
"bt_total_profit",
|
||||||
"from_json",
|
"from_json",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user