Esempio n. 1
0
def allclosed(port):
    """ List the closed positions in this portfolio """
    sortby = request.args.get('sortby')
    closed = Log.get_closed_positions(port, None)
    if not closed.success: 
        flash(closed.message, closed.severity)
        closed.message=[]
    if not closed.message: flash("This portfolio contains no closed positions", "WARNING")
    return render_template("all_closed.html", closed=_sort(closed.message, sortby), port=port)
Esempio n. 2
0
def closed(port, stock):
    """ List closed positions and trades """
    sortby = request.args.get('sortby')
    result = Log.get_closed_positions(port=port, stock=stock)
    if not result.success:
        flash(result.message, result.severity)
        result.message = []
    elif not result.message: flash(f'{stock} has no closed positions', 'WARNING')
    return render_template('closed.html', closed=_sort(result.message, sortby), port=port, stock=stock)
Esempio n. 3
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)