赞
踩
import os
arrRaise=[
[0,[]],
[0.1,[]],
[0.2,[]],
[0.3,[]],
[0.4,[]],
[0.5,[]],
[0.6,[]],
[0.7,[]],
[0.8,[]],
[0.9,[]],
[1,[]],
[2,[]],
[3,[]],
[4,[]],
[5,[]],
[6,[]],
[7,[]],
[8,[]],
[9,[]],
[10,[]]
]
strTest=""
nZhangTing=0
nDieTing=0
strZhangTingDate=""
strDieTingDate=""
nEarn=0
nTotalEarn=0
nBuy=0
nSell=0
strBuyDate=""
strPrebuyDate=False#准备买入
bPreSell=False
bPreBuy=False
strSellDate=""
strOutput=""
nMoney=0
for root,dirs,files in os.walk(r"..\\txt"):
for file in files:
strCodeTemp=os.path.join(root,file)[-10:-4]
if(strCodeTemp!="600213"):
continue
#print("股票代码:"+strCode)
strOutput+="股票代码:"+strCodeTemp+"\n"
date1=""
nStart1=0#第一天开盘价
nEnd1=0#最后一天收盘价
nUpDay=0
nDownDay=0
nTotalDay=0
nTotalMin=999
nTotalMax=0
strMinDate=""
nOldEnd=0
nOldDeal=0
arrLine=[]
for line in open(os.path.join(root,file)):
if(line.find("日线")>0):
arrHead=line.split(" ")
if len(arrHead)>1:
strCode=arrHead[0]
strName=arrHead[1]
arr=line.split(",")
if len(arr)>1:
nTotalDay=nTotalDay+1
nYear=int(line[0:4])
strDate=arr[0]
#strTest+=strDate+"\n"
if(date1==""):
date1=arr[0]
nStart=float(arr[1])#开盘
if(nStart1==0):
nStart1=nStart
nMax=float(arr[2])#最高
nMin=float(arr[3])#最低
nEnd=float(arr[4])#收盘
nDeal=float(arr[5])#成交量
arr=[nStart,nEnd,nMin,nMax,strDate, nTotalDay]
arrLine.append(arr)
#if(nEnd>0 and nOldEnd>0):
#涨停板
if( round(nOldEnd*1.09,2)<=nEnd):
bZhangTing=True
nZhangTing=nZhangTing+1
#print(strDate)
strZhangTingDate+=strDate+"涨停\n"
else:
bZhangTing=False
#跌停板
if( round(nOldEnd*0.9,2)>=nEnd):
bDieTing=True
nDieTing=nDieTing+1
strDieTingDate+=strDate+"跌停\n"
else:
bDieTing=False
nOldEnd=nEnd
nOldDeal=nDeal
arrMax = sorted(arrLine, key=lambda x: x[3],reverse=True)
arrMin = sorted(arrLine, key=lambda x: x[2])
arrMaxTop=[]
i=0
for max in arrMax:
bNear=False
if(i>0):
for m in arrMaxTop:
if(abs(m[5]-max[5])<30):
bNear=True
if(bNear):
continue
arrMaxTop.append(max)
i+=1
if(i>10):
break
i=0
arrMinTop=[]
for min in arrMin:
bNear=False
if(i>0):
for m in arrMinTop:
if(abs(m[5]-min[5])<30):
bNear=True
if(bNear):
continue
arrMinTop.append(min)
i+=1
if(i>10):
break
arrMaxTop = sorted(arrMaxTop, key=lambda x: x[4])
arrMinTop = sorted(arrMinTop, key=lambda x: x[4])
with open("历史最高最低价top10.txt","a") as file1:
file1.write(strCode+strName)
file1.write("\n")
i=0
for max in arrMaxTop:
file1.write("阶段最高价:"+str(max[3]))
file1.write("("+max[4]+")")
file1.write("\n")
file1.write("\n")
for min in arrMinTop:
file1.write("阶段最低价:"+str(min[3]))
file1.write("("+min[4]+")")
file1.write("\n")
file1.write("\n")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。