neurostats-API 0.0.17__tar.gz → 0.0.18__tar.gz
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.
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/PKG-INFO +35 -30
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/README.md +34 -29
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/__init__.py +1 -1
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/base.py +6 -2
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/tej_finance_report.py +11 -20
- neurostats_api-0.0.18/neurostats_API/tools/tej_db_index.yaml +135 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API.egg-info/PKG-INFO +35 -30
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API.egg-info/SOURCES.txt +1 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/setup.py +1 -1
- neurostats_api-0.0.18/test/test_tej.py +49 -0
- neurostats_api-0.0.17/test/test_tej.py +0 -26
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/MANIFEST.in +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/cli.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/__init__.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/balance_sheet.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/cash_flow.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/finance_overview.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/institution.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/margin_trading.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/month_revenue.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/profit_lose.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/tech.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/value_invest.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/main.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/tools/balance_sheet.yaml +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/tools/cash_flow_percentage.yaml +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/tools/finance_overview_dict.yaml +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/tools/profit_lose.yaml +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/tools/seasonal_data_field_dict.txt +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/utils/__init__.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/utils/calculate_value.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/utils/data_process.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/utils/datetime.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/utils/db_client.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/utils/fetcher.py +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API.egg-info/dependency_links.txt +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API.egg-info/requires.txt +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API.egg-info/top_level.txt +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/setup.cfg +0 -0
- {neurostats_api-0.0.17 → neurostats_api-0.0.18}/test/test_fetchers.py +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.18
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -774,43 +774,48 @@ YoY_10 1.420500e-01 1.586797e-01 1.551364e-01
|
|
774
774
|
}
|
775
775
|
```
|
776
776
|
|
777
|
+
### 公司自結資料
|
778
|
+
```Python
|
779
|
+
from neurostats_API import FinanceReportFetcher
|
777
780
|
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
## 0.0.15
|
785
|
-
- TechFetcher中新增指數條件
|
786
|
-
|
787
|
-
- 新增tej_fetcher索取TEJ相關的資料
|
788
|
-
|
789
|
-
- package新增depensnecy,可以安裝需要的相關package
|
781
|
+
fetcher = FinanceReportFetcher(
|
782
|
+
mongo_uri = mongo_uri,
|
783
|
+
db_name = db_name,
|
784
|
+
collection_name = collection_name
|
785
|
+
)
|
790
786
|
|
791
|
-
|
792
|
-
|
787
|
+
data = fetcher.get(
|
788
|
+
ticker = "2330" # 任意的股票代碼
|
789
|
+
fetch_mode = fetcher.FetchMode.QOQ_NOCAL # 取得模式
|
790
|
+
start_date = "2005-01-01",
|
791
|
+
end_date = "2024-12-31",
|
792
|
+
report_type = "Q",
|
793
|
+
indexes = []
|
794
|
+
) # -> pd.DataFrame or Dict[pd.DataFrame]
|
795
|
+
```
|
796
|
+
- `ticker`: 股票代碼
|
793
797
|
|
794
|
-
-
|
798
|
+
- `fetch_mode` : 取得模式,為`fetcher.YOY_NOCAL` 或 `fetcher.QOQ_NOCAL`
|
799
|
+
- `YOY_NOCAL`: 以end_date為準,取得與end_date同季的歷年資料,時間範圍以start_date為起始
|
800
|
+
> 例如`start_date = "2020-07-01"`, `end_date = "2024-01-01"`,會回傳2020~2024的第一季資料
|
795
801
|
|
796
|
-
|
797
|
-
- value_fetcher 新增獲得一序列評價的功能
|
802
|
+
- `QOQ_NOCAL`: 時間範圍內的每季資料
|
798
803
|
|
799
|
-
|
800
|
-
- 新增資券變化(margin trading)
|
804
|
+
- `QOQ`: 時間範圍內每季的每個index的數值以及QoQ
|
801
805
|
|
802
|
-
-
|
806
|
+
- `YoY`: 以end_date為準,取得與end_date同季的歷年資料以及成長率,時間範圍以start_date為起始
|
803
807
|
|
804
|
-
|
805
|
-
- 修復財務分析的千元計算問題
|
808
|
+
- `start_date`: 開始日期,不設定時預設為`2005-01-01`
|
806
809
|
|
807
|
-
-
|
810
|
+
- `end_date`: 結束日期,不設定時預設為資料庫最新資料的日期
|
808
811
|
|
809
|
-
-
|
810
|
-
|
811
|
-
-
|
812
|
+
- `report_type`: 選擇哪種報告,預設為`Q`
|
813
|
+
- `A`: 當年累計
|
814
|
+
- `Q`: 當季數值
|
815
|
+
- `TTM`: 移動四季 (包括當季在內,往前累計四個季度)
|
812
816
|
|
813
|
-
-
|
817
|
+
- `indexes`: 選擇的column,需要以TEJ提供的欄位名稱為準,不提供時或提供`[]`會回傳全部column
|
818
|
+
- 範例輸入: `['bp41', 'bp51']`
|
814
819
|
|
815
|
-
|
816
|
-
|
820
|
+
[TEJ資料集連結](https://tquant.tejwin.com/%E8%B3%87%E6%96%99%E9%9B%86/)
|
821
|
+
請看 `公司自結數`
|
@@ -758,43 +758,48 @@ YoY_10 1.420500e-01 1.586797e-01 1.551364e-01
|
|
758
758
|
}
|
759
759
|
```
|
760
760
|
|
761
|
+
### 公司自結資料
|
762
|
+
```Python
|
763
|
+
from neurostats_API import FinanceReportFetcher
|
761
764
|
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
## 0.0.15
|
769
|
-
- TechFetcher中新增指數條件
|
770
|
-
|
771
|
-
- 新增tej_fetcher索取TEJ相關的資料
|
772
|
-
|
773
|
-
- package新增depensnecy,可以安裝需要的相關package
|
765
|
+
fetcher = FinanceReportFetcher(
|
766
|
+
mongo_uri = mongo_uri,
|
767
|
+
db_name = db_name,
|
768
|
+
collection_name = collection_name
|
769
|
+
)
|
774
770
|
|
775
|
-
|
776
|
-
|
771
|
+
data = fetcher.get(
|
772
|
+
ticker = "2330" # 任意的股票代碼
|
773
|
+
fetch_mode = fetcher.FetchMode.QOQ_NOCAL # 取得模式
|
774
|
+
start_date = "2005-01-01",
|
775
|
+
end_date = "2024-12-31",
|
776
|
+
report_type = "Q",
|
777
|
+
indexes = []
|
778
|
+
) # -> pd.DataFrame or Dict[pd.DataFrame]
|
779
|
+
```
|
780
|
+
- `ticker`: 股票代碼
|
777
781
|
|
778
|
-
-
|
782
|
+
- `fetch_mode` : 取得模式,為`fetcher.YOY_NOCAL` 或 `fetcher.QOQ_NOCAL`
|
783
|
+
- `YOY_NOCAL`: 以end_date為準,取得與end_date同季的歷年資料,時間範圍以start_date為起始
|
784
|
+
> 例如`start_date = "2020-07-01"`, `end_date = "2024-01-01"`,會回傳2020~2024的第一季資料
|
779
785
|
|
780
|
-
|
781
|
-
- value_fetcher 新增獲得一序列評價的功能
|
786
|
+
- `QOQ_NOCAL`: 時間範圍內的每季資料
|
782
787
|
|
783
|
-
|
784
|
-
- 新增資券變化(margin trading)
|
788
|
+
- `QOQ`: 時間範圍內每季的每個index的數值以及QoQ
|
785
789
|
|
786
|
-
-
|
790
|
+
- `YoY`: 以end_date為準,取得與end_date同季的歷年資料以及成長率,時間範圍以start_date為起始
|
787
791
|
|
788
|
-
|
789
|
-
- 修復財務分析的千元計算問題
|
792
|
+
- `start_date`: 開始日期,不設定時預設為`2005-01-01`
|
790
793
|
|
791
|
-
-
|
794
|
+
- `end_date`: 結束日期,不設定時預設為資料庫最新資料的日期
|
792
795
|
|
793
|
-
-
|
794
|
-
|
795
|
-
-
|
796
|
+
- `report_type`: 選擇哪種報告,預設為`Q`
|
797
|
+
- `A`: 當年累計
|
798
|
+
- `Q`: 當季數值
|
799
|
+
- `TTM`: 移動四季 (包括當季在內,往前累計四個季度)
|
796
800
|
|
797
|
-
-
|
801
|
+
- `indexes`: 選擇的column,需要以TEJ提供的欄位名稱為準,不提供時或提供`[]`會回傳全部column
|
802
|
+
- 範例輸入: `['bp41', 'bp51']`
|
798
803
|
|
799
|
-
|
800
|
-
|
804
|
+
[TEJ資料集連結](https://tquant.tejwin.com/%E8%B3%87%E6%96%99%E9%9B%86/)
|
805
|
+
請看 `公司自結數`
|
@@ -97,7 +97,11 @@ class BaseTEJFetcher(abc.ABC):
|
|
97
97
|
year_shifts = [1, 3, 5, 10]
|
98
98
|
return_dict = {}
|
99
99
|
for year in range(start_year, end_year + 1):
|
100
|
-
|
100
|
+
try:
|
101
|
+
year_data = data_dict[f"{year}Q{season}"].copy()
|
102
|
+
except KeyError as e:
|
103
|
+
continue
|
104
|
+
|
101
105
|
year_keys = list(year_data.keys())
|
102
106
|
for key in year_keys:
|
103
107
|
if (key in 'season'):
|
@@ -109,7 +113,7 @@ class BaseTEJFetcher(abc.ABC):
|
|
109
113
|
for shift in year_shifts:
|
110
114
|
this_value = year_data[key]
|
111
115
|
try:
|
112
|
-
past_year =
|
116
|
+
past_year = year - shift
|
113
117
|
last_value = data_dict[f"{past_year}Q{season}"][key]
|
114
118
|
temp_dict[f"YoY_{shift}"] = YoY_Calculator.cal_growth(this_value, last_value, delta=shift)
|
115
119
|
except Exception as e:
|
{neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/fetchers/tej_finance_report.py
RENAMED
@@ -5,6 +5,7 @@ import pandas as pd
|
|
5
5
|
from pymongo import MongoClient
|
6
6
|
from ..utils import StatsProcessor, YoY_Calculator
|
7
7
|
import warnings
|
8
|
+
import yaml
|
8
9
|
|
9
10
|
|
10
11
|
class FinanceReportFetcher(BaseTEJFetcher):
|
@@ -20,18 +21,8 @@ class FinanceReportFetcher(BaseTEJFetcher):
|
|
20
21
|
self.db = self.client[db_name]
|
21
22
|
self.collection = self.db[collection_name]
|
22
23
|
|
23
|
-
|
24
|
-
self.check_index =
|
25
|
-
'coid', 'mdate', 'key3', 'no', 'sem', 'merg', 'curr', 'annd', 'fin_ind', 'bp11', 'bp21', 'bp22', 'bp31',
|
26
|
-
'bp41', 'bp51', 'bp53', 'bp61', 'bp62', 'bp63', 'bp64', 'bp65', 'bf11', 'bf12', 'bf21', 'bf22', 'bf41',
|
27
|
-
'bf42', 'bf43', 'bf44', 'bf45', 'bf99', 'bsca', 'bsnca', 'bsta', 'bscl', 'bsncl', 'bstl', 'bsse', 'bslse',
|
28
|
-
'debt', 'quick', 'ppe', 'ar', 'ip12', 'ip22', 'ip31', 'ip51', 'iv41', 'if11', 'isibt', 'isni', 'isnip',
|
29
|
-
'eps', 'ispsd', 'gm', 'opi', 'nri', 'ri', 'nopi', 'ebit', 'cip31', 'cscfo', 'cscfi', 'cscff', 'person',
|
30
|
-
'shares', 'wavg', 'taxrate', 'r104', 'r115', 'r105', 'r106', 'r107', 'r108', 'r201', 'r112', 'r401', 'r402',
|
31
|
-
'r403', 'r404', 'r405', 'r408', 'r409', 'r410', 'r502', 'r501', 'r205', 'r505', 'r517', 'r512', 'r509',
|
32
|
-
'r608', 'r616', 'r610', 'r607', 'r613', 'r612', 'r609', 'r614', 'r611', 'r307', 'r304', 'r305', 'r306',
|
33
|
-
'r316', 'r834'
|
34
|
-
} # yapf: enabled
|
24
|
+
index_dict = StatsProcessor.load_yaml("tej_db_index.yaml")
|
25
|
+
self.check_index = set(index_dict[collection_name])
|
35
26
|
|
36
27
|
def get(
|
37
28
|
self,
|
@@ -59,17 +50,19 @@ class FinanceReportFetcher(BaseTEJFetcher):
|
|
59
50
|
if (difference):
|
60
51
|
warnings.warn(f"{list(difference)} 沒有出現在資料表中,請確認column名稱是否正確", UserWarning)
|
61
52
|
|
53
|
+
if (not start_date):
|
54
|
+
start_date = datetime.strptime("2005-01-01", "%Y-%m-%d")
|
55
|
+
else:
|
56
|
+
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
57
|
+
|
62
58
|
if (fetch_mode in {self.FetchMode.QOQ, self.FetchMode.QOQ_NOCAL}):
|
63
|
-
|
64
|
-
warnings.warn("No start_date specified, use default date = \"2005-01-01\"", UserWarning)
|
65
|
-
start_date = datetime.strptime("2005-01-01", "%Y-%m-%d")
|
59
|
+
|
66
60
|
if (not end_date):
|
67
|
-
warnings.warn("No end_date specified, use default date = today", UserWarning)
|
68
61
|
end_date = datetime.today()
|
62
|
+
else:
|
63
|
+
end_date = datetime.strptime(end_date, "%Y-%m-%d")
|
69
64
|
|
70
65
|
assert (start_date <= end_date)
|
71
|
-
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
72
|
-
end_date = datetime.strptime(end_date, "%Y-%m-%d")
|
73
66
|
|
74
67
|
start_year = start_date.year
|
75
68
|
start_season = (start_date.month - 1) // 4 + 1
|
@@ -94,7 +87,6 @@ class FinanceReportFetcher(BaseTEJFetcher):
|
|
94
87
|
return data_df
|
95
88
|
|
96
89
|
elif (fetch_mode in {self.FetchMode.YOY, self.FetchMode.YOY_NOCAL}):
|
97
|
-
start_date = datetime.strptime(start_date, "%Y-%m-%d")
|
98
90
|
start_year = start_date.year
|
99
91
|
end_date = self.get_latest_data_time(ticker)
|
100
92
|
if (not end_date):
|
@@ -225,7 +217,6 @@ class FinanceReportFetcher(BaseTEJFetcher):
|
|
225
217
|
]
|
226
218
|
|
227
219
|
fetched_data = self.collection.aggregate(pipeline).to_list()
|
228
|
-
|
229
220
|
data_dict = StatsProcessor.list_of_dict_to_dict(
|
230
221
|
fetched_data, keys=["year", "season"], delimeter="Q", data_key=report_type)
|
231
222
|
|
@@ -0,0 +1,135 @@
|
|
1
|
+
TWN/AINVFQ1:
|
2
|
+
- coid
|
3
|
+
- mdate
|
4
|
+
- key3
|
5
|
+
- 'no'
|
6
|
+
- sem
|
7
|
+
- merg
|
8
|
+
- curr
|
9
|
+
- annd
|
10
|
+
- fin_ind
|
11
|
+
- bp11
|
12
|
+
- bp21
|
13
|
+
- bp22
|
14
|
+
- bp31
|
15
|
+
- bp41
|
16
|
+
- bp51
|
17
|
+
- bp53
|
18
|
+
- bp61
|
19
|
+
- bp62
|
20
|
+
- bp63
|
21
|
+
- bp64
|
22
|
+
- bp65
|
23
|
+
- bf11
|
24
|
+
- bf12
|
25
|
+
- bf21
|
26
|
+
- bf22
|
27
|
+
- bf41
|
28
|
+
- bf42
|
29
|
+
- bf43
|
30
|
+
- bf44
|
31
|
+
- bf45
|
32
|
+
- bf99
|
33
|
+
- bsca
|
34
|
+
- bsnca
|
35
|
+
- bsta
|
36
|
+
- bscl
|
37
|
+
- bsncl
|
38
|
+
- bstl
|
39
|
+
- bsse
|
40
|
+
- bslse
|
41
|
+
- debt
|
42
|
+
- quick
|
43
|
+
- ppe
|
44
|
+
- ar
|
45
|
+
- ip12
|
46
|
+
- ip22
|
47
|
+
- ip31
|
48
|
+
- ip51
|
49
|
+
- iv41
|
50
|
+
- if11
|
51
|
+
- isibt
|
52
|
+
- isni
|
53
|
+
- isnip
|
54
|
+
- eps
|
55
|
+
- ispsd
|
56
|
+
- gm
|
57
|
+
- opi
|
58
|
+
- nri
|
59
|
+
- ri
|
60
|
+
- nopi
|
61
|
+
- ebit
|
62
|
+
- cip31
|
63
|
+
- cscfo
|
64
|
+
- cscfi
|
65
|
+
- cscff
|
66
|
+
- person
|
67
|
+
- shares
|
68
|
+
- wavg
|
69
|
+
- taxrate
|
70
|
+
- r104
|
71
|
+
- r115
|
72
|
+
- r105
|
73
|
+
- r106
|
74
|
+
- r107
|
75
|
+
- r108
|
76
|
+
- r201
|
77
|
+
- r112
|
78
|
+
- r401
|
79
|
+
- r402
|
80
|
+
- r403
|
81
|
+
- r404
|
82
|
+
- r405
|
83
|
+
- r408
|
84
|
+
- r409
|
85
|
+
- r410
|
86
|
+
- r502
|
87
|
+
- r501
|
88
|
+
- r205
|
89
|
+
- r505
|
90
|
+
- r517
|
91
|
+
- r512
|
92
|
+
- r509
|
93
|
+
- r608
|
94
|
+
- r616
|
95
|
+
- r610
|
96
|
+
- r607
|
97
|
+
- r613
|
98
|
+
- r612
|
99
|
+
- r609
|
100
|
+
- r614
|
101
|
+
- r611
|
102
|
+
- r307
|
103
|
+
- r304
|
104
|
+
- r305
|
105
|
+
- r306
|
106
|
+
- r316
|
107
|
+
- r834
|
108
|
+
TWN/AFESTM1:
|
109
|
+
- coid
|
110
|
+
- mdate
|
111
|
+
- key3
|
112
|
+
- 'no'
|
113
|
+
- sem
|
114
|
+
- merg
|
115
|
+
- curr
|
116
|
+
- annd
|
117
|
+
- fin_ind
|
118
|
+
- ip12
|
119
|
+
- gm
|
120
|
+
- opi
|
121
|
+
- isibt
|
122
|
+
- isni
|
123
|
+
- isnip
|
124
|
+
- r306
|
125
|
+
- r316
|
126
|
+
- eps
|
127
|
+
- r105
|
128
|
+
- r106
|
129
|
+
- r107
|
130
|
+
- r108
|
131
|
+
- r401
|
132
|
+
- r402
|
133
|
+
- r403
|
134
|
+
- r404
|
135
|
+
- r405
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: neurostats_API
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.18
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -774,43 +774,48 @@ YoY_10 1.420500e-01 1.586797e-01 1.551364e-01
|
|
774
774
|
}
|
775
775
|
```
|
776
776
|
|
777
|
+
### 公司自結資料
|
778
|
+
```Python
|
779
|
+
from neurostats_API import FinanceReportFetcher
|
777
780
|
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
## 0.0.15
|
785
|
-
- TechFetcher中新增指數條件
|
786
|
-
|
787
|
-
- 新增tej_fetcher索取TEJ相關的資料
|
788
|
-
|
789
|
-
- package新增depensnecy,可以安裝需要的相關package
|
781
|
+
fetcher = FinanceReportFetcher(
|
782
|
+
mongo_uri = mongo_uri,
|
783
|
+
db_name = db_name,
|
784
|
+
collection_name = collection_name
|
785
|
+
)
|
790
786
|
|
791
|
-
|
792
|
-
|
787
|
+
data = fetcher.get(
|
788
|
+
ticker = "2330" # 任意的股票代碼
|
789
|
+
fetch_mode = fetcher.FetchMode.QOQ_NOCAL # 取得模式
|
790
|
+
start_date = "2005-01-01",
|
791
|
+
end_date = "2024-12-31",
|
792
|
+
report_type = "Q",
|
793
|
+
indexes = []
|
794
|
+
) # -> pd.DataFrame or Dict[pd.DataFrame]
|
795
|
+
```
|
796
|
+
- `ticker`: 股票代碼
|
793
797
|
|
794
|
-
-
|
798
|
+
- `fetch_mode` : 取得模式,為`fetcher.YOY_NOCAL` 或 `fetcher.QOQ_NOCAL`
|
799
|
+
- `YOY_NOCAL`: 以end_date為準,取得與end_date同季的歷年資料,時間範圍以start_date為起始
|
800
|
+
> 例如`start_date = "2020-07-01"`, `end_date = "2024-01-01"`,會回傳2020~2024的第一季資料
|
795
801
|
|
796
|
-
|
797
|
-
- value_fetcher 新增獲得一序列評價的功能
|
802
|
+
- `QOQ_NOCAL`: 時間範圍內的每季資料
|
798
803
|
|
799
|
-
|
800
|
-
- 新增資券變化(margin trading)
|
804
|
+
- `QOQ`: 時間範圍內每季的每個index的數值以及QoQ
|
801
805
|
|
802
|
-
-
|
806
|
+
- `YoY`: 以end_date為準,取得與end_date同季的歷年資料以及成長率,時間範圍以start_date為起始
|
803
807
|
|
804
|
-
|
805
|
-
- 修復財務分析的千元計算問題
|
808
|
+
- `start_date`: 開始日期,不設定時預設為`2005-01-01`
|
806
809
|
|
807
|
-
-
|
810
|
+
- `end_date`: 結束日期,不設定時預設為資料庫最新資料的日期
|
808
811
|
|
809
|
-
-
|
810
|
-
|
811
|
-
-
|
812
|
+
- `report_type`: 選擇哪種報告,預設為`Q`
|
813
|
+
- `A`: 當年累計
|
814
|
+
- `Q`: 當季數值
|
815
|
+
- `TTM`: 移動四季 (包括當季在內,往前累計四個季度)
|
812
816
|
|
813
|
-
-
|
817
|
+
- `indexes`: 選擇的column,需要以TEJ提供的欄位名稱為準,不提供時或提供`[]`會回傳全部column
|
818
|
+
- 範例輸入: `['bp41', 'bp51']`
|
814
819
|
|
815
|
-
|
816
|
-
|
820
|
+
[TEJ資料集連結](https://tquant.tejwin.com/%E8%B3%87%E6%96%99%E9%9B%86/)
|
821
|
+
請看 `公司自結數`
|
@@ -26,6 +26,7 @@ neurostats_API/tools/cash_flow_percentage.yaml
|
|
26
26
|
neurostats_API/tools/finance_overview_dict.yaml
|
27
27
|
neurostats_API/tools/profit_lose.yaml
|
28
28
|
neurostats_API/tools/seasonal_data_field_dict.txt
|
29
|
+
neurostats_API/tools/tej_db_index.yaml
|
29
30
|
neurostats_API/utils/__init__.py
|
30
31
|
neurostats_API/utils/calculate_value.py
|
31
32
|
neurostats_API/utils/data_process.py
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import pytest
|
2
|
+
|
3
|
+
mongo_uri = "mongodb+srv://admin:Neurowatt456&@axonnews-mongodb.nlui1.mongodb.net/?retryWrites=true&w=majority&appName=axonnews-mongodb"
|
4
|
+
ticker = "2330"
|
5
|
+
collection_name = "TWN/AFESTM1"
|
6
|
+
# collection_name = "TWN/AINVFQ1"
|
7
|
+
|
8
|
+
def test_QoQ():
|
9
|
+
|
10
|
+
|
11
|
+
from neurostats_API import FinanceReportFetcher
|
12
|
+
|
13
|
+
fetcher = FinanceReportFetcher(mongo_uri, collection_name=collection_name)
|
14
|
+
|
15
|
+
modes = [
|
16
|
+
fetcher.FetchMode.QOQ,
|
17
|
+
fetcher.FetchMode.QOQ_NOCAL
|
18
|
+
]
|
19
|
+
|
20
|
+
|
21
|
+
for mode in modes:
|
22
|
+
print(mode)
|
23
|
+
data = fetcher.get(
|
24
|
+
ticker,
|
25
|
+
fetch_mode = mode,
|
26
|
+
# start_date="2024-01-01",
|
27
|
+
# end_date="2024-12-31",
|
28
|
+
indexes = []
|
29
|
+
)
|
30
|
+
|
31
|
+
print(data)
|
32
|
+
|
33
|
+
def test_YoY():
|
34
|
+
from neurostats_API import FinanceReportFetcher
|
35
|
+
fetcher = FinanceReportFetcher(mongo_uri, collection_name=collection_name)
|
36
|
+
|
37
|
+
modes = [
|
38
|
+
fetcher.FetchMode.YOY,
|
39
|
+
fetcher.FetchMode.YOY_NOCAL
|
40
|
+
]
|
41
|
+
|
42
|
+
for mode in modes:
|
43
|
+
data = fetcher.get(
|
44
|
+
ticker,
|
45
|
+
mode,
|
46
|
+
start_date="2024-01-01",
|
47
|
+
end_date="2024-12-31",
|
48
|
+
indexes = ["ip12"])
|
49
|
+
print (data)
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import pytest
|
2
|
-
|
3
|
-
mongo_uri = "mongodb+srv://admin:Neurowatt456&@axonnews-mongodb.nlui1.mongodb.net/?retryWrites=true&w=majority&appName=axonnews-mongodb"
|
4
|
-
ticker = "2330"
|
5
|
-
|
6
|
-
def test_QoQ():
|
7
|
-
from neurostats_API import FinanceReportFetcher
|
8
|
-
|
9
|
-
fetcher = FinanceReportFetcher(mongo_uri)
|
10
|
-
|
11
|
-
data = fetcher.get(
|
12
|
-
ticker,
|
13
|
-
fetch_mode = fetcher.FetchMode.QOQ_NOCAL,
|
14
|
-
start_date="2024-01-01",
|
15
|
-
end_date="2024-12-31",
|
16
|
-
indexes = ['bp41', 'bp51']
|
17
|
-
)
|
18
|
-
|
19
|
-
print(data)
|
20
|
-
|
21
|
-
def test_YoY():
|
22
|
-
from neurostats_API import FinanceReportFetcher
|
23
|
-
fetcher = FinanceReportFetcher(mongo_uri)
|
24
|
-
|
25
|
-
data = fetcher.get(ticker, fetcher.FetchMode.YOY_NOCAL, indexes = ['bp41', 'bp51', 'arv'])
|
26
|
-
print (data)
|
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
|
File without changes
|
File without changes
|
{neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/tools/cash_flow_percentage.yaml
RENAMED
File without changes
|
{neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API/tools/finance_overview_dict.yaml
RENAMED
File without changes
|
File without changes
|
{neurostats_api-0.0.17 → neurostats_api-0.0.18}/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
|
File without changes
|
{neurostats_api-0.0.17 → neurostats_api-0.0.18}/neurostats_API.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|