def break_low(self, date):
'''
????????????
:param date: ?????? ‘'2017-11-11
:return:
'''
#cmd = 'select * from `{}`'.format(date)
df = pd.read_sql_table(date, daily_engine,index_col='index')
# **** ???index??????
low_db= get_mysql_conn('db_selection')
low_cursor = low_db.cursor()
for i in range(len(df)):
code = df.loc[i]['code']
cur_low = df.loc[i]['low']
mins_date,mins = self.get_lowest(code, '2017',date)
if not mins_date:
continue
if mins and float(cur_low)<=float(mins) and float(cur_low) !=0.0:
print code,
print df.loc[i]['name']
print 'year mins {} at {}'.format(mins,mins_date)
print 'curent mins ',cur_low
create_cmd = 'create table if not exists break_low' \
'(`index` int primary key auto_increment,datetime datetime,code text,name text,low_price float,last_price float, last_price_date datetime);'
low_cursor.execute(create_cmd)
insert_cmd = 'insert into break_low (datetime,code,name,low_price,last_price,last_price_date) values (%s,%s,%s,%s,%s,%s);'
insert_data = (date,code,df.loc[i]['name'],cur_low,mins,mins_date)
low_cursor.execute(insert_cmd,insert_data)
low_db.commit()
评论列表
文章目录