From b5a67d44d3232ef8dbc66126ea8d35cf65372eec Mon Sep 17 00:00:00 2001 From: Gert Wohlgemuth Date: Tue, 5 Jun 2018 17:22:18 -0700 Subject: [PATCH] added support for more metadata in the strategy --- freqtrade/aws/backtesting_lambda.py | 2 +- freqtrade/aws/strategy.py | 1 - freqtrade/aws/trade.py | 21 +++++++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/freqtrade/aws/backtesting_lambda.py b/freqtrade/aws/backtesting_lambda.py index c3ddea76e..d4fe6824a 100644 --- a/freqtrade/aws/backtesting_lambda.py +++ b/freqtrade/aws/backtesting_lambda.py @@ -215,7 +215,7 @@ def _store_aggregated_data(interval, name, result, timerange, user): "losses": row[6], "wins": row[5], "duration": row[4], - "profit_percent": row[2], + "profit_percent": row[2] } print(data) diff --git a/freqtrade/aws/strategy.py b/freqtrade/aws/strategy.py index 74d5b425d..c68af6835 100644 --- a/freqtrade/aws/strategy.py +++ b/freqtrade/aws/strategy.py @@ -199,7 +199,6 @@ def __evaluate(data): data['type'] = "strategy" data['roi'] = strat.minimal_roi data['stoploss'] = strat.stoploss - data['ticker'] = strat.ticker_interval # ensure that the modified file is saved data['content'] = urlsafe_b64encode(strategy.encode('utf-8')) diff --git a/freqtrade/aws/trade.py b/freqtrade/aws/trade.py index 6a4f3c6a9..b392d7e87 100644 --- a/freqtrade/aws/trade.py +++ b/freqtrade/aws/trade.py @@ -1,7 +1,7 @@ import boto3 import simplejson as json import os -from freqtrade.aws.tables import get_trade_table +from freqtrade.aws.tables import get_trade_table, get_strategy_table from boto3.dynamodb.conditions import Key, Attr @@ -15,7 +15,24 @@ def store(event, context): for x in event['Records']: if 'Sns' in x and 'Message' in x['Sns']: data = json.loads(x['Sns']['Message'], use_decimal=True) - get_trade_table().put_item(Item=data) + + table = get_strategy_table() + + response = table.query( + KeyConditionExpression=Key('user').eq(data['user']) & + Key('name').eq(data['strategy']) + ) + + if "Items" in response and len(response['Items']) > 0: + item = response['Items'][0] + + data['strategy'] = { + "name": item['name'], + "user": item['user'], + "public": item['public'] + } + + get_trade_table().put_item(Item=data) def submit(event, context):