Esempio n. 1
0
 def run_update(self):
     for code in market_index_list + code_list.keys():
         self.dbstatistic.initialize(code)
         end_date = self._check_result(code)
         if get_market_date(1) == end_date:
             continue
         self.update_table(code, exist=self.exist)
Esempio n. 2
0
 def run_update(self):
     for code in market_index_list + code_list.keys():
         self.dbstatistic.initialize(code)
         end_date = self._check_result(code)
         if get_market_date(1) == end_date:
             continue
         self.update_table(code, exist=self.exist)
Esempio n. 3
0
 def run_update(self):
     for code in market_index_list + code_list.keys():
         self.code = code
         self.db.initialize(code)
         if not self.db.exist:
             self.db.create_table()
         self.append_to_db()
         self.db.initialize(code)
Esempio n. 4
0
 def run_update(self):
     for code in market_index_list + code_list.keys():
         self.code = code
         self.db.initialize(code)
         if not self.db.exist:
             self.db.create_table()
         self.append_to_db()
         self.db.initialize(code)
Esempio n. 5
0
 def get_result(self, title):
     for code in  ["`{}`".format(code) for code in code_list.keys()]:
         self.execute("select {} from {} where date = '{}'".format(title, code, self.date))
         output = self.cursor.fetchall()
         if not output:
             out = 0
         else:
             out = output[0][0]
         self.result[code] = out
Esempio n. 6
0
 def filter_code(self):
     select_code = []
     for code in ["`{}`".format(code) for code in code_list.keys()]:
         self.execute("select high from {} where date = '{}'".format(code, self.date))
         res = self.cursor.fetchall()
         if not res:
             continue
         high_today = res[0][0]
         self.execute("select count(date), max(high) from {} where date > '{}' and date < '{}'".
                      format(code, self.date-datetime.timedelta(365), self.date))
         output = self.cursor.fetchall()
         if not output:
             continue
         count, highest = output[0]
         #print count, highest, high_today, self.date-datetime.timedelta(365), self.date
         if count > 100 and high_today > highest:
             select_code.append(code)
     print select_code
     return select_code
Esempio n. 7
0
 def run_update(self):
     for code in code_list.keys():
         self._check_result(code)
         self.update_table(code)
Esempio n. 8
0
            print '{:8.4f}'.format(counter_inc /float(counter_inc+counter_dec)), '{:8.4f}'.format((sum_inc+sum_dec)/(counter_dec+counter_inc))

    def rate_st_month(self):
        for i in range(1, 13):
            self.execute('select sum(rate), count(*) from sh  where date > date(\'{}\') and date < date(\'{}\') and month(date) = {}'
                         .format(self.start, self.end, i))
            sum_rate, count = self.cursor.fetchall()[0]
            print '{:8.4f}'.format(sum_rate/count)



if __name__ == '__main__':
    db = Dbstatistic()
    lastday = db._get_latest_date(sh, 1)
    print lastday
    for code in market_index_list + code_list.keys():
        db.initialize(code)
        if db.check_isReach_highest_price(lastday):
            print code








    #print db.cal_fluc(start='2001-08-10', end='2015-08-20')
    #print db.issuspension
    #print db.get_latest_date(10)
Esempio n. 9
0
 def run_update(self):
     for code in code_list.keys():
         self._check_result(code)
         self.update_table(code)
Esempio n. 10
0
            "high double, " + "low double, " + "change_rate double, " +
            "fluctuation double, " + "volume bigint(20), " +
            "amount bigint(20) )")
        self.conn.commit()

    def append_db(self, db_data):
        for timestamp in db_data:
            date = str(timestamp).split()[0]
            value = db_data[timestamp]
            self.execute("insert into {} values (".format(self.code) +
                         "'{}', ".format(date) + "{}, ".format(value['open']) +
                         "{}, ".format(value['close']) +
                         "{}, ".format(value['high']) +
                         "{}, ".format(value['low']) + "null, " + "null, " +
                         "{}, ".format(value['volume']) +
                         "{} )".format(value['amount']))
            self.conn.commit()


if __name__ == '__main__':
    dbdata = Dboperation()
    #data = Dboperation('b000001')
    #data.initialize()
    #data.calculate_change_rate()
    for code in market_index_list + code_list.keys():
        dbdata.initialize(code)
        dbdata.update_type()

    #print data.get_latest_date()
    #print data.get_start_date