当前位置: 首页>>代码示例>>Python>>正文


Python Stock.get_stocks_sorted_by_socialgood方法代码示例

本文整理汇总了Python中models.Stock.get_stocks_sorted_by_socialgood方法的典型用法代码示例。如果您正苦于以下问题:Python Stock.get_stocks_sorted_by_socialgood方法的具体用法?Python Stock.get_stocks_sorted_by_socialgood怎么用?Python Stock.get_stocks_sorted_by_socialgood使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Stock的用法示例。


在下文中一共展示了Stock.get_stocks_sorted_by_socialgood方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: home

# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import get_stocks_sorted_by_socialgood [as 别名]
def home():
    N_STOCKS = 20 # number of stocks to retrieve
    if not account.user_is_logged_in():
        return redirect(url_for("login"))

    # Get all stock tickers
    tickers = Stock.get_all_tickers()

    # Get default sorting metric and order 
    order = None
    metric = request.args.get("metric", "recs")
    order_arg = request.args.get("order", "lowhigh")
    if order_arg == "lowhigh":
        order = True
    elif order_arg == "highlow":
        order = False

    # Get sorted stocks
    stocks = None
    if metric == "alpha":
        stocks = Stock.get_stocks(N_STOCKS, order)
    elif metric == "price":
        stocks = Stock.get_stocks_sorted_by_price(N_STOCKS, order)
    elif metric == "pe":
        stocks = Stock.get_stocks_sorted_by_pe(N_STOCKS, order)
    elif metric == "risk":
        stocks = Stock.get_stocks_sorted_by_risk(N_STOCKS, order)
    elif metric == "recs":
        stocks = Stock.get_recommendations()
    elif metric == "sustainability":
        stocks = Stock.get_stocks_sorted_by_sustainability(N_STOCKS, order)
    elif metric == "socialgood":
        stocks = Stock.get_stocks_sorted_by_socialgood(N_STOCKS, order)
    elif metric == "american":
        stocks = Stock.get_stocks_sorted_by_american(N_STOCKS, order)

    return render_template("home.html", tickers = tickers, stocks = stocks,
                           metric = metric, order = order,
                           has_recs = account.user_has_recommendations())
开发者ID:damlaren,项目名称:investorscope-app,代码行数:41,代码来源:views.py


注:本文中的models.Stock.get_stocks_sorted_by_socialgood方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。