Esempio n. 1
0
def open(port, stock):
    """ List the open positions and trades """
    sortby = request.args.get('sortby')
    result = Log.get_open_positions(port=port, stock=stock)
    if not result.success:
        flash(result.message, result.severity)
        result.message = []
    return render_template('open.html', open=_sort(result.message, sortby), port=port, stock=stock)
Esempio n. 2
0
def allopen(port):
    """ List the positions in this port """
    sortby = request.args.get('sortby')
    open = Log.get_open_positions(port, None)
    if not open.success: 
        flash(open.message, open.severity)
        open.message=[]
    if not open.message: flash("This portfolio contains no open positions", "WARNING")
    return render_template("all_open.html", open=_sort(open.message, sortby), port=port)
Esempio n. 3
0
def prices(port):
    global reverse
    open = Log.get_open_positions(port, None)

    if not open.success: 
        flash(open.message, open.severity)
        return redirect('/price')
    if not open.message: flash("This portfolio contains no open positions", "WARNING")
    
    sortby = request.args.get('sortby') if request.args.get('sortby') else 'stock'
    prices = sorted(Price.get_price(open.message), key=lambda i: i[sortby], reverse=reverse)
    reverse = not reverse
    return render_template('prices.html', prices=prices, port=port)
Esempio n. 4
0
def positions(port):
    """ List the positions in this port """
    sortby = request.args.get('sortby')
    what = request.args.get('what')

    open = Log.get_open_positions(port, None)
    if not open.success: 
        flash(open.message, open.severity)
        open.message=[]
    if not open.message: flash("There are no open positions", "WARNING")
    elif what == 'open': open.message = _sort(open.message, sortby)
    closed = Log.get_closed_positions(port, None)
    if not closed.success: 
        flash(closed.message, closed.severity)
        closed.message=[]
    elif what == 'closed': closed.message = _sort(closed.message, sortby)
    if not closed.message: flash("There are no closed positions", "WARNING")
    return render_template("positions.html", open=open.message, closed=closed.message, port=port)