neurostats-API 0.0.9__tar.gz → 0.0.10__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- neurostats_API-0.0.9/README.md → neurostats_API-0.0.10/PKG-INFO +20 -3
- neurostats_API-0.0.9/PKG-INFO → neurostats_API-0.0.10/README.md +10 -13
- neurostats_API-0.0.10/neurostats_API/__init__.py +1 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/balance_sheet.py +13 -6
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/finance_overview.py +97 -32
- neurostats_API-0.0.10/neurostats_API/fetchers/institution.py +114 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/profit_lose.py +14 -5
- neurostats_API-0.0.10/neurostats_API/tools/balance_sheet.yaml +34 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/tools/finance_overview_dict.yaml +76 -34
- neurostats_API-0.0.10/neurostats_API/tools/profit_lose.yaml +121 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/tools/seasonal_data_field_dict.txt +16 -1
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/utils/data_process.py +13 -2
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API.egg-info/PKG-INFO +11 -4
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API.egg-info/SOURCES.txt +1 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/setup.py +1 -1
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/test/test_fetchers.py +33 -17
- neurostats_API-0.0.9/neurostats_API/__init__.py +0 -1
- neurostats_API-0.0.9/neurostats_API/tools/balance_sheet.yaml +0 -26
- neurostats_API-0.0.9/neurostats_API/tools/profit_lose.yaml +0 -93
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/MANIFEST.in +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/cli.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/__init__.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/base.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/cash_flow.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/month_revenue.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/tech.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/fetchers/value_invest.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/main.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/tools/cash_flow_percentage.yaml +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/utils/__init__.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/utils/datetime.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/utils/db_client.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/utils/fetcher.py +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API.egg-info/dependency_links.txt +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API.egg-info/top_level.txt +0 -0
- {neurostats_API-0.0.9 → neurostats_API-0.0.10}/setup.cfg +0 -0
@@ -1,3 +1,13 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: neurostats_API
|
3
|
+
Version: 0.0.10
|
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
|
+
|
1
11
|
# neurostats_API
|
2
12
|
|
3
13
|
- [檔案架構](#檔案架構)
|
@@ -9,6 +19,8 @@
|
|
9
19
|
- [損益表](#損益表)
|
10
20
|
- [資產負債表](#資產負債表)
|
11
21
|
- [現金流量表](#現金流量表)
|
22
|
+
- [版本紀錄](#版本紀錄)
|
23
|
+
|
12
24
|
|
13
25
|
## 檔案架構
|
14
26
|
|
@@ -68,7 +80,7 @@ pip install neurostats-API
|
|
68
80
|
```Python
|
69
81
|
>>> import neurostats_API
|
70
82
|
>>> print(neurostats_API.__version__)
|
71
|
-
0.0.
|
83
|
+
0.0.10
|
72
84
|
```
|
73
85
|
|
74
86
|
### 得到最新一期的評價資料與歷年評價
|
@@ -424,6 +436,11 @@ stats_fetcher.query()
|
|
424
436
|
> 大部分資料缺失是因為尚未計算,僅先填上已經有的資料
|
425
437
|
|
426
438
|
|
427
|
-
##
|
428
|
-
|
439
|
+
## 版本紀錄
|
440
|
+
### 0.0.10
|
441
|
+
- 更新指標的資料型態: 單位為千元乘以1000之後回傳整數
|
442
|
+
|
443
|
+
- 處理銀行公司在finanace_overview會報錯誤的問題(未完全解決,因銀行公司財報有許多名稱不同,目前都會顯示為None)
|
429
444
|
|
445
|
+
### 0.0.9
|
446
|
+
- 更新指標的資料型態: 單位為日, %, 倍轉為字串
|
@@ -1,13 +1,3 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: neurostats_API
|
3
|
-
Version: 0.0.9
|
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
|
- [檔案架構](#檔案架構)
|
@@ -19,6 +9,8 @@ Description-Content-Type: text/markdown
|
|
19
9
|
- [損益表](#損益表)
|
20
10
|
- [資產負債表](#資產負債表)
|
21
11
|
- [現金流量表](#現金流量表)
|
12
|
+
- [版本紀錄](#版本紀錄)
|
13
|
+
|
22
14
|
|
23
15
|
## 檔案架構
|
24
16
|
|
@@ -78,7 +70,7 @@ pip install neurostats-API
|
|
78
70
|
```Python
|
79
71
|
>>> import neurostats_API
|
80
72
|
>>> print(neurostats_API.__version__)
|
81
|
-
0.0.
|
73
|
+
0.0.10
|
82
74
|
```
|
83
75
|
|
84
76
|
### 得到最新一期的評價資料與歷年評價
|
@@ -434,6 +426,11 @@ stats_fetcher.query()
|
|
434
426
|
> 大部分資料缺失是因為尚未計算,僅先填上已經有的資料
|
435
427
|
|
436
428
|
|
437
|
-
##
|
438
|
-
|
429
|
+
## 版本紀錄
|
430
|
+
### 0.0.10
|
431
|
+
- 更新指標的資料型態: 單位為千元乘以1000之後回傳整數
|
432
|
+
|
433
|
+
- 處理銀行公司在finanace_overview會報錯誤的問題(未完全解決,因銀行公司財報有許多名稱不同,目前都會顯示為None)
|
439
434
|
|
435
|
+
### 0.0.9
|
436
|
+
- 更新指標的資料型態: 單位為日, %, 倍轉為字串
|
@@ -0,0 +1 @@
|
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
35
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
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
|
-
|
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
|
-
|
309
|
-
|
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['
|
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['
|
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
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
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
|
-
|
517
|
-
|
518
|
-
|
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
|
-
'
|
595
|
+
'application_turnover'] = StatsProcessor.cal_percentage(
|
532
596
|
applcation_turnover)
|
533
597
|
|
534
|
-
except
|
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
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
@@ -0,0 +1,34 @@
|
|
1
|
+
balance_sheet:
|
2
|
+
mode: value_and_percentage
|
3
|
+
|
4
|
+
total_asset:
|
5
|
+
mode: value_and_percentage
|
6
|
+
target_index:
|
7
|
+
- 資產總額 負債總額 權益總額
|
8
|
+
- 資產總計 負債總計 權益總計
|
9
|
+
|
10
|
+
current_asset:
|
11
|
+
mode: value_and_percentage
|
12
|
+
target_index:
|
13
|
+
- 流動資產合計
|
14
|
+
|
15
|
+
non_current_asset:
|
16
|
+
mode: value_and_percentage
|
17
|
+
target_index:
|
18
|
+
- 非流動資產合計
|
19
|
+
|
20
|
+
current_debt:
|
21
|
+
mode: value_and_percentage
|
22
|
+
target_index:
|
23
|
+
- 流動負債合計
|
24
|
+
|
25
|
+
non_current_debt:
|
26
|
+
mode: value_and_percentage
|
27
|
+
target_index:
|
28
|
+
- 非流動負債合計
|
29
|
+
|
30
|
+
equity:
|
31
|
+
mode: value_and_percentage
|
32
|
+
target_index:
|
33
|
+
- 權益總額
|
34
|
+
- 權益總計
|
{neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/tools/finance_overview_dict.yaml
RENAMED
@@ -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
|
-
|
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
|
|
@@ -0,0 +1,121 @@
|
|
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
|
+
- 利息收入
|
12
|
+
|
13
|
+
grand_total_revenue:
|
14
|
+
mode: grand_total_growth
|
15
|
+
target_index:
|
16
|
+
- 營業收入合計
|
17
|
+
- 利息收入
|
18
|
+
|
19
|
+
gross_profit:
|
20
|
+
mode: growth
|
21
|
+
target_index:
|
22
|
+
- 營業毛利(毛損)淨額
|
23
|
+
|
24
|
+
grand_total_gross_profit:
|
25
|
+
mode: grand_total_growth
|
26
|
+
target_index:
|
27
|
+
- 營業毛利(毛損)淨額
|
28
|
+
|
29
|
+
gross_profit_percentage:
|
30
|
+
mode: percentage
|
31
|
+
target_index:
|
32
|
+
- 營業毛利(毛損)淨額
|
33
|
+
|
34
|
+
grand_total_gross_profit_percentage:
|
35
|
+
mode: grand_total_percentage
|
36
|
+
target_index:
|
37
|
+
- 營業毛利(毛損)淨額
|
38
|
+
# 營利
|
39
|
+
operating_income:
|
40
|
+
mode: growth
|
41
|
+
target_index:
|
42
|
+
- 營業利益(損失)
|
43
|
+
|
44
|
+
grand_total_operating_income:
|
45
|
+
mode: grand_total_growth
|
46
|
+
target_index:
|
47
|
+
- 營業利益(損失)
|
48
|
+
|
49
|
+
operating_income_percentage:
|
50
|
+
mode: percentage
|
51
|
+
target_index:
|
52
|
+
- 營業利益(損失)
|
53
|
+
|
54
|
+
grand_total_operating_income_percentage:
|
55
|
+
mode: grand_total_percentage
|
56
|
+
target_index:
|
57
|
+
- 營業利益(損失)
|
58
|
+
# 稅前淨利
|
59
|
+
net_income_before_tax:
|
60
|
+
mode: growth
|
61
|
+
target_index:
|
62
|
+
- 稅前淨利(淨損)
|
63
|
+
|
64
|
+
grand_total_net_income_before_tax:
|
65
|
+
mode: grand_total_growth
|
66
|
+
target_index:
|
67
|
+
- 稅前淨利(淨損)
|
68
|
+
|
69
|
+
net_income_before_tax_percentage:
|
70
|
+
mode: percentage
|
71
|
+
target_index:
|
72
|
+
- 稅前淨利(淨損)
|
73
|
+
|
74
|
+
grand_total_net_income_before_tax_percentage:
|
75
|
+
mode: grand_total_percentage
|
76
|
+
target_index:
|
77
|
+
- 稅前淨利(淨損)
|
78
|
+
# 本期淨利
|
79
|
+
net_income:
|
80
|
+
mode: growth
|
81
|
+
target_index:
|
82
|
+
- 本期淨利(淨損)
|
83
|
+
|
84
|
+
grand_total_net_income:
|
85
|
+
mode: grand_total_growth
|
86
|
+
target_index:
|
87
|
+
- 本期淨利(淨損)
|
88
|
+
|
89
|
+
net_income_percentage:
|
90
|
+
mode: percentage
|
91
|
+
target_index:
|
92
|
+
- 本期淨利(淨損)
|
93
|
+
|
94
|
+
grand_total_income_percentage:
|
95
|
+
mode: grand_total_percentage
|
96
|
+
target_index:
|
97
|
+
- 本期淨利(淨損)
|
98
|
+
# EPS
|
99
|
+
EPS:
|
100
|
+
mode: value
|
101
|
+
target_index:
|
102
|
+
- 基本每股盈餘
|
103
|
+
- 基本每股盈餘合計
|
104
|
+
|
105
|
+
EPS_growth:
|
106
|
+
mode: growth
|
107
|
+
target_index:
|
108
|
+
- 基本每股盈餘
|
109
|
+
- 基本每股盈餘合計
|
110
|
+
|
111
|
+
grand_total_EPS:
|
112
|
+
mode: grand_total
|
113
|
+
target_index:
|
114
|
+
- 基本每股盈餘
|
115
|
+
- 基本每股盈餘合計
|
116
|
+
|
117
|
+
grand_total_EPS_growth:
|
118
|
+
mode: grand_total_growth
|
119
|
+
target_index:
|
120
|
+
- 基本每股盈餘
|
121
|
+
- 基本每股盈餘合計
|
{neurostats_API-0.0.9 → neurostats_API-0.0.10}/neurostats_API/tools/seasonal_data_field_dict.txt
RENAMED
@@ -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
|
158
|
-
|
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.
|
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.
|
83
|
+
0.0.10
|
82
84
|
```
|
83
85
|
|
84
86
|
### 得到最新一期的評價資料與歷年評價
|
@@ -434,6 +436,11 @@ stats_fetcher.query()
|
|
434
436
|
> 大部分資料缺失是因為尚未計算,僅先填上已經有的資料
|
435
437
|
|
436
438
|
|
437
|
-
##
|
438
|
-
|
439
|
+
## 版本紀錄
|
440
|
+
### 0.0.10
|
441
|
+
- 更新指標的資料型態: 單位為千元乘以1000之後回傳整數
|
442
|
+
|
443
|
+
- 處理銀行公司在finanace_overview會報錯誤的問題(未完全解決,因銀行公司財報有許多名稱不同,目前都會顯示為None)
|
439
444
|
|
445
|
+
### 0.0.9
|
446
|
+
- 更新指標的資料型態: 單位為日, %, 倍轉為字串
|
@@ -13,6 +13,7 @@ neurostats_API/fetchers/balance_sheet.py
|
|
13
13
|
neurostats_API/fetchers/base.py
|
14
14
|
neurostats_API/fetchers/cash_flow.py
|
15
15
|
neurostats_API/fetchers/finance_overview.py
|
16
|
+
neurostats_API/fetchers/institution.py
|
16
17
|
neurostats_API/fetchers/month_revenue.py
|
17
18
|
neurostats_API/fetchers/profit_lose.py
|
18
19
|
neurostats_API/fetchers/tech.py
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import json
|
1
2
|
from pprint import PrettyPrinter
|
2
3
|
import pytest
|
3
4
|
import pandas as pd
|
@@ -11,13 +12,18 @@ pp = PrettyPrinter(
|
|
11
12
|
indent=2
|
12
13
|
)
|
13
14
|
|
15
|
+
with open(f"./neurostats_API/tw50_company_list.json") as f:
|
16
|
+
company_list = json.load(f)
|
14
17
|
db_client = DBClient("mongodb://neurowatt:neurodb123@db.neurowatt.ai:27017/neurowatt").get_client()
|
15
18
|
|
16
19
|
def test_value():
|
17
20
|
from neurostats_API.fetchers import ValueFetcher
|
18
|
-
|
21
|
+
for ticker in company_list.keys():
|
22
|
+
|
23
|
+
fetcher = ValueFetcher(ticker=ticker, db_client=db_client)
|
19
24
|
|
20
|
-
|
25
|
+
fetched_data = fetcher.query_data()
|
26
|
+
|
21
27
|
|
22
28
|
assert ('daily_data' in fetched_data)
|
23
29
|
assert ('yearly_data' in fetched_data)
|
@@ -32,9 +38,11 @@ def test_value():
|
|
32
38
|
def test_profit_lose():
|
33
39
|
from neurostats_API.fetchers import ProfitLoseFetcher
|
34
40
|
|
35
|
-
|
41
|
+
for ticker in company_list.keys():
|
42
|
+
|
43
|
+
fetcher = ProfitLoseFetcher(ticker, db_client)
|
36
44
|
|
37
|
-
|
45
|
+
data = fetcher.query_data()
|
38
46
|
|
39
47
|
table_settings = StatsProcessor.load_yaml("profit_lose.yaml")
|
40
48
|
|
@@ -47,8 +55,10 @@ def test_profit_lose():
|
|
47
55
|
def test_cash_flow():
|
48
56
|
from neurostats_API.fetchers import CashFlowFetcher
|
49
57
|
|
50
|
-
|
51
|
-
|
58
|
+
for ticker in company_list.keys():
|
59
|
+
|
60
|
+
fetcher = CashFlowFetcher(ticker, db_client)
|
61
|
+
data = fetcher.query_data()
|
52
62
|
|
53
63
|
assert("cash_flow" in data.keys())
|
54
64
|
assert("CASHO" in data.keys())
|
@@ -61,9 +71,10 @@ def test_cash_flow():
|
|
61
71
|
|
62
72
|
def test_month_revenue():
|
63
73
|
from neurostats_API.fetchers import MonthRevenueFetcher
|
64
|
-
|
65
|
-
|
66
|
-
|
74
|
+
for ticker in company_list.keys():
|
75
|
+
|
76
|
+
fetcher = MonthRevenueFetcher(ticker, db_client)
|
77
|
+
data = fetcher.query_data()
|
67
78
|
|
68
79
|
assert("month_revenue" in data.keys())
|
69
80
|
assert("this_month_revenue_over_years" in data.keys())
|
@@ -75,11 +86,12 @@ def test_month_revenue():
|
|
75
86
|
|
76
87
|
def test_balance_sheet():
|
77
88
|
from neurostats_API.fetchers import BalanceSheetFetcher
|
89
|
+
for ticker in company_list.keys():
|
90
|
+
|
91
|
+
fetcher = BalanceSheetFetcher(ticker=ticker, db_client=db_client)
|
78
92
|
|
79
|
-
|
80
|
-
|
81
|
-
data = fetcher.query_data()
|
82
|
-
|
93
|
+
data = fetcher.query_data()
|
94
|
+
|
83
95
|
assert("balance_sheet" in data.keys())
|
84
96
|
assert('total_asset' in data.keys())
|
85
97
|
assert('current_asset' in data.keys())
|
@@ -93,8 +105,12 @@ def test_balance_sheet():
|
|
93
105
|
|
94
106
|
def test_finance_overview():
|
95
107
|
from neurostats_API.fetchers import FinanceOverviewFetcher
|
96
|
-
|
97
|
-
|
108
|
+
for ticker in company_list.keys():
|
109
|
+
fetcher = FinanceOverviewFetcher(ticker=ticker, db_client=db_client)
|
110
|
+
fetched_data = fetcher.query_data()
|
111
|
+
|
112
|
+
# except Exception as e:
|
113
|
+
# print(f"{ticker} finance_overview {str(e)}")
|
98
114
|
|
99
115
|
expected_keys = [
|
100
116
|
# Queried items
|
@@ -107,7 +123,7 @@ def test_finance_overview():
|
|
107
123
|
'financing_cash_flow',
|
108
124
|
'capital',
|
109
125
|
'eps',
|
110
|
-
'
|
126
|
+
'total_assets',
|
111
127
|
'equity',
|
112
128
|
'net_income_before_tax',
|
113
129
|
'interest',
|
@@ -152,7 +168,7 @@ def test_finance_overview():
|
|
152
168
|
'inventories_revenue_ratio',
|
153
169
|
'cash_of_conversion_cycle',
|
154
170
|
'asset_turnover',
|
155
|
-
'
|
171
|
+
'application_turnover',
|
156
172
|
'current_ratio',
|
157
173
|
'quick_ratio',
|
158
174
|
'debt_to_equity_ratio',
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__='0.0.8'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
balance_sheet:
|
2
|
-
mode: value_and_percentage
|
3
|
-
|
4
|
-
total_asset:
|
5
|
-
mode: value_and_percentage
|
6
|
-
target_index: 資產總額 負債總額 權益總額
|
7
|
-
|
8
|
-
current_asset:
|
9
|
-
mode: value_and_percentage
|
10
|
-
target_index: 流動資產合計
|
11
|
-
|
12
|
-
non_current_asset:
|
13
|
-
mode: value_and_percentage
|
14
|
-
target_index: 非流動資產合計
|
15
|
-
|
16
|
-
current_debt:
|
17
|
-
mode: value_and_percentage
|
18
|
-
target_index: 流動負債合計
|
19
|
-
|
20
|
-
non_current_debt:
|
21
|
-
mode: value_and_percentage
|
22
|
-
target_index: 非流動負債合計
|
23
|
-
|
24
|
-
equity:
|
25
|
-
mode: value_and_percentage
|
26
|
-
target_index: 權益總額
|
@@ -1,93 +0,0 @@
|
|
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_growth
|
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: 稀釋每股盈餘
|
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.9 → neurostats_API-0.0.10}/neurostats_API/tools/cash_flow_percentage.yaml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|