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


Python Store.get_bonus方法代码示例

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


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

示例1: analyze_bonus

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import get_bonus [as 别名]
def analyze_bonus():
    s = Store()
    codes = s.get_all_stocks()
    arr = []
    for code in codes:
        print "analyzing %s..."%(code)
        bonus = s.get_bonus(code)
        if len(bonus) > 0:
            bonus = bonus.set_index("announce_date")
            bonus = bonus.sort_index()
        else:
            continue
        finance = s.get_finance(code)
        if len(finance) > 0:
            finance = finance.set_index("date")
            finance = finance.sort_index()
        
        sql = "select MIN(date) from market where code = \"%s\""%(code)
        cursor = conn.cursor()
        count = cursor.execute(sql)
        if count == 0:
            continue
        start_date = cursor.fetchone()[0]
        cursor.close()
        bonus_index = 0
        for i in range(0, len(finance)):
            if bonus_index >= len(bonus):
                break;
            
            bonus_date = bonus.index[bonus_index]
            date = finance.index[i]
            if date < start_date:
                continue
            next_date = datetime.date(2199, 12, 31)
            if i < len(finance) - 1:
                next_date = finance.index[i + 1]
            
            if bonus_date > date and bonus_date <= next_date:
                f = finance.iloc[i]
                b = bonus.iloc[bonus_index]
                dict = {}
                dict["date"] = date
                dict["announce_date"] = bonus_date
                dict["code"] = f.code
                dict["fund"] = f.fund_per_share
                dict["total"] = b.bonus_stock + b.tranadd_stock
                dict["exright_date"] = b.exright_date
                arr.append(dict)
                bonus_index = bonus_index + 1
    
    return pandas.DataFrame(arr)
开发者ID:simpleL,项目名称:FDM,代码行数:53,代码来源:analyzer.py

示例2: __init__

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import get_bonus [as 别名]

#.........这里部分代码省略.........
            count = cursor.execute(query_sql)
            if (count > 0):
                param = (su.get_string(stock["name"]), su.get_string(stock.industry),
                         su.get_string(stock.area), cu.trim_float(stock.outstanding * 10000),
                         cu.trim_float(stock.totals * 10000), cu.trim_float(stock.pe),
                         cu.trim_float(stock.pb), code)
                #print param
                update_list.append(param)
            else:
                param = (code, su.get_string(stock["name"]),
                         su.get_string(stock.industry), su.get_string(stock.area),
                         cu.trim_float(stock.outstanding * 10000), cu.trim_float(stock.totals * 10000),
                         cu.trim_float(stock.pe), cu.trim_float(stock.pb))
                insert_list.append(param)
    
        if (len(insert_list) != 0):
            cursor.executemany(insert_sql, insert_list)
            conn.commit()
        if (len(update_list) != 0):
            cursor.executemany(update_sql, update_list)
            conn.commit()
    
        cursor.close()
    
    def collect_bonus(self):
        codes = self.store.get_all_stocks()
    
        conn = ConnManager.get_conn()
        cursor = conn.cursor()
    
        insert_sql = "insert into bonus (code, announce_date, stat_right_date, exright_date, dividend, bonus_stock, tranadd_stock) values (%s, %s, %s, %s, %s, %s, %s)"
    
        for code in codes:
            server_stock_bonus = crawler.get_dividend(code)
            if len(server_stock_bonus) > 0:
                server_stock_bonus = server_stock_bonus.set_index("announce_date")
                server_stock_bonus = server_stock_bonus.sort_index()
        
            stock_bonus = self.store.get_bonus(code)
            if len(stock_bonus) > 0:
                stock_bonus = stock_bonus.set_index("announce_date")
                stock_bonus = stock_bonus.sort_index()
        
            diff = server_stock_bonus.index.difference(stock_bonus.index)
        
            insert_list = []
        
            for announce_date in diff:
                bonus = server_stock_bonus.loc[announce_date]
                params = (bonus.code, announce_date, bonus.stat_right_date,
                          bonus.exright_date, bonus.dividend, bonus.bonus_stock,
                          bonus.tranadd_stock)
                insert_list.append(params)
        
            if len(insert_list) > 0:
                cursor.executemany(insert_sql, insert_list)
                conn.commit()
        
        cursor.close()

    def collect_finance(self):
        codes = self.store.get_all_stocks()
    
        conn = ConnManager.get_conn()
        cursor = conn.cursor()
        print "collect finance"
        
        insert_sql = "insert into finance (code, date, earning_per_share, net_margin, nonrecurring_net_margin,"\
                     "total_income, asset_per_share, roe, diluted_roe, debt_ratio, fund_per_share,"\
                     "undistributed_profit_per_share, cash_flow_per_share) values"\
                     "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
    
        for code in codes:
            server_stock_finance = self._10jqka.get_finance_data(code)
            if len(server_stock_finance) > 0:
                server_stock_finance = server_stock_finance.set_index("date")
                server_stock_finance = server_stock_finance.sort_index()
        
            stock_finance = self.store.get_finance(code)
            if len(stock_finance) > 0:
                stock_finance = stock_bonus.set_index("date")
                stock_finance = stock_bonus.sort_index()
        
            diff = server_stock_finance.index.difference(stock_finance.index)
        
            insert_list = []
        
            for date in diff:
                finance = server_stock_finance.loc[date]
                params = (finance.code, date, finance.earning_per_share, finance.net_margin,
                          finance.nonrecurring_net_margin, finance.total_income, finance.asset_per_share,
                          finance.roe, finance.diluted_roe, finance.debt_ratio, finance.fund_per_share,
                          finance.undistributed_profit_per_share, finance.cash_flow_per_share)
                insert_list.append(params)
        
            if len(insert_list) > 0:
                cursor.executemany(insert_sql, insert_list)
                conn.commit()
        
        cursor.close()
开发者ID:simpleL,项目名称:FDM,代码行数:104,代码来源:collector.py


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