Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
tef 2022-01-26 07:27:28 -05:00
commit efd18e6ebc
5 changed files with 54 additions and 6 deletions

1
SOL_USDT-5m.json Normal file

File diff suppressed because one or more lines are too long

40
freq_data_cleaner.py Normal file
View File

@ -0,0 +1,40 @@
import json
import datetime
import time
import os
import sys
from user_data.strategies.util import BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH, BACKTEST_YEAR, BACKTEST_MONTH_INDEX
def clean_json():
print("clean_json: json_path = " + BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
file = open(BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
list = []
data = json.load(file)
for datas in data:
unix = datas[0]/1000
unix = int(unix)
date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(unix)))
date = datetime.datetime.strptime(str(date), "%Y-%m-%d %H:%M:%S")
year = date.year
month = date.month
if year == int(BACKTEST_YEAR) and month == int(BACKTEST_MONTH_INDEX):
list.append(datas)
json_object = json.dumps(list)
file.close()
write_to_json(json_object)
def write_to_json(json_object):
print("write_to_json: json_path = " + BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
with open("temp.json", "w") as outfile:
outfile.write(json_object)
os.rename("temp.json", BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH)
if len(sys.argv) < 4:
exit("""Incorrect number of arguments.
python3 freq_data_cleaner.py [json_file] [month index] [year]
""")
else:
BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = sys.argv[1]
BACKTEST_MONTH_INDEX = sys.argv[2]
BACKTEST_YEAR = sys.argv[3]
clean_json()

View File

@ -18,6 +18,7 @@ import threading
from user_data.strategies.util import IS_BACKTEST, launcher, back_tester from user_data.strategies.util import IS_BACKTEST, launcher, back_tester
class Strategy002(IStrategy): class Strategy002(IStrategy):
""" """
Strategy 002 Strategy 002
@ -163,6 +164,7 @@ class Strategy002(IStrategy):
:return bool: When True is returned, then the buy-order is placed on the exchange. :return bool: When True is returned, then the buy-order is placed on the exchange.
False aborts the process False aborts the process
""" """
print("............................................................................"+str(current_time))
mode = "test" mode = "test"
coin = pair.split("/")[0] coin = pair.split("/")[0]
brain = "Freq_" + self.__class__.__name__ brain = "Freq_" + self.__class__.__name__
@ -172,3 +174,4 @@ class Strategy002(IStrategy):
threading.Thread(target=launcher, args=(mode, coin, brain)).start() threading.Thread(target=launcher, args=(mode, coin, brain)).start()
return True return True

View File

@ -1,9 +1,12 @@
import subprocess import subprocess
import threading import threading
BACKTEST_DOWNLOADED_JSON_DATA_FILE_PATH = ""
BACKTEST_YEAR = 2020
BACKTEST_MONTH_INDEX = 9
IS_BACKTEST = False IS_BACKTEST = False
WORKSPACE_PATH = "workspace2" if IS_BACKTEST else "workspace"
EXECUTION_PATH = "/root/workspace/execution/" EXECUTION_PATH = "/root/" + WORKSPACE_PATH + "/execution/"
def launcher(mode, coin, brain): def launcher(mode, coin, brain):
@ -13,5 +16,6 @@ def _perform_launcher(mode, coin, brain):
subprocess.call("python3 "+EXECUTION_PATH+"launcher.py " + mode + " " + coin + " " + brain, shell=True) subprocess.call("python3 "+EXECUTION_PATH+"launcher.py " + mode + " " + coin + " " + brain, shell=True)
def back_tester(date_time, coin, brain): def back_tester(date_time, coin, brain):
date_time = date_time.replace(" ", "#") date = str(date_time)
subprocess.call("python3 " +EXECUTION_PATH+ "back_tester.py " + date_time + " " + coin + " " + brain + "0.45 3", shell=True) date = date.replace(" ", "#")
subprocess.call("python3 "+ EXECUTION_PATH + "back_tester.py " + date + " " + coin + " " + brain + " 0.45 3", shell=True)