neurostats-API 0.0.13__tar.gz → 0.0.14__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/PKG-INFO +7 -2
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/README.md +6 -1
- neurostats_api-0.0.14/neurostats_API/__init__.py +1 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/institution.py +19 -13
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/profit_lose.py +7 -7
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/balance_sheet.yaml +1 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/profit_lose.yaml +25 -3
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/utils/data_process.py +34 -7
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API.egg-info/PKG-INFO +8 -3
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/setup.py +1 -1
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/test/test_fetchers.py +0 -1
- neurostats_API-0.0.13/neurostats_API/__init__.py +0 -1
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/MANIFEST.in +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/cli.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/__init__.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/balance_sheet.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/base.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/cash_flow.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/finance_overview.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/margin_trading.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/month_revenue.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/tech.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/fetchers/value_invest.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/main.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/cash_flow_percentage.yaml +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/finance_overview_dict.yaml +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/seasonal_data_field_dict.txt +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/utils/__init__.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/utils/datetime.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/utils/db_client.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/utils/fetcher.py +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API.egg-info/SOURCES.txt +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API.egg-info/dependency_links.txt +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API.egg-info/top_level.txt +0 -0
- {neurostats_API-0.0.13 → neurostats_api-0.0.14}/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.14
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -83,7 +83,7 @@ pip install neurostats-API
|
|
83
83
|
```Python
|
84
84
|
>>> import neurostats_API
|
85
85
|
>>> print(neurostats_API.__version__)
|
86
|
-
0.0.
|
86
|
+
0.0.14
|
87
87
|
```
|
88
88
|
|
89
89
|
### 得到最新一期的評價資料與歷年評價
|
@@ -668,6 +668,11 @@ fetcher.query()
|
|
668
668
|
請注意`range`, `last_range`, `52week_range`這三個項目型態為字串,其餘為float
|
669
669
|
|
670
670
|
## 版本紀錄
|
671
|
+
## 0.0.14
|
672
|
+
- 修改部分財報資料錯誤的乘以1000的問題
|
673
|
+
|
674
|
+
- 新增例外處理: 若資料庫對於季資料一部分index缺失的情況下仍會盡可能去將資料蒐集並呈現
|
675
|
+
|
671
676
|
### 0.0.13
|
672
677
|
- value_fetcher 新增獲得一序列評價的功能
|
673
678
|
|
@@ -73,7 +73,7 @@ pip install neurostats-API
|
|
73
73
|
```Python
|
74
74
|
>>> import neurostats_API
|
75
75
|
>>> print(neurostats_API.__version__)
|
76
|
-
0.0.
|
76
|
+
0.0.14
|
77
77
|
```
|
78
78
|
|
79
79
|
### 得到最新一期的評價資料與歷年評價
|
@@ -658,6 +658,11 @@ fetcher.query()
|
|
658
658
|
請注意`range`, `last_range`, `52week_range`這三個項目型態為字串,其餘為float
|
659
659
|
|
660
660
|
## 版本紀錄
|
661
|
+
## 0.0.14
|
662
|
+
- 修改部分財報資料錯誤的乘以1000的問題
|
663
|
+
|
664
|
+
- 新增例外處理: 若資料庫對於季資料一部分index缺失的情況下仍會盡可能去將資料蒐集並呈現
|
665
|
+
|
661
666
|
### 0.0.13
|
662
667
|
- value_fetcher 新增獲得一序列評價的功能
|
663
668
|
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__='0.0.14'
|
@@ -164,25 +164,26 @@ class InstitutionFetcher(StatsFetcher):
|
|
164
164
|
latest_daily_data['volume'])
|
165
165
|
}
|
166
166
|
# 一年內法人
|
167
|
-
annual_dates = [
|
167
|
+
annual_dates = [
|
168
|
+
data['date'].strftime("%Y-%m-%d") for data in daily_datas
|
169
|
+
]
|
168
170
|
annual_closes = {
|
169
|
-
data['date'].strftime("%Y-%m-%d")
|
171
|
+
data['date'].strftime("%Y-%m-%d"): data['close']
|
170
172
|
for data in daily_datas
|
171
173
|
if (data['date'].strftime("%Y-%m-%d") in annual_dates)
|
172
174
|
}
|
173
175
|
annual_volumes = {
|
174
|
-
data['date'].strftime("%Y-%m-%d")
|
176
|
+
data['date'].strftime("%Y-%m-%d"): data['volume']
|
175
177
|
for data in daily_datas
|
176
178
|
if (data['date'].strftime("%Y-%m-%d") in annual_dates)
|
177
179
|
}
|
178
180
|
annual_trading = {
|
179
|
-
data['date'].strftime("%Y-%m-%d")
|
181
|
+
data['date'].strftime("%Y-%m-%d"): data
|
180
182
|
for data in institution_tradings
|
181
|
-
}
|
183
|
+
}
|
182
184
|
|
183
185
|
annual_trading = {
|
184
186
|
date: {
|
185
|
-
|
186
187
|
"close": annual_closes[date],
|
187
188
|
"volume": annual_volumes[date],
|
188
189
|
**annual_trading[date]
|
@@ -217,13 +218,18 @@ class InstitutionFetcher(StatsFetcher):
|
|
217
218
|
self.target_institution(latest_trading,
|
218
219
|
latest_table['institutional_investor'],
|
219
220
|
key, volume)
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
221
|
+
# 計算合計
|
222
|
+
for unit in ['stock', 'percentage']:
|
223
|
+
# 買進總和
|
224
|
+
latest_table['institutional_investor']['buy'][unit] = (
|
225
|
+
latest_table['foreign']['buy'][unit] +
|
226
|
+
latest_table['prop']['buy'][unit] +
|
227
|
+
latest_table['mutual']['buy'][unit])
|
228
|
+
# 賣出總和
|
229
|
+
latest_table['institutional_investor']['sell'][unit] = (
|
230
|
+
latest_table['foreign']['sell'][unit] +
|
231
|
+
latest_table['prop']['sell'][unit] +
|
232
|
+
latest_table['mutual']['sell'][unit])
|
227
233
|
|
228
234
|
frames = []
|
229
235
|
for category, trades in latest_table.items():
|
@@ -21,12 +21,6 @@ class ProfitLoseFetcher(StatsFetcher):
|
|
21
21
|
def prepare_query(self, target_season):
|
22
22
|
pipeline = super().prepare_query()
|
23
23
|
|
24
|
-
target_query = {
|
25
|
-
"year": "$$target_season_data.year",
|
26
|
-
"season": "$$target_season_data.season",
|
27
|
-
"balance_sheet": "$$$$target_season_data.balance_sheet"
|
28
|
-
}
|
29
|
-
|
30
24
|
pipeline.append({
|
31
25
|
"$project": {
|
32
26
|
"_id": 0,
|
@@ -121,6 +115,9 @@ class ProfitLoseFetcher(StatsFetcher):
|
|
121
115
|
elif ('YoY' in item_name):
|
122
116
|
if (isinstance(item, (float, int))):
|
123
117
|
item = StatsProcessor.cal_percentage(item)
|
118
|
+
elif ('每股盈餘' in index_name):
|
119
|
+
if (isinstance(item, (float, int))):
|
120
|
+
item = StatsProcessor.cal_non_percentage(item, postfix="元")
|
124
121
|
else:
|
125
122
|
if (isinstance(item, (float, int))):
|
126
123
|
item = StatsProcessor.cal_non_percentage(item, postfix="千元")
|
@@ -153,6 +150,9 @@ class ProfitLoseFetcher(StatsFetcher):
|
|
153
150
|
target_index=target_index)
|
154
151
|
break
|
155
152
|
except Exception as e:
|
156
|
-
|
153
|
+
return_dict[name] = StatsProcessor.slice_multi_col_table(
|
154
|
+
total_table=total_table,
|
155
|
+
mode=setting['mode'],
|
156
|
+
target_index=target_index)
|
157
157
|
|
158
158
|
return return_dict
|
@@ -3,38 +3,45 @@ profit_lose: # 總營收表
|
|
3
3
|
|
4
4
|
grand_total_profit_lose:
|
5
5
|
mode: grand_total_values
|
6
|
-
|
6
|
+
|
7
7
|
revenue:
|
8
8
|
mode: growth
|
9
9
|
target_index:
|
10
10
|
- 營業收入合計
|
11
|
+
- 收入合計
|
11
12
|
- 利息收入
|
12
13
|
|
13
14
|
grand_total_revenue:
|
14
15
|
mode: grand_total_growth
|
15
16
|
target_index:
|
16
17
|
- 營業收入合計
|
18
|
+
- 收入合計
|
17
19
|
- 利息收入
|
18
20
|
|
19
21
|
gross_profit:
|
20
22
|
mode: growth
|
21
23
|
target_index:
|
22
24
|
- 營業毛利(毛損)淨額
|
25
|
+
- 利息淨收益
|
23
26
|
|
24
27
|
grand_total_gross_profit:
|
25
28
|
mode: grand_total_growth
|
26
29
|
target_index:
|
27
30
|
- 營業毛利(毛損)淨額
|
28
|
-
|
31
|
+
- 利息淨收益
|
32
|
+
|
29
33
|
gross_profit_percentage:
|
30
34
|
mode: percentage
|
31
35
|
target_index:
|
32
36
|
- 營業毛利(毛損)淨額
|
37
|
+
- 利息淨收益
|
33
38
|
|
34
39
|
grand_total_gross_profit_percentage:
|
35
40
|
mode: grand_total_percentage
|
36
41
|
target_index:
|
37
42
|
- 營業毛利(毛損)淨額
|
43
|
+
- 利息淨收益
|
44
|
+
|
38
45
|
# 營利
|
39
46
|
operating_income:
|
40
47
|
mode: growth
|
@@ -55,46 +62,61 @@ grand_total_operating_income_percentage:
|
|
55
62
|
mode: grand_total_percentage
|
56
63
|
target_index:
|
57
64
|
- 營業利益(損失)
|
65
|
+
|
58
66
|
# 稅前淨利
|
59
67
|
net_income_before_tax:
|
60
68
|
mode: growth
|
61
69
|
target_index:
|
62
70
|
- 稅前淨利(淨損)
|
71
|
+
- 繼續營業單位稅前損益
|
72
|
+
- 繼續營業單位稅前淨利(淨損)
|
63
73
|
|
64
74
|
grand_total_net_income_before_tax:
|
65
75
|
mode: grand_total_growth
|
66
76
|
target_index:
|
67
77
|
- 稅前淨利(淨損)
|
78
|
+
- 繼續營業單位稅前損益
|
79
|
+
- 繼續營業單位稅前淨利(淨損)
|
68
80
|
|
69
81
|
net_income_before_tax_percentage:
|
70
82
|
mode: percentage
|
71
83
|
target_index:
|
72
84
|
- 稅前淨利(淨損)
|
85
|
+
- 繼續營業單位稅前損益
|
86
|
+
- 繼續營業單位稅前淨利(淨損)
|
73
87
|
|
74
88
|
grand_total_net_income_before_tax_percentage:
|
75
89
|
mode: grand_total_percentage
|
76
90
|
target_index:
|
77
91
|
- 稅前淨利(淨損)
|
92
|
+
- 繼續營業單位稅前損益
|
93
|
+
- 繼續營業單位稅前淨利(淨損)
|
94
|
+
|
78
95
|
# 本期淨利
|
79
96
|
net_income:
|
80
97
|
mode: growth
|
81
98
|
target_index:
|
82
99
|
- 本期淨利(淨損)
|
100
|
+
- 本期稅後淨利(淨損)
|
83
101
|
|
84
102
|
grand_total_net_income:
|
85
103
|
mode: grand_total_growth
|
86
104
|
target_index:
|
87
105
|
- 本期淨利(淨損)
|
106
|
+
- 本期稅後淨利(淨損)
|
88
107
|
|
89
108
|
net_income_percentage:
|
90
109
|
mode: percentage
|
91
110
|
target_index:
|
92
111
|
- 本期淨利(淨損)
|
112
|
+
- 本期稅後淨利(淨損)
|
93
113
|
|
94
114
|
grand_total_income_percentage:
|
95
115
|
mode: grand_total_percentage
|
96
116
|
target_index:
|
97
117
|
- 本期淨利(淨損)
|
118
|
+
- 本期稅後淨利(淨損)
|
119
|
+
|
98
120
|
# EPS
|
99
121
|
EPS:
|
100
122
|
mode: value
|
@@ -118,4 +140,4 @@ grand_total_EPS_growth:
|
|
118
140
|
mode: grand_total_growth
|
119
141
|
target_index:
|
120
142
|
- 基本每股盈餘
|
121
|
-
- 基本每股盈餘合計
|
143
|
+
- 基本每股盈餘合計
|
@@ -97,20 +97,47 @@ class StatsProcessor:
|
|
97
97
|
"""
|
98
98
|
對Multicolumn的dataframe切出目標的index
|
99
99
|
"""
|
100
|
-
times = total_table.columns.get_level_values(0).unique()
|
101
100
|
try:
|
102
101
|
target_metrics = target_metric_dict[mode]
|
103
102
|
except KeyError as e:
|
104
103
|
return f"mode Error: Get mode should be {list(target_metric_dict.keys())} but get {mode}"
|
105
104
|
|
105
|
+
times = total_table.columns.get_level_values(0).unique()
|
106
106
|
desired_order = [(time, value_name) for time in times
|
107
107
|
for value_name in target_metrics]
|
108
108
|
|
109
109
|
if (target_index):
|
110
110
|
target_index = target_index.split()
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
try:
|
112
|
+
sliced_table = total_table.loc[
|
113
|
+
target_index,
|
114
|
+
pd.IndexSlice[:, target_metrics]][desired_order].T
|
115
|
+
|
116
|
+
except Exception as e: # 沒辦法完整取得表格
|
117
|
+
# 先設立空表格
|
118
|
+
empty_index = pd.Index(desired_order)
|
119
|
+
empty_columns = pd.Index(target_index)
|
120
|
+
sliced_table = pd.DataFrame(index=empty_index,
|
121
|
+
columns=empty_columns)
|
122
|
+
|
123
|
+
try:
|
124
|
+
# 提取有效的部分資料
|
125
|
+
partial_table = total_table.loc[
|
126
|
+
total_table.index.intersection(target_index),
|
127
|
+
pd.IndexSlice[:, target_metrics]
|
128
|
+
]
|
129
|
+
|
130
|
+
# 遍歷 partial_table 的索引和值,手動填入 sliced_table
|
131
|
+
for row_index in partial_table.index:
|
132
|
+
for col_index in partial_table.columns:
|
133
|
+
if col_index in desired_order and row_index in target_index:
|
134
|
+
sliced_table.loc[col_index, row_index] = partial_table.loc[row_index, col_index]
|
135
|
+
|
136
|
+
# 確保 `sliced_table` 的排序符合 `desired_order`
|
137
|
+
sliced_table = sliced_table.reindex(index=desired_order, columns=target_index)
|
138
|
+
except Exception as sub_e:
|
139
|
+
pass
|
140
|
+
|
114
141
|
if (mode == 'value_and_percentage'): # 因應balance_sheet 頁面的格式
|
115
142
|
return_table = sliced_table.T
|
116
143
|
return_table.columns = [
|
@@ -146,7 +173,7 @@ class StatsProcessor:
|
|
146
173
|
@classmethod
|
147
174
|
def cal_percentage(cls, value, postfix="%"):
|
148
175
|
if (isinstance(value, (float, int))):
|
149
|
-
value = np.round(value * 100
|
176
|
+
value = np.round(value * 100, 2).item()
|
150
177
|
value = f"{value:.2f}{postfix}"
|
151
178
|
|
152
179
|
return value
|
@@ -157,7 +184,7 @@ class StatsProcessor:
|
|
157
184
|
@classmethod
|
158
185
|
def cal_non_percentage(cls, value, to_str=False, postfix="元"):
|
159
186
|
if (isinstance(value, (float, int))):
|
160
|
-
|
187
|
+
|
161
188
|
value = np.round(value, 2).item()
|
162
189
|
if (postfix == "千元"):
|
163
190
|
value *= 1000
|
@@ -178,7 +205,7 @@ class StatsProcessor:
|
|
178
205
|
|
179
206
|
else:
|
180
207
|
return value
|
181
|
-
|
208
|
+
|
182
209
|
@classmethod
|
183
210
|
def cal_round_int(cls, value):
|
184
211
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
|
-
Name:
|
3
|
-
Version: 0.0.
|
2
|
+
Name: neurostats_API
|
3
|
+
Version: 0.0.14
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -83,7 +83,7 @@ pip install neurostats-API
|
|
83
83
|
```Python
|
84
84
|
>>> import neurostats_API
|
85
85
|
>>> print(neurostats_API.__version__)
|
86
|
-
0.0.
|
86
|
+
0.0.14
|
87
87
|
```
|
88
88
|
|
89
89
|
### 得到最新一期的評價資料與歷年評價
|
@@ -668,6 +668,11 @@ fetcher.query()
|
|
668
668
|
請注意`range`, `last_range`, `52week_range`這三個項目型態為字串,其餘為float
|
669
669
|
|
670
670
|
## 版本紀錄
|
671
|
+
## 0.0.14
|
672
|
+
- 修改部分財報資料錯誤的乘以1000的問題
|
673
|
+
|
674
|
+
- 新增例外處理: 若資料庫對於季資料一部分index缺失的情況下仍會盡可能去將資料蒐集並呈現
|
675
|
+
|
671
676
|
### 0.0.13
|
672
677
|
- value_fetcher 新增獲得一序列評價的功能
|
673
678
|
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__='0.0.13'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/cash_flow_percentage.yaml
RENAMED
File without changes
|
{neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/finance_overview_dict.yaml
RENAMED
File without changes
|
{neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API/tools/seasonal_data_field_dict.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neurostats_API-0.0.13 → neurostats_api-0.0.14}/neurostats_API.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|