def show_watched(request): validate_user(request.user) matching_companies = user_watchlist(request.user) timeframe = Timeframe() return show_companies( matching_companies, request, timeframe, { "title": "Stocks you are watching", "sentiment_heatmap_title": "Watchlist stocks sentiment: {}".format(timeframe.description), })
def render_to_response(self, context, **kwargs): """ Invoke show_companies() """ assert kwargs is not None context.update(self.additional_context(context)) return show_companies( # will typically invoke show_companies() to share code across all views self.qs, self.request, self.timeframe, context, template_name=self.template_name )
def show_watched(request): validate_user(request.user) matching_companies = user_watchlist(request.user) timeframe = Timeframe() return show_companies( matching_companies, request, timeframe, { "title": "Stocks you are watching", "sentiment_heatmap_title": "Watchlist sentiment heatmap", }, )
def show_outliers(request, stocks, n_days=30, extra_context=None): assert stocks is not None assert n_days is not None # typically integer, but desired_dates() is polymorphic timeframe = Timeframe(past_n_days=n_days) cip = selected_cached_stocks_cip(stocks, timeframe) outliers = detect_outliers(stocks, cip) extra_context = { "title": "Unusual stock behaviours: {}".format(timeframe.description), "sentiment_heatmap_title": "Outlier stocks: sentiment", } return show_companies( outliers, request, timeframe, extra_context, )
def render_to_response(self, context): context.update({ "title": "Find companies by financial metric", "sentiment_heatmap_title": "Matching stock sentiment", }) warning( self.request, "Due to experimental data ingest, results may be wrong/inaccurate/misleading. Use at own risk", ) return show_companies( self.object_list, # ie. return result from self.get_queryset() self.request, Timeframe(past_n_days=30), context, self.template_name, )