import os

nZhangTing=0
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:
    
        strCode=os.path.join(root,file)[-10:-4]
        #if(strCode!="000661"):
        #    continue
    
        #print("股票代码:"+strCode)
        strOutput+="股票代码:"+strCode+"\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)):   
            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)
                        strOutput+="准备买入:"+strDate+"\n"
                    
                    
                    
                #卖出
                if(bPreSell and nBuy!=0 and nEnd-nOldEnd<0 and strBuyDate!=strDate and nEnd*100>nBuy):
                    nSell=nEnd*100
                    nEarn=nSell-nBuy
                    nTotalEarn+=nEarn
                    nBuy=0
                    nSell=0
                    strBuyDate=""
                    bPreSell=False
                    #print("卖出价格:"+str(nEnd))
                    #print("卖出日期:"+strDate)
                    #print("盈利:"+str(nEarn))
                    strOutput+="卖出价格:"+str(nEnd)+"\n"
                    strOutput+="卖出日期:"+strDate+"\n"
                    strOutput+="盈利:"+str(nEarn)+"\n"
                    
                    
                #买入
                if(bPreBuy and strPrebuyDate!=""  and nEnd>nStart):
                    nBuy=nEnd*100
                    nMoney+=nBuy
                    strBuyDate=strDate
                    bPreBuy=False
                    bPreSell=True
                    strPrebuyDate=""
                    #print("买入价格:"+str(nEnd))
                    #print("买入日期:"+strDate)
                    strOutput+="买入价格:"+str(nEnd)+"\n"
                    strOutput+="买入日期:"+strDate+"\n"
                
                    
                
                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(strOutput)
    file1.write("\n")
    file1.write("总计花费:"+str(nMoney)+"元")
    file1.write("\n")
    file1.write("总计盈利:"+str(nTotalEarn)+"元")
    file1.write("\n")

python股票分析-放量跌到底买入-涨了再卖相关推荐

  1. python量化交易之 放量跌到底买入-涨1.1再卖

    import os nZhangTing=0 nEarn=0 nTotalEarn=0 nBuy=0 nSell=0 strBuyDate="" strPrebuyDate=Fal ...

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

    import os nZhangTing=0 nEarn=0 nTotalEarn=0 nBuy=0 nSell=0 strBuyDate="" strPrebuyDate=Fal ...

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

    import os nZhangTing=0 nEarn=0 nTotalEarn=0 nBuy=0 nSell=0 strBuyDate="" strPrebuyDate=Fal ...

  4. python股票分析系统代码_Python 代码学习,用于股票分析

    最近,一位常年研究股票系统的开发者 pythonstock 用 Python 写了一个股票分析系统,发布数天就获得了不少关注. 于是我们就推荐给大家,既能学习 python 又能练习炒股.但正如项目作 ...

  5. Python股票分析系列——基础股票数据操作(二).p4

    该系列视频已经搬运至bilibili: 点击查看 欢迎来到Python for Finance教程系列的第4部分.在本教程中,我们将基于Adj Close列创建烛台/ OHLC图,这将允许我介绍重新采 ...

  6. Python股票分析系列——系列介绍和获取股票数据.p1

    本系列转载自youtuber sentdex博主的教程视频内容 https://www.youtube.com/watch?v=19yyasfGLhk&index=4&list=PLQ ...

  7. Python 股票分析快速入门

    Python 股票分析快速入门 这段时间股市又开始火爆起来了,隐约这透着点大牛市气息,多年不用的股票账户也找回来了.然后就想着用python做下股票分析,尝试制作自己的分析脚本,本篇教程是自己的一些笔 ...

  8. Python股票分析系列——数据整理和绘制.p2

    Python股票分析系列--数据整理和绘制.p2 欢迎来到Python for Finance教程系列的第2部分. 在本教程中,我们将利用我们的股票数据进一步分解一些基本的数据操作和可视化. 我们将要 ...

  9. python 股票分析库_GitHub - reference-project/stock-1: stock,股票系统。使用python进行开发。...

    pythonstock V1 项目简介 特别说明:股市有风险投资需谨慎,本项目只能用于Python代码学习,股票分析,投资失败亏钱不负责,不算BUG. PythonStock V1 是基于Python ...

最新文章

  1. VR如何巧妙填补传统数据视觉化的漏洞
  2. 俄罗斯计算机科学留学,中南大学计算机科学与技术、俄罗斯硕士留学有没有寒暑假班?...
  3. 关于使用在webforms里使用routing遇到的问题
  4. python最简单的账号密码验证_Python之简单的用户名密码验证
  5. 在Spring中使用JDBC访问关系数据
  6. 如何方便快速在指定文件夹打开命令行
  7. MyBatis官方文档——动态SQL部分
  8. 浅谈IPFS新激励层Filenet究竟是什么,令牌、公链、应用?超级云系统!
  9. J2Cache以RabbitMQ作为消息通知配置
  10. Spring bean的生命周期
  11. 普通路由器改4g路由器_工业远程管理神器,4G无线路由器更方便
  12. ArrayList 集合底层实现原理解析
  13. 信号与系统(三):系统分析方法对比:微分方程 相量 傅里叶级数/变换 拉普拉斯变换
  14. 均方根值(RMS)、均方根误差(RMSE)、各种平均值
  15. 计算机关机键消失了,电脑关机键不见了,没有了关机按钮怎么办
  16. PL/SQL Developer x64 官网下载、中文包、注册码
  17. 计算机毕业设计 SSM房屋租赁系统 房屋租赁合同管理系统 智慧房屋租赁平台Java Vue MySQL数据库 远程调试 代码讲解
  18. android实现mysql数据库存储_一个简单的Android端对象代理数据库系统的实现(二、执行+存储)...
  19. linux每个文件标识,Linux文件系统中每个文件用____来标识。
  20. android 点对点 通信,将 WLAN 直连(点对点)用于服务发现

热门文章

  1. docker运行分布式搜索引擎ES容器max virtual memory areas vm.max_map_count [65530] is too low, increase to at leas
  2. 微信朋友圈新增仅最近一个月可见;OpenAI 发布音乐生成网络 MuseNet
  3. 开发者必看!Windows Server 2012全攻略
  4. 组策略应用:软件分配及软件发布
  5. (转载)你好,C++(6)2.3 C++兵器谱
  6. matlab 双目 景深,双照相机景深分析的思路
  7. PartyOK酒水知识大全
  8. Python包装网页微信API并实现简单自动回复
  9. 数据治理-理论-2-基本过程
  10. BLDC(直流无刷电机)反电动势测量/观测模型