From e3cccdfc0fdf8f6f1fe0b5c7b84fd5a2b15fab2d Mon Sep 17 00:00:00 2001 From: Muhammad Rifqi Fatchurrahman Putra Danar Date: Mon, 5 Apr 2021 07:31:07 +0700 Subject: [PATCH] ENH: Relax commission constraints for rebates (#300) * commission constraints for rebates * linter warning fix * assert linter warning --- backtesting/backtesting.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backtesting/backtesting.py b/backtesting/backtesting.py index ce1ef57c..edb7be01 100644 --- a/backtesting/backtesting.py +++ b/backtesting/backtesting.py @@ -664,7 +664,9 @@ class _Broker: def __init__(self, *, data, cash, commission, margin, trade_on_close, hedging, exclusive_orders, index): assert 0 < cash, f"cash should be >0, is {cash}" - assert 0 <= commission < .1, f"commission should be between 0-10%, is {commission}" + assert -.1 <= commission < .1, \ + ("commission should be between -10% " + f"(e.g. market-maker's rebates) and 10% (fees), is {commission}") assert 0 < margin <= 1, f"margin should be between 0 and 1, is {margin}" self._data: _Data = data self._cash = cash