mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-05 22:00:25 +00:00
feat: support backtesting with cross configuration
This commit is contained in:
@@ -213,12 +213,17 @@ class Binance(Exchange):
|
||||
mm_ex_1: float = 0.0
|
||||
upnl_ex_1: float = 0.0
|
||||
pairs = [trade.pair for trade in open_trades]
|
||||
funding_rates = self.fetch_funding_rates(pairs)
|
||||
if self._config["runmode"] in ("live", "dry_run"):
|
||||
funding_rates = self.fetch_funding_rates(pairs)
|
||||
for trade in open_trades:
|
||||
if trade.pair == pair:
|
||||
# Only "other" trades are considered
|
||||
continue
|
||||
mark_price = funding_rates[trade.pair]["markPrice"]
|
||||
if self._config["runmode"] in ("live", "dry_run"):
|
||||
mark_price = funding_rates[trade.pair]["markPrice"]
|
||||
else:
|
||||
# Fall back to open rate for backtesting
|
||||
mark_price = trade.open_rate
|
||||
mm_ratio1, maint_amnt1 = self.get_maintenance_ratio_and_amt(
|
||||
trade.pair, trade.stake_amount
|
||||
)
|
||||
@@ -226,6 +231,7 @@ class Binance(Exchange):
|
||||
mm_ex_1 += maint_margin
|
||||
|
||||
upnl_ex_1 += trade.amount * mark_price - trade.amount * trade.open_rate
|
||||
|
||||
cross_vars = upnl_ex_1 - mm_ex_1
|
||||
|
||||
side_1 = -1 if is_short else 1
|
||||
|
||||
Reference in New Issue
Block a user