Comments (6)
效果图如下
{'open': 3432.45, 'high': 3454.14, 'low': 3374.32, 'close': 3423.61, 'amount': 61893476352.0, 'volume': 618934736, 'time_stamp': 1436405700.0, 'datetime': Timestamp('2015-07-09 09:35:00'), 'code': '000001', 'market': 'sh'}
{'open': 3420.56, 'high': 3424.16, 'low': 3395.07, 'close': 3396.33, 'amount': 23416520704.0, 'volume': 234165181, 'time_stamp': 1436406000.0, 'datetime': Timestamp('2015-07-09 09:40:00'), 'code': '000001', 'market': 'sh'}
{'open': 3397.06, 'high': 3397.32, 'low': 3382.25, 'close': 3383.08, 'amount': 17053605888.0, 'volume': 170536031, 'time_stamp': 1436406300.0, 'datetime': Timestamp('2015-07-09 09:45:00'), 'code': '000001', 'market': 'sh'}
{'open': 3381.05, 'high': 3404.28, 'low': 3374.14, 'close': 3404.28, 'amount': 17060175872.0, 'volume': 170601731, 'time_stamp': 1436406600.0, 'datetime': Timestamp('2015-07-09 09:50:00'), 'code': '000001', 'market': 'sh'}
{'open': 3402.08, 'high': 3465.62, 'low': 3401.77, 'close': 3465.62, 'amount': 27869265920.0, 'volume': 278692631, 'time_stamp': 1436406900.0, 'datetime': Timestamp('2015-07-09 09:55:00'), 'code': '000001', 'market': 'sh'}
{'open': 3466.38, 'high': 3483.81, 'low': 3466.16, 'close': 3471.63, 'amount': 31448236032.0, 'volume': 314482333, 'time_stamp': 1436407200.0, 'datetime': Timestamp('2015-07-09 10:00:00'), 'code': '000001', 'market': 'sh'}
{'open': 3470.96, 'high': 3475.17, 'low': 3456.41, 'close': 3475.17, 'amount': 17236410368.0, 'volume': 172364080, 'time_stamp': 1436407500.0, 'datetime': Timestamp('2015-07-09 10:05:00'), 'code': '000001', 'market': 'sh'}
{'open': 3474.17, 'high': 3517.85, 'low': 3474.17, 'close': 3517.85, 'amount': 19058606080.0, 'volume': 190586035, 'time_stamp': 1436407800.0, 'datetime': Timestamp('2015-07-09 10:10:00'), 'code': '000001', 'market': 'sh'}
{'open': 3519.25, 'high': 3593.3, 'low': 3519.25, 'close': 3593.3, 'amount': 27075018752.0, 'volume': 270750160, 'time_stamp': 1436408100.0, 'datetime': Timestamp('2015-07-09 10:15:00'), 'code': '000001', 'market': 'sh'}
{'open': 3591.75, 'high': 3598.01, 'low': 3547.12, 'close': 3547.12, 'amount': 24563826688.0, 'volume': 245638240, 'time_stamp': 1436408400.0, 'datetime': Timestamp('2015-07-09 10:20:00'), 'code': '000001', 'market': 'sh'}
{'open': 3545.8, 'high': 3568.7, 'low': 3532.81, 'close': 3559.89, 'amount': 15218819072.0, 'volume': 152188163, 'time_stamp': 1436408700.0, 'datetime': Timestamp('2015-07-09 10:25:00'), 'code': '000001', 'market': 'sh'}
{'open': 3557.64, 'high': 3557.73, 'low': 3525.33, 'close': 3525.33, 'amount': 12022579200.0, 'volume': 120225766, 'time_stamp': 1436409000.0, 'datetime': Timestamp('2015-07-09 10:30:00'), 'code': '000001', 'market': 'sh'}
{'open': 3524.74, 'high': 3524.74, 'low': 3485.77, 'close': 3491.19, 'amount': 13220511744.0, 'volume': 132205091, 'time_stamp': 1436409300.0, 'datetime': Timestamp('2015-07-09 10:35:00'), 'code': '000001', 'market': 'sh'}
{'open': 3492.47, 'high': 3527.18, 'low': 3491.7, 'close': 3499.96, 'amount': 11236179968.0, 'volume': 112361770, 'time_stamp': 1436409600.0, 'datetime': Timestamp('2015-07-09 10:40:00'), 'code': '000001', 'market': 'sh'}
{'open': 3499.21, 'high': 3521.14, 'low': 3497.17, 'close': 3506.33, 'amount': 8582463488.0, 'volume': 85824606, 'time_stamp': 1436409900.0, 'datetime': Timestamp('2015-07-09 10:45:00'), 'code': '000001', 'market': 'sh'}
{'open': 3506.11, 'high': 3507.04, 'low': 3495.8, 'close': 3501.51, 'amount': 7396982784.0, 'volume': 73969798, 'time_stamp': 1436410200.0, 'datetime': Timestamp('2015-07-09 10:50:00'), 'code': '000001', 'market': 'sh'}
{'open': 3502.47, 'high': 3530.78, 'low': 3502.47, 'close': 3518.38, 'amount': 8850046976.0, 'volume': 88500442, 'time_stamp': 1436410500.0, 'datetime': Timestamp('2015-07-09 10:55:00'), 'code': '000001', 'market': 'sh'}
{'open': 3517.52, 'high': 3523.07, 'low': 3504.68, 'close': 3506.47, 'amount': 7237304320.0, 'volume': 72373015, 'time_stamp': 1436410800.0, 'datetime': Timestamp('2015-07-09 11:00:00'), 'code': '000001', 'market': 'sh'}
{'open': 3504.99, 'high': 3523.63, 'low': 3504.75, 'close': 3521.53, 'amount': 5907382272.0, 'volume': 59073791, 'time_stamp': 1436411100.0, 'datetime': Timestamp('2015-07-09 11:05:00'), 'code': '000001', 'market': 'sh'}
{'open': 3521.3, 'high': 3521.3, 'low': 3512.2, 'close': 3512.2, 'amount': 6271631360.0, 'volume': 62716284, 'time_stamp': 1436411400.0, 'datetime': Timestamp('2015-07-09 11:10:00'), 'code': '000001', 'market': 'sh'}
{'open': 3511.25, 'high': 3513.18, 'low': 3506.34, 'close': 3512.49, 'amount': 6046449664.0, 'volume': 60464469, 'time_stamp': 1436411700.0, 'datetime': Timestamp('2015-07-09 11:15:00'), 'code': '000001', 'market': 'sh'}
{'open': 3511.63, 'high': 3529.93, 'low': 3508.66, 'close': 3529.93, 'amount': 7195262976.0, 'volume': 71952605, 'time_stamp': 1436412000.0, 'datetime': Timestamp('2015-07-09 11:20:00'), 'code': '000001', 'market': 'sh'}
{'open': 3529.05, 'high': 3556.05, 'low': 3529.05, 'close': 3547.3, 'amount': 12224135168.0, 'volume': 122241321, 'time_stamp': 1436412300.0, 'datetime': Timestamp('2015-07-09 11:25:00'), 'code': '000001', 'market': 'sh'}
{'open': 3546.0, 'high': 3552.78, 'low': 3537.31, 'close': 3552.78, 'amount': 9009692672.0, 'volume': 90096894, 'time_stamp': 1436412600.0, 'datetime': Timestamp('2015-07-09 11:30:00'), 'code': '000001', 'market': 'sh'}
{'open': 3553.49, 'high': 3605.61, 'low': 3553.49, 'close': 3605.61, 'amount': 28364013568.0, 'volume': 283640106, 'time_stamp': 1436418300.0, 'datetime': Timestamp('2015-07-09 13:05:00'), 'code': '000001', 'market': 'sh'}
{'open': 3605.09, 'high': 3617.75, 'low': 3605.09, 'close': 3617.71, 'amount': 20885766144.0, 'volume': 208857635, 'time_stamp': 1436418600.0, 'datetime': Timestamp('2015-07-09 13:10:00'), 'code': '000001', 'market': 'sh'}
{'open': 3617.77, 'high': 3659.13, 'low': 3617.74, 'close': 3659.13, 'amount': 23983423488.0, 'volume': 239834207, 'time_stamp': 1436418900.0, 'datetime': Timestamp('2015-07-09 13:15:00'), 'code': '000001', 'market': 'sh'}
{'open': 3660.3, 'high': 3713.07, 'low': 3660.3, 'close': 3700.2, 'amount': 27350237184.0, 'volume': 273502344, 'time_stamp': 1436419200.0, 'datetime': Timestamp('2015-07-09 13:20:00'), 'code': '000001', 'market': 'sh'}
{'open': 3698.15, 'high': 3698.15, 'low': 3674.54, 'close': 3691.47, 'amount': 17180426240.0, 'volume': 171804231, 'time_stamp': 1436419500.0, 'datetime': Timestamp('2015-07-09 13:25:00'), 'code': '000001', 'market': 'sh'}
{'open': 3691.69, 'high': 3691.69, 'low': 3670.69, 'close': 3681.28, 'amount': 12354617344.0, 'volume': 123546151, 'time_stamp': 1436419800.0, 'datetime': Timestamp('2015-07-09 13:30:00'), 'code': '000001', 'market': 'sh'}
{'open': 3681.33, 'high': 3684.42, 'low': 3670.27, 'close': 3670.27, 'amount': 10689773568.0, 'volume': 106897708, 'time_stamp': 1436420100.0, 'datetime': Timestamp('2015-07-09 13:35:00'), 'code': '000001', 'market': 'sh'}
.....
from pytdx.
新修改了一下 直接在dataframe上修改,快多啦
from pytdx.
在quantaxis上已经可以存啦
https://github.com/yutiansut/QUANTAXIS/blob/0.4.0-alpha/update_log.md#131-通达信5分钟线解析保存
from pytdx.
@yutiansut nice
from pytdx.
修改后的
import datetime
import json
import os
import sys
import time
import pymongo
from pytdx.reader import TdxFileNotFoundException, TdxMinBarReader
from QUANTAXIS.QAUtil import QA_Setting,QA_util_log_info
def QA_save_tdx_to_mongo(file_dir, client=QA_Setting.client):
reader = TdxMinBarReader()
__coll = client.quantaxis.stock_min_five
for a, v, files in os.walk(file_dir):
for file in files:
if (str(file)[0:2] == 'sh' and int(str(file)[2]) == 6) or \
(str(file)[0:2] == 'sz' and int(str(file)[2]) == 0) or \
(str(file)[0:2] == 'sz' and int(str(file)[2]) == 3):
QA_util_log_info('Now_saving '+str(file)[2:8]+'\'s 5 min tick')
fname = file_dir + '\\' + file
df = reader.get_df(fname)
df['code'] = str(file)[2:8]
df['market'] = str(file)[0:2]
df['datetime'] = list(df.index)
data_json = json.loads(df.to_json(orient='records'))
__coll.insert_many(data_json)
if __name__ == '__main__':
file_dir = ['C:\\users\\yutiansut\\desktop\\sh5fz','C:\\users\\yutiansut\\desktop\\sz5fz']
for item in file_dir:
QA_save_tdx_to_mongo(item)
from pytdx.
In [2]: QA.QA_SU_save_stock_min_5('C:\\users\\yutiansut\\desktop\\sz5fz')
QUANTAXIS>> Now_saving 000001's 5 min tick
QUANTAXIS>> Now_saving 000002's 5 min tick
QUANTAXIS>> Now_saving 000004's 5 min tick
QUANTAXIS>> Now_saving 000005's 5 min tick
QUANTAXIS>> Now_saving 000006's 5 min tick
QUANTAXIS>> Now_saving 000007's 5 min tick
QUANTAXIS>> Now_saving 000008's 5 min tick
QUANTAXIS>> Now_saving 000009's 5 min tick
QUANTAXIS>> Now_saving 000010's 5 min tick
QUANTAXIS>> Now_saving 000011's 5 min tick
QUANTAXIS>> Now_saving 000012's 5 min tick
QUANTAXIS>> Now_saving 000014's 5 min tick
QUANTAXIS>> Now_saving 000016's 5 min tick
QUANTAXIS>> Now_saving 000017's 5 min tick
QUANTAXIS>> Now_saving 000018's 5 min tick
QUANTAXIS>> Now_saving 000019's 5 min tick
QUANTAXIS>> Now_saving 000020's 5 min tick
QUANTAXIS>> Now_saving 000021's 5 min tick
QUANTAXIS>> Now_saving 000022's 5 min tick
QUANTAXIS>> Now_saving 000023's 5 min tick
QUANTAXIS>> Now_saving 000024's 5 min tick
QUANTAXIS>> Now_saving 000025's 5 min tick
QUANTAXIS>> Now_saving 000026's 5 min tick
QUANTAXIS>> Now_saving 000027's 5 min tick
QUANTAXIS>> Now_saving 000028's 5 min tick
from pytdx.
Related Issues (20)
- 扩展行情的IP都没有可以连接的。 HOT 1
- 扩展行情里面有没有可以获取多个行情quotes的接口?
- get_security_list 请问一下这个是用来获取股票列表的吗? HOT 2
- 请教一下下载的财务数据的 315个列字段的意义问题. HOT 1
- get_security_list这个函数的pre_close有误 HOT 10
- get_security_bars取出来的vol值差了1个 HOT 4
- 跳过的4个字节估计是上一日收盘价
- get_security_list获取的数据中的pre_close有解析正确有些解析不正确 HOT 1
- 不支持美股了?
- AttributeError: __enter__
- 怎么获取行情服务器的IP HOT 1
- 官方文档代码某行缺失 HOT 1
- 请问有办法获取涨停价和跌停价吗 HOT 1
- 可以获取level2的逐笔成交明细吗? HOT 1
- 心跳包还有多线程有没有详细的文档解释? HOT 1
- TdxDailyBarReader() 读取 上海 688 的时候,异常 Unknown security type ! HOT 1
- 盘口价格是不是颠倒了 HOT 1
- exhq.py文件 运行报错 AttributeError: __enter__
- debian python 3.7 get_security_quotes 解析 servertime 报错 HOT 2
- 如何判断股票代码是否指数
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytdx.