From d6d9bf39242c9e2a0a89d2276a1dda07aae99b54 Mon Sep 17 00:00:00 2001 From: VladKochetov007 Date: Thu, 3 Jun 2021 03:40:22 +0300 Subject: [PATCH] debug --- quick_trade/quick_trade_tuner/tuner.py | 5 ++++- quick_trade/trading_sys.py | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/quick_trade/quick_trade_tuner/tuner.py b/quick_trade/quick_trade_tuner/tuner.py index c7ef8432..1704b283 100644 --- a/quick_trade/quick_trade_tuner/tuner.py +++ b/quick_trade/quick_trade_tuner/tuner.py @@ -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) diff --git a/quick_trade/trading_sys.py b/quick_trade/trading_sys.py index daf54d54..51694d5c 100644 --- a/quick_trade/trading_sys.py +++ b/quick_trade/trading_sys.py @@ -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', @@ -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 @@ -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 @@ -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 @@ -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,