server.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:yQuant 作者: yoonbae81 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号