trendet是一个python包,用于对股票时间序列数据进行趋势检测
trendet的Python项目详细描述
trendet是一个python包,用于对股票时间序列数据进行趋势检测
简介
trendet是一个python包,用于检测市场趋势,以便分析其行为。所以,这个包裹
在数据检索方面支持investpy功能
来自不同的金融产品,如股票/股票、基金或ETF;并打算与之结合,
而且每一个pandas.DataFrame
,格式化为ohlc。
安装
要使此软件包正常工作,您需要使用pip安装它,方法是在终端上键入:
$ python -m pip install trendet --upgrade
或者只安装当前版本或特定版本,如:
$ python -m pip install trendet==0.4
用法
由于trendet打算与investpy结合使用,因此主要功能是 检测股票时间序列数据的趋势,以便分析市场及其行为 在一定的日期范围内。
在下面的例子中,将使用identify_all_trends
函数来检测每一个看跌/看涨趋势
当时间窗口超过5天时,例如,这意味着每一个看跌(下降)趋势
长度超过5天将被确定为下降趋势,依此类推添加到已经包含
ohlc值,在名为up trend和down trend的新列中,这些列将按指定进行标记,并带有字母
默认情况下从A到Z。
importtrendetimportmatplotlib.pyplotaspltimportseabornassnssns.set(style='darkgrid')df=trendet.identify_all_trends(equity='bbva',from_date='01/01/2018',to_date='01/01/2019',window_size=5,identify='both')df.reset_index(inplace=True)withplt.style.context('paper'):plt.figure(figsize=(20,10))ax=sns.lineplot(x=df['Date'],y=df['Close'])labels=df['Up Trend'].dropna().unique().tolist()forlabelinlabels:sns.lineplot(x=df[df['Up Trend']==label]['Date'],y=df[df['Up Trend']==label]['Close'],color='green')ax.axvspan(df[df['Up Trend']==label]['Date'].iloc[0],df[df['Up Trend']==label]['Date'].iloc[-1],alpha=0.2,color='green')labels=df['Down Trend'].dropna().unique().tolist()forlabelinlabels:sns.lineplot(x=df[df['Down Trend']==label]['Date'],y=df[df['Down Trend']==label]['Close'],color='red')ax.axvspan(df[df['Down Trend']==label]['Date'].iloc[0],df[df['Down Trend']==label]['Date'].iloc[-1],alpha=0.2,color='red')plt.show()
可以在docs或下面找到进一步的用法细节 gist。不管怎样, 您可以创建自己的脚本,说明如何使用trendet或如何使用它来改进其功能。
贡献
由于这是一个开源项目,它对贡献、错误报告、错误修复、文档改进都是开放的, 改进和想法。
还有一个issues的打开选项卡,任何人都可以在其中贡献打开 新的问题,如果需要或浏览他们,以解决他们或有助于解决。
免责声明
创建此包是为了根据通过 investpy所以要确定市场上流行的趋势 基于单个股票/股权OHLC价值。
得出结论,这是一个研究项目的结果,因此本包的开发具有研究目的和 没有利润。
已经用matplotlib和 seaborn,使用@Dih5paper-themes强烈推荐用于科学出版物。