def stock_expected_rate_by_price(code): stock = db.stock_by_code(code) try: expected_rate_price = float(request.args.get('price')) except ValueError: return redirect(url_for('stock', code=code)) return render_template('stock_detail.html', stock=stock, expected_rate_price=expected_rate_price)
def stock_adjusted_future_pbr(code): if request.method == 'POST': stock = db.stock_by_code(code) stock['adjusted_future_pbr'] = float( request.form.get('adjusted_future_pbr', 0)) db.save_stock(stock) return redirect(url_for('stock_refresh', code=code))
def stock(code): stock = db.stock_by_code(code) filters = db.all_filters() return render_template('stock_detail.html', VERSION=VERSION, stock=stock, filters=filters)
def stock_status(code, status, on): stock = db.stock_by_code(code) stock[status] = on == 'on' if status == 'owned' and stock[status]: stock['starred'] = False elif status == 'starred' and stock[status]: stock['owned'] = False db.save_stock(stock) return redirect(url_for('stock', code=code))
def stock_records(code): import historical stock = db.stock_by_code(code) records_by_year = historical.records_by_year(stock) now = datetime.now() records_by_year = [ data for data in records_by_year if data[0].year >= now.replace(year=now.year - 2).year ] return render_template('stock_records.html', VERSION=VERSION, stock=stock, records_by_year=records_by_year)
def stock_clear_adjusted_future_roe(code): stock = db.stock_by_code(code) stock['adjusted_future_roe'] = 0 db.save_stock(stock) return redirect(url_for('stock_refresh', code=code))
def stock_update_note(code): if request.method == 'POST': stock = db.stock_by_code(code) stock['note'] = str(request.form.get('note', '')) db.save_stock(stock) return redirect(url_for('stock', code=code))
def stock_my_price(code): if request.method == 'POST': stock = db.stock_by_code(code) stock['my_price'] = float(request.form.get('my_price', 0)) db.save_stock(stock) return redirect(url_for('stock_refresh', code=code))
def stock(code): stock = db.stock_by_code(code) return render_template('stock_detail.html', stock=stock)
def stock_expected_rate_by_price(code): if request.method == 'POST': stock = db.stock_by_code(code) expected_rate_price = float(request.form.get('expected_rate_price', 0)) return render_template('stock_detail.html', stock=stock, expected_rate_price=expected_rate_price)