added requested changes to reduced backtesting load and reduce services to start

This commit is contained in:
Gert Wohlgemuth 2018-06-11 23:11:44 -07:00
parent df33de3914
commit 1030a6171a
3 changed files with 22 additions and 60 deletions

View File

@ -371,33 +371,12 @@ def cron(event, context):
:return: :return:
""" """
import boto3 import boto3
from freqtrade.aws.tables import get_strategy_table
# if topic exists, we just reuse it # if topic exists, we just reuse it
client = boto3.client('sns') client = boto3.client('sns')
topic_arn = client.create_topic(Name=os.environ['topic'])['TopicArn'] topic_arn = client.create_topic(Name=os.environ['topic'])['TopicArn']
table = get_strategy_table()
response = table.scan()
def fetch(response, table):
"""
fetches all strategies from the server
technically code duplications
TODO refacture
:param response:
:param table:
:return:
"""
for i in response['Items']:
# fire a message to our queue
message = { message = {
"user": i['user'],
"name": i['name'],
"assets": i['assets'],
"stake_currency": i['stake_currency'],
"local": False, "local": False,
"refresh": True, "refresh": True,
"ticker": ['5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d'], "ticker": ['5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d'],
@ -417,19 +396,6 @@ def cron(event, context):
print(result) print(result)
if 'LastEvaluatedKey' in response:
return table.scan(
ExclusiveStartKey=response['LastEvaluatedKey']
)
else:
return {}
# do/while simulation
response = fetch(response, table)
while 'LastEvaluatedKey' in response:
response = fetch(response, table)
return { return {
"statusCode": 200 "statusCode": 200
} }

View File

@ -39,10 +39,6 @@ def names(event, context):
# map results and hide informations # map results and hide informations
data = list(map(lambda x: {'name': x['name'], 'public': x['public'], 'user': x['user']}, result)) data = list(map(lambda x: {'name': x['name'], 'public': x['public'], 'user': x['user']}, result))
# keep in a result object, so we can later add pagination to it
data = {
"result": data
}
return { return {
"headers": __HTTP_HEADERS__, "headers": __HTTP_HEADERS__,
"statusCode": 200, "statusCode": 200,

View File

@ -141,16 +141,16 @@ def get_trades(event, context):
# preparation for pagination # preparation for pagination
# TODO include in parameters an optional # TODO include in parameters an optional
# start key ExclusiveStartKey=response['LastEvaluatedKey'] # start key ExclusiveStartKey=response['LastEvaluatedKey']
#
data = { # data = {
"result": response['Items'], # "result": response['Items'],
"paginationKey": response.get('LastEvaluatedKey') # "paginationKey": response.get('LastEvaluatedKey')
} # }
return { return {
"headers": __HTTP_HEADERS__, "headers": __HTTP_HEADERS__,
"statusCode": response['ResponseMetadata']['HTTPStatusCode'], "statusCode": response['ResponseMetadata']['HTTPStatusCode'],
"body": json.dumps(data) "body": response['Items']
} }
else: else: