Merge pull request #9 from tef-github/mathod_for_parraler_execution
Mathod for parraler execution
This commit is contained in:
commit
b7147632dc
@ -12,11 +12,9 @@ import talib.abstract as ta
|
|||||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
import numpy # noqa
|
import numpy # noqa
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import subprocess
|
|
||||||
import threading
|
|
||||||
|
|
||||||
from user_data.strategies.util import IS_BACKTEST, launcher, back_tester
|
|
||||||
|
|
||||||
|
from user_data.strategies.util import execute, back_test
|
||||||
|
from config import Config
|
||||||
|
|
||||||
|
|
||||||
class Strategy002(IStrategy):
|
class Strategy002(IStrategy):
|
||||||
@ -168,10 +166,11 @@ 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:
|
if Config.IS_BACKTEST:
|
||||||
threading.Thread(target=back_tester, args=(current_time, coin, brain)).start()
|
back_test(current_time, coin, brain)
|
||||||
else:
|
else:
|
||||||
threading.Thread(target=launcher, args=(mode, coin, brain)).start()
|
execute(mode, coin, brain)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ import numpy # noqa
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from user_data.strategies.util import IS_BACKTEST, back_tester, launcher
|
from user_data.strategies.util import back_test, execute
|
||||||
|
from config import Config
|
||||||
|
|
||||||
|
|
||||||
class Strategy003(IStrategy):
|
class Strategy003(IStrategy):
|
||||||
@ -181,8 +182,8 @@ class Strategy003(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:
|
if Config.IS_BACKTEST:
|
||||||
threading.Thread(target=back_tester, args=(current_time, coin, brain)).start()
|
back_test(current_time, coin, brain)
|
||||||
else:
|
else:
|
||||||
threading.Thread(target=launcher, args=(mode, coin, brain)).start()
|
execute(mode, coin, brain)
|
||||||
return True
|
return True
|
@ -7,12 +7,11 @@ from functools import reduce
|
|||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import subprocess
|
|
||||||
|
|
||||||
import talib.abstract as ta
|
import talib.abstract as ta
|
||||||
|
|
||||||
from user_data.strategies.util import IS_BACKTEST, back_tester, launcher
|
from user_data.strategies.util import back_test, execute
|
||||||
|
from config import Config
|
||||||
|
|
||||||
class Strategy004(IStrategy):
|
class Strategy004(IStrategy):
|
||||||
"""
|
"""
|
||||||
@ -181,8 +180,8 @@ class Strategy004(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:
|
if Config.IS_BACKTEST:
|
||||||
threading.Thread(target=back_tester, args=(current_time, coin, brain)).start()
|
back_test(current_time, coin, brain)
|
||||||
else:
|
else:
|
||||||
threading.Thread(target=launcher, args=(mode, coin, brain)).start()
|
execute(mode, coin, brain)
|
||||||
return True
|
return True
|
||||||
|
8
user_data/strategies/config.py
Normal file
8
user_data/strategies/config.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class Config:
|
||||||
|
BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = ""
|
||||||
|
BACKTEST_YEAR = 2020
|
||||||
|
BACKTEST_MONTH_INDEX = 9
|
||||||
|
IS_BACKTEST = True
|
||||||
|
WORKSPACE_PATH = "workspace2" if IS_BACKTEST else "workspace"
|
||||||
|
EXECUTION_PATH = "/root/" + WORKSPACE_PATH + "/execution/"
|
||||||
|
IS_PARRALER_EXECUTION = False
|
@ -3,11 +3,10 @@ import datetime
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from user_data.strategies.util import BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH, BACKTEST_YEAR, BACKTEST_MONTH_INDEX
|
from config import Config
|
||||||
|
|
||||||
def clean_json():
|
def clean_json():
|
||||||
print("clean_json: json_path = " + BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
print("clean_json: json_path = " + Config.BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
||||||
file = open(BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
file = open(Config.BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
||||||
list = []
|
list = []
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
for datas in data:
|
for datas in data:
|
||||||
@ -17,24 +16,24 @@ def clean_json():
|
|||||||
date = datetime.datetime.strptime(str(date), "%Y-%m-%d %H:%M:%S")
|
date = datetime.datetime.strptime(str(date), "%Y-%m-%d %H:%M:%S")
|
||||||
year = date.year
|
year = date.year
|
||||||
month = date.month
|
month = date.month
|
||||||
if year == int(BACKTEST_YEAR) and month == int(BACKTEST_MONTH_INDEX):
|
if year == int(Config.BACKTEST_YEAR) and month == int(Config.BACKTEST_MONTH_INDEX):
|
||||||
list.append(datas)
|
list.append(datas)
|
||||||
json_object = json.dumps(list)
|
json_object = json.dumps(list)
|
||||||
file.close()
|
file.close()
|
||||||
write_to_json(json_object)
|
write_to_json(json_object)
|
||||||
|
|
||||||
def write_to_json(json_object):
|
def write_to_json(json_object):
|
||||||
print("write_to_json: json_path = " + BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
print("write_to_json: json_path = " + Config.BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
||||||
with open("temp.json", "w") as outfile:
|
with open("temp.json", "w") as outfile:
|
||||||
outfile.write(json_object)
|
outfile.write(json_object)
|
||||||
os.rename("temp.json", BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
os.rename("temp.json", Config.BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
|
||||||
|
|
||||||
if len(sys.argv) < 4:
|
if len(sys.argv) < 4:
|
||||||
exit("""Incorrect number of arguments.
|
exit("""Incorrect number of arguments.
|
||||||
python3 freq_data_cleaner.py [json_file] [month index] [year]
|
python3 freq_data_cleaner.py [json_file] [month index] [year]
|
||||||
""")
|
""")
|
||||||
else:
|
else:
|
||||||
BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = sys.argv[1]
|
Config.BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = sys.argv[1]
|
||||||
BACKTEST_MONTH_INDEX = sys.argv[2]
|
Config.BACKTEST_MONTH_INDEX = sys.argv[2]
|
||||||
BACKTEST_YEAR = sys.argv[3]
|
Config.BACKTEST_YEAR = sys.argv[3]
|
||||||
clean_json()
|
clean_json()
|
@ -1,21 +1,23 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
|
from user_data.strategies.config import Config
|
||||||
|
|
||||||
BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = ""
|
def execute(mode, coin, brain):
|
||||||
BACKTEST_YEAR = 2020
|
if Config.IS_PARRALER_EXECUTION:
|
||||||
BACKTEST_MONTH_INDEX = 9
|
threading.Thread(target=_perform_execute, args=(mode, coin, brain)).start()
|
||||||
IS_BACKTEST = False
|
else:
|
||||||
WORKSPACE_PATH = "workspace2" if IS_BACKTEST else "workspace"
|
_perform_execute(mode, coin, brain)
|
||||||
EXECUTION_PATH = "/root/" + WORKSPACE_PATH + "/execution/"
|
|
||||||
|
|
||||||
|
def _perform_execute(mode, coin, brain):
|
||||||
|
subprocess.call("python3 "+Config.EXECUTION_PATH+"executeer.py " + mode + " " + coin + " " + brain, shell=True)
|
||||||
|
|
||||||
def launcher(mode, coin, brain):
|
def _perform_back_test(date_time, coin, brain):
|
||||||
threading.Thread(target=_perform_launcher, args=(mode, coin, brain)).start()
|
|
||||||
|
|
||||||
def _perform_launcher(mode, coin, brain):
|
|
||||||
subprocess.call("python3 "+EXECUTION_PATH+"launcher.py " + mode + " " + coin + " " + brain, shell=True)
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
def back_test(date_time, coin, brain):
|
||||||
|
if Config.IS_PARRALER_EXECUTION:
|
||||||
|
threading.Thread(target=_perform_back_test, args=(coin, brain, date_time)).start()
|
||||||
|
else:
|
||||||
|
_perform_back_test(date_time, coin, brain)
|
Loading…
Reference in New Issue
Block a user