Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
通过get_k_data()获取个股数据后,通过各个指标算法计算出相关数据。
包括MA,MD,EMA,MACD,KDJ,RSI,BOLL,WNR,DMI,BIAS,ASI,VR,ARBR,DPO,TRIX,BBI,MTM,OBV指标。
例1:获取工商银行(601398)自2018-01-01到2018-05-27的MACD指标:
import tushare as ts
data = ts.get_k_data("601398", start="2018-01-01", end="2018-05-27")
#数据按日期升序列排序
data = data.sort_values(by=["date"], ascending=True)
MACD = ts.indictor.macd(data, quick_n=12, slow_n=26, dem_n=9)
例2:绘制工商银行(601398)自2018-01-01到2018-05-27全部指标图表:
import tushare as ts
data = ts.get_k_data("601398", start="2018-01-01", end="2018-05-27")
data = data.sort_values(by=["date"], ascending=True)
ts.indictor.plot_all(data, is_show=True, output=None)
缺陷与注意事项:
1 只对计算结果正确性做了最初步的判断和检查,不能完全保证正确,需要金融界专业人士判断并指正。
2 一部分需要设置统计时长n,例如移动平均值MA(n=10),数据的前n条不可信,可以使用的有效数据应避开前n行。
3 其他指标将陆续添加。
输出图例: