python股票分析之放量跌倒底买入

import os

nZhangTing=0
nEarn=0
nTotalEarn=0
nBuy=0
nSell=0
strBuyDate=""
strPrebuyDate=False#准备买入
bPreSell=False
bPreBuy=False
strSellDate=""
for root,dirs,files in os.walk(r"..\\txt"):
    for file in files:
    
        strCode=os.path.join(root,file)[-10:-4]
        if(strCode!="000661"):
            continue
    
        print("股票代码:"+strCode)
        
        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)):   
            arr=line.split(",")
            if len(arr)>1: 
                nTotalDay=nTotalDay+1
                nYear=int(line[0:4])
                strDate=arr[0]
                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])#成交量
                
                #放量跌,准备买入
                if(nOldDeal>0):
                    if(nDeal/nOldDeal>5 and nEnd-nOldEnd<0):
                        strPrebuyDate=strDate
                        bPreBuy=True#准备买入
                        print("准备买入:"+strDate)
                    
                    
                    
                #卖出
                if(bPreSell and nBuy!=0 and nEnd-nOldEnd<0 and strBuyDate!=strDate):
                    nSell=nEnd*100
                    nEarn=nSell-nBuy
                    nTotalEarn+=nEarn
                    nBuy=0
                    nSell=0
                    strBuyDate=""
                    bPreSell=False
                    print("卖出价格:"+str(nEnd))
                    print("卖出日期:"+strDate)
                    print("盈利:"+str(nEarn))
                    
                    
                #买入
                if(bPreBuy and strPrebuyDate!=""  and nEnd>nStart):
                    nBuy=nEnd*100
                    strBuyDate=strDate
                    bPreBuy=False
                    bPreSell=True
                    strPrebuyDate=""
                    print("买入价格:"+str(nEnd))
                    print("买入日期:"+strDate)
                    
                    
                
                    
                
                arr=[nStart,nEnd,nMin,nMax]
                
                arrLine.append(arr)
                
                
                
                #涨停板
                if( round(nOldEnd*1.1,2)<=nEnd):
                    bZhangTing=True
                else:
                    bZhangTing=False
                
                nOldEnd=nEnd
                nOldDeal=nDeal
                
        #print("收盘1:"+str(arrLine[len(arrLine)-2][1]))        
        #print("收盘2:"+str(arrLine[len(arrLine)-1][1]))     

        #nEnd1=arrLine[len(arrLine)-2][1]
        #nZhangTing=round(nEnd1*1.1,2)
        #print("涨停价:"+str(nZhangTing))    
'''
        if(bZhangTing):
            nZhangTing=nZhangTing+1
            with open("追涨.txt","a") as file1: 
                file1.write(strCode)
                file1.write("总计盈利:"+str(nEarn)+"元")
                file1.write("\n")
                 
            '''    
                 
'''
with open("追涨.txt","a") as file1: 
    file1.write("今日涨停股票数量:"+str(nZhangTing))
    file1.write("\n")
'''
print("总盈利:"+str(nTotalEarn))
with open("放量跌马上买入.txt","a") as file1: 
    file1.write(strCode)
    file1.write("总计盈利:"+str(nTotalEarn)+"元")
    file1.write("\n")


    

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

懒人编程学院

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值