kernc/backtesting.py

CGPT5 proposed enhancements

オープン

#1,318 opened on 2025/10/05

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)Python (863 件のフォーク)batch import
good first issuehelp wanted

Repository metrics

Stars
 (4,387 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

Enhancement description

  1. Silent order cancellations → add warning with equity & margin context in _Broker._process_orders().
  2. Contingent SL/TP validation missing → ensure SL < entry < TP (or reverse for shorts) when trade is not None.
  3. Same-bar SL/TP ambiguity → replace deferred execution with deterministic rule (e.g., pessimistic fill).
  4. Division by zero in PL% → guard denominators (entry_price, total_invested) against 0 or NaN.
  5. Tiny Trade.close() overshoot → rounding to 1 unit may overshoot; document quantization behavior.
  6. Bankruptcy leaves open orders → clear self.orders when equity <= 0.
  7. Recursive reprocessing risk → replace _process_orders() recursion with while loop.
  8. Canceled proportional order warning → include timestamp, equity, and margin context in the warning.
  9. OHLC sanity checks → optionally assert High >= max(Open,Close) and Low <= min(Open,Close).
  10. Numeric index misdetection → improve timestamp inference (detect seconds vs. milliseconds).
  11. Equity backfill perf → replace pandas backfill with NumPy for large datasets.
  12. Commission config → expose risk_free_rate param and commission timing option ('entry'|'exit'|'both').
  13. Better Strategy param errors → fix spacing and suggest close matches using difflib.get_close_matches.
  14. Strategy.I() Series support → accept pandas Series; refine transpose logic.
  15. SL/TP helper methods → add move_sl_to_break_even() and trail_sl() convenience APIs.
  16. Commission impact option → allow open-trade P/L to include entry commission.
  17. Minor typos → fix “the the”, “leverge”, and clarify bullet in Strategy.sell.
  18. Type hints polish → tighten annotations for Trade, Order, Backtest.optimize.
  19. Order.repr verbosity → omit falsy booleans (e.g., contingent=False).
  20. Deprecation message spacing → add missing space before “Backtesting 0.2.0.”

コントリビューターガイド