fixed some format issues and added better logging

This commit is contained in:
Gert Wohlgemuth 2018-05-24 16:58:09 -07:00
parent beb45bc58f
commit 86de538d9e
2 changed files with 38 additions and 31 deletions

View File

@ -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,10 +193,13 @@ 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 = { message = {
"user": i['user'], "user": i['user'],
"name": i['name'] "name": i['name'],
"asset": x,
"stake_currency": i['stake_currency']
} }
# triggered over html, let's provide # triggered over html, let's provide

View File

@ -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)