neurostats-API 0.0.12__py3-none-any.whl → 0.0.13__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.12'
1
+ __version__='0.0.13'
@@ -79,6 +79,78 @@ class ValueFetcher(StatsFetcher):
79
79
  )
80
80
 
81
81
  return fetched_data
82
+
83
+ def query_value_serie(self):
84
+ """
85
+ 回傳指定公司的歷來評價
86
+ return : Dict[pd.DataFrame]
87
+ Dict中包含以下八個key, 每個key對應DataFrame
88
+ {
89
+ P_E,
90
+ P_FCF,
91
+ P_S,
92
+ P_B,
93
+ EV_OPI,
94
+ EV_EBIT,
95
+ EV_EBITDA,
96
+ EV_S
97
+ }
98
+ """
99
+
100
+ pipeline = [
101
+ {
102
+ "$match": {
103
+ "ticker": self.ticker,
104
+ }
105
+ },
106
+ {
107
+ "$project": {
108
+ "_id": 0,
109
+ "ticker": 1,
110
+ "company_name": 1,
111
+ "daily_data": {
112
+ "$map": {
113
+ "input": "$daily_data", # 正確地指定要處理的陣列
114
+ "as": "daily", # 每個元素的名稱
115
+ "in": {
116
+ "date": "$$daily.date",
117
+ "P_E": "$$daily.P_E",
118
+ "P_FCF": "$$daily.P_FCF",
119
+ "P_B": "$$daily.P_B",
120
+ "P_S": "$$daily.P_S",
121
+ "EV_OPI": "$$daily.EV_OPI",
122
+ "EV_EBIT": "$$daily.EV_EBIT",
123
+ "EV_EBITDA": "$$daily.EV_EBITDA",
124
+ "EV_S": "$$daily.EV_S"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ ]
131
+
132
+ fetched_data = self.collection.aggregate(pipeline).to_list()
133
+ fetched_data = fetched_data[0]
134
+
135
+ value_keys = ["P_E", "P_FCF", "P_B", "P_S", "EV_OPI", "EV_EBIT", "EV_EVITDA", "EV_S"]
136
+ return_dict = {
137
+ value_key: dict() for value_key in value_keys
138
+ }
139
+
140
+ for value_key in value_keys:
141
+ for data in fetched_data['daily_data']:
142
+ if (value_key not in data.keys()):
143
+ continue
144
+ else:
145
+ return_dict[value_key].update({
146
+ data['date']: data[value_key]
147
+ })
148
+
149
+ return_dict = {
150
+ value_key: pd.DataFrame.from_dict(value_dict, orient = 'index', columns = [value_key])
151
+ for value_key, value_dict in return_dict.items()
152
+ }
153
+ return return_dict
82
154
 
83
155
 
84
156
  class ValueProcessor(StatsProcessor):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: neurostats_API
3
- Version: 0.0.12
2
+ Name: neurostats-API
3
+ Version: 0.0.13
4
4
  Summary: The service of NeuroStats website
5
5
  Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
6
6
  Author: JasonWang@Neurowatt
@@ -14,6 +14,7 @@ Description-Content-Type: text/markdown
14
14
  - [使用方法](#使用方法)
15
15
  - [下載](#下載)
16
16
  - [價值投資](#得到最新一期的評價資料與歷年評價)
17
+ - [歷史評價](#得到指定公司的歷來評價)
17
18
  - [財務分析-重要指標](#財務分析-重要指標)
18
19
  - [月營收表](#回傳月營收表)
19
20
  - [損益表](#損益表)
@@ -82,7 +83,7 @@ pip install neurostats-API
82
83
  ```Python
83
84
  >>> import neurostats_API
84
85
  >>> print(neurostats_API.__version__)
85
- 0.0.10
86
+ 0.0.13
86
87
  ```
87
88
 
88
89
  ### 得到最新一期的評價資料與歷年評價
@@ -127,6 +128,69 @@ fetcher.query_data()
127
128
  ```
128
129
  > 這裡有Nan是因為本益比與P/B等資料沒有爬到最新的時間
129
130
 
131
+ ### 得到指定公司的歷來評價
132
+ ``` Python
133
+ from neurostats_API.utils import ValueFetcher, DBClient
134
+ db_client = DBClient("<連接的DB位置>").get_client()
135
+ ticker = "2330" # 換成tw50內任意ticker
136
+ fetcher = ValueFetcher(ticker, db_client)
137
+
138
+ fetcher.query_value_serie()
139
+ ```
140
+ #### 回傳(2330為例)
141
+ ```Python
142
+ {
143
+ 'EV_EBIT': EV_EBIT
144
+ 2014-01-02 NaN
145
+ 2014-01-03 NaN
146
+ ... ...
147
+ 2024-12-12 15.021431
148
+ 2024-12-13 15.088321
149
+ ,
150
+ 'EV_OPI': EV_OPI
151
+ 2014-01-03 NaN
152
+ ... ...
153
+ 2024-12-12 15.999880
154
+ 2024-12-13 16.071128
155
+ ,
156
+ 'EV_S': EV_S
157
+ 2014-01-02 NaN
158
+ 2014-01-03 NaN
159
+ ... ...
160
+ 2024-12-12 6.945457
161
+ 2024-12-13 6.976385
162
+ ,
163
+ 'P_B': P_B
164
+ 2014-01-02 NaN
165
+ 2014-01-03 NaN
166
+ ... ...
167
+ 2024-12-12 6.79
168
+ 2024-12-13 6.89
169
+ ,
170
+ 'P_E': P_E
171
+ 2014-01-02 NaN
172
+ 2014-01-03 NaN
173
+ ... ...
174
+ 2024-12-12 26.13
175
+ 2024-12-13 26.50
176
+ ,
177
+ 'P_FCF': P_FCF
178
+ 2014-01-02 NaN
179
+ 2014-01-03 NaN
180
+ ... ...
181
+ 2024-12-12 45.302108
182
+ 2024-12-13 45.515797
183
+ ,
184
+ 'P_S': P_S
185
+ 2014-01-02 NaN
186
+ 2014-01-03 NaN
187
+ ... ...
188
+ 2024-12-12 6.556760
189
+ 2024-12-13 6.587688
190
+ }
191
+ ```
192
+
193
+
130
194
  ### 回傳月營收表
131
195
  ``` Python
132
196
  from neurostats_API.fetchers import MonthRevenueFetcher, DBClient
@@ -604,6 +668,14 @@ fetcher.query()
604
668
  請注意`range`, `last_range`, `52week_range`這三個項目型態為字串,其餘為float
605
669
 
606
670
  ## 版本紀錄
671
+ ### 0.0.13
672
+ - value_fetcher 新增獲得一序列評價的功能
673
+
674
+ ### 0.0.12
675
+ - 新增資券變化(margin trading)
676
+
677
+ - 修改法人買賣(institution_trading)的query方式
678
+
607
679
  ### 0.0.11
608
680
  - 修復財務分析的千元計算問題
609
681
 
@@ -1,4 +1,4 @@
1
- neurostats_API/__init__.py,sha256=9UMAkivMiZfppwpwVdBxJI652ZiB-ir2iX3yh0Gxu9M,20
1
+ neurostats_API/__init__.py,sha256=UDEAcv3wrFvy1-DjCv7qON8202kc3zUGHpfClyTJWhs,20
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=ylYEySHQxcAhUUWEOCGZfmaAg7Mir5MfuEhOjk3POJg,406
@@ -11,7 +11,7 @@ neurostats_API/fetchers/margin_trading.py,sha256=lQImtNdvaBoSlKhJvQ3DkH3HjSSgKRJ
11
11
  neurostats_API/fetchers/month_revenue.py,sha256=nixX2llzjCFr2m2YVjxrSfkBusnZPrPb2dRDq1XLGhw,4251
12
12
  neurostats_API/fetchers/profit_lose.py,sha256=xlLNsGSy4Azf4HyZyYaX3dFad-ACO-vuQToBooZi1_w,5698
13
13
  neurostats_API/fetchers/tech.py,sha256=wH1kkqiETQhF0HAhk-UIiucnZ3EiL85Q-yMWCcVOiFM,11395
14
- neurostats_API/fetchers/value_invest.py,sha256=O5IKC8Nl7p5-E-1zoyAyWtiDznaxNemeabanmaHDdJs,3327
14
+ neurostats_API/fetchers/value_invest.py,sha256=_eQxuEnIYvksb06QHixGK29Gnwr_3xmI6Tu7dv4J__E,5769
15
15
  neurostats_API/tools/balance_sheet.yaml,sha256=yTxrWh7m4K3LnaNunETidfNzl6S4Bf58VIg9U38XShQ,648
16
16
  neurostats_API/tools/cash_flow_percentage.yaml,sha256=fk2Z4eb1JjGFvP134eJatHacB7BgTkBenhDJr83w8RE,1345
17
17
  neurostats_API/tools/finance_overview_dict.yaml,sha256=B9nV75StXkrF3yv2-eezzitlJ38eEK86RD_VY6588gQ,2884
@@ -22,7 +22,7 @@ neurostats_API/utils/data_process.py,sha256=2yrO0iP1LHhF0uhXZ442PHQBI-Zd2xIqNItk
22
22
  neurostats_API/utils/datetime.py,sha256=XJya4G8b_-ZOaBbMXgQjWh2MC4wc-o6goQ7EQJQMWrQ,773
23
23
  neurostats_API/utils/db_client.py,sha256=OYe6yazcR4Aa6jYmy47JrryUeh2NnKGqY2K_lSZe6i8,455
24
24
  neurostats_API/utils/fetcher.py,sha256=VbrUhjA-GG5AyjPX2SHtFIbZM4dm3jo0RgZzuCbb_Io,40927
25
- neurostats_API-0.0.12.dist-info/METADATA,sha256=-1MqxrAVp-6u25PFIMmrMv5ad6RrWwguHiONp0worpc,24008
26
- neurostats_API-0.0.12.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
27
- neurostats_API-0.0.12.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
28
- neurostats_API-0.0.12.dist-info/RECORD,,
25
+ neurostats_API-0.0.13.dist-info/METADATA,sha256=tj8M4sSgXPprPV472mYHdEY_QOBpcObMXXo5lLGSOic,25744
26
+ neurostats_API-0.0.13.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
27
+ neurostats_API-0.0.13.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
28
+ neurostats_API-0.0.13.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: bdist_wheel (0.45.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5