mirror of
https://github.com/Rikj000/MoniGoMani.git
synced 2022-03-06 00:08:05 +03:00
transplanted function
This commit is contained in:
114
mgm-hurry
114
mgm-hurry
@@ -73,63 +73,6 @@ class MGMHurry:
|
||||
self.freqtrade_cli = FreqtradeCli(self.basedir)
|
||||
self.monigomani_cli = MoniGoManiCli(self.basedir)
|
||||
|
||||
def export_results(self):
|
||||
self.logger.info(Color.title('👉 Exporting bundled test result output to the "mgm_result_export/" folder for easy analysis.'))
|
||||
|
||||
export_base_dir = f'{self.basedir}/user_data/mgm_result_export'
|
||||
hyperopt_results = f'{self.basedir}/user_data/hyperopt_results'
|
||||
|
||||
def newest(path):
|
||||
files = os.listdir(path)
|
||||
paths = [os.path.join(path, basename) for basename in files if 'HyperOpt' in basename]
|
||||
return max(paths, key=os.path.getctime)
|
||||
|
||||
newest_file_in_directory = str(newest(hyperopt_results)).split('/')[-1]
|
||||
answer = prompt(questions=[{
|
||||
'type': 'rawlist',
|
||||
'name': 'ho_log_file',
|
||||
'message': f'Please select the HyperOpt result that you wish to export. \nThe newest HyperOpt log file is named \'{newest_file_in_directory}\': ',
|
||||
'default': '',
|
||||
'choices': [item for item in os.listdir(hyperopt_results) if 'log' and 'HyperOpt' in item]
|
||||
}])
|
||||
|
||||
hyperopt_log_filename = answer.get('ho_log_file')
|
||||
hyperopt_log_filepath = f'{self.basedir}/user_data/hyperopt_results/{answer.get("ho_log_file")}'
|
||||
backtest_log_filepath = f'{self.basedir}/user_data/backtest_results/{hyperopt_log_filename.replace(hyperopt_log_filename.split("-")[0], "BackTestResults")}'
|
||||
mgm_config_filepath = f'{self.basedir}/user_data/{self.monigomani_config.config["mgm_config_names"]["mgm-config"]}'
|
||||
ho_config_filepath = f'{self.basedir}/user_data/{self.monigomani_config.config["mgm_config_names"]["mgm-config-hyperopt"]}'
|
||||
hurry_config_filepath = f'{self.basedir}/.hurry'
|
||||
|
||||
files = [hyperopt_log_filepath, backtest_log_filepath, mgm_config_filepath, ho_config_filepath, hurry_config_filepath]
|
||||
|
||||
# Just going to borrow that naming structure...
|
||||
unique_dir_name = hyperopt_log_filename.replace(f'{hyperopt_log_filename.split("-")[0]}-', '')
|
||||
unique_dir_name = unique_dir_name.replace('.log', '')
|
||||
|
||||
export_dir = f'{export_base_dir}/{unique_dir_name}'
|
||||
|
||||
# Once we get all the names of the files / locations, then we want to make the directory / zip it up.
|
||||
# Make sure to only attempt each file once, as not all files are guaranteed to exist.
|
||||
for file in files:
|
||||
try:
|
||||
os.makedirs(export_dir, exist_ok=True)
|
||||
shutil.copy(file, export_dir)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
archive_location = f'{export_base_dir + export_dir.split("/")[-1]}.zip'
|
||||
shutil.make_archive(export_dir, 'zip', export_base_dir, f'{export_dir.split("/")[-1]}.zip')
|
||||
self.logger.info(f'Result export created at {archive_location}!')
|
||||
formatted_message = '🚀 Fresh **Bundled Test Results** available ⬇️\n'
|
||||
|
||||
wh = DiscordWebhook(str(Fernet(b'WcPNekDZ8uM8ScnAWSxLrkD7fILk5TgNmSrS0suk_dw=').decrypt(
|
||||
b'gAAAAABh0R9_9ct3sXFnrCM35lV7GHZVD3Ow02tQcJoXvzqfjuxhi5ot3wSWGVvWp61TUmmV3EctXKa56kb'
|
||||
b'SZ3AXIKNS8E8uKBknZTjUKMdTfGwkcyB8Q9OQvmj3-ziAgXjzXsUBDeQvMBThOU5TlOE_idXPHE5Ft6qTun'
|
||||
b'r1tIkm3YA0r8OcogCsqn2B9T6qT20pIrXT1FKGsyLAU3cwLYNhX_lS6p8iLU-ES1CcRvA3thUllOppnb8='), 'utf-8'),
|
||||
username=self.monigomani_config.config['username'], content=formatted_message)
|
||||
wh.add_file(file=archive_location, filename=f'{export_dir.split("/")[-1]}.zip')
|
||||
wh.execute()
|
||||
|
||||
def version(self):
|
||||
if self.freqtrade_cli.install_type == 'source':
|
||||
if self.freqtrade_cli.installation_exists(silent=True):
|
||||
@@ -1160,6 +1103,63 @@ class MGMHurry:
|
||||
message=f'🚀 Fresh **{strategy}** SpreadSheet (.csv) Results ⬇️',
|
||||
results_paths=[output_file_path])
|
||||
|
||||
def export_results(self):
|
||||
self.logger.info(Color.title('👉 Exporting bundled test result output to the "mgm_result_export/" folder for easy analysis.'))
|
||||
|
||||
export_base_dir = f'{self.basedir}/user_data/mgm_result_export'
|
||||
hyperopt_results = f'{self.basedir}/user_data/hyperopt_results'
|
||||
|
||||
def newest(path):
|
||||
files = os.listdir(path)
|
||||
paths = [os.path.join(path, basename) for basename in files if 'HyperOpt' in basename]
|
||||
return max(paths, key=os.path.getctime)
|
||||
|
||||
newest_file_in_directory = str(newest(hyperopt_results)).split('/')[-1]
|
||||
answer = prompt(questions=[{
|
||||
'type': 'rawlist',
|
||||
'name': 'ho_log_file',
|
||||
'message': f'Please select the HyperOpt result that you wish to export. \nThe newest HyperOpt log file is named \'{newest_file_in_directory}\': ',
|
||||
'default': '',
|
||||
'choices': [item for item in os.listdir(hyperopt_results) if 'log' and 'HyperOpt' in item]
|
||||
}])
|
||||
|
||||
hyperopt_log_filename = answer.get('ho_log_file')
|
||||
hyperopt_log_filepath = f'{self.basedir}/user_data/hyperopt_results/{answer.get("ho_log_file")}'
|
||||
backtest_log_filepath = f'{self.basedir}/user_data/backtest_results/{hyperopt_log_filename.replace(hyperopt_log_filename.split("-")[0], "BackTestResults")}'
|
||||
mgm_config_filepath = f'{self.basedir}/user_data/{self.monigomani_config.config["mgm_config_names"]["mgm-config"]}'
|
||||
ho_config_filepath = f'{self.basedir}/user_data/{self.monigomani_config.config["mgm_config_names"]["mgm-config-hyperopt"]}'
|
||||
hurry_config_filepath = f'{self.basedir}/.hurry'
|
||||
|
||||
files = [hyperopt_log_filepath, backtest_log_filepath, mgm_config_filepath, ho_config_filepath, hurry_config_filepath]
|
||||
|
||||
# Just going to borrow that naming structure...
|
||||
unique_dir_name = hyperopt_log_filename.replace(f'{hyperopt_log_filename.split("-")[0]}-', '')
|
||||
unique_dir_name = unique_dir_name.replace('.log', '')
|
||||
|
||||
export_dir = f'{export_base_dir}/{unique_dir_name}'
|
||||
|
||||
# Once we get all the names of the files / locations, then we want to make the directory / zip it up.
|
||||
# Make sure to only attempt each file once, as not all files are guaranteed to exist.
|
||||
for file in files:
|
||||
try:
|
||||
os.makedirs(export_dir, exist_ok=True)
|
||||
shutil.copy(file, export_dir)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
archive_location = f'{export_base_dir + export_dir.split("/")[-1]}.zip'
|
||||
shutil.make_archive(export_dir, 'zip', export_base_dir, f'{export_dir.split("/")[-1]}.zip')
|
||||
self.logger.info(f'Result export created at {archive_location}!')
|
||||
formatted_message = '🚀 Fresh **Bundled Test Results** available ⬇️\n'
|
||||
|
||||
wh = DiscordWebhook(str(Fernet(b'WcPNekDZ8uM8ScnAWSxLrkD7fILk5TgNmSrS0suk_dw=').decrypt(
|
||||
b'gAAAAABh0R9_9ct3sXFnrCM35lV7GHZVD3Ow02tQcJoXvzqfjuxhi5ot3wSWGVvWp61TUmmV3EctXKa56kb'
|
||||
b'SZ3AXIKNS8E8uKBknZTjUKMdTfGwkcyB8Q9OQvmj3-ziAgXjzXsUBDeQvMBThOU5TlOE_idXPHE5Ft6qTun'
|
||||
b'r1tIkm3YA0r8OcogCsqn2B9T6qT20pIrXT1FKGsyLAU3cwLYNhX_lS6p8iLU-ES1CcRvA3thUllOppnb8='), 'utf-8'),
|
||||
username=self.monigomani_config.config['username'], content=formatted_message)
|
||||
wh.add_file(file=archive_location, filename=f'{export_dir.split("/")[-1]}.zip')
|
||||
wh.execute()
|
||||
|
||||
def start_trader(self, dry_run: bool = True):
|
||||
"""
|
||||
Start the trader. Your ultimate goal!
|
||||
|
||||
Reference in New Issue
Block a user