added requested changes to reduced backtesting load and reduce services to start
This commit is contained in:
parent
df33de3914
commit
1030a6171a
@ -371,64 +371,30 @@ 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()
|
message = {
|
||||||
response = table.scan()
|
"local": False,
|
||||||
|
"refresh": True,
|
||||||
|
"ticker": ['5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d'],
|
||||||
|
"days": [1, 2, 3, 4, 5, 6, 7, 14, 30, 90]
|
||||||
|
}
|
||||||
|
|
||||||
def fetch(response, table):
|
print("submitting: {}".format(message))
|
||||||
"""
|
serialized = json.dumps(message, use_decimal=True)
|
||||||
fetches all strategies from the server
|
# submit item to queue for routing to the correct persistence
|
||||||
technically code duplications
|
|
||||||
TODO refacture
|
|
||||||
:param response:
|
|
||||||
:param table:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
|
|
||||||
for i in response['Items']:
|
result = client.publish(
|
||||||
# fire a message to our queue
|
TopicArn=topic_arn,
|
||||||
|
Message=json.dumps({'default': serialized}),
|
||||||
|
Subject="schedule",
|
||||||
|
MessageStructure='json'
|
||||||
|
)
|
||||||
|
|
||||||
message = {
|
print(result)
|
||||||
"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'],
|
|
||||||
"days": [1, 2, 3, 4, 5, 6, 7, 14, 30, 90]
|
|
||||||
}
|
|
||||||
|
|
||||||
print("submitting: {}".format(message))
|
|
||||||
serialized = json.dumps(message, use_decimal=True)
|
|
||||||
# submit item to queue for routing to the correct persistence
|
|
||||||
|
|
||||||
result = client.publish(
|
|
||||||
TopicArn=topic_arn,
|
|
||||||
Message=json.dumps({'default': serialized}),
|
|
||||||
Subject="schedule",
|
|
||||||
MessageStructure='json'
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -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,
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user