From 6fa57da664db7ce05391341942a0f67a05a63194 Mon Sep 17 00:00:00 2001 From: Gert Wohlgemuth Date: Mon, 4 Jun 2018 14:30:00 -0700 Subject: [PATCH] fixed some minor issues --- freqtrade/aws/backtesting_lambda.py | 10 +++++----- freqtrade/tests/aws/test_strategy_lambda.py | 13 +++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/freqtrade/aws/backtesting_lambda.py b/freqtrade/aws/backtesting_lambda.py index 81e02ff94..bb64169dd 100644 --- a/freqtrade/aws/backtesting_lambda.py +++ b/freqtrade/aws/backtesting_lambda.py @@ -59,7 +59,7 @@ def backtest(event, context): ) till = datetime.datetime.today() - fromDate = till - datetime.timedelta(days=1) + fromDate = till - datetime.timedelta(days=90) if 'from' in event['body']: fromDate = datetime.datetime.strptime(event['body']['from'], '%Y%m%d') @@ -69,7 +69,7 @@ def backtest(event, context): try: if "Items" in response and len(response['Items']) > 0: - print("schedule backtesting from {} till {} for {} with {} vs {}".format(fromDate, till, name, + print("schedule back testing from {} till {} for {} with {} vs {}".format(fromDate, till, name, event['body'][ 'stake_currency'], event['body'][ @@ -129,7 +129,7 @@ def _submit_result_to_backend(data): """ print(data) try: - print(post("{}/trade".format(os.environ['BASE_URL']), data=data)) + print(post("{}/trade".format(os.environ.get('BASE_URL', 'http://freq.isaac.international/dev/trade')), data=data)) except Exception as e: print("submission ignored: {}".format(e)) @@ -171,7 +171,7 @@ def _generate_configuration(event, fromDate, name, response, till): "chat_id": "0" }, "initial_state": "running", - "datadir": os.environ("FREQ_DATA_DIR", tempfile.gettempdir()), + "datadir": tempfile.gettempdir(), "experimental": { "use_sell_signal": response['Items'][0]['use_sell'], "sell_profit_only": True @@ -183,7 +183,7 @@ def _generate_configuration(event, fromDate, name, response, till): "loglevel": logging.INFO, "strategy": "{}:{}".format(name, content), "timerange": "{}-{}".format(fromDate.strftime('%Y%m%d'), till.strftime('%Y%m%d')), - "refresh_pairs": True + "refresh_pairs": False # no longer required, we will maintain static files for the future } return configuration diff --git a/freqtrade/tests/aws/test_strategy_lambda.py b/freqtrade/tests/aws/test_strategy_lambda.py index 8afab16d3..8ecc0799b 100644 --- a/freqtrade/tests/aws/test_strategy_lambda.py +++ b/freqtrade/tests/aws/test_strategy_lambda.py @@ -63,15 +63,14 @@ class TestStrategy(IStrategy): "public": False } - # db should be empty - assert (len(json.loads(aws.names({}, {})['body']['result'])) == 0) # now we add an entry aws.submit({ "body": json.dumps(request) }, {}) # now we should have items - assert (len(json.loads(aws.names({}, {})['body']['result'])) == 1) + print(json.loads(aws.names({}, {})['body'])) + assert (len(json.loads(aws.names({}, {})['body'])['result']) == 1) # able to add a second strategy with the sample name, but different user @@ -87,7 +86,7 @@ class TestStrategy(IStrategy): "body": json.dumps(request) }, {}) - assert (len(json.loads(aws.names({}, {})['body']['result'])) == 2) + assert (len(json.loads(aws.names({}, {})['body'])['result']) == 2) # able to add a duplicated strategy, which should overwrite the existing strategy @@ -99,13 +98,11 @@ class TestStrategy(IStrategy): "public": True } - print(json.dumps(request)) - aws.submit({ "body": json.dumps(request) }, {}) - assert (len(json.loads(aws.names({}, {})['body'])) == 2) + assert (len(json.loads(aws.names({}, {})['body'])['result']) == 2) # we need to be able to get a strategy ( code cannot be included ) strategy = aws.get({'pathParameters': { @@ -131,7 +128,7 @@ class TestStrategy(IStrategy): print(code) # code should equal our initial content - #assert code == content + # assert code == content # we are not allowed to load a private strategy code = aws.code({'pathParameters': {