QUANTAXIS的行情分析与研究部分

QUANTAXIS的行情分析与研究部分

主要是针对行情的各种统计学特征/指标等分析,支持QADataStruct系列的add_func()功能。

接受DataFrame形式的行情以及QA.QADATA格式的行情。
目前的属性有:

  1. 一阶差分;
  2. 样本方差;
  3. 方差;
  4. 标准差;
  5. 样本标准差;
  6. 平均数;
  7. 调和平均数;
  8. 众数;
  9. 振幅(极差);
  10. 偏度;
  11. 峰度;
  12. 百分比变化;
  13. 平均绝对偏差。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import QUANTAXIS as QA
da = QA.QA_fetch_stock_day_adv('000001', '2018-01-01', '2018-09-24')
# 可选to_qfq()和to_hfq()
s = QA.QAAnalysis_stock(da)
type(s)
Out[54]: QUANTAXIS.QAAnalysis.QAAnalysis_dataframe.QAAnalysis_stock
# open/close/high/low/vol/volume/date/datetime/index
s.open.head()
Out[56]:
date code
2018-01-02 000001 13.35
2018-01-03 000001 13.73
2018-01-04 000001 13.32
2018-01-05 000001 13.21
2018-01-08 000001 13.25
Name: open, dtype: float64
s.index
Out[57]:
MultiIndex(levels=[[2018-01-02 00:00:00, 2018-01-03 00:00:00,
······
2018-09-14 00:00:00, 2018-09-17 00:00:00, 2018-09-18 00:00:00, 2018-09-19 00:00:00, 2018-09-20 00:00:00, 2018-09-21 00:00:00], ['000001']],
labels=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
······
177, 178], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
······
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
names=['date', 'code'])
# 平均价(O+H+L+C)/4
s.price.head()
Out[59]:
date code
2018-01-02 000001 13.5750
2018-01-03 000001 13.5300
2018-01-04 000001 13.2675
2018-01-05 000001 13.2525
2018-01-08 000001 13.0900
dtype: float64
# 平均价的mean/max/min/mad(平均绝对偏差)/mode(众数)
s.mad
Out[61]: 1.3226729814924636
# 平均价的diff(一节差分)/variance/
# pvariance(样本方差)/stdev(标准差)/
# pstdev(样本标准差)/mean_harmonic(调和平均数)/
# amplitude(振幅[极差])/skewness(偏度)/kurtosis(峰度)/
# pct_chage(百分比变化序列)
s.mean_harmonic
Out[67]: 10.698158508671485
s.pct_change.head()
Out[68]:
date code
2018-01-02 000001 NaN
2018-01-03 000001 -0.003315
2018-01-04 000001 -0.019401
2018-01-05 000001 -0.001131
2018-01-08 000001 -0.012262
dtype: float64

【add_func()功能】:

1
2
3
4
5
6
7
8
9
s.add_func(QA.QA_indicator_KDJ).head()
Out[73]:
KDJ_D KDJ_J KDJ_K
date code
2018-01-11 000001 64.485981 64.485981 64.485981
2018-01-12 000001 64.485981 64.485981 64.485981
2018-01-15 000001 67.449368 85.229689 73.376142
2018-01-16 000001 71.067376 92.775426 78.303393
2018-01-17 000001 72.625511 81.974320 75.741781

# Python

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×