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:
"""
import boto3
from freqtrade.aws.tables import get_strategy_table
# if topic exists, we just reuse it
client = boto3.client('sns')
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 = {
"user": i['user'],
"name": i['name'],
"assets": i['assets'],
"stake_currency": i['stake_currency'],
"local": False,
"refresh": True,
"ticker": ['5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d'],
@ -417,19 +396,6 @@ def cron(event, context):
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 {
"statusCode": 200
}

View File

@ -39,10 +39,6 @@ def names(event, context):
# map results and hide informations
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 {
"headers": __HTTP_HEADERS__,
"statusCode": 200,

View File

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