def __filter(self, stocks):
     content = []
     results = []
     miss = []
     p = 0.0
     b = 0.0
     net_profit = 0.0
     gdp_value = gdp.get().value
     for s in stocks:
         if s.ticker[0] == '2' or s.ticker[0] == '9':
             content.append("%s %s is B Stock\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.market_capital == 0.0:
             content.append("The market capital is 0 for %s %s\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.earnings_date is None:
             content.append("There is no earnings for %s %s\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if datetime.date.today().year - s.earnings_date.year > 2:
             content.append("The earnings is too old for %s %s %s\n" % (s.ticker, s.title, s.earnings_date.strftime("%Y%m%d")))
             miss.append(s.ticker)
             continue
         p += s.market_capital
         b += s.ownership_interest
         net_profit += s.net_profit
         if s.bank_flag == True:
             content.append("The stock (%s, %s) is a bank\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if (s.category.find('D') > 0 or s.category.find('G') > 0 or s.category.find('N') > 0):
             content.append("The stock (%s, %s) is Public Utilities\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.category.find('J') > 0:
             content.append('The stock (%s, %s) is Finance\n' % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.market_capital_date != datetime.date.today():
             content.append("The stock (%s, %s) is not in Google List\n" % (s.ticker, s.title))
         sv = stock.MagicFormulaStockView()
         try:
             sv.parse(s)
         except Exception as e:
             content.append("Parse stock (%s, %s) for %s %s\n" % (s.ticker, s.title, e, repr(s)))
             continue
         results.append(sv)
     content.append("Total: %s, Sorted: %s Miss: %s" % (len(stocks), len(results), len(miss)))
     mail.send_mail(sender="*****@*****.**",
                    to="*****@*****.**",
                    subject="神奇公式执行结果",
                    body=''.join(content))
     return (results, p / b, p / net_profit, p * 100 / gdp_value)
 def __filter(self, stocks):
     content = []
     results = []
     miss = []
     p = 0.0
     b = 0.0
     net_profit = 0.0
     ownership_interest = 0.0
     gdp_value = gdp.get().value
     for s in stocks:
         if s.ticker[0] == '2' or s.ticker[0] == '9':
             logging.warn("%s %s is B Stock" % (s.ticker, s.title))
             continue
         if s.market_capital == 0.0:
             logging.warn("The market capital is 0 for %s %s" %
                          (s.ticker, s.title))
             continue
         if s.earnings_date is None:
             logging.warn("There is no earnings for %s %s" %
                          (s.ticker, s.title))
             continue
         if datetime.date.today().year - s.earnings_date.year > 2:
             logging.warn(
                 "The earnings is too old for %s %s %s" %
                 (s.ticker, s.title, s.earnings_date.strftime("%Y%m%d")))
             continue
         p += s.market_capital
         b += s.ownership_interest
         net_profit += s.net_profit
         ownership_interest += s.ownership_interest
         if s.bank_flag == True:
             content.append("The stock (%s, %s) is a bank\n" %
                            (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.market_capital_date != datetime.date.today():
             logging.warn("The stock (%s, %s) is not in Google List" %
                          (s.ticker, s.title))
         sv = stock.NetCurrentAssetApproachStockView()
         try:
             sv.parse(s)
         except Exception as e:
             logging.warn("Parse stock (%s, %s) for %s" %
                          (s.ticker, s.title, e))
             continue
         if sv.pe > 0 and sv.net_current_assets > sv.market_capital:
             sv.format()
             results.append(sv)
     return (results, p / b, p / net_profit,
             net_profit * 100 / ownership_interest, p * 100 / gdp_value)
 def __filter(self, stocks):
     content = []
     results = []
     miss = []
     p = 0.0
     b = 0.0
     net_profit = 0.0
     ownership_interest = 0.0
     gdp_value = gdp.get().value
     for s in stocks:
         if s.ticker[0] == '2' or s.ticker[0] == '9':
             logging.warn("%s %s is B Stock" % (s.ticker, s.title))
             continue
         if s.market_capital == 0.0:
             logging.warn("The market capital is 0 for %s %s" % (s.ticker, s.title))
             continue
         if s.earnings_date is None:
             logging.warn("There is no earnings for %s %s" % (s.ticker, s.title))
             continue
         if datetime.date.today().year - s.earnings_date.year > 2:
             logging.warn("The earnings is too old for %s %s %s" % (s.ticker, s.title, s.earnings_date.strftime("%Y%m%d")))
             continue
         p += s.market_capital
         b += s.lastest_ownership_interest
         net_profit += s.lastest_net_profit
         ownership_interest += s.lastest_ownership_interest
         if s.bank_flag == True:
             content.append("The stock (%s, %s) is a bank\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.market_capital_date != datetime.date.today():
             logging.warn("The stock (%s, %s) is not in Google List" % (s.ticker, s.title))
         sv = stock.NetCurrentAssetApproachStockView()
         try:
             sv.parse(s)
         except Exception as e:
             logging.warn("Parse stock (%s, %s) for %s" % (s.ticker, s.title, e))
             continue
         if sv.pe > 0 and sv.net_current_assets > sv.market_capital:
             sv.format()
             results.append(sv)
     return (results, p / b, p / net_profit, net_profit * 100/ownership_interest, p * 100 / gdp_value)
 def __filter(self, stocks):
     content = []
     results = []
     miss = []
     p = 0.0
     b = 0.0
     net_profit = 0.0
     gdp_value = gdp.get().value
     for s in stocks:
         if s.ticker[0] == '2' or s.ticker[0] == '9':
             logging.warn("%s %s is B Stock" % (s.ticker, s.title))
             continue
         if s.market_capital == 0.0:
             logging.warn("The market capital is 0 for %s %s" % (s.ticker, s.title))
             continue
         if s.earnings_date is None:
             logging.warn("There is no earnings for %s %s" % (s.ticker, s.title))
             continue
         if datetime.date.today().year - s.earnings_date.year > 2:
             logging.warn("The earnings is too old for %s %s %s" % (s.ticker, s.title, s.earnings_date.strftime("%Y%m%d")))
             continue
         p += s.market_capital
         b += s.ownership_interest
         net_profit += s.net_profit
         if s.market_capital_date != datetime.date.today():
             logging.warn("The stock (%s, %s) is not in Google List" % (s.ticker, s.title))
         sv = stock.GrahamFormulaStockView()
         try:
             sv.parse(s)
         except Exception as e:
             logging.warn("Parse stock (%s, %s) for %s" % (s.ticker, s.title, e))
             continue
         if sv.pe <= 10 and sv.pe > 0 and sv.debt_asset_ratio <= 50:
             sv.format()
             results.append(sv)
     return (results, p / b, p / net_profit, p * 100 / gdp_value)
Exemple #5
0
 def __filter(self, stocks):
     content = []
     results = []
     miss = []
     p = 0.0
     b = 0.0
     net_profit = 0.0
     ownership_interest = 0.0
     gdp_value = gdp.get().value
     for s in stocks:
         if s.ticker[0] == '2' or s.ticker[0] == '9':
             content.append("%s %s is B Stock\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.market_capital == 0.0:
             content.append("The market capital is 0 for %s %s\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.earnings_date is None:
             content.append("There is no earnings for %s %s\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if datetime.date.today().year - s.earnings_date.year > 2:
             content.append("The earnings is too old for %s %s %s\n" % (s.ticker, s.title, s.earnings_date.strftime("%Y%m%d")))
             miss.append(s.ticker)
             continue
         p += s.market_capital
         b += s.lastest_ownership_interest
         net_profit += s.lastest_net_profit
         ownership_interest += s.lastest_ownership_interest
         if s.bank_flag == True:
             content.append("The stock (%s, %s) is a bank\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.category == None:
             s.category = ""
         if s.subcategory == None:
             s.subcategory = ""
             content.append("The stock (%s, %s) don't have category\n" % (s.ticker, s.title))
             continue
         if s.tangible_asset == 0:
             content.append("The stock (%s, %s) tangible asset is 0\n" % (s.ticker, s.title))
             continue
         if (s.category.find('D') > 0 or s.category.find('G') > 0 or s.category.find('N') > 0):
             content.append("The stock (%s, %s) is Public Utilities\n" % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.category.find('J') > 0:
             content.append('The stock (%s, %s) is Finance\n' % (s.ticker, s.title))
             miss.append(s.ticker)
             continue
         if s.market_capital_date != datetime.date.today():
             content.append("The stock (%s, %s) is not in Google List\n" % (s.ticker, s.title))
         sv = stock.MagicFormulaStockView()
         try:
             sv.parse(s)
         except Exception as e:
             content.append("Parse stock (%s, %s) for %s %s\n" % (s.ticker, s.title, e, repr(s)))
             continue
         results.append(sv)
     content.append("Total: %s, Sorted: %s Miss: %s" % (len(stocks), len(results), len(miss)))
     mail.send_mail(sender="*****@*****.**",
                    to="*****@*****.**",
                    subject="神奇公式执行结果",
                    body=''.join(content))
     return (results, p / b, p / net_profit, net_profit * 100 / ownership_interest, p * 100 / gdp_value)