Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
VladKochetov007 committed Jun 3, 2021
1 parent d4e1d2e commit d6d9bf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 4 additions & 1 deletion quick_trade/quick_trade_tuner/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ def __init__(self,
def tune(
self,
your_trading_class,
backtest_kwargs: Dict[str, Any] = dict(plot=False, print_out=False, show=False)
**backtest_kwargs
) -> dict:
backtest_kwargs['plot'] = False
backtest_kwargs['show'] = False
backtest_kwargs['print_out'] = False
def best():
return defaultdict(best)

Expand Down
19 changes: 10 additions & 9 deletions quick_trade/trading_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def inverse_strategy(self, swap_tpop_take: bool = True, *args, **kwargs) -> util
def backtest(self,
deposit: float = 10_000.0,
bet: float = np.inf,
commission: float = 0.0,
commission_reuse: float = 0.0,
plot: bool = True,
print_out: bool = True,
column: str = 'Close',
Expand All @@ -711,7 +711,7 @@ def backtest(self,
testing the strategy.
:param deposit: start deposit.
:param bet: fixed bet to quick_trade. np.inf = all moneys.
:param commission: percentage commission (0 -- 100).
:param commission_reuse: percentage commission (0 -- 100).
:param plot: plotting.
:param print_out: printing.
:param column: column of dataframe to backtest
Expand Down Expand Up @@ -742,7 +742,7 @@ def backtest(self,
moneys_open_bet: float = deposit
money_start: float = deposit
oldsig = utils.EXIT
start_commission: float = commission
start_commission: float = commission_reuse

e: int
sig: utils.PREDICT_TYPE
Expand All @@ -767,15 +767,16 @@ def backtest(self,

if seted is not np.nan:
if oldsig != utils.EXIT:
commission = start_commission * 2
commission_reuse = 2
else:
commission = start_commission
commission_reuse = 1
if bet > deposit:
bet = deposit
open_price = data_column[e]
deposit -= bet * (commission / 100) * credit_lev
if bet > deposit:
bet = deposit
for i in range(commission_reuse):
deposit -= bet * (start_commission / 100) * credit_lev
if bet > deposit:
bet = deposit
moneys_open_bet = deposit
no_order = False
exit_take_stop = False
Expand Down Expand Up @@ -967,7 +968,7 @@ def multi_backtest(self,
new_trader._get_attr(strategy_name)(**strategy_kwargs)
new_trader.backtest(deposit=deposit / len(tickers),
bet=bet,
commission=commission,
commission_reuse=commission,
plot=False,
print_out=False,
column=column,
Expand Down

0 comments on commit d6d9bf3

Please sign in to comment.