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
data = pd.read_csv('./202301-03打板盈利首笔大于500w2.csv',encoding='gbk')
data['日期']=pd.to_datetime(data['日期'])
with open('./' + '202301-03打板盈利首笔大于500w开盘价' + '.csv', 'w', encoding='gbk', newline='') as csfile:
    writer = csv.writer(csfile)
    writer.writerow(
        ['代码', '日期', '昨日收盘价','开盘价','最低价' ,'最高价涨幅', '成交量', '成交额', '换手率', '买入价格', '卖出价格', '盈利',
         '涨幅', '10日涨幅', '流通市值', '涨停trainID', '涨停BuyOrderID', '涨停vol', '涨停amount', '大于500w'])
    for index, item in data.iterrows():
         codedata=pd.read_csv(root+item['代码']+'.csv',encoding='gbk')
         codedata['时间'] = pd.to_datetime(codedata['时间'])
         codedata=codedata[codedata['时间']==item['日期']]
         codedata=codedata.iloc[0]
         writer.writerow(
             [item['代码'],
              item['日期'],
              item['昨日收盘价'],
              codedata['开盘价'],
              codedata['最低价'],
              item['最高价涨幅'],
              item['成交量'],
              item['成交额'],
              item['换手率'],
              item['买入价格'],
              item['卖出价格'],
              item['盈利'],
              item[ '涨幅'],
              item['10日涨幅'],
              item['流通市值'],
              item['涨停trainID'],
              item['涨停BuyOrderID'],
              item['涨停vol'],
              item['涨停amount'],
              item['大于500w']])
