CzscTrader
- class czsc.traders.CzscTrader(bg: BarGenerator | None = None, positions: List[Position] | None = None, ensemble_method: AnyStr | Callable = 'mean', **kwargs)[source]
Bases:
CzscSignals缠中说禅技术分析理论之多级别联立交易决策类(支持多策略独立执行)
Attributes Summary
判断仓位是否发生变化
Methods Summary
get_ensemble_pos([method])获取多个仓位的集成仓位
on_bar(bar)输入基础周期已完成K线,更新信号,更新仓位
on_sig(sig)通过信号字典直接交易
take_snapshot([file_html, width, height])获取快照
update(bar)输入基础周期已完成K线,更新信号,更新仓位
Attributes Documentation
- pos_changed
判断仓位是否发生变化
- Returns:
True/False
Methods Documentation
- get_ensemble_pos(method: AnyStr | Callable | None = None) float[source]
获取多个仓位的集成仓位
- Parameters:
method –
多个仓位集成一个仓位的方法,可选值 mean, vote, max;也可以传入一个回调函数
假设有三个仓位对象,当前仓位分别是 1, 1, -1 mean - 平均仓位,pos = np.mean([1, 1, -1]) = 0.33 vote - 投票表决,pos = 1 max - 取最大,pos = 1
对于传入回调函数的情况,输入是 self.positions
- Returns:
pos, 集成仓位