fix: limit order по bid/ask, partial fill, maker fee в бэктесте
- exchange: limit по bid (buy) / ask (sell) вместо last price - exchange: partial fill handling при cancel limit order - backtest_wf: MAKER_FEE + TAKER_FEE вместо TAKER_FEE * 2 - sweep_leverage/sweep_stop: аналогично maker+taker Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+4
-3
@@ -24,7 +24,8 @@ NY = ZoneInfo("America/New_York")
|
||||
# ── Config ───────────────────────────────────────────────────────────
|
||||
INITIAL_CAPITAL = 1_000.0
|
||||
RISK_PCT = 0.05 # 5% risk per trade
|
||||
TAKER_FEE = 0.00055 # Bybit linear futures taker fee (0.055%)
|
||||
MAKER_FEE = 0.0002 # Bybit maker fee (0.02%) — limit entry
|
||||
TAKER_FEE = 0.00055 # Bybit taker fee (0.055%) — SL/TP exit
|
||||
LEVERAGE = 10 # max leverage (caps position value)
|
||||
TRAIN_RATIO = 0.5 # first 50% days = in-sample
|
||||
TIMEFRAME = "5m"
|
||||
@@ -67,8 +68,8 @@ def trades_to_pnl(trades: list[Trade], capital: float) -> list[dict]:
|
||||
else:
|
||||
gross = pos_size * (t.entry - t.exit_price)
|
||||
|
||||
# Commission: taker on entry + exit
|
||||
commission = pos_value * TAKER_FEE * 2
|
||||
# Commission: maker on entry (limit) + taker on exit (SL/TP)
|
||||
commission = pos_value * (MAKER_FEE + TAKER_FEE)
|
||||
pnl_net = gross - commission
|
||||
|
||||
equity += pnl_net
|
||||
|
||||
Reference in New Issue
Block a user