neurostats-API 0.0.19__py3-none-any.whl → 0.0.20__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.
- neurostats_API/__init__.py +1 -1
- neurostats_API/fetchers/base.py +23 -30
- neurostats_API/fetchers/tech.py +1 -1
- neurostats_API/fetchers/tej_finance_report.py +1 -1
- {neurostats_API-0.0.19.dist-info → neurostats_API-0.0.20.dist-info}/METADATA +14 -12
- {neurostats_API-0.0.19.dist-info → neurostats_API-0.0.20.dist-info}/RECORD +8 -8
- {neurostats_API-0.0.19.dist-info → neurostats_API-0.0.20.dist-info}/WHEEL +0 -0
- {neurostats_API-0.0.19.dist-info → neurostats_API-0.0.20.dist-info}/top_level.txt +0 -0
neurostats_API/__init__.py
CHANGED
neurostats_API/fetchers/base.py
CHANGED
@@ -81,10 +81,14 @@ class BaseTEJFetcher(abc.ABC):
|
|
81
81
|
|
82
82
|
def get_latest_data_time(self, ticker):
|
83
83
|
latest_data = self.collection.find_one(
|
84
|
-
{
|
84
|
+
{
|
85
|
+
"ticker": ticker
|
86
|
+
},
|
87
|
+
{
|
85
88
|
"last_update": 1,
|
86
89
|
"_id": 0
|
87
|
-
}
|
90
|
+
}
|
91
|
+
)
|
88
92
|
|
89
93
|
try:
|
90
94
|
latest_date = latest_data['last_update']["latest_data_date"]
|
@@ -116,9 +120,8 @@ class BaseTEJFetcher(abc.ABC):
|
|
116
120
|
try:
|
117
121
|
past_year = year - shift
|
118
122
|
last_value = data_dict[f"{past_year}Q{season}"][key]
|
119
|
-
temp_dict[
|
120
|
-
|
121
|
-
this_value, last_value, delta=shift)
|
123
|
+
temp_dict[f"YoY_{shift}"] = YoY_Calculator.cal_growth(
|
124
|
+
this_value, last_value, delta=shift) * 100
|
122
125
|
except Exception as e:
|
123
126
|
temp_dict[f"YoY_{shift}"] = None
|
124
127
|
|
@@ -160,7 +163,7 @@ class BaseTEJFetcher(abc.ABC):
|
|
160
163
|
key]['value']
|
161
164
|
|
162
165
|
temp_dict['growth'] = YoY_Calculator.cal_growth(
|
163
|
-
this_value, last_value, delta=1)
|
166
|
+
this_value, last_value, delta=1) * 100
|
164
167
|
except Exception as e:
|
165
168
|
temp_dict['growth'] = None
|
166
169
|
|
@@ -180,31 +183,21 @@ class BaseTEJFetcher(abc.ABC):
|
|
180
183
|
return data_dict
|
181
184
|
|
182
185
|
def set_time_shift(self, date: Union[str, datetime], period: str):
|
183
|
-
if
|
186
|
+
if isinstance(date, str):
|
184
187
|
date = datetime.strptime(date, "%Y-%m-%d")
|
185
|
-
if (period == '1d'):
|
186
|
-
return date - timedelta(days=1)
|
187
|
-
|
188
|
-
elif (period == '7d'):
|
189
|
-
return date - timedelta(days=7)
|
190
|
-
|
191
|
-
elif (period == '1m'):
|
192
|
-
return date - timedelta(days=30)
|
193
|
-
|
194
|
-
elif (period == '3m'):
|
195
|
-
return date - timedelta(days=90)
|
196
188
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
return date - timedelta(days=365 * 10)
|
189
|
+
period_mapping = {
|
190
|
+
"1d": timedelta(days=1),
|
191
|
+
"7d": timedelta(days=7),
|
192
|
+
"1m": timedelta(days=30),
|
193
|
+
"3m": timedelta(days=90),
|
194
|
+
"1y": timedelta(days=365),
|
195
|
+
"3y": timedelta(days=365 * 3),
|
196
|
+
"5y": timedelta(days=365 * 5),
|
197
|
+
"10y": timedelta(days=365 * 10),
|
198
|
+
}
|
208
199
|
|
209
|
-
|
200
|
+
if period == "all":
|
210
201
|
return datetime.strptime("1991-01-01", "%Y-%m-%d")
|
202
|
+
|
203
|
+
return date - period_mapping.get(period, timedelta(days=0)) # 預設為不變
|
neurostats_API/fetchers/tech.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: neurostats_API
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.20
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
7
7
|
Author-email: jason@neurowatt.ai
|
8
8
|
Requires-Python: >=3.6
|
9
9
|
Description-Content-Type: text/markdown
|
10
|
-
Requires-Dist: numpy
|
10
|
+
Requires-Dist: numpy
|
11
11
|
Requires-Dist: pandas>=2.2.0
|
12
12
|
Requires-Dist: pymongo
|
13
13
|
Requires-Dist: pytz
|
@@ -728,6 +728,7 @@ data = fetcher.get(
|
|
728
728
|
#### 回傳資料
|
729
729
|
##### `YOY_NOCAL` 與 `QOQ_NOCAL`
|
730
730
|
為回傳`pd.DataFrame`,column名稱為<年份>Q<季>, row名稱為指定財報項目
|
731
|
+
|
731
732
|
```Python
|
732
733
|
# fetch_mode = fetcher.FetchMode.QOQ_NOCAL
|
733
734
|
2024Q3 2024Q2 2024Q1
|
@@ -742,17 +743,18 @@ bp51 3.111298e+09 3.173919e+09 2.453840e+09
|
|
742
743
|
|
743
744
|
##### `YOY` 與 `QOQ`
|
744
745
|
回傳為`Dict[pd.DataFrame]`, key 為指定的index, DataFrame中則是該index歷年的數值與成長率
|
746
|
+
成長率單位為`%`
|
745
747
|
```Python
|
746
748
|
# fetch_mode = fetcher.FetchMode.QOQ
|
747
749
|
{
|
748
750
|
'bp41':
|
749
751
|
2024Q3 2024Q2 2024Q1
|
750
752
|
value 7.082005e+07 6.394707e+07 5.761001e+07
|
751
|
-
growth 1.074791e
|
753
|
+
growth 1.074791e+01 1.099994e+01 5.532101e-01,
|
752
754
|
'bp51':
|
753
755
|
2024Q3 2024Q2 2024Q1
|
754
756
|
value 3.111298e+09 3.145373e+09 3.091985e+09
|
755
|
-
growth -1.083335e
|
757
|
+
growth -1.083335e+00 1.726663e+00 -4.159542e-01
|
756
758
|
}
|
757
759
|
|
758
760
|
# fetch_mode = fetcher.FetchMode.YOY
|
@@ -760,17 +762,17 @@ growth -1.083335e-02 1.726663e-02 -4.159542e-03
|
|
760
762
|
'bp41':
|
761
763
|
2024Q3 2023Q3 2022Q3
|
762
764
|
value 7.082005e+07 5.377231e+07 6.201822e+07
|
763
|
-
YoY_1
|
764
|
-
YoY_3 1.729171e
|
765
|
-
YoY_5 1.389090e
|
766
|
-
YoY_10 1.255138e
|
765
|
+
YoY_1 3.170357e+01 -1.329596e+01 4.130744e+01
|
766
|
+
YoY_3 1.729171e+01 9.556684e+00 1.883274e+01
|
767
|
+
YoY_5 1.389090e+01 1.215242e+01 1.642914e+01
|
768
|
+
YoY_10 1.255138e+01 1.356297e+01 1.559702e+01
|
767
769
|
'bp51':
|
768
770
|
2024Q3 2023Q3 2022Q3
|
769
771
|
value 3.111298e+09 3.173919e+09 2.453840e+09
|
770
|
-
YoY_1
|
771
|
-
YoY_3 1.866752e
|
772
|
-
YoY_5 2.068132e
|
773
|
-
YoY_10 1.420500e
|
772
|
+
YoY_1 -1.972987e+00 2.934499e+01 3.179539e+01
|
773
|
+
YoY_3 1.866752e+01 2.766851e+01 2.638677e+01
|
774
|
+
YoY_5 2.068132e+01 2.479698e+01 1.815106e+01
|
775
|
+
YoY_10 1.420500e+01 1.586797e+01 1.551364e+01
|
774
776
|
}
|
775
777
|
```
|
776
778
|
|
@@ -1,17 +1,17 @@
|
|
1
|
-
neurostats_API/__init__.py,sha256=
|
1
|
+
neurostats_API/__init__.py,sha256=Kn7oiUopkqGqo6EOJPdszCzLnzb9FwYpN_e4zjI5MBw,288
|
2
2
|
neurostats_API/cli.py,sha256=UJSWLIw03P24p-gkBb6JSEI5dW5U12UvLf1L8HjQD-o,873
|
3
3
|
neurostats_API/main.py,sha256=QcsfmWivg2Dnqw3MTJWiI0QvEiRs0VuH-BjwQHFCv00,677
|
4
4
|
neurostats_API/fetchers/__init__.py,sha256=KCw-yRSDFa3fw83u73LJ9OVop7gRl_YQYlQq-cITxuo,511
|
5
5
|
neurostats_API/fetchers/balance_sheet.py,sha256=sQv4Gk5uoKURLEdh57YknOQWiyVwaXJ2Mw75jxNqUS0,5804
|
6
|
-
neurostats_API/fetchers/base.py,sha256=
|
6
|
+
neurostats_API/fetchers/base.py,sha256=Gw1pUFJtl-ot5kp7v_1ueTA7Y__-mghNqD3kFlbVBTc,6515
|
7
7
|
neurostats_API/fetchers/cash_flow.py,sha256=TY7VAWVXkj5-mzH5Iu0sIE-oV8MvGmmDy0URNotNV1E,7614
|
8
8
|
neurostats_API/fetchers/finance_overview.py,sha256=PxUdWY0x030olYMLcCHDBn068JLmCE2RTOce1dxs5vM,27753
|
9
9
|
neurostats_API/fetchers/institution.py,sha256=UrcBc6t7u7CnEwUsf6YmLbbJ8VncdWpq8bCz17q2dgs,11168
|
10
10
|
neurostats_API/fetchers/margin_trading.py,sha256=lQImtNdvaBoSlKhJvQ3DkH3HjSSgKRJz4ZZpyR5-Z4I,10433
|
11
11
|
neurostats_API/fetchers/month_revenue.py,sha256=nixX2llzjCFr2m2YVjxrSfkBusnZPrPb2dRDq1XLGhw,4251
|
12
12
|
neurostats_API/fetchers/profit_lose.py,sha256=EN9Y0iamcAaHMZdjHXO6b_2buLnORssf8ZS7A0hi74s,5896
|
13
|
-
neurostats_API/fetchers/tech.py,sha256=
|
14
|
-
neurostats_API/fetchers/tej_finance_report.py,sha256=
|
13
|
+
neurostats_API/fetchers/tech.py,sha256=mcwfE3xzZNmo6P7NS37wQBFnCt4f0uwxWUDSOC00I7M,13428
|
14
|
+
neurostats_API/fetchers/tej_finance_report.py,sha256=VZximF1Lct3r-E01VwcDX0Zj_CIVSvpdEAuU9I9OsJc,14007
|
15
15
|
neurostats_API/fetchers/value_invest.py,sha256=b_x2Dpgs8VBU5HdG8ocKtfIEkqhU-Q0S5n6RxuFuM2g,7467
|
16
16
|
neurostats_API/tools/balance_sheet.yaml,sha256=6XygNG_Ybb1Xkk1e39LMLKr7ATvaCP3xxuwFbgNl6dA,673
|
17
17
|
neurostats_API/tools/cash_flow_percentage.yaml,sha256=fk2Z4eb1JjGFvP134eJatHacB7BgTkBenhDJr83w8RE,1345
|
@@ -25,7 +25,7 @@ neurostats_API/utils/data_process.py,sha256=A--dzOsu42jRxqqCD41gTtjE5rhEBYmhB6y-
|
|
25
25
|
neurostats_API/utils/datetime.py,sha256=XJya4G8b_-ZOaBbMXgQjWh2MC4wc-o6goQ7EQJQMWrQ,773
|
26
26
|
neurostats_API/utils/db_client.py,sha256=OYe6yazcR4Aa6jYmy47JrryUeh2NnKGqY2K_lSZe6i8,455
|
27
27
|
neurostats_API/utils/fetcher.py,sha256=VbrUhjA-GG5AyjPX2SHtFIbZM4dm3jo0RgZzuCbb_Io,40927
|
28
|
-
neurostats_API-0.0.
|
29
|
-
neurostats_API-0.0.
|
30
|
-
neurostats_API-0.0.
|
31
|
-
neurostats_API-0.0.
|
28
|
+
neurostats_API-0.0.20.dist-info/METADATA,sha256=uG49C2eYBlTroejgDPkECjyfkRxBp7APAGxAihksMo0,30997
|
29
|
+
neurostats_API-0.0.20.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
30
|
+
neurostats_API-0.0.20.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
|
31
|
+
neurostats_API-0.0.20.dist-info/RECORD,,
|
File without changes
|
File without changes
|