method and restructuring enabled

This commit is contained in:
Bemhreth 2022-01-26 15:51:55 +03:00
parent 47018eb03e
commit d7f257282c
4 changed files with 27 additions and 17 deletions

View File

@ -15,7 +15,7 @@ from datetime import datetime
import subprocess import subprocess
import threading import threading
from user_data.strategies.util import IS_BACKTEST, launcher, back_tester from user_data.strategies.util import IS_BACKTEST, launcher, _perform_launcher
@ -168,10 +168,8 @@ class Strategy002(IStrategy):
mode = "test" mode = "test"
coin = pair.split("/")[0] coin = pair.split("/")[0]
brain = "Freq_" + self.__class__.__name__ brain = "Freq_" + self.__class__.__name__
if IS_BACKTEST: launcher(mode, current_time, coin, brain)
threading.Thread(target=back_tester, args=(current_time, coin, brain)).start()
else:
threading.Thread(target=launcher, args=(mode, coin, brain)).start()
return True return True

View File

@ -0,0 +1,8 @@
class Config:
BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = ""
BACKTEST_YEAR = 2020
BACKTEST_MONTH_INDEX = 9
IS_BACKTEST = False
WORKSPACE_PATH = "workspace2" if IS_BACKTEST else "workspace"
EXECUTION_PATH = "/root/" + WORKSPACE_PATH + "/execution/"
IS_PARRALER_EXECUTION = True

View File

@ -1,21 +1,25 @@
import subprocess import subprocess
import threading import threading
from config import Config
BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = "" def launcher(mode, coin, brain,date_time):
BACKTEST_YEAR = 2020 if Config.IS_BACKTEST:
BACKTEST_MONTH_INDEX = 9 if Config.IS_PARRALER_EXECUTION:
IS_BACKTEST = False threading.Thread(target=_perform_launcher, args=(mode, coin, brain)).start()
WORKSPACE_PATH = "workspace2" if IS_BACKTEST else "workspace" else:
EXECUTION_PATH = "/root/" + WORKSPACE_PATH + "/execution/" date = str(date_time)
date = date.replace(" ", "#")
subprocess.call("python3 "+ Config.EXECUTION_PATH + "back_tester.py " + date + " " + coin + " " + brain + " 0.45 3", shell=True)
def launcher(mode, coin, brain): else:
threading.Thread(target=_perform_launcher, args=(mode, coin, brain)).start() if Config.IS_PARRALER_EXECUTION:
threading.Thread(target=_perform_launcher, args=(mode, coin, brain)).start()
else:
subprocess.call("python3 "+Config.EXECUTION_PATH+"launcher.py " + mode + " " + coin + " " + brain, shell=True)
def _perform_launcher(mode, coin, brain): def _perform_launcher(mode, coin, brain):
subprocess.call("python3 "+EXECUTION_PATH+"launcher.py " + mode + " " + coin + " " + brain, shell=True) subprocess.call("python3 "+Config.EXECUTION_PATH+"launcher.py " + mode + " " + coin + " " + brain, shell=True)
def back_tester(date_time, coin, brain): def back_tester(date_time, coin, brain):
date = str(date_time) date = str(date_time)
date = date.replace(" ", "#") date = date.replace(" ", "#")
subprocess.call("python3 "+ EXECUTION_PATH + "back_tester.py " + date + " " + coin + " " + brain + " 0.45 3", shell=True) subprocess.call("python3 "+ Config.EXECUTION_PATH + "back_tester.py " + date + " " + coin + " " + brain + " 0.45 3", shell=True)