added service to query aggregated trades
This commit is contained in:
parent
50dd33b35f
commit
b41dd0b790
@ -354,6 +354,7 @@ def cron(event, context):
|
|||||||
"days": day
|
"days": day
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print("submitting: {}".format(message))
|
||||||
serialized = json.dumps(message, use_decimal=True)
|
serialized = json.dumps(message, use_decimal=True)
|
||||||
# submit item to queue for routing to the correct persistence
|
# submit item to queue for routing to the correct persistence
|
||||||
|
|
||||||
@ -364,6 +365,8 @@ def cron(event, context):
|
|||||||
MessageStructure='json'
|
MessageStructure='json'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(result)
|
||||||
|
|
||||||
if 'LastEvaluatedKey' in response:
|
if 'LastEvaluatedKey' in response:
|
||||||
return table.scan(
|
return table.scan(
|
||||||
ExclusiveStartKey=response['LastEvaluatedKey']
|
ExclusiveStartKey=response['LastEvaluatedKey']
|
||||||
|
@ -43,6 +43,7 @@ def submit(event, context):
|
|||||||
"body": json.dumps(result)
|
"body": json.dumps(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_aggregated_trades(event, context):
|
def get_aggregated_trades(event, context):
|
||||||
"""
|
"""
|
||||||
returns the aggregated trades for the given key combination
|
returns the aggregated trades for the given key combination
|
||||||
@ -52,11 +53,46 @@ def get_aggregated_trades(event, context):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
assert 'pathParameters' in event
|
assert 'pathParameters' in event
|
||||||
assert 'user' in event['pathParameters']
|
|
||||||
assert 'name' in event['pathParameters']
|
|
||||||
assert 'ticker' in event['pathParameters']
|
assert 'ticker' in event['pathParameters']
|
||||||
assert 'days' in event['pathParameters']
|
assert 'days' in event['pathParameters']
|
||||||
|
|
||||||
|
table = get_trade_table()
|
||||||
|
|
||||||
|
response = table.query(
|
||||||
|
KeyConditionExpression=Key('id').eq(
|
||||||
|
"aggregate:{}:{}:{}:test".format(
|
||||||
|
"TOTAL",
|
||||||
|
event['pathParameters']['ticker'],
|
||||||
|
event['pathParameters']['days']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if "Items" in response and len(response['Items']) > 0:
|
||||||
|
|
||||||
|
# preparation for pagination
|
||||||
|
# TODO include in parameters an optional
|
||||||
|
# start key ExclusiveStartKey=response['LastEvaluatedKey']
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"result": response['Items'],
|
||||||
|
"paginationKey": response.get('LastEvaluatedKey')
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"statusCode": response['ResponseMetadata']['HTTPStatusCode'],
|
||||||
|
"body": json.dumps(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
"statusCode": 404,
|
||||||
|
"body": json.dumps({
|
||||||
|
"error": "sorry this query did not produce any results",
|
||||||
|
"event": event
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_trades(event, context):
|
def get_trades(event, context):
|
||||||
"""
|
"""
|
||||||
|
@ -105,25 +105,6 @@ functions:
|
|||||||
environment:
|
environment:
|
||||||
strategyTable: ${self:custom.strategyTable}
|
strategyTable: ${self:custom.strategyTable}
|
||||||
|
|
||||||
#TODO
|
|
||||||
#returns the performance for the given strategy
|
|
||||||
performance:
|
|
||||||
memorySize: 128
|
|
||||||
handler: freqtrade/aws/strategy.performance
|
|
||||||
events:
|
|
||||||
- http:
|
|
||||||
path: strategies/{user}/{name}/performance
|
|
||||||
method: get
|
|
||||||
cors: true
|
|
||||||
request:
|
|
||||||
parameter:
|
|
||||||
paths:
|
|
||||||
user: true
|
|
||||||
name: true
|
|
||||||
|
|
||||||
environment:
|
|
||||||
strategyTable: ${self:custom.strategyTable}
|
|
||||||
|
|
||||||
#returns the source code of this given strategy
|
#returns the source code of this given strategy
|
||||||
#unless it's private
|
#unless it's private
|
||||||
code:
|
code:
|
||||||
@ -169,7 +150,7 @@ functions:
|
|||||||
# loads all trades for a strategy and it's associated pairs
|
# loads all trades for a strategy and it's associated pairs
|
||||||
trades:
|
trades:
|
||||||
memorySize: 128
|
memorySize: 128
|
||||||
handler: freqtrade/aws/strategy.get_trades
|
handler: freqtrade/aws/trade.get_trades
|
||||||
events:
|
events:
|
||||||
- http:
|
- http:
|
||||||
path: strategies/{user}/{name}/{stake}/{asset}
|
path: strategies/{user}/{name}/{stake}/{asset}
|
||||||
@ -227,6 +208,24 @@ functions:
|
|||||||
environment:
|
environment:
|
||||||
tradeTable: ${self:custom.tradeTable}
|
tradeTable: ${self:custom.tradeTable}
|
||||||
|
|
||||||
|
# stores the received message in the trade table
|
||||||
|
trade-aggregate:
|
||||||
|
memorySize: 128
|
||||||
|
handler: freqtrade/aws/trade.get_aggregated_trades
|
||||||
|
|
||||||
|
events:
|
||||||
|
- http:
|
||||||
|
path: trades/aggregate/{ticker}/{days}
|
||||||
|
method: get
|
||||||
|
cors: true
|
||||||
|
request:
|
||||||
|
parameter:
|
||||||
|
paths:
|
||||||
|
ticker: true
|
||||||
|
days: true
|
||||||
|
environment:
|
||||||
|
tradeTable: ${self:custom.tradeTable}
|
||||||
|
|
||||||
#submits a new strategy to the system
|
#submits a new strategy to the system
|
||||||
submit_github:
|
submit_github:
|
||||||
memorySize: 128
|
memorySize: 128
|
||||||
|
Loading…
Reference in New Issue
Block a user