读取上市以来所有的历史K线数据,前后复权数据等。支持读取日K、周K、月K、年K等数据
读取日K历史数据
# 读取历史K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.DAY).dataframe()
print(result)
输出格式 [日期,开,高,低,收,成交量,成交额]
0
0 20230227,621462.0,13.88,13.68,13.86,621462.0,8...
1 20230224,14.02,14.03,13.80,13.86,729989,101265...
2 20230223,14.00,14.32,13.98,14.05,824491,116553...
3 20230222,14.00,14.12,13.94,14.02,638922,895742...
4 20230221,14.06,14.20,13.92,14.10,990495,139315...
.. ...
315 20211109,17.48,17.65,17.26,17.53,1240573,21631...
316 20211108,17.62,17.81,17.36,17.42,1376815,24064...
317 20211105,17.85,18.00,17.57,17.64,1096040,19424...
318 20211104,18.08,18.10,17.80,17.87,983411,176067...
319 20211103,18.10,18.24,17.85,18.03,1114972,20093...
读取周K历史数据
# 读取周K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.WEEK).dataframe()
print(result)
读取月K历史数据
# 读取月K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.MONTH).dataframe()
print(result)
读取年K历史数据
# 读取年K线数据
result = dd.get_klines("000001",dsxquant.MARKET.SZ,cycle=dsxquant.config.CYCLE.YEAR).dataframe()
print(result)