def net_assets_html(self): ast_str = self.net_assets() if ast_str.endswith('B'): return format.green(ast_str) if ast_str.endswith('M'): ast_value = float(ast_str[:-1]) if ast_value <= 100: return format.red(ast_str) if ast_value > 100 and ast_value <= 300: return format.orange(ast_str) return format.green(ast_str) return format.red(ast_str)
def ma_rally_days_html(self): days = self.ma_rally_days() if days >= 20: return format.red(days) if days <= 5: return format.orange(days) return format.green(days)
def rsi_html(self): rsi = self.rsi_value() if rsi >= 65: return format.red(rsi) if rsi <= 30: return format.green(rsi) return format.orange(rsi)
def relative_volume_html(self): rel_vol = self.relative_volume() if rel_vol > 1.2: return format.green(rel_vol) if rel_vol <= 1.2 and rel_vol >= 0.8: return format.orange(rel_vol) return format.red(rel_vol)
def ma_rally_gain_html(self): gain = self.ma_rally_gain() * 100 gain_str = str(gain) + '%' if gain <= 3: return format.green(gain_str) if gain > 3 and gain < 7: return format.orange(gain_str) return format.red(gain_str)
def treynor_html(self, value_str): if value_str == 'N/A': return value_str value = misc.to_float_value(value_str) if value > 5: return format.green(value_str) if value <= 0: return format.red(value_str) return format.orange(value_str)
def beta_html(self, value_str): if value_str == 'N/A': return value_str value = misc.to_float_value(value_str) if value >= 1.25: return format.red(value_str) if value >= 1.05: return format.orange(value_str) return format.green(value_str)
def yearly_perf_html(self, value_str): if value_str == 'N/A': return value_str value = misc.to_float_value(value_str) if value >= 10: return format.green(value_str) if value >= 3: return format.orange(value_str) return format.red(value_str)
def fund_pe_html(self): pe = self.fund_pe() pe_str = self.holdings_dict.get('Price/Earnings', 'N/A') if pe == 'N/A': return format.orange(pe) if pe >= 40: return format.red(pe_str) if pe >= 30 and pe < 40: return format.orange(pe_str) return format.green(pe_str)
def expense_ratio_html(self): exp_ratio = self.expense_ratio() if exp_ratio == 'N/A': return format.orange(exp_ratio) expense_ratio = misc.to_float_value(exp_ratio) if expense_ratio >= 0.5: return format.red(exp_ratio) if expense_ratio >= 0.4: return format.orange(exp_ratio) return format.green(exp_ratio)
def perf_trend_html(self, perf_rate): if perf_rate < -0.02: return format.red(perf_rate) if perf_rate > 0.1: return format.green(perf_rate) return format.orange(perf_rate)
def change_html(self): change = self.change() change_str = str(change) + '%' if change >= 0: return format.green(change_str) return format.red(change_str)
def gen_left_td(symbol_obj, relative_rank_y2_dict, relative_rank_y_dict): finviz_url = constants.finviz_quote_url % symbol_obj.symbol html_str = '<tr><td align=\"left\" valign=\"top\" width=\"28%\">' html_str = '%s<strong><a href=\"%s\">%s</a></strong>' % ( html_str, finviz_url, symbol_obj.symbol) if symbol_obj.is_pick_today(): html_str = "%s (★ %s ★)" % (html_str, format.green("PoD")) if symbol_obj.is_high_volume(): html_str = "%s (⚡ %s ⚡)" % (html_str, format.orange("HV")) if symbol_obj.price_below_ma200(): html_str = "%s (☠ %s ☠)" % (html_str, format.red("B-200")) elif symbol_obj.price_below_ma50(): html_str = "%s (☹ %s ☹)" % (html_str, format.orange("B-50")) yahoo_url = constants.yahoo_holdings_url % symbol_obj.symbol html_str = "%s<br><a href=\"%s\">%s</a>" %( html_str, yahoo_url, symbol_obj.desc) html_str = "%s<br>%s: %s" %(html_str, "Change", symbol_obj.change_html()) html_str = "%s<br>%s: %s" %(html_str, "RSI", symbol_obj.rsi_html()) if symbol_obj.ma_rally_days() > 0: html_str = "%s<br>%s(%s): %s for %s days" %( html_str, "Ma_gain", symbol_obj.ma_diff_trend_html(), symbol_obj.ma_rally_gain_html(), symbol_obj.ma_rally_days_html()) else: html_str = "%s<br>%s(%s): %s" %(html_str, "Ma_diff", symbol_obj.ma_diff_trend_html(), symbol_obj.ma_diff_ratio_html()) html_str = "%s<br>%s: %s" %( html_str, "Trend Y/2", symbol_obj.perf_trend_html(symbol_obj.perf_trend_since_half_year()), ) if not symbol_obj.symbol in constants.sticky_dict: rank_change = relative_rank_y2_dict.get(symbol_obj.symbol, ('N/A', 'N/A'))[1] html_str = "%s (%s)" %( html_str, format.rank_change_html(rank_change) ) html_str = "%s<br><u style=\"text-decoration-color: darkgray;\">%s: %s</u>" %( html_str, "Trend Year", symbol_obj.perf_trend_html(symbol_obj.perf_trend_since_year()) ) if not symbol_obj.symbol in constants.sticky_dict: rank_change = relative_rank_y_dict.get(symbol_obj.symbol, ('N/A', 'N/A'))[1] html_str = "%s<u style=\"text-decoration-color: darkgray;\"> (%s)</u>" %( html_str, format.rank_change_html(rank_change) ) html_str = "%s<br>%s: %s" %(html_str, "P/E", symbol_obj.fund_pe_html()) beta = symbol_obj.five_year_beta() treynor = symbol_obj.five_year_treynor() html_str = "%s<br>%s: %s / %s" %(html_str, "5YR-Beta-Treynor", symbol_obj.beta_html(beta), symbol_obj.treynor_html(treynor)) html_str = "%s<br>%s: %s" %(html_str, "Assets", symbol_obj.net_assets_html() ) html_str = "%s<br>%s: <b>%s</b>" %(html_str, "Dividend", symbol_obj.attr_dict['Dividend %']) html_str = "%s<br>%s: %s" %(html_str, "Expense Ratio", symbol_obj.expense_ratio_html()) html_str += "</td>" return html_str
def change_html(value): if value.startswith('-'): return format.red(value) return format.green(value)