Fixed: self.use_backslap = Bool on line97
If self.use_backslap = True Backslap executes If self.use_backslap = False Original Backtest Code executes
This commit is contained in:
parent
5aaf454f12
commit
4a39a754f4
@ -94,12 +94,12 @@ class Backtesting(object):
|
|||||||
self.np_sto: int = self.np_close # stops_triggered_on - Should be low, FT uses close
|
self.np_sto: int = self.np_close # stops_triggered_on - Should be low, FT uses close
|
||||||
self.np_sco: int = self.np_close # stops_calculated_on - Should be stop, FT uses close
|
self.np_sco: int = self.np_close # stops_calculated_on - Should be stop, FT uses close
|
||||||
|
|
||||||
self.use_backslap = True # Enable backslap
|
self.use_backslap = True # Enable backslap - if false Orginal code is executed.
|
||||||
self.debug = True # Main debug enable, very print heavy, enable 2 loops recommended
|
self.debug = True # Main debug enable, very print heavy, enable 2 loops recommended
|
||||||
self.debug_timing = False # Stages within Backslap
|
self.debug_timing = False # Stages within Backslap
|
||||||
self.debug_2loops = False # Limit each pair to two loops, useful when debugging
|
self.debug_2loops = False # Limit each pair to two loops, useful when debugging
|
||||||
self.debug_vector = True # Debug vector calcs
|
self.debug_vector = True # Debug vector calcs
|
||||||
self.debug_timing_main_loop = False # print overall timing per pair
|
self.debug_timing_main_loop = False # print overall timing per pair - works in Backtest and Backslap
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -245,18 +245,18 @@ class Backtesting(object):
|
|||||||
:return: DataFrame
|
:return: DataFrame
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
headers = ['date', 'buy', 'open', 'close', 'sell', 'high', 'low']
|
|
||||||
processed = args['processed']
|
|
||||||
max_open_trades = args.get('max_open_trades', 0)
|
|
||||||
realistic = args.get('realistic', False)
|
|
||||||
trades = []
|
|
||||||
trade_count_lock: Dict = {}
|
|
||||||
|
|
||||||
use_backslap = self.use_backslap
|
use_backslap = self.use_backslap
|
||||||
debug_timing = self.debug_timing_main_loop
|
debug_timing = self.debug_timing_main_loop
|
||||||
|
|
||||||
if use_backslap: # Use Back Slap code
|
if use_backslap: # Use Back Slap code
|
||||||
|
|
||||||
|
headers = ['date', 'buy', 'open', 'close', 'sell', 'high', 'low']
|
||||||
|
processed = args['processed']
|
||||||
|
max_open_trades = args.get('max_open_trades', 0)
|
||||||
|
realistic = args.get('realistic', False)
|
||||||
|
trades = []
|
||||||
|
trade_count_lock: Dict = {}
|
||||||
|
|
||||||
########################### Call out BSlap Loop instead of Original BT code
|
########################### Call out BSlap Loop instead of Original BT code
|
||||||
bslap_results: list = []
|
bslap_results: list = []
|
||||||
for pair, pair_data in processed.items():
|
for pair, pair_data in processed.items():
|
||||||
@ -304,6 +304,13 @@ class Backtesting(object):
|
|||||||
else: # use Original Back test code
|
else: # use Original Back test code
|
||||||
########################## Original BT loop
|
########################## Original BT loop
|
||||||
|
|
||||||
|
headers = ['date', 'buy', 'open', 'close', 'sell']
|
||||||
|
processed = args['processed']
|
||||||
|
max_open_trades = args.get('max_open_trades', 0)
|
||||||
|
realistic = args.get('realistic', False)
|
||||||
|
trades = []
|
||||||
|
trade_count_lock: Dict = {}
|
||||||
|
|
||||||
for pair, pair_data in processed.items():
|
for pair, pair_data in processed.items():
|
||||||
if debug_timing: # Start timer
|
if debug_timing: # Start timer
|
||||||
fl = self.s()
|
fl = self.s()
|
||||||
@ -1035,16 +1042,28 @@ class Backtesting(object):
|
|||||||
if self.config.get('export', False):
|
if self.config.get('export', False):
|
||||||
self._store_backtest_result(self.config.get('exportfilename'), results)
|
self._store_backtest_result(self.config.get('exportfilename'), results)
|
||||||
|
|
||||||
logger.info(
|
if self.use_backslap:
|
||||||
'\n====================================================== '
|
logger.info(
|
||||||
'BackSLAP REPORT'
|
'\n====================================================== '
|
||||||
' =======================================================\n'
|
'BackSLAP REPORT'
|
||||||
'%s',
|
' =======================================================\n'
|
||||||
self._generate_text_table(
|
'%s',
|
||||||
data,
|
self._generate_text_table(
|
||||||
results
|
data,
|
||||||
|
results
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
'\n================================================= '
|
||||||
|
'BACKTEST REPORT'
|
||||||
|
' ==================================================\n'
|
||||||
|
'%s',
|
||||||
|
self._generate_text_table(
|
||||||
|
data,
|
||||||
|
results
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
## TODO. Catch open trades for this report.
|
## TODO. Catch open trades for this report.
|
||||||
# logger.info(
|
# logger.info(
|
||||||
|
Loading…
Reference in New Issue
Block a user