예제 #1
0
파일: accounts.py 프로젝트: sopnic/ybk
def trade_account_update():
    ids = request.form.getlist('ids[]')
    try:
        trade_accounts = TradeAccount.query({'_id': {'$in': ids}})
        for ta in trade_accounts:
            update_trade_account(ta)
    except Exception as e:
        log.exception(str(e))
        return jsonify(status=500, reason=str(e))

    return jsonify(status=200, reason='')
예제 #2
0
파일: accounts.py 프로젝트: maocis/ybk
def trade_account_update():
    ids = request.form.getlist('ids[]')
    try:
        trade_accounts = TradeAccount.query({'_id': {'$in': ids}})
        for ta in trade_accounts:
            update_trade_account(ta)
    except Exception as e:
        log.exception(str(e))
        return jsonify(status=500, reason=str(e))

    return jsonify(status=200, reason='')
예제 #3
0
파일: accounts.py 프로젝트: maocis/ybk
def trade_account_refresh_status():
    account_id = request.form.get('account_id')
    ta = TradeAccount.query_one({'_id': account_id})
    if ta:
        try:
            update_trade_account(ta)
        except Exception as e:
            log.exception(str(e))
            return jsonify(status=500, reason=str(e))

        return jsonify(
            status=200,
            position=sorted([p.to_dict() for p in ta.position],
                            key=lambda p: p['symbol']),
            money=ta.money.to_dict(),
            orders=sorted([o.to_dict() for o in ta.orders],
                          key=lambda o: o['symbol']),
            order_status=sorted([o.to_dict() for o in ta.order_status],
                                key=lambda o: o['symbol']),
        )
    else:
        return jsonify(status=500, reason='账号未找到')
예제 #4
0
파일: accounts.py 프로젝트: sopnic/ybk
def trade_account_refresh_status():
    account_id = request.form.get('account_id')
    ta = TradeAccount.query_one({'_id': account_id})
    if ta:
        try:
            update_trade_account(ta)
        except Exception as e:
            log.exception(str(e))
            return jsonify(status=500,
                           reason=str(e))

        return jsonify(status=200,
                       position=sorted([p.to_dict() for p in ta.position],
                                       key=lambda p: p['symbol']),
                       money=ta.money.to_dict(),
                       orders=sorted([o.to_dict() for o in ta.orders],
                                     key=lambda o: o['symbol']),
                       order_status=sorted([o.to_dict()
                                            for o in ta.order_status],
                                           key=lambda o: o['symbol']),
                       )
    else:
        return jsonify(status=500,
                       reason='账号未找到')