minor optimizations

This commit is contained in:
Gert Wohlgemuth 2018-06-04 14:55:19 -07:00
parent 6fa57da664
commit 536e78bff5

View File

@ -4,16 +4,11 @@ import os
import tempfile import tempfile
from base64 import urlsafe_b64encode from base64 import urlsafe_b64encode
import boto3
import simplejson as json import simplejson as json
from boto3.dynamodb.conditions import Key
from freqtrade.aws.tables import get_strategy_table
from freqtrade.optimize.backtesting import Backtesting from freqtrade.optimize.backtesting import Backtesting
from requests import post from requests import post
db = boto3.resource('dynamodb')
def backtest(event, context): def backtest(event, context):
""" """
@ -41,6 +36,8 @@ def backtest(event, context):
:return: :return:
no return no return
""" """
from boto3.dynamodb.conditions import Key
from freqtrade.aws.tables import get_strategy_table
if 'Records' in event: if 'Records' in event:
for x in event['Records']: for x in event['Records']:
@ -70,10 +67,10 @@ def backtest(event, context):
if "Items" in response and len(response['Items']) > 0: if "Items" in response and len(response['Items']) > 0:
print("schedule back testing from {} till {} for {} with {} vs {}".format(fromDate, till, name, print("schedule back testing from {} till {} for {} with {} vs {}".format(fromDate, till, name,
event['body'][ event['body'][
'stake_currency'], 'stake_currency'],
event['body'][ event['body'][
'assets'])) 'assets']))
configuration = _generate_configuration(event, fromDate, name, response, till) configuration = _generate_configuration(event, fromDate, name, response, till)
print("configuration: \n{}\n".format( print("configuration: \n{}\n".format(
@ -129,7 +126,8 @@ def _submit_result_to_backend(data):
""" """
print(data) print(data)
try: try:
print(post("{}/trade".format(os.environ.get('BASE_URL', 'http://freq.isaac.international/dev/trade')), data=data)) print(
post("{}/trade".format(os.environ.get('BASE_URL', 'http://freq.isaac.international/dev/trade')), data=data))
except Exception as e: except Exception as e:
print("submission ignored: {}".format(e)) print("submission ignored: {}".format(e))
@ -198,6 +196,8 @@ def cron(event, context):
:param context: :param context:
:return: :return:
""" """
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')