neurostats-API 0.0.5__py3-none-any.whl → 0.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,138 @@
1
1
  from importlib.resources import files
2
2
  import json
3
+ import pandas as pd
3
4
  import yaml
4
5
 
6
+ target_metric_dict = {
7
+ 'value': ['value'],
8
+ 'value_and_percentage': ['value', 'percentage'],
9
+ 'percentage': ['percentage'],
10
+ 'grand_total': ['grand_total'],
11
+ 'grand_total_values': ['grand_total', 'grand_total_percentage'],
12
+ 'grand_total_percentage': ['grand_total_percentage'],
13
+ 'growth': [f'YoY_{i}' for i in [1, 3, 5, 10]],
14
+ 'grand_total_growth': [f"grand_total_YoY_{i}" for i in [1, 3, 5, 10]]
15
+ }
16
+
17
+
5
18
  class StatsProcessor:
19
+
6
20
  @classmethod
7
- def load_txt(cls, filename, json_load = True):
21
+ def load_txt(cls, filename, json_load=True):
8
22
  txt_path = files('neurostats_API.tools').joinpath(filename)
9
23
  with open(txt_path, 'r', encoding='utf-8') as f:
10
- data = json.load(f) if (json_load) else f.read()
24
+ data = json.load(f) if (json_load) else f.read()
11
25
  return data
26
+
12
27
  @classmethod
13
28
  def load_yaml(cls, filename):
14
29
  yaml_path = files('neurostats_API.tools').joinpath(filename)
15
30
  with open(yaml_path, 'r', encoding='utf-8') as f:
16
31
  data = yaml.safe_load(f)
17
32
 
18
- return data
33
+ return data
34
+
35
+ @classmethod
36
+ def expand_value_percentage(cls, dataframe):
37
+
38
+ expanded_columns = {}
39
+ for col in dataframe.columns:
40
+ # Use json_normalize to split 'value' and 'percentage'
41
+ expanded_df = pd.json_normalize(
42
+ dataframe[col]).add_prefix(f"{col}_")
43
+ expanded_df.index = dataframe.index
44
+ # Append the expanded columns to the new DataFrame
45
+ expanded_columns[col] = expanded_df
46
+
47
+ expanded_df = pd.concat(expanded_columns.values(), axis=1)
48
+
49
+ return expanded_df
50
+
51
+ @classmethod
52
+ def slice_table(
53
+ cls,
54
+ total_table,
55
+ mode='value',
56
+ target_index=None, # None or Str, 要特別抓哪個index
57
+ ):
58
+ """
59
+ total_table: column應為 <時間>_<單位>
60
+ 對只有單層column的table,切出想要的index
61
+ """
62
+ times = [
63
+ column.split("_")[0] for column in total_table.columns.unique()
64
+ ] #取出timeIndex
65
+ try:
66
+ target_metrics = target_metric_dict[mode]
67
+ except KeyError as e:
68
+ return f"mode Error: Get mode should be {list(target_metric_dict.keys())} but get {mode}"
69
+
70
+ desired_order = [
71
+ f"{time}_{value_name}" for time in times
72
+ for value_name in target_metrics
73
+ ]
74
+
75
+ if (target_index):
76
+ target_index = target_index.split()
77
+ sliced_table = total_table.loc[target_index, desired_order].T
78
+
79
+ return sliced_table.T
80
+
81
+ else:
82
+ return total_table.loc[:, desired_order]
83
+
84
+ @classmethod
85
+ def slice_multi_col_table(
86
+ cls,
87
+ total_table,
88
+ mode='value',
89
+ target_index=None, # None or Str, 要特別抓哪個index
90
+ ):
91
+ """
92
+ 對Multicolumn的dataframe切出目標的index
93
+ """
94
+ times = total_table.columns.get_level_values(0).unique()
95
+ try:
96
+ target_metrics = target_metric_dict[mode]
97
+ except KeyError as e:
98
+ return f"mode Error: Get mode should be {list(target_metric_dict.keys())} but get {mode}"
99
+
100
+ desired_order = [(time, value_name) for time in times
101
+ for value_name in target_metrics]
102
+
103
+ if (target_index):
104
+ target_index = target_index.split()
105
+ sliced_table = total_table.loc[
106
+ target_index, pd.IndexSlice[:,
107
+ target_metrics]][desired_order].T
108
+ if (mode == 'value_and_percentage'): # 因應balance_sheet 頁面的格式
109
+ return_table = sliced_table.T
110
+ return_table.columns = [
111
+ "_".join(flatten_indexs)
112
+ for flatten_indexs in return_table.columns.to_flat_index()
113
+ ]
114
+ return return_table
115
+
116
+ sliced_table = sliced_table.reset_index()
117
+ sliced_table = sliced_table.pivot(index='level_1',
118
+ columns='level_0',
119
+ values=target_index).sort_index(
120
+ axis=1, level = 1,ascending = False
121
+ )
122
+
123
+ sliced_table.columns = sliced_table.columns.get_level_values(1)
124
+ sliced_table.columns.name = None
125
+ sliced_table.index.name = None
126
+
127
+ return sliced_table.reindex(target_metrics)
128
+
129
+ else:
130
+ return_table = total_table.loc[:, pd.IndexSlice[:,
131
+ target_metrics]][
132
+ desired_order]
133
+ return_table.columns = [
134
+ "_".join(flatten_indexs)
135
+ for flatten_indexs in return_table.columns.to_flat_index()
136
+ ]
137
+ return return_table
138
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: neurostats_API
3
- Version: 0.0.5
2
+ Name: neurostats-API
3
+ Version: 0.0.7
4
4
  Summary: The service of NeuroStats website
5
5
  Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
6
6
  Author: JasonWang@Neurowatt
@@ -30,10 +30,15 @@ Description-Content-Type: text/markdown
30
30
  │   ├── fetchers
31
31
  │   │   ├── __init__.py
32
32
  │   │   ├── base.py
33
+ │   │   ├── balance_sheet.py
34
+ │   │   ├── cash_flow.py
33
35
  │   │   ├── finance_overview.py
36
+ │   │   ├── profit_lose.py
34
37
  │   │   ├── tech.py
35
- │   │   └── value_invest.py
38
+ │   │   ├── value_invest.py
36
39
  │   ├── tools
40
+ │   │   ├── balance_sheet.yaml
41
+ │   │   ├── cash_flow_percentage.yaml
37
42
  │   │   ├── finance_overview_dict.yaml
38
43
  │   │   ├── profit_lose.yaml
39
44
  │   │   └── seasonal_data_field_dict.txt
@@ -73,14 +78,15 @@ pip install neurostats-API
73
78
  ```Python
74
79
  >>> import neurostats_API
75
80
  >>> print(neurostats_API.__version__)
76
- 0.0.5
81
+ 0.0.6
77
82
  ```
78
83
 
79
84
  ### 得到最新一期的評價資料與歷年評價
80
85
  ``` Python
81
- from neurostats_API.fetchers import ValueFetcher
82
- ticker = 2330 # 換成tw50內任意ticker
83
- fetcher = ValueFetcher(ticker)
86
+ from neurostats_API.utils import ValueFetcher, DBClient
87
+ db_client = DBClient("<連接的DB位置>").get_client()
88
+ ticker = "2330" # 換成tw50內任意ticker
89
+ fetcher = ValueFetcher(ticker, db_client)
84
90
  data = stats_fetcher.query_data()
85
91
  ```
86
92
 
@@ -118,42 +124,42 @@ data = stats_fetcher.query_data()
118
124
 
119
125
  ### 回傳月營收表
120
126
  ``` Python
121
- from neurostats_API.utils import StatsFetcher
122
- ticker = 2330 # 換成tw50內任意ticker
123
- fetcher = StatsFetcher()
124
- data = stats_fetcher.get_month_revenue_sheet(ticker)
127
+ from neurostats_API.fetchers import MonthRevenueFetcher, DBClient
128
+ db_client = DBClient("<連接的DB位置>").get_client()
129
+ ticker = "2330" # 換成tw50內任意ticker
130
+ fetcher = MonthRevenueFetcherFetcher(ticker, db_client)
131
+ data = fetcher.query_data()
125
132
  ```
126
133
 
127
134
  #### 回傳
128
135
  ```Python
129
136
  {
130
- "_id": 671b776dd834afbfbeb9adb3
131
- "ticker": 2330
132
- "company_name":台積電
137
+ "ticker": "2330",
138
+ "company_name": "台積電",
133
139
  "month_revenue":
134
- 2014 2015 ... 2023 2024
135
- 1 51,429,993 87,120,068 ... 200,050,544 215,785,127
136
- 2 46,829,051 62,645,075 ... 163,174,097 181,648,270
137
- ... ... ... ... ... ...
138
- 12 69,510,190 58,347,005 ... 176,299,866 None
139
- grand_total None 639,978,805 ... 1,536,206,985 2,025,846,521
140
+ year 2024 ... 2014
141
+ month ...
142
+ grand_total 2.025847e+09 ... NaN
143
+ 12 NaN ... 69510190.0
144
+ ... ... ... ...
145
+ 2 1.816483e+08 ... 46829051.0
146
+ 1 2.157851e+08 ... 51429993.0
140
147
 
141
148
  "this_month_revenue_over_years":
142
- 2015 2016 ... 2023 2024
143
- revenue 64,514,083 89,702,807 ... 180,430,282 251,872,717
144
- MoM None None ... None None
145
- ... ... ... ... ... ...
146
- YoY_5 None None ... None None
147
- YoY_10 None None ... None None
148
-
149
+ year 2024 ... 2015
150
+ revenue 2.518727e+08 ... 64514083.0
151
+ revenue_increment_ratio 3.960000e+01 ... -13.8
152
+ ... ... ... ...
153
+ YoY_5 1.465200e+02 ... NaN
154
+ YoY_10 NaN ... NaN
149
155
 
150
156
  "grand_total_over_years":
151
- 2015 2016 ... 2023 2024
152
- revenue 639,978,805 685,711,092 ... 1,536,206,985 2,025,846,521
153
- MoM None None ... None None
154
- ... ... ... ... ... ...
155
- YoY_5 None None ... None None
156
- YoY_10 None None ... None None
157
+ year 2024 ... 2015
158
+ grand_total 2.025847e+09 ... 6.399788e+08
159
+ grand_total_increment_ratio 3.187000e+01 ... 1.845000e+01
160
+ ... ... ... ...
161
+ grand_total_YoY_5 1.691300e+02 ... NaN
162
+ grand_total_YoY_10 NaN ... NaN
157
163
 
158
164
 
159
165
  }
@@ -170,9 +176,10 @@ YoY_10 None None ... None None
170
176
  ### 財務分析: 重要指標
171
177
  對應https://ifa.ai/tw-stock/2330/finance-overview
172
178
  ```Python
173
- from neurostats_API.fetchers import FinanceOverviewFetcher
179
+ from neurostats_API.fetchers import FinanceOverviewFetcher, DBClient
180
+ db_client = DBClient("<連接的DB位置>").get_client()
174
181
  ticker = "2330"
175
- fetcher = FinanceOverviewFetcher(ticker = "2330")
182
+ fetcher = FinanceOverviewFetcher(ticker = "2330", db_client = db_client)
176
183
  data = fetcher.query_data()
177
184
  ```
178
185
 
@@ -192,6 +199,7 @@ markdown
192
199
  複製程式碼
193
200
  | 英文 | 中文 |
194
201
  |-----------------------------------|-----------------------------|
202
+ |**財務概況**|
195
203
  | revenue | 營業收入 |
196
204
  | gross_profit | 營業毛利 |
197
205
  | operating_income | 營業利益 |
@@ -199,6 +207,7 @@ markdown
199
207
  | operating_cash_flow | 營業活動之現金流 |
200
208
  | invest_cash_flow | 投資活動之淨現金流 |
201
209
  | financing_cash_flow | 籌資活動之淨現金流 |
210
+ |**每股財務狀況**|
202
211
  | revenue_per_share | 每股營收 |
203
212
  | gross_per_share | 每股營業毛利 |
204
213
  | operating_income_per_share | 每股營業利益 |
@@ -207,6 +216,7 @@ markdown
207
216
  | fcf_per_share | 每股自由現金流 |
208
217
  | debt_to_operating_cash_flow | 每股有息負債 |
209
218
  | equity | 每股淨值 |
219
+ |**獲利能力**|
210
220
  | roa | 資產報酬率 |
211
221
  | roe | 股東權益報酬率 |
212
222
  | gross_over_asset | 營業毛利÷總資產 |
@@ -215,10 +225,12 @@ markdown
215
225
  | operation_profit_rate | 營業利益率 |
216
226
  | net_income_rate | 淨利率 |
217
227
  | operating_cash_flow_profit_rate | 營業現金流利潤率 |
228
+ |**成長動能**|
218
229
  | revenue_YoY | 營收年成長率 |
219
230
  | gross_prof_YoY | 營業毛利年成長率 |
220
231
  | operating_income_YoY | 營業利益年成長率 |
221
232
  | net_income_YoY | 淨利年成長率 |
233
+ |**營運指標**|
222
234
  | dso | 應收帳款收現天數 |
223
235
  | account_receive_over_revenue | 應收帳款佔營收比率 |
224
236
  | dio | 平均售貨天數 |
@@ -227,6 +239,7 @@ markdown
227
239
  | cash_of_conversion_cycle | 現金循環週期 |
228
240
  | asset_turnover | 總資產週轉率 |
229
241
  | applcation_turnover | 不動產、廠房及設備週轉率 |
242
+ |**財務韌性**|
230
243
  | current_ratio | 流動比率 |
231
244
  | quick_ratio | 速動比率 |
232
245
  | debt_to_equity_ratio | 負債權益比率 |
@@ -235,6 +248,7 @@ markdown
235
248
  | debt_to_operating_cash_flow | 有息負債÷營業活動現金流 |
236
249
  | debt_to_free_cash_flow | 有息負債÷自由現金流 |
237
250
  | cash_flow_ratio | 現金流量比率 |
251
+ |**資產負債表**|
238
252
  | current_assets | 流動資產 |
239
253
  | current_liabilities | 流動負債 |
240
254
  | non_current_assets | 非流動資產 |
@@ -246,17 +260,19 @@ markdown
246
260
  #### 以下數值未在回傳資料中,待資料庫更新
247
261
  |英文|中文|
248
262
  |---|----|
249
- | operating_cash_flow_YoY (not in list, inferred) | 營業現金流年成長率 |
250
- | fcf_YoY (not in list, inferred) | 自由現金流年成長率 |
251
- | operating_cash_flow_per_share_YoY (not in list, inferred) | 每股營業現金流年成長率 |
252
- | fcf_per_share_YoY (not in list, inferred) | 每股自由現金流年成長率 |
263
+ |**成長動能**|
264
+ | operating_cash_flow_YoY | 營業現金流年成長率 |
265
+ | fcf_YoY | 自由現金流年成長率 |
266
+ | operating_cash_flow_per_share_YoY | 每股營業現金流年成長率 |
267
+ | fcf_per_share_YoY | 每股自由現金流年成長率 |
253
268
 
254
269
  ### 損益表
255
270
  ```Python
256
- from neurostats_API.utils import StatsFetcher
257
- fetcher = StatsFetcher()
258
- ticker = 2330 # 換成tw50內任意ticker
259
- data = fetcher.get_profit_lose(ticker)
271
+ from neurostats_API.fetchers import ProfitLoseFetcher, DBClient
272
+ db_client = DBClient("<連接的DB位置>").get_client()
273
+ fetcher = ProfitLoseFetcher(db_client)
274
+ ticker = "2330" # 換成tw50內任意ticker
275
+ data = fetcher.query_data()
260
276
  ```
261
277
 
262
278
  #### 回傳
@@ -269,82 +285,85 @@ data = fetcher.get_profit_lose(ticker)
269
285
  "profit_lose": #損益表,
270
286
  "grand_total_profit_lose": #今年度累計損益表,
271
287
  # 營業收入
272
- "revenue":
273
- "grand_total_revenue":
288
+ "revenue": # 營收成長率
289
+ "grand_total_revenue": # 營收累計成場濾
274
290
  # 毛利
275
- "gross_profit":
276
- "grand_total_gross_profit":
277
- "gross_profit_percentage":
278
- "grand_total_gross_profit_percentage"
291
+ "gross_profit": # 毛利成長率
292
+ "grand_total_gross_profit": # 累計毛利成長率
293
+ "gross_profit_percentage": # 毛利率
294
+ "grand_total_gross_profit_percentage" # 累計毛利率
279
295
  # 營利
280
- "operating_income":
281
- "grand_total_operating_income":
282
- "operating_income_percentage":
283
- "grand_total_operating_income_percentage":
296
+ "operating_income": # 營利成長率
297
+ "grand_total_operating_income": # 累計營利成長率
298
+ "operating_income_percentage": # 營利率
299
+ "grand_total_operating_income_percentage": # 累計營利率
284
300
  # 稅前淨利
285
- "net_income_before_tax":
286
- "grand_total_net_income_before_tax":
287
- "net_income_before_tax_percentage":
288
- "grand_total_net_income_before_tax_percentage":
301
+ "net_income_before_tax": # 稅前淨利成長率
302
+ "grand_total_net_income_before_tax": # 累計稅前淨利成長率
303
+ "net_income_before_tax_percentage": # 稅前淨利率
304
+ "grand_total_net_income_before_tax_percentage": # 累計稅前淨利率
289
305
  # 本期淨利
290
- "net_income":
291
- "grand_total_net_income":
292
- "net_income_percentage":
293
- "grand_total_income_percentage":
306
+ "net_income": # 本期淨利成長率
307
+ "grand_total_net_income": # 累計本期淨利成長率
308
+ "net_income_percentage": # 本期淨利率
309
+ "grand_total_income_percentage": # 累計本期淨利率
294
310
  # EPS
295
- "EPS":
296
- "EPS_growth":
297
- "grand_total_EPS":
298
- "grand_total_EPS_growth":
311
+ "EPS": # EPS
312
+ "EPS_growth": # EPS成長率
313
+ "grand_total_EPS": # 累計EPS
314
+ "grand_total_EPS_growth": # 累計EPS成長率
299
315
  }
300
316
  ```
301
317
 
302
318
  ### 資產負債表
303
319
  ``` Python
304
- from neurostats_API.utils import StatsFetcher
305
- fetcher = StatsFetcher()
306
- ticker = 2330 # 換成tw50內任意ticker
307
- stats_fetcher.get_balance_sheet(ticker)
320
+ from neurostats_API.fetchers import BalanceSheetFetcher, DBClient
321
+ db_client = DBClient("<連接的DB位置>").get_client()
322
+ ticker = "2330" # 換成tw50內任意ticker
323
+ fetcher = BalanceSheetFetcher(ticker, db_client)
324
+
325
+ stats_fetcher.query_data()
308
326
  ```
309
327
 
310
328
  #### 回傳
311
329
  ```Python
312
330
  {
313
331
  "ticker": "2330"
314
- "company_name": "台積電"
332
+ "company_name":"台積電"
315
333
  "balance_sheet":
316
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value 2024Q2_percentage
317
- 流動資產 NaN NaN ... NaN NaN
318
- 現金及約當現金 632229880.0 30.79 ... 1.799127e+09 30.07
319
- ... ... ... ... ... ... ...
320
- 按攤銷後成本衡量之金融資產-非流動 NaN NaN ... 8.868079e+07 1.48
321
- 其他權益 NaN NaN ... NaN NaN
334
+ 2024Q2_value ... 2018Q2_percentage
335
+ 流動資產 NaN ... NaN
336
+ 現金及約當現金 1.799127e+09 ... 30.79
337
+ ... ... ... ...
338
+ 避險之衍生金融負債-流動 NaN ... 0.00
339
+ 負債準備-流動 NaN ... 0.00
322
340
 
323
341
  "total_asset":
324
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value 2024Q2_percentage
325
- total_asset 2.053413e+09 100.00 ... 5.982364e+09 100.00
326
- total_debt 5.627777e+08 27.41 ... 2.162216e+09 36.14
327
- total_equity 1.490635e+09 72.59 ... 3.820148e+09 63.86
342
+ 2024Q2_value ... 2018Q2_percentage
343
+ 資產總額 5.982364e+09 ... 100.00
344
+ 負債總額 2.162216e+09 ... 27.41
345
+ 權益總額 3.820148e+09 ... 72.59
346
+
328
347
 
329
348
  "current_asset":
330
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value 2024Q2_percentage
331
- current_asset 959042679.0 46.7 ... 2.591658e+09 43.32
349
+ 2024Q2_value ... 2018Q2_percentage
350
+ 流動資產合計 2.591658e+09 ... 46.7
332
351
 
333
352
  "non_current_asset":
334
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value 2024Q2_percentage
335
- non_current_asset 1.094370e+09 53.3 ... 3.390706e+09 56.68
353
+ 2024Q2_value ... 2018Q2_percentage
354
+ 非流動資產合計 3.390706e+09 ... 53.3
336
355
 
337
356
  "current_debt":
338
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value 2024Q2_percentage
339
- current_debt 1.094370e+09 53.3 ... 3.390706e+09 56.68
357
+ 2024Q2_value ... 2018Q2_percentage
358
+ 流動負債合計 1.048916e+09 ... 22.55
340
359
 
341
360
  "non_current_debt":
342
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value 2024Q2_percentage
343
- non_current_debt 1.094370e+09 53.3 ... 3.390706e+09 56.68
361
+ 2024Q2_value ... 2018Q2_percentage
362
+ 非流動負債合計 1.113300e+09 ... 4.86
344
363
 
345
364
  "equity":
346
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value 2024Q2_percentage
347
- equity 1.094370e+09 53.3 ... 3.390706e+09 56.68
365
+ 2024Q2_value ... 2018Q2_percentage
366
+ 權益總額 3.820148e+09 ... 72.59
348
367
 
349
368
  }
350
369
  ```
@@ -360,76 +379,48 @@ equity 1.094370e+09 53.3 ... 3.390706e+09 56.68
360
379
 
361
380
  ### 現金流量表
362
381
  ``` Python
363
- from neurostats_API.utils import StatsFetcher
364
- fetcher = StatsFetcher()
382
+ from neurostats_API.utils import StatsFetcher, DBClient
383
+ db_client = DBClient("<連接的DB位置>").get_client()
384
+ fetcher = StatsFetcher(db_client)
365
385
  ticker = 2330 # 換成tw50內任意ticker
366
386
  stats_fetcher.get_cash_flow(ticker)
367
387
  ```
368
388
  #### 回傳
369
389
  ```Python
370
390
  {
371
- "ticker":2330
372
- "company_name":台積電
391
+ "ticker": "2330"
392
+ "company_name": "台積電"
373
393
  "cash_flow":
374
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value \
375
- 營業活動之現金流量-間接法 NaN NaN ... NaN
376
- 繼續營業單位稅前淨利(淨損) 187531229.0 0.645548 ... 572853779.0
377
- ... ... ... ... ...
378
- 存出保證金增加 NaN NaN ... -122271.0
379
- 收取之股利 NaN NaN ... 895503.0
380
-
381
- 2024Q2_percentage
382
- 營業活動之現金流量-間接法 NaN
383
- 繼續營業單位稅前淨利(淨損) 0.703769
384
- ... ...
385
- 存出保證金增加 0.000755
386
- 收取之股利 -0.005530
387
-
388
- "CASHO":
389
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value \
390
- 營業活動之現金流量-間接法 NaN NaN ... NaN
391
- 繼續營業單位稅前淨利(淨損) 187531229.0 0.645548 ... 572853779.0
392
- ... ... ... ... ...
393
- 退還(支付)之所得稅 -31709079.0 -0.109154 ... -89154446.0
394
- 營業活動之淨現金流入(流出) 290499278.0 1.000000 ... 813979318.0
395
-
396
- 2024Q2_percentage
397
- 營業活動之現金流量-間接法 NaN
398
- 繼續營業單位稅前淨利(淨損) 0.703769
399
- ... ...
400
- 退還(支付)之所得稅 -0.109529
401
- 營業活動之淨現金流入(流出) 1.000000
402
-
403
- "CASHI":
404
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value \
405
- 投資活動之現金流量 NaN NaN ... NaN
406
- 取得透過其他綜合損益按公允價值衡量之金融資產 -47523622.0 0.355889 ... -43780180.0
407
- ... ... ... ... ...
408
- 其他投資活動 -149104.0 0.001117 ... 7956680.0
409
- 投資活動之淨現金流入(流出) -133534789.0 1.000000 ... -357414321.0
410
-
411
- 2024Q2_percentage
412
- 投資活動之現金流量 NaN
413
- 取得透過其他綜合損益按公允價值衡量之金融資產 0.122491
414
- ... ...
415
- 其他投資活動 -0.022262
416
- 投資活動之淨現金流入(流出) 1.000000
417
-
418
- "CASHF":
419
- 2018Q2_value 2018Q2_percentage ... 2024Q2_value \
420
- 籌資活動之現金流量 NaN NaN ... NaN
421
- 短期借款減少 -33743725.0 0.387977 ... NaN
422
- ... ... ... ... ...
423
- 存出保證金增加 NaN NaN ... -122271.0
424
- 收取之股利 NaN NaN ... 895503.0
425
-
426
- 2024Q2_percentage
427
- 籌資活動之現金流量 NaN
428
- 短期借款減少 NaN
429
- ... ...
430
- 存出保證金增加 0.000755
431
- 收取之股利 -0.005530
432
-
394
+ 2023Q3_value ... 2018Q3_percentage
395
+ 營業活動之現金流量-間接法 NaN ... NaN
396
+ 繼續營業單位稅前淨利(淨損) 700890335.0 ... 0.744778
397
+ ... ... ... ...
398
+ 以成本衡量之金融資產減資退回股款 NaN ... NaN
399
+ 除列避險之金融負債∕避險 之衍生金融負債 NaN ... -0.000770
400
+
401
+ "CASHO":
402
+ 2023Q3_value ... 2018Q3_percentage
403
+ 營業活動之現金流量-間接法 NaN ... NaN
404
+ 繼續營業單位稅前淨利(淨損) 700890335.0 ... 0.744778
405
+ ... ... ... ...
406
+ 持有供交易之金融資產(增加)減少 NaN ... 0.001664
407
+ 負債準備增加(減少) NaN ... NaN
408
+
409
+ "CASHI":
410
+ 2023Q3_value ... 2018Q3_percentage
411
+ 投資活動之現金流量 NaN ... NaN
412
+ 取得透過其他綜合損益按公允價值衡量之金融資產 -54832622.0 ... 0.367413
413
+ ... ... ... ...
414
+ 持有至到期日金融資產到期還本 NaN ... NaN
415
+ 取得以成本衡量之金融資產 NaN ... NaN
416
+
417
+ "CASHF":
418
+ 2023Q3_value ... 2018Q3_percentage
419
+ 籌資活動之現金流量 NaN ... NaN
420
+ 短期借款減少 0.0 ... NaN
421
+ ... ... ... ...
422
+ 以成本衡量之金融資產減資退回股款 NaN ... NaN
423
+ 除列避險之金融負債∕避險 之衍生金融負債 NaN ... -0.00077
433
424
  }
434
425
  ```
435
426
  - `'ticker'`: 股票代碼
@@ -442,44 +433,6 @@ stats_fetcher.get_cash_flow(ticker)
442
433
  > 大部分資料缺失是因為尚未計算,僅先填上已經有的資料
443
434
 
444
435
 
445
-
446
-
447
- ## cli 範例輸入
448
- ```
449
- python ./cli.py --ticker 1101
450
- ```
451
-
452
- ### cli 輸出
453
- ```Python
454
- _id
455
- ObjectId('67219e046104872ef7490cd3')
456
- ticker
457
- '1101'
458
- company_name
459
- '台泥'
460
- yearly_data
461
- year P_E P_FCF P_B P_S EV_OPI EV_EBIT EV_EBITDA EV_S
462
- 0 107 9.78 66.346637 1.07 1.963814 16.061211 14.807325 32.858903 3.685025
463
- 1 108 10.76 23.532308 1.35 3.296749 21.995948 19.877169 44.395187 5.338454
464
- 2 109 10.29 -26.134468 1.32 4.282560 26.353871 23.417022 46.269197 6.908155
465
- 3 110 14.08 22.345215 1.50 5.558267 42.034804 32.290621 77.139298 7.973839
466
- 4 111 28.04 -63.248928 1.16 4.595606 -136332.740038 149.169022 -756.781156 7.324556
467
- 5 112 29.53 -18.313377 1.15 5.301801 98.225453 65.598234 321.991608 8.582981
468
- 6 過去4季 NaN -24.929987 NaN 4.300817 83.102921 55.788996 -1073.037084 7.436656
469
- daily_data
470
- { 'EV_EBIT': 55.78899626851681,
471
- 'EV_EBITDA': -1073.037084015388,
472
- 'EV_OPI': 83.10292101832388,
473
- 'EV_S': 7.436656083243897,
474
- 'P_B': None,
475
- 'P_E': None,
476
- 'P_FCF': -24.92998660989962,
477
- 'P_S': 4.300817175744059,
478
- 'close': 32.150001525878906,
479
- }
480
- ```
481
- > 這裡有Nan是因為本益比與P/B等資料沒有爬到最新的時間
482
-
483
436
  ## TODO
484
437
  - 將utils/fetcher.py中的功能切分到fetchers資料夾中
485
438