fixed some format issues and added better logging
This commit is contained in:
parent
beb45bc58f
commit
86de538d9e
@ -69,13 +69,13 @@ def backtest(event, context):
|
|||||||
if "Items" in response and len(response['Items']) > 0:
|
if "Items" in response and len(response['Items']) > 0:
|
||||||
|
|
||||||
print("backtesting from {} till {} for {} with {} vs {}".format(yesterday, today, name,
|
print("backtesting from {} till {} for {} with {} vs {}".format(yesterday, today, name,
|
||||||
response['Items'][0][
|
event['body'][
|
||||||
'stake_currency'],
|
'stake_currency'],
|
||||||
response['Items'][0]['assets']))
|
event['body']['asset']))
|
||||||
content = response['Items'][0]['content']
|
content = response['Items'][0]['content']
|
||||||
configuration = {
|
configuration = {
|
||||||
"max_open_trades": 1,
|
"max_open_trades": 1,
|
||||||
"stake_currency": response['Items'][0]['stake_currency'],
|
"stake_currency": event['body']['stake_currency'].upper(),
|
||||||
"stake_amount": 1,
|
"stake_amount": 1,
|
||||||
"fiat_display_currency": "USD",
|
"fiat_display_currency": "USD",
|
||||||
"unfilledtimeout": 600,
|
"unfilledtimeout": 600,
|
||||||
@ -88,9 +88,11 @@ def backtest(event, context):
|
|||||||
"enabled": True,
|
"enabled": True,
|
||||||
"key": "key",
|
"key": "key",
|
||||||
"secret": "secret",
|
"secret": "secret",
|
||||||
"pair_whitelist": list(
|
"pair_whitelist": [
|
||||||
map(lambda x: "{}/{}".format(x, response['Items'][0]['stake_currency']).upper(),
|
"{}/{}".format(event['body']['asset'].upper(),
|
||||||
response['Items'][0]['assets']))
|
event['body']['stake_currency']).upper(),
|
||||||
|
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"telegram": {
|
"telegram": {
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
@ -191,29 +193,32 @@ def cron(event, context):
|
|||||||
for i in response['Items']:
|
for i in response['Items']:
|
||||||
# fire a message to our queue
|
# fire a message to our queue
|
||||||
|
|
||||||
print(i)
|
for x in i['assets']:
|
||||||
message = {
|
|
||||||
"user": i['user'],
|
|
||||||
"name": i['name']
|
|
||||||
}
|
|
||||||
|
|
||||||
# triggered over html, let's provide
|
message = {
|
||||||
# a date range for the backtesting
|
"user": i['user'],
|
||||||
if 'pathParameters' in event:
|
"name": i['name'],
|
||||||
if 'from' in event['pathParameters']:
|
"asset": x,
|
||||||
message['from'] = event['pathParameters']['from']
|
"stake_currency": i['stake_currency']
|
||||||
if 'till' in event['pathParameters']:
|
}
|
||||||
message['till'] = event['pathParameters']['till']
|
|
||||||
|
|
||||||
serialized = json.dumps(message, use_decimal=True)
|
# triggered over html, let's provide
|
||||||
# submit item to queue for routing to the correct persistence
|
# a date range for the backtesting
|
||||||
|
if 'pathParameters' in event:
|
||||||
|
if 'from' in event['pathParameters']:
|
||||||
|
message['from'] = event['pathParameters']['from']
|
||||||
|
if 'till' in event['pathParameters']:
|
||||||
|
message['till'] = event['pathParameters']['till']
|
||||||
|
|
||||||
result = client.publish(
|
serialized = json.dumps(message, use_decimal=True)
|
||||||
TopicArn=topic_arn,
|
# submit item to queue for routing to the correct persistence
|
||||||
Message=json.dumps({'default': serialized}),
|
|
||||||
Subject="schedule backtesting",
|
result = client.publish(
|
||||||
MessageStructure='json'
|
TopicArn=topic_arn,
|
||||||
)
|
Message=json.dumps({'default': serialized}),
|
||||||
|
Subject="schedule backtesting",
|
||||||
|
MessageStructure='json'
|
||||||
|
)
|
||||||
|
|
||||||
if 'LastEvaluatedKey' in response:
|
if 'LastEvaluatedKey' in response:
|
||||||
return table.scan(
|
return table.scan(
|
||||||
|
@ -71,7 +71,9 @@ class MyFancyTestStrategy(IStrategy):
|
|||||||
"user": "GCU4LW2XXZW3A3FM2XZJTEJHNWHTWDKY2DIJLCZJ5ULVZ4K7LZ7D23TG",
|
"user": "GCU4LW2XXZW3A3FM2XZJTEJHNWHTWDKY2DIJLCZJ5ULVZ4K7LZ7D23TG",
|
||||||
"name": "MyFancyTestStrategy",
|
"name": "MyFancyTestStrategy",
|
||||||
"from": "20180401",
|
"from": "20180401",
|
||||||
"till": "20180501"
|
"till": "20180501",
|
||||||
|
"stake_currency": "usdt",
|
||||||
|
"asset": "ltc"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +165,9 @@ class MyFancyTestStrategy(IStrategy):
|
|||||||
# build sns request
|
# build sns request
|
||||||
request = {
|
request = {
|
||||||
"user": "GCU4LW2XXZW3A3FM2XZJTEJHNWHTWDKY2DIJLCZJ5ULVZ4K7LZ7D23TG",
|
"user": "GCU4LW2XXZW3A3FM2XZJTEJHNWHTWDKY2DIJLCZJ5ULVZ4K7LZ7D23TG",
|
||||||
"name": "MyFancyTestStrategy"
|
"name": "MyFancyTestStrategy",
|
||||||
|
"stake_currency": "usdt",
|
||||||
|
"asset": "ltc"
|
||||||
}
|
}
|
||||||
|
|
||||||
data = json.loads(backtest({
|
data = json.loads(backtest({
|
||||||
@ -184,9 +188,7 @@ class MyFancyTestStrategy(IStrategy):
|
|||||||
data = get_trades({
|
data = get_trades({
|
||||||
'pathParameters': {
|
'pathParameters': {
|
||||||
'user': "GCU4LW2XXZW3A3FM2XZJTEJHNWHTWDKY2DIJLCZJ5ULVZ4K7LZ7D23TG",
|
'user': "GCU4LW2XXZW3A3FM2XZJTEJHNWHTWDKY2DIJLCZJ5ULVZ4K7LZ7D23TG",
|
||||||
"name": "MyFancyTestStrategy",
|
"name": "MyFancyTestStrategy"
|
||||||
'stake': "USDT",
|
|
||||||
'asset': "{}".format(data[0]['pair'].split("/")[0])
|
|
||||||
}
|
}
|
||||||
}, {})['body']
|
}, {})['body']
|
||||||
print(data)
|
print(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user