Пример #1
0
def position():
    nav = 'position'
    today = (datetime.utcnow() + timedelta(hours=8)).strftime('%Y-%m-%d')
    user = current_user._id
    num_collections = Position.num_collections(user)
    average_increase = Position.average_increase(user)
    market_value = Position.market_value(user)
    realized_profit = Position.realized_profit(user)
    unrealized_profit = Position.unrealized_profit(user)
    annual_profit = Position.annual_profit(user)
    position = Position.user_position(user)

    # charts
    pfs = ProfitLog.profits(user)
    pldates = [pf['date'].strftime('%Y-%m-%d') for pf in pfs]
    plvalues = [int(pf['profit']) for pf in pfs]

    exchanges = [{'value': n, 'text': n}
                 for n in sorted(ABBRS)]
    total_transactions = Transaction.user_total_transactions(user)
    transactions = Transaction.user_recent_transactions(
        user)
    for t in transactions:
        t.typecn = '买入' if t.type_ == 'buy' else '卖出'
    return render_template('user/position.html', **locals())
Пример #2
0
def transaction_list():
    offset = int(request.form.get('offset', 0))
    limit = int(request.form.get('limit', 10))
    total_transactions = Transaction.user_total_transactions(user)
    transactions = Transaction.user_recent_transactions(user, offset, limit)
    return jsonify(status=200,
                   total_transactions=total_transactions,
                   transactions=transactions)