You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Increased entry price when selling while it decreases when buying.
Actual Behavior
No matter if it is a positive or negative commission, it is counted as a positive value.
For example, when 0 commission is set, the entry price is 5,429,749 for buying. (calculated with atr values)
When setting 0.04% commission, it becomes 5,431,921, which is 1.0004x than the 0 commission.
When setting -0.04%, the entry price stays the same as 5,431,921. This should be 5,427,577.1004(5,429,749*0.9996)?
For selling, 5,458,457 for both -0.0004 and 0.0004% commission, which is 1.0004x less than commission 0 for 5,460,642.
Steps to Reproduce
Create any strategy
place order with limit price.
run backtest with negative commision like -0.0001
run backtest with positive commision like 0.0001
compare the result and entry prices in _trade
Additional info
I see the code accepting negative commision til -10% but negative commision doent seem to be working.
class_Broker:
def__init__(self, *, data, cash, commission, margin,
trade_on_close, hedging, exclusive_orders, index):
assert0<cash, f"cash should be >0, is {cash}"assert-.1<=commission<.1, \
("commission should be between -10% "f"(e.g. market-maker's rebates) and 10% (fees), is {commission}")
Backtesting version: 0.3.3
I'm sorry if i am missing something for negative commission settings.
The text was updated successfully, but these errors were encountered:
@masafumimori
The problem is copysign function behavior, copysing(x,y) returns a float with the magnitude (absolute value) of x but the sign of y. The _adjusted_price method, which adjust the price, uses copysign and therefore always use the absolute value of commission
def_adjusted_price(self, size=None, price=None) ->float:
""" Long/short `price`, adjusted for commisions. In long positions, the adjusted price is a fraction higher, and vice versa. """return (priceorself.last_price) * (1+copysign(self._commission, size))
Expected Behavior
Increased entry price when selling while it decreases when buying.
Actual Behavior
No matter if it is a positive or negative commission, it is counted as a positive value.
For example, when 0 commission is set, the entry price is
5,429,749
for buying. (calculated with atr values)When setting 0.04% commission, it becomes
5,431,921
, which is 1.0004x than the 0 commission.When setting -0.04%, the entry price stays the same as
5,431,921
. This should be5,427,577.1004
(5,429,749*0.9996)?For selling,
5,458,457
for both -0.0004 and 0.0004% commission, which is 1.0004x less than commission 0 for5,460,642
.Steps to Reproduce
_trade
Additional info
I see the code accepting negative commision til -10% but negative commision doent seem to be working.
Backtesting version: 0.3.3
I'm sorry if i am missing something for negative commission settings.
The text was updated successfully, but these errors were encountered: