diff --git a/.gitignore b/.gitignore index aeb7b36..7cbe8f7 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ parallel.py tmp pypy* .pytest_cache +.idea/ diff --git a/cryptoalgotrading/cryptoalgotrading.py b/cryptoalgotrading/cryptoalgotrading.py index 490e5d7..dbb7415 100644 --- a/cryptoalgotrading/cryptoalgotrading.py +++ b/cryptoalgotrading/cryptoalgotrading.py @@ -51,7 +51,7 @@ def signal_handler(sig, frame): simplefilter(action='ignore', category=FutureWarning) -#@safe +@safe def is_time_to_exit(data, funcs, smas=var.default_smas, @@ -85,7 +85,7 @@ def is_time_to_exit(data, return False -#@safe +@safe def is_time_to_buy(data, funcs, smas=var.default_smas, diff --git a/cryptoalgotrading/var.py b/cryptoalgotrading/var.py index beea1c7..b21b18d 100644 --- a/cryptoalgotrading/var.py +++ b/cryptoalgotrading/var.py @@ -7,7 +7,7 @@ framework if user wants to use DB and Exchanges' credentials. """ -from os import environ +from os import environ, getenv #import lib_bittrex log = True @@ -16,33 +16,19 @@ # DATABASE VARIABLES # Best option should be define vars on system # and then get environment variables. -try: - db_user = environ['DB_USER'] - db_password = environ['DB_PASSWD'] - db_name = environ['DB_NAME'] - -except Exception as e: - print(f"Could not use environment user and password variables-> {e}") - db_user = "user" - db_password = "passwd" - db_name = "bd" - -if 'DATA_DIR' in environ: - data_dir = environ['DATA_DIR'] -else: - data_dir = "." - -if 'LOGS_DIR' in environ: - logs_dir = environ['LOGS_DIR'] -else: - logs_dir = "." +db_user = getenv('DB_USER') or "user" +db_password = getenv('DB_PASSWD') or "passwd" +db_name = getenv('DB_NAME') or "bd" + +data_dir = getenv('DATA_DIR') or "." +logs_dir = getenv('LOGS_DIR') or "." LOG_FILENAME = logs_dir + '/indicators.log' fig_dir = "figs/" -db_host = 'localhost' -db_port = 8086 +db_host = getenv('db_host') or 'localhost' +db_port = getenv('db_port') or 8086 # interval must be coincident with Influxdb intervals. default_interval = '10m' @@ -61,12 +47,8 @@ exchange = 'bittrex' -try: - ky = environ['API_KEY'] - sct= environ['API_SECRET'] -except Exception as e: - print(f"Could not use environment variables for key and secret->{e}") - #pass +ky = getenv('API_KEY') or "" +sct= getenv('API_SECRET') or "" # Add API Key and API Secret as variables if needed. #try: