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='')
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='账号未找到')
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='账号未找到')