diff --git a/user_data/strategies/Strategy002.py b/user_data/strategies/Strategy002.py index 2fc5cfce4..813a8ba1f 100644 --- a/user_data/strategies/Strategy002.py +++ b/user_data/strategies/Strategy002.py @@ -13,6 +13,9 @@ import freqtrade.vendor.qtpylib.indicators as qtpylib import numpy # noqa from datetime import datetime import subprocess +import threading + +from user_data.strategies.util import thread_executor, IS_BACKTEST, launcher, back_tester class Strategy002(IStrategy): @@ -162,6 +165,9 @@ class Strategy002(IStrategy): """ mode = "test" coin = pair.split("/")[0] - subprocess.call("python3 /root/workspace/execution/launcher.py " + mode + " " + coin, shell=True) + if IS_BACKTEST: + threading.Thread(target=back_tester, args=(current_time, coin)).start() + else: + threading.Thread(target=launcher, args=(mode, coin)).start() return True diff --git a/user_data/strategies/Strategy003.py b/user_data/strategies/Strategy003.py index 3856e9a50..2b64cdf15 100644 --- a/user_data/strategies/Strategy003.py +++ b/user_data/strategies/Strategy003.py @@ -1,5 +1,7 @@ # --- Do not remove these libs --- +import threading + from freqtrade.strategy.interface import IStrategy from typing import Dict, List from functools import reduce @@ -12,6 +14,9 @@ import numpy # noqa from datetime import datetime import subprocess +from user_data.strategies.util import IS_BACKTEST, back_tester, launcher + + class Strategy003(IStrategy): """ Strategy 003 @@ -175,5 +180,8 @@ class Strategy003(IStrategy): """ mode = "test" coin = pair.split("/")[0] - subprocess.call("python3 /root/workspace/execution/launcher.py " + mode + " " + coin, shell=True) + if IS_BACKTEST: + threading.Thread(target=back_tester, args=(current_time, coin)).start() + else: + threading.Thread(target=launcher, args=(mode, coin)).start() return True \ No newline at end of file diff --git a/user_data/strategies/Strategy004.py b/user_data/strategies/Strategy004.py index 3645b17dc..ef0b6b87f 100644 --- a/user_data/strategies/Strategy004.py +++ b/user_data/strategies/Strategy004.py @@ -1,4 +1,6 @@ # --- Do not remove these libs --- +import threading + from freqtrade.strategy import IStrategy from typing import Dict, List from functools import reduce @@ -9,6 +11,8 @@ import subprocess import talib.abstract as ta +from user_data.strategies.util import IS_BACKTEST, back_tester, launcher + class Strategy004(IStrategy): """ @@ -176,5 +180,8 @@ class Strategy004(IStrategy): """ mode = "test" coin = pair.split("/")[0] - subprocess.call("python3 /root/workspace/execution/launcher.py " + mode + " " + coin, shell=True) + if IS_BACKTEST: + threading.Thread(target=back_tester, args=(current_time, coin)).start() + else: + threading.Thread(target=launcher, args=(mode, coin)).start() return True diff --git a/user_data/strategies/util.py b/user_data/strategies/util.py new file mode 100644 index 000000000..5e0bb60ee --- /dev/null +++ b/user_data/strategies/util.py @@ -0,0 +1,11 @@ +import subprocess + +IS_BACKTEST = False + +EXECUTION_PATH = "/root/workspace2/execution/" + +def launcher(mode, coin): + subprocess.call("python3 "+EXECUTION_PATH+"launcher.py " + mode + " " + coin, shell=True) + +def back_tester(date_time, coin): + subprocess.call("python3 "+EXECUTION_PATH+"back_tester.py " + date_time + " " + coin, shell=True)