def handler(request):
try:
print(f'Requested: {request.path_qs}')
_, symbol, price, volume = request.path_qs.split('/')
except ValueError:
return web.Response(status=500)
t0 = time.time() # for profiling
SHARED_MEMORY[symbol].append(price)
strength = STRATEGY_FUNC(SHARED_MEMORY, symbol, price, volume)
elapsed_time = time.time() - t0 # for profiling
# Send a signal
print(f'Analyzed {symbol} => {strength} ({elapsed_time:.4f})')
result = {
'symbol': symbol,
'price': price,
'strategy': ARGS['strategy'],
'strength': strength,
'stoploss': int(price) - 3000,
'elapsedTime': elapsed_time
}
return web.json_response(result)
评论列表
文章目录