[python]沪深龙虎榜数据导入通达信的自选板块,并标注于K线图上
将沪深龙虎榜数据导入通达信的自选板块,并标注于K线图上
原理:python读取前一次处理完的计算5日后涨跌幅输出的csv文件
文件名前加"[paint]"
安照通达信的画图文件和板块文件格式,输出文件
用通达信的导入功能,导入画图文件和板块文件即可
事前数据截图:

处理后所得文件:

导入通达信后板块截图:

k线截图:

代码:
#coding=utf-8 #读取'[paint]'开头的csv文件
#copyright @ WangXinsheng
#http://www.cnblogs.com/wangxinsheng/
import os
import struct
import time
import datetime def getPriceByte(infile,arg,code,ss,day):
dirc = {"-5":-3,"-3":-2,"-1":-1,"":1,"":2,"":3,"":4,"":5,"":6}
first = 0
second = 0
a = float(arg)
for i in [-5,-3,-1,1,3,5,7,9,11]:
ib = i - 2
if(a>=2**ib and a<2**i):
#print(str(a)+":["+str(2**ib)+","+str(2**i)+"]"+"i:"+str(i)+" ib:"+str(ib))
first = ib
break;
#print(first)
chushu = 2**first
if(arg >= chushu*2):
second = arg / chushu
#print(second)
second = int(second*64)
else:
second = arg / chushu -1
#print(second)
second = int(second*128) if(first<0):
first = 64 + dirc[str(first)]
else:
first = 63 + dirc[str(first)]
'''
print(first)
print(second)
print(struct.pack('B',first))
print(struct.pack('B',second))
'''
#print(struct.pack('B',first))
#print(struct.pack('B',second)) infile.write(struct.pack('B',ss))
infile.write(code.encode())
infile.write(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
infile.write(b'\x03')
infile.write('STANDK'.encode())
infile.write(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
infile.write(b'\x04')
infile.write(b'\x00')
infile.write(b'\x1a\x10\x00\x00')
infile.write(struct.pack('i',int(day)))
infile.write(b'\x00\x00')
infile.write(struct.pack('B',second))
infile.write(struct.pack('B',first))
infile.write(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdcz3\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') print(str(code)+':已在 '+day+"日,价格:"+str(arg)+"加入标记")
#infile = open("tdxline.eld","rw")
#getPriceByte(5.55)
file = open("WXSline.eld","wb")
zxg = ''
path=r'.'
files = os.listdir(path)
files.sort()
j=0
for f in files:
if(f.startswith('[paint]') and f.endswith('.csv')):
print('读取文件:'+path+'/'+f) f=open(path+'/'+f,'rt')
infos = f.readlines()
f.close()
i=0
for info in infos:
if(i==0):
i=i+1
continue
tmp = info.split(',')
if(len(tmp)<2):
continue
code = str(tmp[1].replace('"','').replace("'",""))
if(code.startswith('')):
ss = 1
else:
ss = 0
addzxg = ''
try:
zxg.index(str(ss)+code)
except:
addzxg = str(ss)+code+"\n" if(addzxg!=''):
zxg = zxg + str(ss)+code+"\n"
if(len(tmp)<10):
continue days = tmp[0].split('-')
if(len(days)<2):
days = tmp[0].split('/') if(len(days)<2):
continue if(len(days[1])<2):
days[1] = ''+days[1]
if(len(days[2])<2):
days[2] = ''+days[2]
day = days[0]+days[1]+days[2]
#print(day) priceArr = tmp[9].replace('"','').split('%')
if(len(priceArr)<2):
continue
a = float(priceArr[1].replace('[','').replace(']',''))*(1-float(priceArr[0].replace('%',''))/100)
a = round(a,2)
code = str(tmp[1].replace('"','').replace("'",""))
if(code.startswith('')):
ss = 1
else:
ss = 0 getPriceByte(file,a,code,ss,day)
'''
if(j>3):
break
else:
j=j+1
''' fileA = open("WXS条件股.ebk","w")
fileA.write(zxg)
fileA.close()
file.close()
print('处理完了\n画图文件地址:./WXSline.eld')
print('\n板块文件地址:./WXS条件股.ebk')
[python]沪深龙虎榜数据导入通达信的自选板块,并标注于K线图上的更多相关文章
- [python]沪深龙虎榜数据进一步处理,计算日后5日的涨跌幅
沪深龙虎榜数据进一步处理,计算日后5日的涨跌幅 事前数据: 前面处理得到的csv文件 文件名前加入“[wait]”等待程序处理 python代码从雅虎股票历史数据api获取数据,计算后面5日的涨跌幅 ...
- [python]数据整理,将取得的众多的沪深龙虎榜数据整一整
将昨日取得的众多的沪深龙虎榜数据整一整 提取文件夹内所有抓取下来的沪深龙虎榜数据,整理出沪深两市(含中小创)涨幅榜股票及前5大买入卖出资金净值,保存到csv文件 再手动使用数据透视表进行统计 原始数据 ...
- Python数学建模-02.数据导入
数据导入是所有数模编程的第一步,比你想象的更重要. 先要学会一种未必最佳,但是通用.安全.简单.好学的方法. 『Python 数学建模 @ Youcans』带你从数模小白成为国赛达人. 1. 数据导入 ...
- python pandas 画图、显示中文、股票K线图
目录: 1.pandas官方画图链接 2.标记图中数据点 3.画图显示中文 4.画股票K线图 5.matplotlib基本用法 6.format输出 6.format输出例子 eps_range=[0 ...
- 使用Python的pandas模块、mplfinance模块、matplotlib模块绘制K线图
目录 pandas模块.mplfinance模块和matplotlib模块介绍 pandas模块 mplfinance模块和matplotlib模块 安装mplfinance模块.pandas模块和m ...
- C#下如何用NPlot绘制期货股票K线图(2):读取数据文件让K线图自动更新
[内容介绍]上一篇介绍了K线图的基本绘制方法,但很不完善,本篇增加了它直接读取数据的功能,这对于金融市场的数据量大且又需要动态刷新功能的实现很重要. [实现方法] 1.需要一个数据文件,这里用的是直接 ...
- 【Python 数据分析】pandas数据导入
导入CSV文件数据 环境 C:\Users\Thinkpad\Desktop\Data\信息表.csv 语法 pd.read_csv(filename):从CSV文件导入数据 实现代码 import ...
- python twisted异步将数据导入到数据库中
from twisted.enterprise import adbapi from twisted.internet import reactor def creat_conn(): # 数据库基本 ...
- python读取csv文件数据绘制图像,例子绘制天气每天最高最低气温气象图
随机推荐
- VMware Workstation and Hyper-V are not compatible. 解决方案
VMware 和 Hyper-V 不能共存问题报错如下:VMware Workstation and Hyper-V are notcompatible. Remove the Hyper-V rol ...
- 【Win 10应用开发】Adaptive磁贴模板的XML文档结构
在若干天之前,老周给大家讲了Adaptive Toast通知的XML模板,所以相应地,今天老周给大家介绍一下Adaptive磁贴的新XML模板. 同样道理,你依旧可以使用8.1时候的磁贴模板,在win ...
- ng1和ng2的部分对比----angular2系列(四)
前言: angular2相比angular1做了革命性的改变.对于开发者来说,我们知道它框架的实现上改变极大.我们看到代码也能发现它写法上变化很大,似乎完全是另一个东西. 但是当我们真正去写下去的时候 ...
- 【Android】[转] Android Codec默认profile使用的是Baseline
关于Android默认Codec使用的Profile找了半天没发现,还是Google的时候发现了开源中国有网友写的这边博客,相关的内容很少,便贴了过来做个笔记. 以下内容转自Android Media ...
- git log命令全解析,打log还能这么随心所欲!
git log命令非常强大而好用,在复杂系统的版本管理中扮演着重要的角色,但默认的git log命令显示出的东西实在太丑,不好好打扮一下根本没法见人,打扮好了用alias命令拍个照片,就正式出道了! ...
- 6.Configure Domain Classes(配置领域类)【EF Code-First 系列】
在前面的部分中,我们学习了Code-First默认约定,Code-First使用默认的约定,根据你的领域类,然后生成概念模型. Code-First模式,发起了一种编程模式:约定大于配置.这也就是说, ...
- Windows应用程序快捷方式创建工具
说明 在windows中经常用到将程序添加到桌面或者是开始菜单,乘着休息时间就做了这么一个快捷的工具. 程序展示: 用法 1. 命令行(CMD命令窗口) 命令: C:\Users\Administra ...
- Windows Server配置Jenkins,实现监测SVN提交自动构建.net4.5的项目
1,持续集成 概念:http://baike.baidu.com/view/5253255.htm,对于大多数人而言,自动构建/自动测试/自动部署,已经很发挥它的价值了.选择上: 推荐jenkins, ...
- jQuery实现方式不一样的跳转到底部
jQuery跳转到页面底部效果 在线体验:http://hovertree.com/texiao/jquery/9.htm 以下是完整HTML代码: <!DOCTYPE html> < ...
- 实用的CSS3属性和使用技巧
CSS可以改进网站的设计并且开拓网站设计更多的可能性,可以令你的网页更具吸引力.对于前端开发者.网站设计师来说,掌握并熟练应用CSS是一项必不可少的技能. 下面列出了一些非常实用的CSS3属性和使用技 ...