Ejemplo n.º 1
0
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='')
Ejemplo n.º 2
0
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='')
Ejemplo n.º 3
0
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='账号未找到')
Ejemplo n.º 4
0
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='账号未找到')