import csv
import os
import time

import numpy as np
import pandas as pd
root='/Users/yumingwu/Downloads/Stk_Day_QFQ/'
path =os.listdir(root)
path.sort()
num =45
day=time.strftime("%Y-%m-%d",time.localtime())

with open('./'+day+"-rate"+'.csv','w',encoding='gbk',newline='') as csfile:
    writer =csv.writer(csfile)
    writer.writerow(['代码','日期','昨日涨幅'])

    for spath in path:
        # 过滤000
        if spath.find("SZ") == -1:
            continue

        print(spath)


        data = pd.read_csv(root + spath, encoding='gbk')
        data['时间']=pd.to_datetime(data['时间'])
        if len(data)<20:
            continue

        item0 = data.iloc[-1]
        if item0['时间'] != pd.to_datetime('20230411'):
            continue
        item1 = data.iloc[-2]
        if (item0['收盘价']/item1['收盘价']>1.098):
            writer.writerow([item0['代码'], item0['时间'], item0['收盘价']/item1['收盘价']-1])













