2016-9-3 使用Yahoo的接口也能够获取到数据 https://github.com/lukaszbanasiak/yahoo-finance
通达信网站为券商系统提供交易数据下载,如:上证所有证券日线shlday.zip,深证所有证券日线szlday.zip。shlday.zip下载加压后会得到sh000001.day、sh000002.day等312个独立的数据文件,sh000001.day代表了上证股票000001的所有日线数据。
1.日线数据格式
1-4字节 Date:LongInt; //日期
5-8字节 OPen:LongInt; //开盘*100(元)
9-12字节 High:LongInt; //最高价*100(元)
13-16字节 Low:LongInt; //最低价*100(元)
17-20字节 Close:LongInt; //收盘*100(元)
21-24字节 Amount;//成交额
25-28字节 Volume:LongInt; //Volume 成交量(股)
29-32字节 // Reserved 保留值
2.python程序
本程序代码将给定日线数据文件内容输出到csv文件以供后续程序分析用。
2.1.代码
# -*- coding:utf-8 -*-
import os
import os.path
import struct
import time,datetime
time_original='17/Sep/2012:11:40:00'
time_format=datetime.datetime.strptime(time_original,'%d/%b/%Y:%H:%M:%S')
<