Subpackages

czsc Package

Functions

EMA(close[, timeperiod])

https://baike.baidu.com/item/EMA/12646151

KDJ(close, high, low)

param close

收盘价序列

MACD(close[, fastperiod, slowperiod, ...])

MACD 异同移动平均线 https://baike.baidu.com/item/MACD%E6%8C%87%E6%A0%87/6271283

SMA(close[, timeperiod])

简单移动平均

create_advanced_trader(bg, raw_bars, strategy)

为交易策略 tactic 创建对应的 trader

empty_cache_path()

get_dir_size(path)

获取目录大小,单位:Bytes

Classes

CZSC(bars[, get_signals, max_bi_num])

CzscAdvancedTrader(bg[, strategy])

缠中说禅技术分析理论之多级别联立交易决策类(支持分批开平仓 / 支持从任意周期开始交易)

Direction(value)

An enumeration.

Event(name, operate, factors[, signals_all, ...])

Factor(name, signals_all[, signals_any, ...])

Freq(value)

An enumeration.

NewBar(symbol, id, dt, freq, open, ], close, ...)

去除包含关系后的K线元素

Operate(value)

An enumeration.

RawBar(symbol, id, dt, freq, open, ], close, ...)

原始K线元素

Signal([signal, score, k1, k2, k3, v1, v2, v3])

czsc.analyze Module

Functions

check_bi(bars[, benchmark])

输入一串无包含关系K线,查找其中的一笔

check_fx(k1, k2, k3)

查找分型

check_fxs(bars)

输入一串无包含关系K线,查找其中所有分型

kline_pro(kline[, fx, bi, xd, bs, title, ...])

绘制缠中说禅K线分析结果

remove_include(k1, k2, k3)

去除包含关系:输入三根k线,其中k1和k2为没有包含关系的K线,k3为原始K线

Classes

BI(symbol[, fx_a, fx_b, fxs, direction, ...])

CZSC(bars[, get_signals, max_bi_num])

Direction(value)

An enumeration.

FX(symbol, dt, mark, high, ], low, ], fx, ], ...)

Mark(value)

An enumeration.

NewBar(symbol, id, dt, freq, open, ], close, ...)

去除包含关系后的K线元素

OrderedDict

Dictionary that remembers insertion order

RawBar(symbol, id, dt, freq, open, ], close, ...)

原始K线元素

czsc.signals Package

Functions

bar_accelerate_V221110(c[, di, window])

辨别加速走势

bar_accelerate_V221118(c[, di, window, ma1])

辨别加速走势

bar_cross_ps_V221112(c[, di, num])

倒数第 di 根 K 线穿越支撑、压力位的数量【慎用,非常耗时】

bar_end_V221111(c[, k1])

分钟 K 线结束

bar_mean_amount_V221112(c[, di, n, th1, th2])

截取一段时间内的平均成交金额分类信号

bar_operate_span_V221111(c[, k1, span])

日内操作时间区间,c 必须是

bar_section_momentum_V221112(c[, di, n, th])

获取某个区间(固定K线数量)的动量强弱

bar_vol_grow_V221112(c[, di, n])

倒数第 i 根 K 线的成交量相比于前 N 根 K 线放量

bar_zdf_V221203(c[, di, mode, span])

单根K线的涨跌幅区间

bar_zdt_V221110(c[, di])

计算倒数第di根K线的涨跌停信息

bar_zdt_V221111(cat, freq[, di])

更精确地倒数第1根K线的涨跌停计算

byi_symmetry_zs_V2211007(c[, di])

对称中枢信号

coo_td_V221110(c[, di])

获取倒数第i根K线的TD信号

cxt_bi_break_V221126(c[, di])

向上笔突破回调不破信号

cxt_first_buy_V221126(c[, di])

一买信号

cxt_first_sell_V221126(c[, di])

一卖信号

cxt_fx_power_V221107(c[, di])

倒数第di个分型的强弱

jcc_bai_san_bin_V221030(c[, di, th])

白三兵;贡献者:鲁克林

jcc_ci_tou_V221101(c[, di, z, th])

刺透形态

jcc_fan_ji_xian_V221121(c[, di])

反击线;贡献者:lynxluu

jcc_fen_shou_xian_V20221113(c[, di, zdf])

分手线:分手形态是一个中继形态;贡献者:琅盎

jcc_gap_yin_yang_V221121(c[, di])

跳空与并列阴阳形态 贡献者:平凡

jcc_ping_tou_V221113(c[, di, th])

平头形态,贡献者:平凡

jcc_san_fa_V20221115(c[, di, zdf])

上升&下降三法;贡献者:琅盎

jcc_san_fa_V20221118(c[, di])

上升&下降三法

jcc_san_szx_V221122(c[, di, th])

三星形态

jcc_san_xing_xian_V221023(c[, di, th])

伞形线

jcc_shan_chun_V221121(c[, di])

山川形态,表示三山形态和三川形态

jcc_szx_V221111(c[, di, th])

十字线

jcc_ta_xing_V221124(c[, di])

塔形顶底

jcc_ten_mo_V221028(c[, di])

吞没形态;贡献者:琅盎

jcc_three_crow_V221108(c[, di])

三只乌鸦,贡献者:马鸣

jcc_three_soldiers_V221030(c[, di, th, ri])

白三兵,贡献者:鲁克林

jcc_two_crow_V221108(c[, di])

两只乌鸦

jcc_wu_yun_gai_ding_V221101(c[, di, z, th])

乌云盖顶,贡献者:魏永超

jcc_xing_xian_V221118(c[, di, th])

星形态

jcc_yun_xian_V221118(c[, di])

孕线形态

jcc_zhu_huo_xian_V221027(c[, di, th, zf])

烛火线,贡献者:琅盎

jcc_zhuo_yao_dai_xian_v221113(c[, di, left])

捉腰带线,贡献者:平凡

tas_boll_bc_V221118(c[, di, n, m, line])

BOLL背驰辅助

tas_boll_power_V221112(c[, di])

BOLL指标强弱

tas_double_ma_V221203(c[, di, ma1, ma2, th])

双均线多空和强弱信号

tas_double_rsi_V221203(c[, di, rsi1, rsi2])

两个周期的RSI多空信号

tas_kdj_base_V221101(c[, di, key])

KDJ金叉死叉信号

tas_ma_base_V221101(c[, di, key])

MA 多空和方向信号

tas_ma_base_V221203(c[, di, key, th])

MA 多空和方向信号,加距离限制

tas_ma_round_V221206(c[, di, key, th])

笔端点在均线附近

tas_macd_base_V221028(c[, di, key])

MACD|DIF|DEA 多空和方向信号

tas_macd_bc_V221201(c[, di, n, m])

MACD背驰辅助

tas_macd_change_V221105(c[, di, n])

MACD颜色变化;贡献者:马鸣

tas_macd_direct_V221106(c[, di])

MACD方向;贡献者:马鸣

tas_macd_power_V221108(c[, di])

MACD强弱

tas_macd_xt_V221208(c[, di])

MACD形态信号

update_boll_cache(c, **kwargs)

更新K线的BOLL缓存

update_kdj_cache(c, **kwargs)

更新KDJ缓存

update_ma_cache(c, ma_type, timeperiod, **kwargs)

更新均线缓存

update_macd_cache(c, **kwargs)

更新MACD缓存

update_rsi_cache(c, **kwargs)

更新RSI缓存

czsc.sensors Package

Functions

check_signals_acc(bars[, signals, strategy, ...])

人工验证形态信号识别的准确性的辅助工具:

compound_returns(n1b)

复利收益计算

discretizer(df, col[, n_bins, encode, strategy])

使用 KBinsDiscretizer 对连续变量在时间截面上进行离散化

generate_signals(bars, sdt, strategy)

获取历史信号

generate_stocks_signals(dc, signals_path, ...)

使用 Tushare 数据获取股票市场全部股票的信号

generate_symbol_signals(dc, ts_code, asset, ...)

使用 Tushare 数据生产某个标的的信号

get_index_beta(dc, sdt, edt[, freq, ...])

获取基准指数的Beta

read_cached_signals(file_output[, path_pat, ...])

读取缓存信号

turn_over_rate(df_holds)

计算持仓明细对应的组合换手率

Classes

StocksDaySensor(experiment_path, sdt, edt, ...)

以日线为基础周期的强势股票感应器

ThsConceptsSensor(results_path, sdt, edt, ...)

输入:同花顺概念列表;同花顺概念日线行情 输出:每一个交易日的同花顺强势概念

czsc.traders Package

Functions

create_advanced_trader(bg, raw_bars, strategy)

为交易策略 tactic 创建对应的 trader

trade_replay(bg, raw_bars, strategy, res_path)

交易策略交易过程回放

trader_fast_backtest(bars, init_n, strategy)

纯 CTA 择时系统快速回测,多空交易通通支持

Classes

CzscAdvancedTrader(bg[, strategy])

缠中说禅技术分析理论之多级别联立交易决策类(支持分批开平仓 / 支持从任意周期开始交易)

CzscDummyTrader(dfs, strategy)

虚拟交易员,直接输入信号驱动,不需要输入K线

PairsPerformance(df_pairs)

交易对效果评估

TradeSimulator(dc, strategy[, res_path, init_n])

交易策略仿真跟踪

TradersPerformance(traders_pat)

Trader Strategy 的效果评估

TsStocksBacktest(dc, strategy, init_n, sdt, edt)

基于 Tushare 数据的择时回测系统(股票市场)

czsc.utils Package

Functions

check_gap_info(bars)

检查 bars 中的缺口信息

check_pressure_support(bars[, q_seq])

检查 bars 中的支撑、压力信息

create_logger(log_file[, name, cmd, level])

define a logger for your program

dill_dump(data, file)

dill_load(file)

fast_slow_cross(fast, slow)

计算 fast 和 slow 的交叉信息

freq_end_time(dt, freq)

获取 dt 对应的K线周期结束时间

get_py_namespace(file_py[, keys])

获取 python 脚本文件中的 namespace

get_sub_elements(elements[, di, n])

获取截止到倒数第 di 个元素的前 n 个元素

heat_map(data[, x_label, y_label, title, ...])

绘制热力图

is_bis_down(bis)

判断 bis 中的连续笔是否是向下的

is_bis_up(bis)

判断 bis 中的连续笔是否是向上的

kline_pro(kline[, fx, bi, xd, bs, title, ...])

绘制缠中说禅K线分析结果

nmi_matrix(df[, heatmap])

计算高维标准化互信息并以矩阵形式输出

read_json(file)

same_dir_counts(seq)

计算 seq 中与最后一个数字同向的数字数量

save_json(data, file)

single_linear(y[, x])

单变量线性拟合

x_round(x[, digit])

用去尾法截断小数

Classes

BarGenerator(base_freq, freqs[, max_count])

使用日线合成周线、月线、季线

WordWriter([file_docx])

用 Word 文档记录信息

czsc.aphorism Module

Functions

print_one()

czsc.enum Module

Classes

Direction(value)

An enumeration.

Enum(value)

Generic enumeration.

Freq(value)

An enumeration.

Mark(value)

An enumeration.

Operate(value)

An enumeration.

czsc.envs Module

Functions

get_bi_change_th([v])

bi_change_th - 成笔需要超过benchmark的比例阈值

get_max_bi_num([v])

max_bi_num - 单个级别K线分析中,程序最大保存的笔数量

get_min_bi_len([v])

min_bi_len - 一笔的最小长度,也就是无包含K线的数量,7是老笔的要求,6是新笔的要求

get_verbose([verbose])

verbose - 是否输出执行过程的详细信息

get_welcome()

welcome - 是否输出版本标识和缠中说禅博客摘记

czsc.objects Module

Functions

RSQ(close)

拟合优度 R Square

cal_break_even_point(seq)

计算单笔收益序列的盈亏平衡点

create_fake_bis(fxs)

创建 fake_bis 列表

dataclass([cls, init, repr, eq, order, ...])

Returns the same class as was passed in, with dunder methods added based on the fields defined in the class.

evaluate_pairs(pairs, symbol, trade_dir[, cost])

评估交易表现

Classes

BI(symbol[, fx_a, fx_b, fxs, direction, ...])

Direction(value)

An enumeration.

Event(name, operate, factors[, signals_all, ...])

FX(symbol, dt, mark, high, ], low, ], fx, ], ...)

Factor(name, signals_all[, signals_any, ...])

FakeBI(symbol, sdt, edt, direction, high, ], ...)

虚拟笔:主要为笔的内部分析提供便利

Freq(value)

An enumeration.

Machine([model, states, initial, ...])

Machine manages states, transitions and models.

Mark(value)

An enumeration.

NewBar(symbol, id, dt, freq, open, ], close, ...)

去除包含关系后的K线元素

Operate(value)

An enumeration.

Position(symbol, events[, hold_a, hold_b, ...])

PositionLong(symbol[, hold_long_a, ...])

PositionShort(symbol[, hold_short_a, ...])

RawBar(symbol, id, dt, freq, open, ], close, ...)

原始K线元素

Signal([signal, score, k1, k2, k3, v1, v2, v3])

Tick(symbol[, name, price, vol])

ZS(symbol, bis[, cache])

中枢对象,主要用于辅助信号函数计算

datetime(year, month, day[, hour[, minute[, ...)

The year, month and day arguments are required.

czsc.strategies Module

Functions

trader_example1(symbol[, T0, min_interval])

A股市场择时策略样例,支持按交易标的独立设置参数

trader_standard(symbol[, T0, min_interval])

择时策略编写的一些标准说明

trader_strategy_a(symbol)

A股市场择时策略A

czsc.ai Package

Functions

evaluate_estimator(estimator, df, x_cols[, ...])

评估模型表现

get_datetime_spans(sdt, edt, train_days, ...)

滚动训练数据分割时间范围

train_estimator(estimator, df, x_cols, ...)

训练模型