Fix 2 bugs in ROI calculation
This commit is contained in:
parent
298797cbfd
commit
a89c1da19f
@ -429,7 +429,7 @@ class Backtesting:
|
|||||||
# - (Expected abs profit - open_rate - open_fee) / (fee_close -1)
|
# - (Expected abs profit - open_rate - open_fee) / (fee_close -1)
|
||||||
roi_rate = trade.open_rate * roi / leverage
|
roi_rate = trade.open_rate * roi / leverage
|
||||||
open_fee_rate = side_1 * trade.open_rate * (1 + side_1 * trade.fee_open)
|
open_fee_rate = side_1 * trade.open_rate * (1 + side_1 * trade.fee_open)
|
||||||
close_rate = -side_1 * (roi_rate + open_fee_rate) / (trade.fee_close - side_1 * 1)
|
close_rate = -(roi_rate + open_fee_rate) / (trade.fee_close - side_1 * 1)
|
||||||
if is_short:
|
if is_short:
|
||||||
is_new_roi = sell_row[OPEN_IDX] < close_rate
|
is_new_roi = sell_row[OPEN_IDX] < close_rate
|
||||||
else:
|
else:
|
||||||
|
@ -869,7 +869,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
|||||||
force_stoploss=force_stoploss, low=low, high=high)
|
force_stoploss=force_stoploss, low=low, high=high)
|
||||||
|
|
||||||
# Set current rate to high for backtesting sell
|
# Set current rate to high for backtesting sell
|
||||||
current_rate = high or rate
|
current_rate = (low if trade.is_short else high) or rate
|
||||||
current_profit = trade.calc_profit_ratio(current_rate)
|
current_profit = trade.calc_profit_ratio(current_rate)
|
||||||
|
|
||||||
# if enter signal and ignore_roi is set, we don't need to evaluate min_roi.
|
# if enter signal and ignore_roi is set, we don't need to evaluate min_roi.
|
||||||
|
Loading…
Reference in New Issue
Block a user