Skip to content

Commit 38192f9

Browse files
committed
REFACTOR: change the examples folder
1 parent eb1747c commit 38192f9

File tree

7 files changed

+61
-50
lines changed

7 files changed

+61
-50
lines changed

PyFin/examples/__init__.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

doc/analysis/pandas.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,38 @@
33
## 数据准备
44

55
```python
6-
In [1]: from PyFin.examples.datas import sample_data
7-
In [2]: sample_data
6+
In[1]:
7+
from examples.datas import sample_data
8+
9+
In[2]: sample_data
810
Out[2]:
9-
code open close
10-
2016-01-01 1 2.0 1.7
11-
2016-01-01 2 1.0 1.6
12-
2016-01-02 1 1.5 0.9
13-
2016-01-02 2 3.0 3.8
14-
2016-01-03 1 2.4 1.6
15-
2016-01-03 2 3.5 2.1
11+
code
12+
open
13+
close
14+
2016 - 01 - 01
15+
1
16+
2.0
17+
1.7
18+
2016 - 01 - 01
19+
2
20+
1.0
21+
1.6
22+
2016 - 01 - 02
23+
1
24+
1.5
25+
0.9
26+
2016 - 01 - 02
27+
2
28+
3.0
29+
3.8
30+
2016 - 01 - 03
31+
1
32+
2.4
33+
1.6
34+
2016 - 01 - 03
35+
2
36+
3.5
37+
2.1
1638
```
1739

1840
## 构造指标
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
# -*- coding: utf-8 -*-
2-
u"""
3-
Created on 2016-12-25
4-
5-
@author: cheng.li
6-
"""
7-
8-
import datetime as dt
9-
import pandas as pd
10-
11-
sample_data = pd.DataFrame(
12-
data={'code': [1, 2, 1, 2, 1, 2],
13-
'open': [2.0, 1.0, 1.5, 3.0, 2.4, 3.5],
14-
'close': [1.7, 1.6, 0.9, 3.8, 1.6, 2.1]},
15-
index=[dt.datetime(2016, 1, 1),
16-
dt.datetime(2016, 1, 1),
17-
dt.datetime(2016, 1, 2),
18-
dt.datetime(2016, 1, 2),
19-
dt.datetime(2016, 1, 3),
20-
dt.datetime(2016, 1, 3)]
21-
)
22-
23-
sample_data = sample_data[['code', 'open', 'close']]
24-
25-
26-
if __name__ == '__main__':
27-
28-
from PyFin.api import MA
29-
ts = MA(2, 'close')
30-
res = ts.transform(sample_data, name='ma_2_no_code')
1+
# -*- coding: utf-8 -*-
2+
u"""
3+
Created on 2016-12-25
4+
5+
@author: cheng.li
6+
"""
7+
8+
import datetime as dt
9+
import pandas as pd
10+
11+
sample_data = pd.DataFrame(
12+
data={'code': [1, 2, 1, 2, 1, 2],
13+
'open': [2.0, 1.0, 1.5, 3.0, 2.4, 3.5],
14+
'close': [1.7, 1.6, 0.9, 3.8, 1.6, 2.1]},
15+
index=[dt.datetime(2016, 1, 1),
16+
dt.datetime(2016, 1, 1),
17+
dt.datetime(2016, 1, 2),
18+
dt.datetime(2016, 1, 2),
19+
dt.datetime(2016, 1, 3),
20+
dt.datetime(2016, 1, 3)]
21+
)
22+
23+
sample_data = sample_data[['code', 'open', 'close']]
24+
25+
26+
if __name__ == '__main__':
27+
28+
from PyFin.api import MA
29+
ts = MA(2, 'close')
30+
res = ts.transform(sample_data, name='ma_2_no_code')
3131
print(res)
File renamed without changes.

examples/performance.py

Whitespace-only changes.
File renamed without changes.

0 commit comments

Comments
 (0)