forked from waditu/czsc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 0.9.15 start coding * 0.9.15 fix bug * 0.9.15 fix bug * 0.9.15 彻底删除 get_signals 参数 * 0.9.15 新增投研数据共享接口 * 0.9.15 update * 0.9.15 update * 0.9.15 update * 0.9.15 update * 0.9.15 update * 0.9.15 update * 0.9.15 update * 0.9.15 update * 0.9.15 update docs * 0.9.15 新增 config_to_keys * 0.9.15 update * 0.9.15 优化 get_signals_freqs 方法 * 0.9.15 update * 0.9.15 update * 0.9.15 fix bug: dummy 模式下 sdt 不生效
- Loading branch information
Showing
35 changed files
with
315 additions
and
1,344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,10 @@ | |
from czsc.sensors import holds_concepts_effect, StocksDaySensor, ThsConceptsSensor, SignalsPerformance | ||
|
||
|
||
__version__ = "0.9.14" | ||
__version__ = "0.9.15" | ||
__author__ = "zengbin93" | ||
__email__ = "[email protected]" | ||
__date__ = "20230323" | ||
__date__ = "20230331" | ||
|
||
|
||
def welcome(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
author: zengbin93 | ||
email: [email protected] | ||
create_dt: 2023/3/5 20:45 | ||
describe: CZSC投研数据共享接口 | ||
投研数据共享说明(含下载地址):https://s0cqcxuy3p.feishu.cn/wiki/wikcnzuPawXtBB7Cj7mqlYZxpDh | ||
""" | ||
import os | ||
import czsc | ||
import glob | ||
import pandas as pd | ||
|
||
# 投研共享数据的本地缓存路径,需要根据实际情况修改 | ||
cache_path = os.environ.get('czsc_research_cache', r"D:\CZSC投研数据") | ||
if not os.path.exists(cache_path): | ||
raise ValueError(f"请设置环境变量 czsc_research_cache 为投研共享数据的本地缓存路径,当前路径不存在:{cache_path}。\n\n" | ||
f"投研数据共享说明(含下载地址):https://s0cqcxuy3p.feishu.cn/wiki/wikcnzuPawXtBB7Cj7mqlYZxpDh") | ||
|
||
|
||
def get_symbols(name, **kwargs): | ||
"""获取指定分组下的所有标的代码 | ||
:param name: 分组名称,可选值:'A股主要指数', 'A股场内基金', '中证500成分股', '期货主力' | ||
:param kwargs: | ||
:return: | ||
""" | ||
files = glob.glob(os.path.join(cache_path, name, "*.parquet")) | ||
return [os.path.basename(x).replace('.parquet', '') for x in files] | ||
|
||
|
||
def get_raw_bars(symbol, freq, sdt, edt, fq='前复权', **kwargs): | ||
"""获取 CZSC 库定义的标准 RawBar 对象列表 | ||
:param symbol: 标的代码 | ||
:param freq: 周期,支持 Freq 对象,或者字符串,如 | ||
'1分钟', '5分钟', '15分钟', '30分钟', '60分钟', '日线', '周线', '月线', '季线', '年线' | ||
:param sdt: 开始时间 | ||
:param edt: 结束时间 | ||
:param fq: 除权类型,投研共享数据默认都是后复权,不需要再处理 | ||
:param kwargs: | ||
:return: | ||
""" | ||
kwargs['fq'] = fq | ||
file = glob.glob(os.path.join(cache_path, "*", f"{symbol}.parquet"))[0] | ||
freq = czsc.Freq(freq) | ||
kline = pd.read_parquet(file) | ||
if 'dt' not in kline.columns: | ||
kline['dt'] = pd.to_datetime(kline['datetime']) | ||
kline = kline[(kline['dt'] >= sdt) & (kline['dt'] <= edt)] | ||
_bars = czsc.resample_bars(kline, freq, raw_bars=True) | ||
return _bars | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.