neurostats-API 0.0.3__tar.gz → 0.0.5__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- neurostats_api-0.0.5/MANIFEST.in +2 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/PKG-INFO +73 -28
- neurostats_API-0.0.3/neurostats_API.egg-info/PKG-INFO → neurostats_api-0.0.5/README.md +72 -37
- neurostats_api-0.0.5/neurostats_API/__init__.py +1 -0
- neurostats_api-0.0.5/neurostats_API/fetchers/__init__.py +3 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/fetchers/base.py +4 -9
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/fetchers/finance_overview.py +7 -9
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/fetchers/tech.py +2 -3
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/fetchers/value_invest.py +4 -4
- neurostats_api-0.0.5/neurostats_API/tools/finance_overview_dict.yaml +136 -0
- neurostats_api-0.0.5/neurostats_API/tools/profit_lose.yaml +93 -0
- neurostats_api-0.0.5/neurostats_API/tools/seasonal_data_field_dict.txt +158 -0
- neurostats_api-0.0.5/neurostats_API/utils/__init__.py +4 -0
- neurostats_api-0.0.5/neurostats_API/utils/data_process.py +18 -0
- neurostats_api-0.0.5/neurostats_API/utils/db_client.py +16 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/utils/fetcher.py +17 -98
- neurostats_API-0.0.3/README.md → neurostats_api-0.0.5/neurostats_API.egg-info/PKG-INFO +82 -27
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API.egg-info/SOURCES.txt +5 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/setup.py +4 -3
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/test/test_fetchers.py +35 -8
- neurostats_API-0.0.3/neurostats_API/__init__.py +0 -1
- neurostats_API-0.0.3/neurostats_API/fetchers/__init__.py +0 -1
- neurostats_API-0.0.3/neurostats_API/utils/__init__.py +0 -2
- neurostats_API-0.0.3/neurostats_API/utils/db_client.py +0 -10
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/cli.py +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/fetchers/balance_sheet.py +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/fetchers/month_revenue.py +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/fetchers/profit_lose.py +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/main.py +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API/utils/datetime.py +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API.egg-info/dependency_links.txt +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/neurostats_API.egg-info/top_level.txt +0 -0
- {neurostats_API-0.0.3 → neurostats_api-0.0.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: neurostats_API
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.5
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -12,46 +12,78 @@ Description-Content-Type: text/markdown
|
|
12
12
|
|
13
13
|
- [檔案架構](#檔案架構)
|
14
14
|
- [使用方法](#使用方法)
|
15
|
-
- [
|
15
|
+
- [下載](#下載)
|
16
16
|
- [價值投資](#得到最新一期的評價資料與歷年評價)
|
17
17
|
- [財務分析-重要指標](#財務分析-重要指標)
|
18
18
|
- [月營收表](#回傳月營收表)
|
19
|
+
- [損益表](#損益表)
|
19
20
|
- [資產負債表](#資產負債表)
|
20
21
|
- [現金流量表](#現金流量表)
|
21
22
|
|
22
23
|
## 檔案架構
|
23
24
|
|
24
25
|
```
|
25
|
-
|
26
|
-
├──
|
27
|
-
├──
|
26
|
+
├── neurostats_API
|
27
|
+
│ ├── __init__.py
|
28
|
+
│ ├── cli.py
|
29
|
+
│ ├── main.py
|
30
|
+
│ ├── fetchers
|
31
|
+
│ │ ├── __init__.py
|
32
|
+
│ │ ├── base.py
|
33
|
+
│ │ ├── finance_overview.py
|
34
|
+
│ │ ├── tech.py
|
35
|
+
│ │ └── value_invest.py
|
36
|
+
│ ├── tools
|
37
|
+
│ │ ├── finance_overview_dict.yaml
|
38
|
+
│ │ ├── profit_lose.yaml
|
39
|
+
│ │ └── seasonal_data_field_dict.txt
|
40
|
+
│ └── utils
|
41
|
+
│ ├──__init__.py
|
42
|
+
│ ├── data_process.py
|
43
|
+
│ ├── datetime.py
|
44
|
+
│ ├── db_client.py
|
45
|
+
│ └── fetcher.py
|
46
|
+
├── test
|
47
|
+
│ ├── __init__.py
|
48
|
+
│ └── test_fetchers.py
|
49
|
+
├── Makefile
|
50
|
+
├── MANIFEST.in
|
28
51
|
├── README.md
|
29
52
|
├── requirement.txt
|
30
|
-
├──
|
31
|
-
└── utils
|
32
|
-
├── fetcher.py
|
33
|
-
├── __init__.py
|
34
|
-
```
|
35
|
-
|
36
|
-
`main.py`: 執行檔
|
37
|
-
`cli.py`: 命令輸入的檔案
|
38
|
-
`utils`: 存放fetcher
|
39
|
-
- `fetcher.py`: Service的主架構
|
40
|
-
`tw50_company_list.json`: tw50的公司列表
|
41
|
-
|
42
|
-
## 使用方法
|
53
|
+
├── setup.py
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
55
|
+
```
|
56
|
+
- `neurostats_API`: 主要的package運行內容
|
57
|
+
- `fetchers`: 回傳service內容的fetcher檔案夾
|
58
|
+
- `base.py`: 基本架構
|
59
|
+
- `value_invest.py`: iFa.ai -> 價值投資
|
60
|
+
- `finance_overview.py`: iFa.ai -> 財務分析 -> 重要指標
|
61
|
+
- `tech.py`: iFa.ai -> 技術指標
|
62
|
+
- `tools`: 存放各種設定檔與資料庫index對應領域的dictionary
|
63
|
+
- `utils`:
|
64
|
+
- `fetcher.py`: Service的舊主架構, 月營收, 損益表, 資產負債表, 資產收益表目前在這裡
|
65
|
+
- `data_process.py`: config資料的讀取
|
66
|
+
- `datetime.py`: 時間格式,包括日期,年度,月份,日,季度
|
67
|
+
|
68
|
+
## 下載
|
69
|
+
```
|
70
|
+
pip install neurostats-API
|
71
|
+
```
|
72
|
+
### 確認下載成功
|
73
|
+
```Python
|
74
|
+
>>> import neurostats_API
|
75
|
+
>>> print(neurostats_API.__version__)
|
76
|
+
0.0.5
|
48
77
|
```
|
49
78
|
|
50
79
|
### 得到最新一期的評價資料與歷年評價
|
51
80
|
``` Python
|
81
|
+
from neurostats_API.fetchers import ValueFetcher
|
52
82
|
ticker = 2330 # 換成tw50內任意ticker
|
53
|
-
|
83
|
+
fetcher = ValueFetcher(ticker)
|
84
|
+
data = stats_fetcher.query_data()
|
54
85
|
```
|
86
|
+
|
55
87
|
#### 回傳(2330為例)
|
56
88
|
```Python
|
57
89
|
{
|
@@ -86,8 +118,10 @@ stats_fetcher.get_value_sheet(ticker)
|
|
86
118
|
|
87
119
|
### 回傳月營收表
|
88
120
|
``` Python
|
121
|
+
from neurostats_API.utils import StatsFetcher
|
89
122
|
ticker = 2330 # 換成tw50內任意ticker
|
90
|
-
|
123
|
+
fetcher = StatsFetcher()
|
124
|
+
data = stats_fetcher.get_month_revenue_sheet(ticker)
|
91
125
|
```
|
92
126
|
|
93
127
|
#### 回傳
|
@@ -136,9 +170,10 @@ YoY_10 None None ... None None
|
|
136
170
|
### 財務分析: 重要指標
|
137
171
|
對應https://ifa.ai/tw-stock/2330/finance-overview
|
138
172
|
```Python
|
139
|
-
from fetchers import FinanceOverviewFetcher
|
140
|
-
|
141
|
-
fetcher
|
173
|
+
from neurostats_API.fetchers import FinanceOverviewFetcher
|
174
|
+
ticker = "2330"
|
175
|
+
fetcher = FinanceOverviewFetcher(ticker = "2330")
|
176
|
+
data = fetcher.query_data()
|
142
177
|
```
|
143
178
|
|
144
179
|
#### 回傳
|
@@ -218,8 +253,10 @@ markdown
|
|
218
253
|
|
219
254
|
### 損益表
|
220
255
|
```Python
|
256
|
+
from neurostats_API.utils import StatsFetcher
|
257
|
+
fetcher = StatsFetcher()
|
221
258
|
ticker = 2330 # 換成tw50內任意ticker
|
222
|
-
|
259
|
+
data = fetcher.get_profit_lose(ticker)
|
223
260
|
```
|
224
261
|
|
225
262
|
#### 回傳
|
@@ -264,6 +301,8 @@ stats_fetcher.get_profit_lose(ticker)
|
|
264
301
|
|
265
302
|
### 資產負債表
|
266
303
|
``` Python
|
304
|
+
from neurostats_API.utils import StatsFetcher
|
305
|
+
fetcher = StatsFetcher()
|
267
306
|
ticker = 2330 # 換成tw50內任意ticker
|
268
307
|
stats_fetcher.get_balance_sheet(ticker)
|
269
308
|
```
|
@@ -321,6 +360,8 @@ equity 1.094370e+09 53.3 ... 3.390706e+09 56.68
|
|
321
360
|
|
322
361
|
### 現金流量表
|
323
362
|
``` Python
|
363
|
+
from neurostats_API.utils import StatsFetcher
|
364
|
+
fetcher = StatsFetcher()
|
324
365
|
ticker = 2330 # 換成tw50內任意ticker
|
325
366
|
stats_fetcher.get_cash_flow(ticker)
|
326
367
|
```
|
@@ -400,6 +441,9 @@ stats_fetcher.get_cash_flow(ticker)
|
|
400
441
|
|
401
442
|
> 大部分資料缺失是因為尚未計算,僅先填上已經有的資料
|
402
443
|
|
444
|
+
|
445
|
+
|
446
|
+
|
403
447
|
## cli 範例輸入
|
404
448
|
```
|
405
449
|
python ./cli.py --ticker 1101
|
@@ -437,4 +481,5 @@ daily_data
|
|
437
481
|
> 這裡有Nan是因為本益比與P/B等資料沒有爬到最新的時間
|
438
482
|
|
439
483
|
## TODO
|
484
|
+
- 將utils/fetcher.py中的功能切分到fetchers資料夾中
|
440
485
|
|
@@ -1,57 +1,79 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: neurostats-API
|
3
|
-
Version: 0.0.3
|
4
|
-
Summary: The service of NeuroStats website
|
5
|
-
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
|
-
Author: JasonWang@Neurowatt
|
7
|
-
Author-email: jason@neurowatt.ai
|
8
|
-
Requires-Python: >=3.6
|
9
|
-
Description-Content-Type: text/markdown
|
10
|
-
|
11
1
|
# neurostats_API
|
12
2
|
|
13
3
|
- [檔案架構](#檔案架構)
|
14
4
|
- [使用方法](#使用方法)
|
15
|
-
- [
|
5
|
+
- [下載](#下載)
|
16
6
|
- [價值投資](#得到最新一期的評價資料與歷年評價)
|
17
7
|
- [財務分析-重要指標](#財務分析-重要指標)
|
18
8
|
- [月營收表](#回傳月營收表)
|
9
|
+
- [損益表](#損益表)
|
19
10
|
- [資產負債表](#資產負債表)
|
20
11
|
- [現金流量表](#現金流量表)
|
21
12
|
|
22
13
|
## 檔案架構
|
23
14
|
|
24
15
|
```
|
25
|
-
|
26
|
-
├──
|
27
|
-
├──
|
16
|
+
├── neurostats_API
|
17
|
+
│ ├── __init__.py
|
18
|
+
│ ├── cli.py
|
19
|
+
│ ├── main.py
|
20
|
+
│ ├── fetchers
|
21
|
+
│ │ ├── __init__.py
|
22
|
+
│ │ ├── base.py
|
23
|
+
│ │ ├── finance_overview.py
|
24
|
+
│ │ ├── tech.py
|
25
|
+
│ │ └── value_invest.py
|
26
|
+
│ ├── tools
|
27
|
+
│ │ ├── finance_overview_dict.yaml
|
28
|
+
│ │ ├── profit_lose.yaml
|
29
|
+
│ │ └── seasonal_data_field_dict.txt
|
30
|
+
│ └── utils
|
31
|
+
│ ├──__init__.py
|
32
|
+
│ ├── data_process.py
|
33
|
+
│ ├── datetime.py
|
34
|
+
│ ├── db_client.py
|
35
|
+
│ └── fetcher.py
|
36
|
+
├── test
|
37
|
+
│ ├── __init__.py
|
38
|
+
│ └── test_fetchers.py
|
39
|
+
├── Makefile
|
40
|
+
├── MANIFEST.in
|
28
41
|
├── README.md
|
29
42
|
├── requirement.txt
|
30
|
-
├──
|
31
|
-
└── utils
|
32
|
-
├── fetcher.py
|
33
|
-
├── __init__.py
|
34
|
-
```
|
35
|
-
|
36
|
-
`main.py`: 執行檔
|
37
|
-
`cli.py`: 命令輸入的檔案
|
38
|
-
`utils`: 存放fetcher
|
39
|
-
- `fetcher.py`: Service的主架構
|
40
|
-
`tw50_company_list.json`: tw50的公司列表
|
43
|
+
├── setup.py
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
```
|
46
|
+
- `neurostats_API`: 主要的package運行內容
|
47
|
+
- `fetchers`: 回傳service內容的fetcher檔案夾
|
48
|
+
- `base.py`: 基本架構
|
49
|
+
- `value_invest.py`: iFa.ai -> 價值投資
|
50
|
+
- `finance_overview.py`: iFa.ai -> 財務分析 -> 重要指標
|
51
|
+
- `tech.py`: iFa.ai -> 技術指標
|
52
|
+
- `tools`: 存放各種設定檔與資料庫index對應領域的dictionary
|
53
|
+
- `utils`:
|
54
|
+
- `fetcher.py`: Service的舊主架構, 月營收, 損益表, 資產負債表, 資產收益表目前在這裡
|
55
|
+
- `data_process.py`: config資料的讀取
|
56
|
+
- `datetime.py`: 時間格式,包括日期,年度,月份,日,季度
|
57
|
+
|
58
|
+
## 下載
|
59
|
+
```
|
60
|
+
pip install neurostats-API
|
61
|
+
```
|
62
|
+
### 確認下載成功
|
63
|
+
```Python
|
64
|
+
>>> import neurostats_API
|
65
|
+
>>> print(neurostats_API.__version__)
|
66
|
+
0.0.5
|
48
67
|
```
|
49
68
|
|
50
69
|
### 得到最新一期的評價資料與歷年評價
|
51
70
|
``` Python
|
71
|
+
from neurostats_API.fetchers import ValueFetcher
|
52
72
|
ticker = 2330 # 換成tw50內任意ticker
|
53
|
-
|
73
|
+
fetcher = ValueFetcher(ticker)
|
74
|
+
data = stats_fetcher.query_data()
|
54
75
|
```
|
76
|
+
|
55
77
|
#### 回傳(2330為例)
|
56
78
|
```Python
|
57
79
|
{
|
@@ -86,8 +108,10 @@ stats_fetcher.get_value_sheet(ticker)
|
|
86
108
|
|
87
109
|
### 回傳月營收表
|
88
110
|
``` Python
|
111
|
+
from neurostats_API.utils import StatsFetcher
|
89
112
|
ticker = 2330 # 換成tw50內任意ticker
|
90
|
-
|
113
|
+
fetcher = StatsFetcher()
|
114
|
+
data = stats_fetcher.get_month_revenue_sheet(ticker)
|
91
115
|
```
|
92
116
|
|
93
117
|
#### 回傳
|
@@ -136,9 +160,10 @@ YoY_10 None None ... None None
|
|
136
160
|
### 財務分析: 重要指標
|
137
161
|
對應https://ifa.ai/tw-stock/2330/finance-overview
|
138
162
|
```Python
|
139
|
-
from fetchers import FinanceOverviewFetcher
|
140
|
-
|
141
|
-
fetcher
|
163
|
+
from neurostats_API.fetchers import FinanceOverviewFetcher
|
164
|
+
ticker = "2330"
|
165
|
+
fetcher = FinanceOverviewFetcher(ticker = "2330")
|
166
|
+
data = fetcher.query_data()
|
142
167
|
```
|
143
168
|
|
144
169
|
#### 回傳
|
@@ -218,8 +243,10 @@ markdown
|
|
218
243
|
|
219
244
|
### 損益表
|
220
245
|
```Python
|
246
|
+
from neurostats_API.utils import StatsFetcher
|
247
|
+
fetcher = StatsFetcher()
|
221
248
|
ticker = 2330 # 換成tw50內任意ticker
|
222
|
-
|
249
|
+
data = fetcher.get_profit_lose(ticker)
|
223
250
|
```
|
224
251
|
|
225
252
|
#### 回傳
|
@@ -264,6 +291,8 @@ stats_fetcher.get_profit_lose(ticker)
|
|
264
291
|
|
265
292
|
### 資產負債表
|
266
293
|
``` Python
|
294
|
+
from neurostats_API.utils import StatsFetcher
|
295
|
+
fetcher = StatsFetcher()
|
267
296
|
ticker = 2330 # 換成tw50內任意ticker
|
268
297
|
stats_fetcher.get_balance_sheet(ticker)
|
269
298
|
```
|
@@ -321,6 +350,8 @@ equity 1.094370e+09 53.3 ... 3.390706e+09 56.68
|
|
321
350
|
|
322
351
|
### 現金流量表
|
323
352
|
``` Python
|
353
|
+
from neurostats_API.utils import StatsFetcher
|
354
|
+
fetcher = StatsFetcher()
|
324
355
|
ticker = 2330 # 換成tw50內任意ticker
|
325
356
|
stats_fetcher.get_cash_flow(ticker)
|
326
357
|
```
|
@@ -400,6 +431,9 @@ stats_fetcher.get_cash_flow(ticker)
|
|
400
431
|
|
401
432
|
> 大部分資料缺失是因為尚未計算,僅先填上已經有的資料
|
402
433
|
|
434
|
+
|
435
|
+
|
436
|
+
|
403
437
|
## cli 範例輸入
|
404
438
|
```
|
405
439
|
python ./cli.py --ticker 1101
|
@@ -437,4 +471,5 @@ daily_data
|
|
437
471
|
> 這裡有Nan是因為本益比與P/B等資料沒有爬到最新的時間
|
438
472
|
|
439
473
|
## TODO
|
474
|
+
- 將utils/fetcher.py中的功能切分到fetchers資料夾中
|
440
475
|
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__='0.0.5'
|
@@ -3,15 +3,13 @@ import pandas as pd
|
|
3
3
|
import json
|
4
4
|
import pytz
|
5
5
|
from datetime import datetime, timedelta, date
|
6
|
-
from utils import StatsDateTime
|
6
|
+
from ..utils import StatsDateTime, StatsProcessor
|
7
7
|
import yaml
|
8
|
-
from .utils.db_client import shared_client
|
9
8
|
|
10
9
|
class StatsFetcher:
|
11
|
-
|
12
|
-
def __init__(self, ticker):
|
10
|
+
def __init__(self, ticker, db_client):
|
13
11
|
self.ticker = ticker
|
14
|
-
self.db =
|
12
|
+
self.db = db_client[
|
15
13
|
"company"] # Replace with your database name
|
16
14
|
self.collection = self.db["twse_stats"]
|
17
15
|
|
@@ -28,6 +26,7 @@ class StatsFetcher:
|
|
28
26
|
'grand_total_growth': [f"YoY_{i}" for i in [1, 3, 5, 10]]
|
29
27
|
}
|
30
28
|
|
29
|
+
|
31
30
|
def prepare_query(self):
|
32
31
|
return [
|
33
32
|
{
|
@@ -53,7 +52,3 @@ class StatsFetcher:
|
|
53
52
|
season = (month - 1) // 3 + 1
|
54
53
|
|
55
54
|
return StatsDateTime(date, year, month, day, season)
|
56
|
-
|
57
|
-
|
58
|
-
class StatsProcessor:
|
59
|
-
pass
|
@@ -1,7 +1,8 @@
|
|
1
|
-
from .base import StatsFetcher,
|
1
|
+
from .base import StatsFetcher, StatsDateTime
|
2
2
|
import json
|
3
3
|
import pandas as pd
|
4
|
-
from utils import StatsDateTime
|
4
|
+
from ..utils import StatsDateTime, StatsProcessor
|
5
|
+
import importlib.resources as pkg_resources
|
5
6
|
import yaml
|
6
7
|
|
7
8
|
|
@@ -10,14 +11,11 @@ class FinanceOverviewFetcher(StatsFetcher):
|
|
10
11
|
對應iFa.ai -> 財務分析 -> 重要指標(finance_overview)
|
11
12
|
"""
|
12
13
|
|
13
|
-
def __init__(self, ticker):
|
14
|
-
super().__init__(ticker)
|
14
|
+
def __init__(self, ticker, db_client):
|
15
|
+
super().__init__(ticker, db_client)
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
with open("./tools/seasonal_data_field_dict.txt") as f:
|
20
|
-
self.inverse_dict = json.load(f)
|
17
|
+
self.target_fields = StatsProcessor.load_yaml("finance_overview_dict.yaml")
|
18
|
+
self.inverse_dict = StatsProcessor.load_txt("seasonal_data_field_dict.txt", json_load=True)
|
21
19
|
|
22
20
|
def prepare_query(self, target_year, target_season):
|
23
21
|
|
@@ -3,9 +3,8 @@ import pandas as pd
|
|
3
3
|
|
4
4
|
class TechFetcher(StatsFetcher):
|
5
5
|
|
6
|
-
def __init__(self, ticker:str):
|
7
|
-
super().__init__()
|
8
|
-
self.ticker = ticker
|
6
|
+
def __init__(self, ticker:str, db_client):
|
7
|
+
super().__init__(ticker, db_client)
|
9
8
|
self.full_ohlcv = self._get_ohlcv()
|
10
9
|
self.basic_indexes = ['SMA5', 'SMA20', 'SMA60', 'EMA5', 'EMA20',
|
11
10
|
'EMA40', 'EMA12', 'EMA26', 'RSI7', 'RSI14',
|
@@ -1,13 +1,13 @@
|
|
1
|
-
from .base import StatsFetcher
|
1
|
+
from .base import StatsFetcher
|
2
2
|
from datetime import datetime, timedelta, date
|
3
3
|
import pandas as pd
|
4
|
-
from utils import StatsDateTime
|
4
|
+
from ..utils import StatsDateTime, StatsProcessor
|
5
5
|
|
6
6
|
|
7
7
|
class ValueFetcher(StatsFetcher):
|
8
8
|
|
9
|
-
def __init__(self, ticker: str):
|
10
|
-
super().__init__(ticker)
|
9
|
+
def __init__(self, ticker: str, db_client):
|
10
|
+
super().__init__(ticker, db_client)
|
11
11
|
|
12
12
|
def prepare_query(self, start_date, end_date):
|
13
13
|
pipeline = super().prepare_query()
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# 財務概況
|
2
|
+
revenue:
|
3
|
+
field: 營業收入合計
|
4
|
+
value: value
|
5
|
+
|
6
|
+
gross_profit:
|
7
|
+
field: 營業毛利(毛損)淨額
|
8
|
+
value: value
|
9
|
+
|
10
|
+
operating_income:
|
11
|
+
field: 營業利益(損失)
|
12
|
+
value: value
|
13
|
+
|
14
|
+
net_income:
|
15
|
+
field: 本期淨利(淨損)
|
16
|
+
value: value
|
17
|
+
|
18
|
+
# TODO: 以下所爬到的資料都是累計的,Ifa有額外計算當季的變化量
|
19
|
+
operating_cash_flow:
|
20
|
+
field: 營業活動之淨現金流入(流出)
|
21
|
+
value: value
|
22
|
+
|
23
|
+
invest_cash_flow:
|
24
|
+
field: 投資活動之淨現金流入(流出)
|
25
|
+
value: value
|
26
|
+
|
27
|
+
financing_cash_flow:
|
28
|
+
field: 籌資活動之淨現金流入(流出)
|
29
|
+
value: value
|
30
|
+
|
31
|
+
fcf:
|
32
|
+
field: 本期現金及約當現金增加(減少)數
|
33
|
+
value: value
|
34
|
+
# ^^^ 以上皆需要額外在DataBase處理
|
35
|
+
|
36
|
+
# 每股財務狀況
|
37
|
+
capital:
|
38
|
+
field: 普通股股本
|
39
|
+
value: value
|
40
|
+
eps:
|
41
|
+
field: 基本每股盈餘
|
42
|
+
value: value
|
43
|
+
|
44
|
+
# 獲利能力
|
45
|
+
total_asset:
|
46
|
+
field: 資產總額
|
47
|
+
value: value
|
48
|
+
|
49
|
+
equity:
|
50
|
+
field: 權益總額
|
51
|
+
value: value
|
52
|
+
|
53
|
+
net_income_before_tax:
|
54
|
+
field: 稅前淨利(淨損)
|
55
|
+
value: value
|
56
|
+
|
57
|
+
interest:
|
58
|
+
field: 利息收入
|
59
|
+
value: value
|
60
|
+
|
61
|
+
operating_expenses:
|
62
|
+
field: 營業費用合計
|
63
|
+
value: value
|
64
|
+
|
65
|
+
net_income_rate:
|
66
|
+
field: 本期淨利(淨損)
|
67
|
+
value: percentage
|
68
|
+
# 成長動能
|
69
|
+
revenue_YoY:
|
70
|
+
field: 營業收入合計
|
71
|
+
value: YoY_1
|
72
|
+
|
73
|
+
gross_prof_YoY:
|
74
|
+
field: 營業毛利(毛損)淨額
|
75
|
+
value: YoY_1
|
76
|
+
|
77
|
+
operating_income_YoY:
|
78
|
+
field: 營業利益(損失)
|
79
|
+
value: YoY_1
|
80
|
+
|
81
|
+
net_income_YoY:
|
82
|
+
field: 本期淨利(淨損)
|
83
|
+
value: YoY_1
|
84
|
+
|
85
|
+
operating_cash_flow_YoY:
|
86
|
+
field: 營業活動之淨現金流入(流出)
|
87
|
+
value: YoY_1
|
88
|
+
|
89
|
+
# operating_cash_flow_per_share_YoY:
|
90
|
+
# field: 每股營業現金流年成長率
|
91
|
+
# value: YoY_1
|
92
|
+
# 營運指標
|
93
|
+
account_receive:
|
94
|
+
field: 應收帳款淨額
|
95
|
+
value: value
|
96
|
+
|
97
|
+
account_pay:
|
98
|
+
field: 應付帳款
|
99
|
+
value: value
|
100
|
+
|
101
|
+
inventories:
|
102
|
+
field: 存貨
|
103
|
+
value: value
|
104
|
+
|
105
|
+
operating_cost:
|
106
|
+
field: 營業成本合計
|
107
|
+
value: value
|
108
|
+
|
109
|
+
application:
|
110
|
+
field: 不動產、廠房及設備
|
111
|
+
value: value
|
112
|
+
|
113
|
+
# 財務韌性
|
114
|
+
current_assets:
|
115
|
+
field: 流動資產合計
|
116
|
+
value: value
|
117
|
+
|
118
|
+
current_liabilities:
|
119
|
+
field: 流動負債合計
|
120
|
+
value: value
|
121
|
+
|
122
|
+
total_liabilities:
|
123
|
+
field: 負債總額
|
124
|
+
value: value
|
125
|
+
|
126
|
+
#
|
127
|
+
cash_and_cash_equivalents:
|
128
|
+
field: 現金及約當現金
|
129
|
+
value: value
|
130
|
+
|
131
|
+
interest_expense:
|
132
|
+
field: 利息費用
|
133
|
+
value: value
|
134
|
+
|
135
|
+
|
136
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
profit_lose: # 總營收表
|
2
|
+
mode: value_and_percentage
|
3
|
+
|
4
|
+
grand_total_profit_lose:
|
5
|
+
mode: grand_total_values
|
6
|
+
|
7
|
+
revenue:
|
8
|
+
mode: growth
|
9
|
+
target_index: 營業收入合計
|
10
|
+
|
11
|
+
grand_total_revenue:
|
12
|
+
mode: grand_total_values
|
13
|
+
target_index: 營業收入合計
|
14
|
+
|
15
|
+
gross_profit:
|
16
|
+
mode: growth
|
17
|
+
target_index: 營業毛利(毛損)淨額
|
18
|
+
|
19
|
+
grand_total_gross_profit:
|
20
|
+
mode: grand_total_growth
|
21
|
+
target_index: 營業毛利(毛損)淨額
|
22
|
+
|
23
|
+
gross_profit_percentage:
|
24
|
+
mode: percentage
|
25
|
+
target_index: 營業毛利(毛損)淨額
|
26
|
+
|
27
|
+
grand_total_gross_profit_percentage:
|
28
|
+
mode: grand_total_percentage
|
29
|
+
target_index: 營業毛利(毛損)淨額
|
30
|
+
# 營利
|
31
|
+
operating_income:
|
32
|
+
mode: growth
|
33
|
+
target_index: 營業利益(損失)
|
34
|
+
|
35
|
+
grand_total_operating_income:
|
36
|
+
mode: grand_total_growth
|
37
|
+
target_index: 營業利益(損失)
|
38
|
+
|
39
|
+
operating_income_percentage:
|
40
|
+
mode: percentage
|
41
|
+
target_index: 營業利益(損失)
|
42
|
+
|
43
|
+
grand_total_operating_income_percentage:
|
44
|
+
mode: grand_total_percentage
|
45
|
+
target_index: 營業利益(損失)
|
46
|
+
# 稅前淨利
|
47
|
+
net_income_before_tax:
|
48
|
+
mode: growth
|
49
|
+
target_index: 稅前淨利(淨損)
|
50
|
+
|
51
|
+
grand_total_net_income_before_tax:
|
52
|
+
mode: grand_total_growth
|
53
|
+
target_index: 稅前淨利(淨損)
|
54
|
+
|
55
|
+
net_income_before_tax_percentage:
|
56
|
+
mode: percentage
|
57
|
+
target_index: 稅前淨利(淨損)
|
58
|
+
|
59
|
+
grand_total_net_income_before_tax_percentage:
|
60
|
+
mode: grand_total_percentage
|
61
|
+
target_index: 稅前淨利(淨損)
|
62
|
+
# 本期淨利
|
63
|
+
net_income:
|
64
|
+
mode: growth
|
65
|
+
target_index: 本期淨利(淨損)
|
66
|
+
|
67
|
+
grand_total_net_income:
|
68
|
+
mode: grand_total_growth
|
69
|
+
target_index: 本期淨利(淨損)
|
70
|
+
|
71
|
+
net_income_percentage:
|
72
|
+
mode: percentage
|
73
|
+
target_index: 本期淨利(淨損)
|
74
|
+
|
75
|
+
grand_total_income_percentage:
|
76
|
+
mode: grand_total_percentage
|
77
|
+
target_index: 本期淨利(淨損)
|
78
|
+
# EPS
|
79
|
+
EPS:
|
80
|
+
mode: value
|
81
|
+
target_index: 稀釋每股盈餘
|
82
|
+
|
83
|
+
EPS_growth:
|
84
|
+
mode: growth
|
85
|
+
target_index: 稀釋每股盈餘
|
86
|
+
|
87
|
+
grand_total_EPS:
|
88
|
+
mode: grand_total
|
89
|
+
target_index: 稀釋每股盈餘
|
90
|
+
|
91
|
+
grand_total_EPS_growth:
|
92
|
+
mode: grand_total_growth
|
93
|
+
target_index: 稀釋每股盈餘
|