neurostats-API 0.0.9__py3-none-any.whl → 0.0.10__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- __version__='0.0.8'
1
+ __version__='0.0.10'
@@ -132,10 +132,17 @@ class BalanceSheetFetcher(StatsFetcher):
132
132
  total_table.columns = pd.MultiIndex.from_tuples(total_table.columns)
133
133
 
134
134
  for name, setting in self.table_settings.items():
135
- return_dict[name] = StatsProcessor.slice_multi_col_table(
136
- total_table=total_table,
137
- mode=setting['mode'],
138
- target_index=setting['target_index']
139
- if "target_index" in setting.keys() else None)
140
-
135
+ if ('target_index' in setting.keys()):
136
+ target_indexes = [target_index.strip() for target_index in setting['target_index']]
137
+ else:
138
+ target_indexes = [None]
139
+ for target_index in target_indexes:
140
+ try:
141
+ return_dict[name] = StatsProcessor.slice_multi_col_table(
142
+ total_table=total_table,
143
+ mode=setting['mode'],
144
+ target_index=target_index)
145
+ break
146
+ except Exception as e:
147
+ continue
141
148
  return return_dict
@@ -31,15 +31,19 @@ class FinanceOverviewFetcher(StatsFetcher):
31
31
 
32
32
  for key, target_sets in self.target_fields.items():
33
33
  try:
34
- small_target = target_sets['field']
35
- big_target = self.inverse_dict[
36
- small_target] # balance_sheet/profit_lose/cash_flow
34
+ small_targets = target_sets['field']
35
+
37
36
  value_index = target_sets['value'] # "金額" or "%"
38
37
 
39
- target_query.update({
40
- f"{key}":
41
- f"$$target_season_data.{big_target}.{small_target}.{value_index}"
42
- })
38
+ for small_target in small_targets:
39
+ big_target = self.inverse_dict[
40
+ small_target] # balance_sheet/profit_lose/cash_flow
41
+ if (small_target == "利息費用_bank"):
42
+ small_target = small_target[:small_target.find("_bank")]
43
+ target_query.update({
44
+ f"{key}":
45
+ f"$$target_season_data.{big_target}.{small_target}.{value_index}"
46
+ })
43
47
  except Exception:
44
48
  continue
45
49
 
@@ -98,8 +102,16 @@ class FinanceOverviewFetcher(StatsFetcher):
98
102
  finance_dict = fetched_data['seasonal_data'][0]
99
103
  FinanceOverviewProcessor.process_rate(finance_dict)
100
104
  FinanceOverviewProcessor.process_all(finance_dict)
105
+ self.fill_nan_index(finance_dict)
106
+ FinanceOverviewProcessor.process_thousand_dollar(finance_dict)
101
107
  fetched_data['seasonal_data'] = finance_dict
108
+
102
109
  return fetched_data
110
+
111
+ def fill_nan_index(self, finance_dict):
112
+ for key in self.target_fields.keys():
113
+ if (key not in finance_dict.keys()):
114
+ finance_dict[key] = None
103
115
 
104
116
 
105
117
  class FinanceOverviewProcessor(StatsProcessor):
@@ -116,6 +128,34 @@ class FinanceOverviewProcessor(StatsProcessor):
116
128
  else:
117
129
  finance_dict[key] = StatsProcessor.cal_non_percentage(
118
130
  finance_dict[key])
131
+
132
+
133
+ @classmethod
134
+ def process_thousand_dollar(cls, finance_dict):
135
+ process_index = [
136
+ "revenue",
137
+ "gross_profit",
138
+ "operating_income",
139
+ "net_income",
140
+ "operating_cash_flow",
141
+ "invest_cash_flow",
142
+ "financing_cash_flow",
143
+ "fcf",
144
+
145
+ 'current_assets',
146
+ 'current_liabilities',
147
+ 'non_current_assets',
148
+ 'non_current_liabilities',
149
+ 'total_assets',
150
+ "total_liabilities",
151
+ "equity"
152
+ ]
153
+
154
+ for index in process_index:
155
+ try:
156
+ finance_dict[index] = StatsProcessor.cal_non_percentage(finance_dict[index], postfix="千元")
157
+ except Exception as e:
158
+ finance_dict[index] = None
119
159
 
120
160
  @classmethod
121
161
  def process_all(cls, finance_dict):
@@ -135,12 +175,16 @@ class FinanceOverviewProcessor(StatsProcessor):
135
175
  cls.cal_quick_ratio, cls.cal_debt_to_equity_ratio,
136
176
  cls.cal_net_debt_to_equity_ratio, cls.cal_interest_coverage_ratio,
137
177
  cls.cal_debt_to_operating_cash_flow,
138
- cls.cal_debt_to_free_cash_flow, cls.cal_cash_flow_ratio
178
+ cls.cal_debt_to_free_cash_flow, cls.cal_cash_flow_ratio,
179
+
180
+ # process to 千元
181
+ cls.process_thousand_dollar
139
182
  ]
140
183
 
141
184
  for method in methods:
142
185
  method(finance_dict)
143
186
 
187
+
144
188
  @classmethod
145
189
  def cal_EBIT(cls, finance_dict):
146
190
  """
@@ -224,7 +268,14 @@ class FinanceOverviewProcessor(StatsProcessor):
224
268
  計算每股毛利
225
269
  = (當期營業毛利)÷(當期在外流通股數)
226
270
  """
227
-
271
+ if ('gross_profit' not in finance_dict.keys()):
272
+ try:
273
+ finance_dict['gross_profit'] = (
274
+ finance_dict['revenue'] -
275
+ finance_dict['operating_cost']
276
+ )
277
+ except:
278
+ finance_dict['gross_profit'] = None
228
279
  try:
229
280
  gross_per_share = (finance_dict['gross_profit'] /
230
281
  finance_dict['share_outstanding'])
@@ -267,7 +318,7 @@ class FinanceOverviewProcessor(StatsProcessor):
267
318
  operating_cash_flow_per_share)
268
319
  except (KeyError, ZeroDivisionError, TypeError) as e:
269
320
  finance_dict['operating_cash_flow_per_share'] = None
270
- print(f'operating_cash_flow_per_share because of {str(e)}')
321
+ # print(f'operating_cash_flow_per_share because of {str(e)}')
271
322
 
272
323
  @classmethod
273
324
  def fcf_per_share(cls, finance_dict):
@@ -292,12 +343,15 @@ class FinanceOverviewProcessor(StatsProcessor):
292
343
  計算資產報酬率(ROA)
293
344
  ROA = [ 本期淨利 + 利息費用 × (1-有效稅率) ] ÷(資產總額)
294
345
  """
295
- roa = (
296
- finance_dict['net_income'] + finance_dict['interest'] +
297
- (1 * 0.1) # 有效稅率需要改,這裡先設0.1
298
- ) / finance_dict['inventories']
346
+ try:
347
+ roa = (
348
+ finance_dict['net_income'] + finance_dict['interest'] +
349
+ (1 * 0.1) # 有效稅率需要改,這裡先設0.1
350
+ ) / finance_dict['inventories']
299
351
 
300
- finance_dict["roa"] = StatsProcessor.cal_percentage(roa)
352
+ finance_dict["roa"] = StatsProcessor.cal_percentage(roa)
353
+ except Exception as e:
354
+ finance_dict["roa"] = None
301
355
 
302
356
  @classmethod
303
357
  def cal_roe(cls, finance_dict):
@@ -305,8 +359,11 @@ class FinanceOverviewProcessor(StatsProcessor):
305
359
  計算股東權益報酬率(ROE)
306
360
  ROE = (本期淨利) ÷(權益總額)
307
361
  """
308
- roe = (finance_dict['net_income'] / finance_dict['equity'])
309
- finance_dict['roe'] = StatsProcessor.cal_percentage(roe)
362
+ try:
363
+ roe = (finance_dict['net_income'] / finance_dict['equity'])
364
+ finance_dict['roe'] = StatsProcessor.cal_percentage(roe)
365
+ except Exception as e:
366
+ finance_dict['roe'] = None
310
367
 
311
368
  @classmethod
312
369
  def cal_gross_over_asset(cls, finance_dict):
@@ -315,7 +372,7 @@ class FinanceOverviewProcessor(StatsProcessor):
315
372
  """
316
373
  try:
317
374
  gross_over_asset = (finance_dict['gross_profit'] /
318
- finance_dict['total_asset'])
375
+ finance_dict['total_assets'])
319
376
  finance_dict['gross_over_asset'] = StatsProcessor.cal_percentage(
320
377
  gross_over_asset)
321
378
  except (KeyError, ZeroDivisionError, TypeError) as e:
@@ -331,7 +388,7 @@ class FinanceOverviewProcessor(StatsProcessor):
331
388
  try:
332
389
  roce = ((finance_dict['net_income_before_tax'] +
333
390
  finance_dict['interest']) /
334
- (finance_dict['total_asset'] -
391
+ (finance_dict['total_assets'] -
335
392
  finance_dict['current_liabilities']))
336
393
  finance_dict['roce'] = StatsProcessor.cal_percentage(roce)
337
394
 
@@ -351,7 +408,7 @@ class FinanceOverviewProcessor(StatsProcessor):
351
408
  finance_dict[
352
409
  'gross_profit_margin'] = StatsProcessor.cal_percentage(
353
410
  gross_profit_margin)
354
- except:
411
+ except Exception as e:
355
412
  finance_dict['gross_profit_margin'] = None
356
413
  print(f"gross_profit_margin failed because of {str(e)}")
357
414
 
@@ -409,7 +466,7 @@ class FinanceOverviewProcessor(StatsProcessor):
409
466
  (finance_dict['account_pay'] / finance_dict['revenue']))
410
467
  finance_dict['dso'] = StatsProcessor.cal_non_percentage(
411
468
  dso, to_str=True, postfix="日")
412
- except:
469
+ except Exception as e:
413
470
  finance_dict['dso'] = None
414
471
  print(f"Error calculating 應收帳款收現天數 because of {str(e)}")
415
472
 
@@ -419,11 +476,15 @@ class FinanceOverviewProcessor(StatsProcessor):
419
476
  計算應收帳款佔營收比率
420
477
  = 應收帳款平均餘額 ÷ 營業收入
421
478
  """
422
- account_receive_over_revenue = (finance_dict['account_receive'] /
423
- finance_dict['revenue'])
424
- finance_dict[
425
- "account_receive_over_revenue"] = StatsProcessor.cal_percentage(
426
- account_receive_over_revenue)
479
+ try:
480
+ account_receive_over_revenue = (finance_dict['account_receive'] /
481
+ finance_dict['revenue'])
482
+ finance_dict[
483
+ "account_receive_over_revenue"] = StatsProcessor.cal_percentage(
484
+ account_receive_over_revenue)
485
+ except Exception as e:
486
+ finance_dict[
487
+ "account_receive_over_revenue"] = None
427
488
 
428
489
  @classmethod
429
490
  def cal_dpo(cls, finance_dict):
@@ -513,10 +574,13 @@ class FinanceOverviewProcessor(StatsProcessor):
513
574
  計算資產周轉率
514
575
  營業收入 ÷ 資產總額
515
576
  """
516
- asset_turnover = (finance_dict["revenue"] /
517
- finance_dict["inventories"])
518
- finance_dict["asset_turnover"] = StatsProcessor.cal_percentage(
519
- asset_turnover)
577
+ try:
578
+ asset_turnover = (finance_dict["revenue"] /
579
+ finance_dict["inventories"])
580
+ finance_dict["asset_turnover"] = StatsProcessor.cal_percentage(
581
+ asset_turnover)
582
+ except Exception as e:
583
+ finance_dict["asset_turnover"] = None
520
584
 
521
585
  @classmethod
522
586
  def cal_application_turnover(cls, finance_dict):
@@ -528,11 +592,12 @@ class FinanceOverviewProcessor(StatsProcessor):
528
592
  applcation_turnover = (finance_dict['revenue'] /
529
593
  finance_dict["application"])
530
594
  finance_dict[
531
- 'applcation_turnover'] = StatsProcessor.cal_percentage(
595
+ 'application_turnover'] = StatsProcessor.cal_percentage(
532
596
  applcation_turnover)
533
597
 
534
- except (KeyError, ZeroDivisionError, TypeError) as e:
598
+ except Exception as e:
535
599
  finance_dict['application_turnover'] = None
600
+
536
601
 
537
602
  @classmethod
538
603
  def cal_current_ratio(cls, finance_dict):
@@ -0,0 +1,114 @@
1
+ from .base import StatsFetcher
2
+ from datetime import datetime, timedelta
3
+ import json
4
+ import numpy as np
5
+ import pandas as pd
6
+ from ..utils import StatsDateTime, StatsProcessor
7
+ import importlib.resources as pkg_resources
8
+ import yaml
9
+
10
+
11
+ class InstitutionFetcher(StatsFetcher):
12
+ """
13
+ iFa -> 交易資訊 -> 法人買賣
14
+
15
+ 包括:
16
+ 1. 當日交易
17
+ 2. 一年內交易
18
+ """
19
+
20
+ def __init__(self, ticker, db_client):
21
+ raise(NotImplementedError("InstitutionFetcher : Not done yet"))
22
+ super().__init__(ticker, db_client)
23
+
24
+ def prepare_query(self, start_date, end_date):
25
+ pipeline = super().prepare_query()
26
+
27
+ target_query = {
28
+ "date": date,
29
+ "institution_trading": "$$target_season_data.institution_trading"
30
+ }
31
+
32
+
33
+ pipeline.append({
34
+ "$project": {
35
+ "_id": 0,
36
+ "ticker": 1,
37
+ "company_name": 1,
38
+ "profit_loses": {
39
+ "$map": {
40
+ "input": {
41
+ "$filter": {
42
+ "input": "$daily_data",
43
+ "as": "daily",
44
+ "cond": {
45
+ "$and": [
46
+ {"$gte": ["$$daily.date", start_date]},
47
+ {"$lte": ["$$daily.date", end_date]}
48
+ ]
49
+ }
50
+ }
51
+ },
52
+ "as": "target_daily_data",
53
+ "in": "$$target_daily_data"
54
+ }
55
+ }
56
+ }
57
+ })
58
+
59
+ return pipeline
60
+
61
+ def collect_data(self, date):
62
+ pipeline = self.prepare_query(date)
63
+
64
+ fetched_data = self.collection.aggregate(pipeline).to_list()
65
+
66
+ return fetch_data[-1]
67
+
68
+ def query_data(self):
69
+ try:
70
+ latest_time = StatsDateTime.get_latest_time(
71
+ self.ticker, self.collection)['last_update_time']
72
+ latest_date = latest_time['daily_data']['institution_trading']['last_update']
73
+ date = latest_date.replace(hour=0, minute=0, second=0, microsecond=0)
74
+ except Exception as e:
75
+ print(f"No updated time for institution_trading in {self.ticker}, use current time instead")
76
+ date = datetime.now(self.timezone)
77
+ date = date.replace(hour=0, minute=0, second=0, microsecond=0)
78
+
79
+ if (date.hour < 17): # 拿不到今天的資料
80
+ date = date - timedelta(days=1)
81
+
82
+ start_date = start_date - timedelta(days=365)
83
+
84
+ daily_data = self.collect_data(date)
85
+
86
+ daily_data = sorted(daily_data['daily_data'], key = lambda x : x['date'], reverse = True)
87
+
88
+ self.process_data(self.ticker, daily_data)
89
+
90
+ def process_data(self, daily_data):
91
+ table_dict = dict()
92
+
93
+ latest_data = daily_data[0]
94
+ yesterday_data = daily_data[1]
95
+
96
+ # 交易價格與昨天交易
97
+ table_dict = {
98
+ "open": latest_data['open'],
99
+ 'close': latest_data['close'],
100
+ 'range': f"{latest_data['high']}-{latest_data['low']}",
101
+ 'volumn': latest_data['volumn'] / 1000
102
+
103
+ }
104
+
105
+ # 今日法人買賣
106
+
107
+ # 一年內法人
108
+
109
+
110
+
111
+
112
+
113
+
114
+
@@ -137,10 +137,19 @@ class ProfitLoseFetcher(StatsFetcher):
137
137
  total_table = total_table.replace("N/A", None)
138
138
 
139
139
  for name, setting in self.table_settings.items():
140
- return_dict[name] = StatsProcessor.slice_multi_col_table(
141
- total_table=total_table,
142
- mode=setting['mode'],
143
- target_index=setting['target_index']
144
- if "target_index" in setting.keys() else None)
140
+ if ('target_index' in setting.keys()):
141
+ target_indexes = [target.strip() for target in setting['target_index']]
142
+ else:
143
+ target_indexes = [None]
144
+
145
+ for target_index in target_indexes:
146
+ try:
147
+ return_dict[name] = StatsProcessor.slice_multi_col_table(
148
+ total_table=total_table,
149
+ mode=setting['mode'],
150
+ target_index=target_index)
151
+ break
152
+ except Exception as e:
153
+ continue
145
154
 
146
155
  return return_dict
@@ -3,24 +3,32 @@ balance_sheet:
3
3
 
4
4
  total_asset:
5
5
  mode: value_and_percentage
6
- target_index: 資產總額 負債總額 權益總額
7
-
6
+ target_index:
7
+ - 資產總額 負債總額 權益總額
8
+ - 資產總計 負債總計 權益總計
9
+
8
10
  current_asset:
9
11
  mode: value_and_percentage
10
- target_index: 流動資產合計
12
+ target_index:
13
+ - 流動資產合計
11
14
 
12
15
  non_current_asset:
13
16
  mode: value_and_percentage
14
- target_index: 非流動資產合計
17
+ target_index:
18
+ - 非流動資產合計
15
19
 
16
20
  current_debt:
17
21
  mode: value_and_percentage
18
- target_index: 流動負債合計
22
+ target_index:
23
+ - 流動負債合計
19
24
 
20
25
  non_current_debt:
21
26
  mode: value_and_percentage
22
- target_index: 非流動負債合計
27
+ target_index:
28
+ - 非流動負債合計
23
29
 
24
30
  equity:
25
31
  mode: value_and_percentage
26
- target_index: 權益總額
32
+ target_index:
33
+ - 權益總額
34
+ - 權益總計
@@ -1,89 +1,111 @@
1
1
  # 財務概況
2
2
  revenue:
3
- field: 營業收入合計
3
+ field:
4
+ - 營業收入合計
4
5
  value: value
5
6
 
6
7
  gross_profit:
7
- field: 營業毛利(毛損)淨額
8
+ field:
9
+ - 營業毛利(毛損)淨額
8
10
  value: value
9
11
 
10
12
  operating_income:
11
- field: 營業利益(損失)
13
+ field:
14
+ - 營業利益(損失)
12
15
  value: value
13
16
 
14
17
  net_income:
15
- field: 本期淨利(淨損)
18
+ field:
19
+ - 本期淨利(淨損)
16
20
  value: value
17
21
 
18
22
  tax_fee:
19
- field: 所得稅費用(利益)合計
23
+ field:
24
+ - 所得稅費用(利益)合計
20
25
  value: value
21
26
 
22
27
  # TODO: 以下所爬到的資料都是累計的,Ifa有額外計算當季的變化量
23
28
  operating_cash_flow:
24
- field: 營業活動之淨現金流入(流出)
29
+ field:
30
+ - 營業活動之淨現金流入(流出)
25
31
  value: single_season_value
26
32
 
27
33
  invest_cash_flow:
28
- field: 投資活動之淨現金流入(流出)
34
+ field:
35
+ - 投資活動之淨現金流入(流出)
29
36
  value: single_season_value
30
37
 
31
38
  financing_cash_flow:
32
- field: 籌資活動之淨現金流入(流出)
39
+ field:
40
+ - 籌資活動之淨現金流入(流出)
33
41
  value: single_season_value
34
42
  # ^^^ 以上皆需要額外在DataBase處理
35
43
 
36
44
  # 每股財務狀況
37
45
  capital:
38
- field: 普通股股本
46
+ field:
47
+ - 普通股股本
39
48
  value: value
49
+
40
50
  eps:
41
- field: 基本每股盈餘
51
+ field:
52
+ - 基本每股盈餘
42
53
  value: value
43
54
 
44
55
  # 獲利能力
45
- total_asset:
46
- field: 資產總額
56
+ total_assets:
57
+ field:
58
+ - 資產總額
47
59
  value: value
48
60
 
49
61
  equity:
50
- field: 權益總額
62
+ field:
63
+ - 權益總額
51
64
  value: value
52
65
 
53
66
  net_income_before_tax:
54
- field: 稅前淨利(淨損)
67
+ field:
68
+ - 稅前淨利(淨損)
55
69
  value: value
56
70
 
57
71
  interest:
58
- field: 利息收入
72
+ field:
73
+ - 利息收入
59
74
  value: value
60
75
 
61
76
  operating_expenses:
62
- field: 營業費用合計
77
+ field:
78
+ - 營業費用合計
63
79
  value: value
64
80
 
65
81
  net_income_rate:
66
- field: 本期淨利(淨損)
82
+ field:
83
+ - 本期淨利(淨損)
67
84
  value: percentage
68
85
  # 成長動能
69
86
  revenue_YoY:
70
- field: 營業收入合計
87
+ field:
88
+ - 營業收入合計
71
89
  value: YoY_1
72
90
 
73
91
  gross_prof_YoY:
74
- field: 營業毛利(毛損)淨額
92
+ field:
93
+ - 營業毛利(毛損)淨額
75
94
  value: YoY_1
76
95
 
77
96
  operating_income_YoY:
78
- field: 營業利益(損失)
97
+ field:
98
+ - 營業利益(損失)
79
99
  value: YoY_1
80
100
 
81
101
  net_income_YoY:
82
- field: 本期淨利(淨損)
102
+ field:
103
+ - 本期淨利(淨損)
83
104
  value: YoY_1
84
105
 
85
106
  operating_cash_flow_YoY:
86
- field: 營業活動之淨現金流入(流出)
107
+ field:
108
+ - 營業活動之淨現金流入(流出)
87
109
  value: single_season_YoY
88
110
 
89
111
  # operating_cash_flow_per_share_YoY:
@@ -91,53 +113,73 @@ operating_cash_flow_YoY:
91
113
  # value: YoY_1
92
114
  # 營運指標
93
115
  account_receive:
94
- field: 應收帳款淨額
116
+ field:
117
+ - 應收帳款淨額
95
118
  value: value
96
119
 
97
120
  account_pay:
98
- field: 應付帳款
121
+ field:
122
+ - 應付帳款
99
123
  value: value
100
124
 
101
125
  inventories:
102
- field: 存貨
126
+ field:
127
+ - 存貨
103
128
  value: value
104
129
 
105
130
  operating_cost:
106
- field: 營業成本合計
131
+ field:
132
+ - 營業成本合計
107
133
  value: value
108
134
 
109
135
  application:
110
- field: 不動產、廠房及設備
136
+ field:
137
+ - 不動產、廠房及設備
111
138
  value: value
112
139
 
113
140
  # 財務韌性
114
141
  current_assets:
115
- field: 流動資產合計
142
+ field:
143
+ - 流動資產合計
116
144
  value: value
117
145
 
118
146
  current_liabilities:
119
- field: 流動負債合計
147
+ field:
148
+ - 流動負債合計
120
149
  value: value
121
150
 
122
151
  total_liabilities:
123
- field: 負債總額
152
+ field:
153
+ - 負債總額
124
154
  value: value
125
155
 
126
156
  short_term_liabilities:
127
- field: 短期借款
157
+ field:
158
+ - 短期借款
128
159
  value: value
129
160
 
130
161
  long_term_liabilities:
131
- field: 長期借款
162
+ field:
163
+ - 長期借款
132
164
  value: value
133
165
  #
134
166
  cash_and_cash_equivalents:
135
- field: 現金及約當現金
167
+ field:
168
+ - 現金及約當現金
136
169
  value: value
137
170
 
138
171
  interest_expense:
139
- field: 利息費用
172
+ field:
173
+ - 利息費用
140
174
  value: value
141
175
 
176
+ non_current_assets:
177
+ field:
178
+ - 非流動資產合計
179
+ value: value
142
180
 
181
+ non_current_liabilities:
182
+ field:
183
+ - 非流動負債合計
184
+ value: value
143
185
 
@@ -6,88 +6,116 @@ grand_total_profit_lose:
6
6
 
7
7
  revenue:
8
8
  mode: growth
9
- target_index: 營業收入合計
9
+ target_index:
10
+ - 營業收入合計
11
+ - 利息收入
10
12
 
11
13
  grand_total_revenue:
12
14
  mode: grand_total_growth
13
- target_index: 營業收入合計
15
+ target_index:
16
+ - 營業收入合計
17
+ - 利息收入
14
18
 
15
19
  gross_profit:
16
20
  mode: growth
17
- target_index: 營業毛利(毛損)淨額
21
+ target_index:
22
+ - 營業毛利(毛損)淨額
18
23
 
19
24
  grand_total_gross_profit:
20
25
  mode: grand_total_growth
21
- target_index: 營業毛利(毛損)淨額
26
+ target_index:
27
+ - 營業毛利(毛損)淨額
22
28
 
23
29
  gross_profit_percentage:
24
30
  mode: percentage
25
- target_index: 營業毛利(毛損)淨額
31
+ target_index:
32
+ - 營業毛利(毛損)淨額
26
33
 
27
34
  grand_total_gross_profit_percentage:
28
35
  mode: grand_total_percentage
29
- target_index: 營業毛利(毛損)淨額
36
+ target_index:
37
+ - 營業毛利(毛損)淨額
30
38
  # 營利
31
39
  operating_income:
32
40
  mode: growth
33
- target_index: 營業利益(損失)
41
+ target_index:
42
+ - 營業利益(損失)
34
43
 
35
44
  grand_total_operating_income:
36
45
  mode: grand_total_growth
37
- target_index: 營業利益(損失)
46
+ target_index:
47
+ - 營業利益(損失)
38
48
 
39
49
  operating_income_percentage:
40
50
  mode: percentage
41
- target_index: 營業利益(損失)
51
+ target_index:
52
+ - 營業利益(損失)
42
53
 
43
54
  grand_total_operating_income_percentage:
44
55
  mode: grand_total_percentage
45
- target_index: 營業利益(損失)
56
+ target_index:
57
+ - 營業利益(損失)
46
58
  # 稅前淨利
47
59
  net_income_before_tax:
48
60
  mode: growth
49
- target_index: 稅前淨利(淨損)
61
+ target_index:
62
+ - 稅前淨利(淨損)
50
63
 
51
64
  grand_total_net_income_before_tax:
52
65
  mode: grand_total_growth
53
- target_index: 稅前淨利(淨損)
66
+ target_index:
67
+ - 稅前淨利(淨損)
54
68
 
55
69
  net_income_before_tax_percentage:
56
70
  mode: percentage
57
- target_index: 稅前淨利(淨損)
71
+ target_index:
72
+ - 稅前淨利(淨損)
58
73
 
59
74
  grand_total_net_income_before_tax_percentage:
60
75
  mode: grand_total_percentage
61
- target_index: 稅前淨利(淨損)
76
+ target_index:
77
+ - 稅前淨利(淨損)
62
78
  # 本期淨利
63
79
  net_income:
64
80
  mode: growth
65
- target_index: 本期淨利(淨損)
81
+ target_index:
82
+ - 本期淨利(淨損)
66
83
 
67
84
  grand_total_net_income:
68
85
  mode: grand_total_growth
69
- target_index: 本期淨利(淨損)
86
+ target_index:
87
+ - 本期淨利(淨損)
70
88
 
71
89
  net_income_percentage:
72
90
  mode: percentage
73
- target_index: 本期淨利(淨損)
91
+ target_index:
92
+ - 本期淨利(淨損)
74
93
 
75
94
  grand_total_income_percentage:
76
95
  mode: grand_total_percentage
77
- target_index: 本期淨利(淨損)
96
+ target_index:
97
+ - 本期淨利(淨損)
78
98
  # EPS
79
99
  EPS:
80
100
  mode: value
81
- target_index: 稀釋每股盈餘
101
+ target_index:
102
+ - 基本每股盈餘
103
+ - 基本每股盈餘合計
82
104
 
83
105
  EPS_growth:
84
106
  mode: growth
85
- target_index: 稀釋每股盈餘
107
+ target_index:
108
+ - 基本每股盈餘
109
+ - 基本每股盈餘合計
86
110
 
87
111
  grand_total_EPS:
88
112
  mode: grand_total
89
- target_index: 稀釋每股盈餘
113
+ target_index:
114
+ - 基本每股盈餘
115
+ - 基本每股盈餘合計
90
116
 
91
117
  grand_total_EPS_growth:
92
118
  mode: grand_total_growth
93
- target_index: 稀釋每股盈餘
119
+ target_index:
120
+ - 基本每股盈餘
121
+ - 基本每股盈餘合計
@@ -22,11 +22,14 @@
22
22
  "其他非流動資產": "balance_sheet",
23
23
  "非流動資產合計": "balance_sheet",
24
24
  "資產總額": "balance_sheet",
25
+ "資產總計": "balance_sheet",
25
26
  "短期借款": "balance_sheet",
26
27
  "長期借款": "balance_sheet",
27
28
  "透過損益按公允價值衡量之金融負債-流動": "balance_sheet",
28
29
  "應付票據": "balance_sheet",
29
30
  "應付帳款": "balance_sheet",
31
+ "應收款項-淨額": "balance_sheet",
32
+ "應付款項": "balance_sheet",
30
33
  "應付帳款-關係人": "balance_sheet",
31
34
  "其他應付款": "balance_sheet",
32
35
  "其他應付款項-關係人": "balance_sheet",
@@ -38,6 +41,7 @@
38
41
  "其他非流動負債": "balance_sheet",
39
42
  "非流動負債合計": "balance_sheet",
40
43
  "負債總額": "balance_sheet",
44
+ "負債總計": "balance_sheet",
41
45
  "普通股股本": "balance_sheet",
42
46
  "股本合計": "balance_sheet",
43
47
  "資本公積-發行溢價": "balance_sheet",
@@ -52,10 +56,12 @@
52
56
  "歸屬於母公司業主之權益合計": "balance_sheet",
53
57
  "非控制權益": "balance_sheet",
54
58
  "權益總額": "balance_sheet",
59
+ "權益總計": "balance_sheet",
55
60
  "負債及權益總計": "balance_sheet",
56
61
  "待註銷股本股數(單位:股)": "balance_sheet",
57
62
  "預收股款(權益項下)之約當發行股數(單位:股)": "balance_sheet",
58
63
  "母公司暨子公司所持有之母公司庫藏股股數(單位:股)": "balance_sheet",
64
+ "應收款項-淨額": "balance_sheet",
59
65
  "繼續營業單位稅前淨利(淨損)": "cash_flow",
60
66
  "停業單位稅前淨利(淨損)": "cash_flow",
61
67
  "本期稅前淨利(淨損)": "cash_flow",
@@ -135,6 +141,7 @@
135
141
  "管理費用": "profit_lose",
136
142
  "研究發展費用": "profit_lose",
137
143
  "營業費用合計": "profit_lose",
144
+ "營業費用": "profit_lose",
138
145
  "營業利益(損失)": "profit_lose",
139
146
  "其他收入": "profit_lose",
140
147
  "其他利益及損失淨額": "profit_lose",
@@ -142,6 +149,7 @@
142
149
  "營業外收入及支出合計": "profit_lose",
143
150
  "稅前淨利(淨損)": "profit_lose",
144
151
  "所得稅費用(利益)合計": "profit_lose",
152
+ "所得稅費用(利益)": "profit_lose",
145
153
  "繼續營業單位本期淨利(淨損)": "profit_lose",
146
154
  "本期淨利(淨損)": "profit_lose",
147
155
  "確定福利計畫之再衡量數": "profit_lose",
@@ -155,5 +163,12 @@
155
163
  "母公司業主(綜合損益)": "profit_lose",
156
164
  "非控制權益(綜合損益)": "profit_lose",
157
165
  "基本每股盈餘": "profit_lose",
158
- "稀釋每股盈餘": "profit_lose"
166
+ "稀釋每股盈餘": "profit_lose",
167
+ "淨收益": "profit_lose",
168
+ "利息收入": "profit_lose",
169
+ "利息費用_bank": "profit_lose",
170
+ "利息淨收益": "profit_lose",
171
+ "繼續營業單位稅前損益": "profit_lose",
172
+ "本期稅後淨利(淨損)": "profit_lose",
173
+ "減:利息費用": "profit_lose"
159
174
  }
@@ -152,10 +152,21 @@ class StatsProcessor:
152
152
  @classmethod
153
153
  def cal_non_percentage(cls, value, to_str=False, postfix="元"):
154
154
  if (isinstance(value, (float, int))):
155
+
155
156
  value = np.round(value, 2).item()
157
+ if (postfix == "千元"):
158
+ value *= 1000
159
+ value = int(value)
160
+
161
+ postfix = "元"
162
+
156
163
  if (to_str):
157
- value = f"{value:.2f}{postfix}"
158
- return value
164
+ if (isinstance(value, float)):
165
+ value = f"{value:.2f}{postfix}"
166
+ return value
167
+ elif (isinstance(value, int)):
168
+ value = f"{value}{postfix}"
169
+ return value
159
170
 
160
171
  else:
161
172
  return value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neurostats-API
3
- Version: 0.0.9
3
+ Version: 0.0.10
4
4
  Summary: The service of NeuroStats website
5
5
  Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
6
6
  Author: JasonWang@Neurowatt
@@ -19,6 +19,8 @@ Description-Content-Type: text/markdown
19
19
  - [損益表](#損益表)
20
20
  - [資產負債表](#資產負債表)
21
21
  - [現金流量表](#現金流量表)
22
+ - [版本紀錄](#版本紀錄)
23
+
22
24
 
23
25
  ## 檔案架構
24
26
 
@@ -78,7 +80,7 @@ pip install neurostats-API
78
80
  ```Python
79
81
  >>> import neurostats_API
80
82
  >>> print(neurostats_API.__version__)
81
- 0.0.9
83
+ 0.0.10
82
84
  ```
83
85
 
84
86
  ### 得到最新一期的評價資料與歷年評價
@@ -434,6 +436,11 @@ stats_fetcher.query()
434
436
  > 大部分資料缺失是因為尚未計算,僅先填上已經有的資料
435
437
 
436
438
 
437
- ## TODO
438
- - 將utils/fetcher.py中的功能切分到fetchers資料夾中
439
+ ## 版本紀錄
440
+ ### 0.0.10
441
+ - 更新指標的資料型態: 單位為千元乘以1000之後回傳整數
442
+
443
+ - 處理銀行公司在finanace_overview會報錯誤的問題(未完全解決,因銀行公司財報有許多名稱不同,目前都會顯示為None)
439
444
 
445
+ ### 0.0.9
446
+ - 更新指標的資料型態: 單位為日, %, 倍轉為字串
@@ -0,0 +1,27 @@
1
+ neurostats_API/__init__.py,sha256=WzeHQJ3r8kPKWXSBuphad80I6bJ-GJORgQF6wSrYmhI,20
2
+ neurostats_API/cli.py,sha256=UJSWLIw03P24p-gkBb6JSEI5dW5U12UvLf1L8HjQD-o,873
3
+ neurostats_API/main.py,sha256=QcsfmWivg2Dnqw3MTJWiI0QvEiRs0VuH-BjwQHFCv00,677
4
+ neurostats_API/fetchers/__init__.py,sha256=U_OMG-mLpsVKYnCBrW2OjFuCzvPeVQ__7A676vGzztY,313
5
+ neurostats_API/fetchers/balance_sheet.py,sha256=3FzVuDPm88tgljvu5gIxVXcZYQWebMrGnM5_ch9Vdgw,5549
6
+ neurostats_API/fetchers/base.py,sha256=NW2SFzrimyAIrdJx1LVmTazelyZOAtcj54kJKHc4Vaw,1662
7
+ neurostats_API/fetchers/cash_flow.py,sha256=4G4SIUoBSwT-BePmz-SprQ0IJRL2QNWqWdQtlgaRKd4,7371
8
+ neurostats_API/fetchers/finance_overview.py,sha256=hmMurCSCEjYBQ6gRmVgoX6T57g8MjsdWec6LdVztVoE,27813
9
+ neurostats_API/fetchers/institution.py,sha256=EYxPebJrcCMm7fW2nBlu4bVsksMMxgcQh16jJ1NxP6I,3384
10
+ neurostats_API/fetchers/month_revenue.py,sha256=QmhMAO8jbkjg2R1LR0TAPE3bmDnyuLNjnD24ZsFkTBU,3501
11
+ neurostats_API/fetchers/profit_lose.py,sha256=nc9YVi5kv3_loF8m82h3Fxpms7573_rPP9OM36bCK3A,5455
12
+ neurostats_API/fetchers/tech.py,sha256=wH1kkqiETQhF0HAhk-UIiucnZ3EiL85Q-yMWCcVOiFM,11395
13
+ neurostats_API/fetchers/value_invest.py,sha256=O5IKC8Nl7p5-E-1zoyAyWtiDznaxNemeabanmaHDdJs,3327
14
+ neurostats_API/tools/balance_sheet.yaml,sha256=yTxrWh7m4K3LnaNunETidfNzl6S4Bf58VIg9U38XShQ,648
15
+ neurostats_API/tools/cash_flow_percentage.yaml,sha256=fk2Z4eb1JjGFvP134eJatHacB7BgTkBenhDJr83w8RE,1345
16
+ neurostats_API/tools/finance_overview_dict.yaml,sha256=B9nV75StXkrF3yv2-eezzitlJ38eEK86RD_VY6588gQ,2884
17
+ neurostats_API/tools/profit_lose.yaml,sha256=dcO-0J0BC4p06XBNuowu8ux0NTbyZiOkGfy6szHF6fw,2402
18
+ neurostats_API/tools/seasonal_data_field_dict.txt,sha256=X8yc_el6p8BH_3FikTqBVFGsvWdXT6MHXLfKfi44334,8491
19
+ neurostats_API/utils/__init__.py,sha256=FTYKRFzW2XVXdnSHXnS3mQQaHlKF9xGqrMsgZZ2kroc,142
20
+ neurostats_API/utils/data_process.py,sha256=mDznLqAAZ7gFX3LlJkJvtrMPt38Lh5-NONqgnqT5tSY,5990
21
+ neurostats_API/utils/datetime.py,sha256=XJya4G8b_-ZOaBbMXgQjWh2MC4wc-o6goQ7EQJQMWrQ,773
22
+ neurostats_API/utils/db_client.py,sha256=OYe6yazcR4Aa6jYmy47JrryUeh2NnKGqY2K_lSZe6i8,455
23
+ neurostats_API/utils/fetcher.py,sha256=VbrUhjA-GG5AyjPX2SHtFIbZM4dm3jo0RgZzuCbb_Io,40927
24
+ neurostats_API-0.0.10.dist-info/METADATA,sha256=2zDomUXohUsLpnl4MeD6anZimrhnWvd8n0Rv8d4qkUk,18529
25
+ neurostats_API-0.0.10.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
26
+ neurostats_API-0.0.10.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
27
+ neurostats_API-0.0.10.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- neurostats_API/__init__.py,sha256=9_jSwg7P5SlFv0Ci2ZSYBcAbygp9XV2C8sryRO8tvko,19
2
- neurostats_API/cli.py,sha256=UJSWLIw03P24p-gkBb6JSEI5dW5U12UvLf1L8HjQD-o,873
3
- neurostats_API/main.py,sha256=QcsfmWivg2Dnqw3MTJWiI0QvEiRs0VuH-BjwQHFCv00,677
4
- neurostats_API/fetchers/__init__.py,sha256=U_OMG-mLpsVKYnCBrW2OjFuCzvPeVQ__7A676vGzztY,313
5
- neurostats_API/fetchers/balance_sheet.py,sha256=VeWhd8Z2XZnL5RzxmenLzAd4eyK2sWTuiRGkqWsEmzk,5219
6
- neurostats_API/fetchers/base.py,sha256=NW2SFzrimyAIrdJx1LVmTazelyZOAtcj54kJKHc4Vaw,1662
7
- neurostats_API/fetchers/cash_flow.py,sha256=4G4SIUoBSwT-BePmz-SprQ0IJRL2QNWqWdQtlgaRKd4,7371
8
- neurostats_API/fetchers/finance_overview.py,sha256=EVP7k0JkQq3ydXy0f3t2kzy12iIQEwDniTLn98qZ460,25637
9
- neurostats_API/fetchers/month_revenue.py,sha256=QmhMAO8jbkjg2R1LR0TAPE3bmDnyuLNjnD24ZsFkTBU,3501
10
- neurostats_API/fetchers/profit_lose.py,sha256=C0y42RBA-s20XcG6CJ10Rt6Gm_rB6lcvBmIzbTpn64o,5123
11
- neurostats_API/fetchers/tech.py,sha256=wH1kkqiETQhF0HAhk-UIiucnZ3EiL85Q-yMWCcVOiFM,11395
12
- neurostats_API/fetchers/value_invest.py,sha256=O5IKC8Nl7p5-E-1zoyAyWtiDznaxNemeabanmaHDdJs,3327
13
- neurostats_API/tools/balance_sheet.yaml,sha256=dKTMbsYR9EFp48WAzmm_ISHMiJQLyE0V-XWS_gkxmr0,541
14
- neurostats_API/tools/cash_flow_percentage.yaml,sha256=fk2Z4eb1JjGFvP134eJatHacB7BgTkBenhDJr83w8RE,1345
15
- neurostats_API/tools/finance_overview_dict.yaml,sha256=URL1IFqO0j5uOwN3xETHriy_u9lYbLvdwghuznenP2Q,2500
16
- neurostats_API/tools/profit_lose.yaml,sha256=qHBnqG7fR4Pxc_c3n4raL-3l7o5RnABLz9YGOXoaGiA,2086
17
- neurostats_API/tools/seasonal_data_field_dict.txt,sha256=Za1fJR1yERbqrX8TgsS2kmMYMbaye43Gu_5ukUNBCNM,7904
18
- neurostats_API/utils/__init__.py,sha256=FTYKRFzW2XVXdnSHXnS3mQQaHlKF9xGqrMsgZZ2kroc,142
19
- neurostats_API/utils/data_process.py,sha256=m1B4EhCNSzOMfTBDtYCjkQSjbDTAEFC6TNf3NNxV36k,5657
20
- neurostats_API/utils/datetime.py,sha256=XJya4G8b_-ZOaBbMXgQjWh2MC4wc-o6goQ7EQJQMWrQ,773
21
- neurostats_API/utils/db_client.py,sha256=OYe6yazcR4Aa6jYmy47JrryUeh2NnKGqY2K_lSZe6i8,455
22
- neurostats_API/utils/fetcher.py,sha256=VbrUhjA-GG5AyjPX2SHtFIbZM4dm3jo0RgZzuCbb_Io,40927
23
- neurostats_API-0.0.9.dist-info/METADATA,sha256=z--BAc0e6HHBuXSQgc5ikwjPFzTfe-2o02gFLmgY_do,18232
24
- neurostats_API-0.0.9.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
25
- neurostats_API-0.0.9.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
26
- neurostats_API-0.0.9.dist-info/RECORD,,