Skip to content

Commit

Permalink
更新代码
Browse files Browse the repository at this point in the history
  • Loading branch information
don2vito authored Sep 29, 2022
1 parent 65b481c commit a246fd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Binary file added 001_获取股票日线数据/pytdx_day.xlsx
Binary file not shown.
12 changes: 12 additions & 0 deletions 001_获取股票日线数据/获取股票日线数据.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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():
'''
Expand Down Expand Up @@ -160,6 +171,7 @@ def opendatatools2df():
def main():
file_name = './sh600006.day'
TDX2df(file_name)
pytdx2df(file_name)
akshare2df()
baostock2df()
opendatatools2df()
Expand Down

0 comments on commit a246fd1

Please sign in to comment.