From a246fd11cb3ffc08f21992b6d8bf5475e990faeb Mon Sep 17 00:00:00 2001 From: don2vito <43207483+don2vito@users.noreply.github.com> Date: Thu, 29 Sep 2022 10:20:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pytdx_day.xlsx" | Bin 0 -> 5875 bytes ...7\245\347\272\277\346\225\260\346\215\256.py" | 12 ++++++++++++ 2 files changed, 12 insertions(+) create mode 100644 "001_\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256/pytdx_day.xlsx" diff --git "a/001_\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256/pytdx_day.xlsx" "b/001_\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256/pytdx_day.xlsx" new file mode 100644 index 0000000000000000000000000000000000000000..d7e180e468e7742eec6d24e7dae4367bfa8081be GIT binary patch literal 5875 zcmZ`-1yq#X)*d>gk(7?1XJF_~=>~xj5$Wy{0qG725v02jBqbyUkOt{gKtRf&Te#!* z-FvNx->sF})TN0FZzR01zX7fyz2L zx?4E9o9OyDTeul>dpp=yCJ(B2g9zl$6t88!aVam>N@4Qv1@#fJYe{s>CiRw?L9=XZ zZnKmw3Fxe&=hZ6Ae=NH7#fgz~QKfRx<=$&2`I*PcyDvh%Q(Wl%R&2eIK~{SiNG6v2 z3=OEzJs90-PKw0$YQKALic%55nZ)!8&zpA>wdD% z4t-cKM#Zo0RE_=g5O|VEgsf#gp>xFc`U`UXt=)GxyRZ^Ug>y$D5 z8+7~2C*F36{0Xsoc~(>Jl+$zi*yNHccurfciTHF=raEYj!l2mJC=?(ca}`B%(^MZG zXgKO^xYJq5oMhpv=uQ9i$Od4av0%;@^SvAX zLX~`eg=El|NG;F7Eu8@T+9OH#Z}rMgpRgT>JD(=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O~NSbJH)ReTqIFA8q z9lO@+0w8h^gv|C)-r4g9k~yDz%7h&1f`}e;=IVL)>VRb5H0;~fBkiCy0TYrLhmx(~ zZS>@#4H!zsMAYmNPzUCd+&WQv;8l@mhfn&l8CI6-Hk$;J86V;J%Ww8F>9h;(fDsUc zPTD8@JyW+;H3r9$y=?Jgp~C%#DDS7WG8QpdSC3BSg6Je2&ph&s*s1e1%3dB4%aVv^ za>T0~7KyNKzC%#oc|`zVKe2Hh?6UXS>DE~!m@M)`4Cyy81(A&Z|3v97&)rGOZ=Oa(_#t@yaqe=L<*woU&2ozVUzY#a&%5BeuIV?} z5ux%wd8oS#cP+_p1|6)w8UAZf?n3W&slTDVh-u|N^sILY?$*HH1Wynp@&8oByYRco g{u^FL^gr-_r@p2N8bVJ102}dri8yEDUoI2yFUW`%W&i*H literal 0 HcmV?d00001 diff --git "a/001_\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256/\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256.py" "b/001_\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256/\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256.py" index 237d346..068192c 100644 --- "a/001_\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256/\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256.py" +++ "b/001_\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256/\350\216\267\345\217\226\350\202\241\347\245\250\346\227\245\347\272\277\346\225\260\346\215\256.py" @@ -1,6 +1,7 @@ import pandas as pd from struct import unpack import os +from pytdx.reader import TdxDailyBarReader,TdxFileNotFoundException import akshare as ak import baostock as bs from opendatatools import stock @@ -43,6 +44,16 @@ def TDX2df(file_name): print('成功导出 Excel 文件!') +# 将 pytdx 日线数据转换为 dataframe +# 注意,导出的数据未复权! +def pytdx2df(file_name): + reader = TdxDailyBarReader() + pytdx_df = reader.get_df(file_name) + pytdx_df = pytdx_df.loc['20120301':'20120315'] + print(f'将 pytdx 日线数据转换为 dataframe:\n{pytdx_df}') + pytdx_df.to_excel('./pytdx_day.xlsx',index=False) + print('成功导出 Excel 文件!') + # 将 akshare 日线数据转换为 dataframe def akshare2df(): ''' @@ -160,6 +171,7 @@ def opendatatools2df(): def main(): file_name = './sh600006.day' TDX2df(file_name) + pytdx2df(file_name) akshare2df() baostock2df() opendatatools2df()