Newer
Older
stockTray / stock_filter / main / cal.py
bdapp on 18 Apr 2019 930 bytes 调整策略规则
import tushare as ts
import db
import history
import time

# # 初始化数据库操作类
mysql2 = db.MY_SQL()
#
# profit = mysql.get_pre_day_data('600212', '2018-10-31')
# #for i in range(len(profit)):
# print(profit[5])

# print(ts.get_hist_data('300316', '2018-08-28', '2018-08-28'))

# t = '2018-10-29'

# mysql = db.MY_SQL()
# history.query_stock_history(mysql, t, '000014', '沙河fff', 'aa')

df = ts.get_hist_data('300308', start='2018-08-29', end='2018-08-29')
if df is not None:
    for i in df.index:
        profit = mysql2.get_pre_day_data('300308', '2018-08-28')
        print(profit)
        if profit is not None:
            # 取开盘价
            price = df.loc[i]['open']
            print('300308')
            print(profit[2])

            if '300308' == profit[2]:
                old_price = profit[5]
                p = float(price) - float(old_price)
                mysql2.cale_profit(profit[0], p)