neurostats-API 0.0.4__tar.gz → 0.0.6__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/PKG-INFO +16 -11
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/README.md +15 -10
- neurostats_API-0.0.6/neurostats_API/__init__.py +1 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/base.py +2 -5
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/finance_overview.py +2 -2
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/tech.py +2 -3
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/value_invest.py +2 -2
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/utils/__init__.py +1 -1
- neurostats_API-0.0.6/neurostats_API/utils/db_client.py +16 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/utils/fetcher.py +2 -3
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API.egg-info/PKG-INFO +16 -11
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/setup.py +1 -1
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/test/test_fetchers.py +8 -7
- neurostats_API-0.0.4/neurostats_API/__init__.py +0 -1
- neurostats_API-0.0.4/neurostats_API/utils/db_client.py +0 -10
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/MANIFEST.in +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/cli.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/__init__.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/balance_sheet.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/month_revenue.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/fetchers/profit_lose.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/main.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/tools/finance_overview_dict.yaml +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/tools/profit_lose.yaml +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/tools/seasonal_data_field_dict.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/utils/data_process.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API/utils/datetime.py +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API.egg-info/SOURCES.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API.egg-info/dependency_links.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/neurostats_API.egg-info/top_level.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_API-0.0.6}/setup.cfg +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.6
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -118,9 +118,10 @@ data = stats_fetcher.query_data()
|
|
118
118
|
|
119
119
|
### 回傳月營收表
|
120
120
|
``` Python
|
121
|
-
from neurostats_API.utils import StatsFetcher
|
121
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
122
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
122
123
|
ticker = 2330 # 換成tw50內任意ticker
|
123
|
-
fetcher = StatsFetcher()
|
124
|
+
fetcher = StatsFetcher(db_client)
|
124
125
|
data = stats_fetcher.get_month_revenue_sheet(ticker)
|
125
126
|
```
|
126
127
|
|
@@ -170,9 +171,10 @@ YoY_10 None None ... None None
|
|
170
171
|
### 財務分析: 重要指標
|
171
172
|
對應https://ifa.ai/tw-stock/2330/finance-overview
|
172
173
|
```Python
|
173
|
-
from neurostats_API.
|
174
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
175
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
174
176
|
ticker = "2330"
|
175
|
-
fetcher = FinanceOverviewFetcher(ticker = "2330")
|
177
|
+
fetcher = FinanceOverviewFetcher(ticker = "2330", db_client = db_client)
|
176
178
|
data = fetcher.query_data()
|
177
179
|
```
|
178
180
|
|
@@ -253,8 +255,9 @@ markdown
|
|
253
255
|
|
254
256
|
### 損益表
|
255
257
|
```Python
|
256
|
-
from neurostats_API.utils import StatsFetcher
|
257
|
-
|
258
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
259
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
260
|
+
fetcher = StatsFetcher(db_client)
|
258
261
|
ticker = 2330 # 換成tw50內任意ticker
|
259
262
|
data = fetcher.get_profit_lose(ticker)
|
260
263
|
```
|
@@ -301,8 +304,9 @@ data = fetcher.get_profit_lose(ticker)
|
|
301
304
|
|
302
305
|
### 資產負債表
|
303
306
|
``` Python
|
304
|
-
from neurostats_API.utils import StatsFetcher
|
305
|
-
|
307
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
308
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
309
|
+
fetcher = StatsFetcher(db_client)
|
306
310
|
ticker = 2330 # 換成tw50內任意ticker
|
307
311
|
stats_fetcher.get_balance_sheet(ticker)
|
308
312
|
```
|
@@ -360,8 +364,9 @@ equity 1.094370e+09 53.3 ... 3.390706e+09 56.68
|
|
360
364
|
|
361
365
|
### 現金流量表
|
362
366
|
``` Python
|
363
|
-
from neurostats_API.utils import StatsFetcher
|
364
|
-
|
367
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
368
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
369
|
+
fetcher = StatsFetcher(db_client)
|
365
370
|
ticker = 2330 # 換成tw50內任意ticker
|
366
371
|
stats_fetcher.get_cash_flow(ticker)
|
367
372
|
```
|
@@ -108,9 +108,10 @@ data = stats_fetcher.query_data()
|
|
108
108
|
|
109
109
|
### 回傳月營收表
|
110
110
|
``` Python
|
111
|
-
from neurostats_API.utils import StatsFetcher
|
111
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
112
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
112
113
|
ticker = 2330 # 換成tw50內任意ticker
|
113
|
-
fetcher = StatsFetcher()
|
114
|
+
fetcher = StatsFetcher(db_client)
|
114
115
|
data = stats_fetcher.get_month_revenue_sheet(ticker)
|
115
116
|
```
|
116
117
|
|
@@ -160,9 +161,10 @@ YoY_10 None None ... None None
|
|
160
161
|
### 財務分析: 重要指標
|
161
162
|
對應https://ifa.ai/tw-stock/2330/finance-overview
|
162
163
|
```Python
|
163
|
-
from neurostats_API.
|
164
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
165
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
164
166
|
ticker = "2330"
|
165
|
-
fetcher = FinanceOverviewFetcher(ticker = "2330")
|
167
|
+
fetcher = FinanceOverviewFetcher(ticker = "2330", db_client = db_client)
|
166
168
|
data = fetcher.query_data()
|
167
169
|
```
|
168
170
|
|
@@ -243,8 +245,9 @@ markdown
|
|
243
245
|
|
244
246
|
### 損益表
|
245
247
|
```Python
|
246
|
-
from neurostats_API.utils import StatsFetcher
|
247
|
-
|
248
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
249
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
250
|
+
fetcher = StatsFetcher(db_client)
|
248
251
|
ticker = 2330 # 換成tw50內任意ticker
|
249
252
|
data = fetcher.get_profit_lose(ticker)
|
250
253
|
```
|
@@ -291,8 +294,9 @@ data = fetcher.get_profit_lose(ticker)
|
|
291
294
|
|
292
295
|
### 資產負債表
|
293
296
|
``` Python
|
294
|
-
from neurostats_API.utils import StatsFetcher
|
295
|
-
|
297
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
298
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
299
|
+
fetcher = StatsFetcher(db_client)
|
296
300
|
ticker = 2330 # 換成tw50內任意ticker
|
297
301
|
stats_fetcher.get_balance_sheet(ticker)
|
298
302
|
```
|
@@ -350,8 +354,9 @@ equity 1.094370e+09 53.3 ... 3.390706e+09 56.68
|
|
350
354
|
|
351
355
|
### 現金流量表
|
352
356
|
``` Python
|
353
|
-
from neurostats_API.utils import StatsFetcher
|
354
|
-
|
357
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
358
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
359
|
+
fetcher = StatsFetcher(db_client)
|
355
360
|
ticker = 2330 # 換成tw50內任意ticker
|
356
361
|
stats_fetcher.get_cash_flow(ticker)
|
357
362
|
```
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__='0.0.6'
|
@@ -5,14 +5,11 @@ import pytz
|
|
5
5
|
from datetime import datetime, timedelta, date
|
6
6
|
from ..utils import StatsDateTime, StatsProcessor
|
7
7
|
import yaml
|
8
|
-
from ..utils import shared_client
|
9
|
-
|
10
8
|
|
11
9
|
class StatsFetcher:
|
12
|
-
|
13
|
-
def __init__(self, ticker):
|
10
|
+
def __init__(self, ticker, db_client):
|
14
11
|
self.ticker = ticker
|
15
|
-
self.db =
|
12
|
+
self.db = db_client[
|
16
13
|
"company"] # Replace with your database name
|
17
14
|
self.collection = self.db["twse_stats"]
|
18
15
|
|
@@ -11,8 +11,8 @@ class FinanceOverviewFetcher(StatsFetcher):
|
|
11
11
|
對應iFa.ai -> 財務分析 -> 重要指標(finance_overview)
|
12
12
|
"""
|
13
13
|
|
14
|
-
def __init__(self, ticker):
|
15
|
-
super().__init__(ticker)
|
14
|
+
def __init__(self, ticker, db_client):
|
15
|
+
super().__init__(ticker, db_client)
|
16
16
|
|
17
17
|
self.target_fields = StatsProcessor.load_yaml("finance_overview_dict.yaml")
|
18
18
|
self.inverse_dict = StatsProcessor.load_txt("seasonal_data_field_dict.txt", json_load=True)
|
@@ -3,9 +3,8 @@ import pandas as pd
|
|
3
3
|
|
4
4
|
class TechFetcher(StatsFetcher):
|
5
5
|
|
6
|
-
def __init__(self, ticker:str):
|
7
|
-
super().__init__()
|
8
|
-
self.ticker = ticker
|
6
|
+
def __init__(self, ticker:str, db_client):
|
7
|
+
super().__init__(ticker, db_client)
|
9
8
|
self.full_ohlcv = self._get_ohlcv()
|
10
9
|
self.basic_indexes = ['SMA5', 'SMA20', 'SMA60', 'EMA5', 'EMA20',
|
11
10
|
'EMA40', 'EMA12', 'EMA26', 'RSI7', 'RSI14',
|
@@ -6,8 +6,8 @@ from ..utils import StatsDateTime, StatsProcessor
|
|
6
6
|
|
7
7
|
class ValueFetcher(StatsFetcher):
|
8
8
|
|
9
|
-
def __init__(self, ticker: str):
|
10
|
-
super().__init__(ticker)
|
9
|
+
def __init__(self, ticker: str, db_client):
|
10
|
+
super().__init__(ticker, db_client)
|
11
11
|
|
12
12
|
def prepare_query(self, start_date, end_date):
|
13
13
|
pipeline = super().prepare_query()
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import os
|
2
|
+
from pymongo import MongoClient
|
3
|
+
from dotenv import load_dotenv
|
4
|
+
|
5
|
+
class DBClient:
|
6
|
+
def __init__(self, mongo_uri):
|
7
|
+
"""初始化時接收 MongoDB 連接 URI"""
|
8
|
+
self.client = MongoClient(mongo_uri)
|
9
|
+
self.db = self.client["twse_company"]
|
10
|
+
|
11
|
+
def get_client(self):
|
12
|
+
return self.client
|
13
|
+
|
14
|
+
def get_collection(self, collection_name):
|
15
|
+
"""返回指定名稱的集合"""
|
16
|
+
return self.db[collection_name]
|
@@ -1,4 +1,3 @@
|
|
1
|
-
from .db_client import shared_client
|
2
1
|
import pandas as pd
|
3
2
|
import json
|
4
3
|
import pytz
|
@@ -9,8 +8,8 @@ import yaml
|
|
9
8
|
|
10
9
|
class StatsFetcher:
|
11
10
|
|
12
|
-
def __init__(self):
|
13
|
-
self.db =
|
11
|
+
def __init__(self, db_client):
|
12
|
+
self.db = db_client["company"] # Replace with your database name
|
14
13
|
self.collection = self.db["twse_stats"]
|
15
14
|
|
16
15
|
self.timezone = pytz.timezone("Asia/Taipei")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: neurostats-API
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.6
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -118,9 +118,10 @@ data = stats_fetcher.query_data()
|
|
118
118
|
|
119
119
|
### 回傳月營收表
|
120
120
|
``` Python
|
121
|
-
from neurostats_API.utils import StatsFetcher
|
121
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
122
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
122
123
|
ticker = 2330 # 換成tw50內任意ticker
|
123
|
-
fetcher = StatsFetcher()
|
124
|
+
fetcher = StatsFetcher(db_client)
|
124
125
|
data = stats_fetcher.get_month_revenue_sheet(ticker)
|
125
126
|
```
|
126
127
|
|
@@ -170,9 +171,10 @@ YoY_10 None None ... None None
|
|
170
171
|
### 財務分析: 重要指標
|
171
172
|
對應https://ifa.ai/tw-stock/2330/finance-overview
|
172
173
|
```Python
|
173
|
-
from neurostats_API.
|
174
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
175
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
174
176
|
ticker = "2330"
|
175
|
-
fetcher = FinanceOverviewFetcher(ticker = "2330")
|
177
|
+
fetcher = FinanceOverviewFetcher(ticker = "2330", db_client = db_client)
|
176
178
|
data = fetcher.query_data()
|
177
179
|
```
|
178
180
|
|
@@ -253,8 +255,9 @@ markdown
|
|
253
255
|
|
254
256
|
### 損益表
|
255
257
|
```Python
|
256
|
-
from neurostats_API.utils import StatsFetcher
|
257
|
-
|
258
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
259
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
260
|
+
fetcher = StatsFetcher(db_client)
|
258
261
|
ticker = 2330 # 換成tw50內任意ticker
|
259
262
|
data = fetcher.get_profit_lose(ticker)
|
260
263
|
```
|
@@ -301,8 +304,9 @@ data = fetcher.get_profit_lose(ticker)
|
|
301
304
|
|
302
305
|
### 資產負債表
|
303
306
|
``` Python
|
304
|
-
from neurostats_API.utils import StatsFetcher
|
305
|
-
|
307
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
308
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
309
|
+
fetcher = StatsFetcher(db_client)
|
306
310
|
ticker = 2330 # 換成tw50內任意ticker
|
307
311
|
stats_fetcher.get_balance_sheet(ticker)
|
308
312
|
```
|
@@ -360,8 +364,9 @@ equity 1.094370e+09 53.3 ... 3.390706e+09 56.68
|
|
360
364
|
|
361
365
|
### 現金流量表
|
362
366
|
``` Python
|
363
|
-
from neurostats_API.utils import StatsFetcher
|
364
|
-
|
367
|
+
from neurostats_API.utils import StatsFetcher, DBClient
|
368
|
+
db_client = DBClient("<連接的DB位置>").get_client()
|
369
|
+
fetcher = StatsFetcher(db_client)
|
365
370
|
ticker = 2330 # 換成tw50內任意ticker
|
366
371
|
stats_fetcher.get_cash_flow(ticker)
|
367
372
|
```
|
@@ -1,12 +1,13 @@
|
|
1
1
|
import pytest
|
2
2
|
import pandas as pd
|
3
3
|
import yaml
|
4
|
-
from neurostats_API.utils import StatsProcessor
|
4
|
+
from neurostats_API.utils import StatsProcessor, DBClient
|
5
5
|
|
6
|
+
db_client = DBClient("mongodb://neurowatt:neurodb123@db.neurowatt.ai:27017/neurowatt").get_client()
|
6
7
|
|
7
8
|
def test_value():
|
8
9
|
from neurostats_API.fetchers import ValueFetcher
|
9
|
-
fetcher = ValueFetcher(ticker='2330')
|
10
|
+
fetcher = ValueFetcher(ticker='2330', db_client=db_client)
|
10
11
|
|
11
12
|
fetched_data = fetcher.query_data()
|
12
13
|
|
@@ -19,7 +20,7 @@ def test_value():
|
|
19
20
|
def test_profit_lose():
|
20
21
|
from neurostats_API.utils import StatsFetcher
|
21
22
|
|
22
|
-
fetcher = StatsFetcher()
|
23
|
+
fetcher = StatsFetcher(db_client)
|
23
24
|
|
24
25
|
data = fetcher.get_profit_lose("2330")
|
25
26
|
|
@@ -31,7 +32,7 @@ def test_profit_lose():
|
|
31
32
|
def test_cash_flow():
|
32
33
|
from neurostats_API.utils import StatsFetcher
|
33
34
|
|
34
|
-
fetcher = StatsFetcher()
|
35
|
+
fetcher = StatsFetcher(db_client)
|
35
36
|
data = fetcher.get_cash_flow("2330")
|
36
37
|
|
37
38
|
assert("cash_flow" in data.keys())
|
@@ -39,7 +40,7 @@ def test_cash_flow():
|
|
39
40
|
def test_month_revenue():
|
40
41
|
from neurostats_API.utils import StatsFetcher
|
41
42
|
|
42
|
-
fetcher = StatsFetcher()
|
43
|
+
fetcher = StatsFetcher(db_client)
|
43
44
|
data = fetcher.get_month_revenue_sheet("2330")
|
44
45
|
|
45
46
|
assert("month_revenue" in data.keys())
|
@@ -47,7 +48,7 @@ def test_month_revenue():
|
|
47
48
|
def test_balance_sheet():
|
48
49
|
from neurostats_API.utils import StatsFetcher
|
49
50
|
|
50
|
-
fetcher = StatsFetcher()
|
51
|
+
fetcher = StatsFetcher(db_client)
|
51
52
|
|
52
53
|
data = fetcher.get_balance_sheet("2330")
|
53
54
|
|
@@ -57,7 +58,7 @@ def test_balance_sheet():
|
|
57
58
|
|
58
59
|
def test_finance_overview():
|
59
60
|
from neurostats_API.fetchers import FinanceOverviewFetcher
|
60
|
-
fetcher = FinanceOverviewFetcher(ticker='2330')
|
61
|
+
fetcher = FinanceOverviewFetcher(ticker='2330', db_client=db_client)
|
61
62
|
fetched_data = fetcher.query_data()
|
62
63
|
|
63
64
|
expected_keys = [
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__='0.0.4'
|
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.4 → neurostats_API-0.0.6}/neurostats_API/tools/finance_overview_dict.yaml
RENAMED
File without changes
|
File without changes
|
{neurostats_API-0.0.4 → neurostats_API-0.0.6}/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
|