neurostats-API 0.0.4__tar.gz → 0.0.5__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.5}/PKG-INFO +1 -1
- neurostats_api-0.0.5/neurostats_API/__init__.py +1 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/base.py +2 -5
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/finance_overview.py +2 -2
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/tech.py +2 -3
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/value_invest.py +2 -2
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/utils/__init__.py +1 -1
- neurostats_api-0.0.5/neurostats_API/utils/db_client.py +16 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/utils/fetcher.py +2 -3
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API.egg-info/PKG-INFO +2 -2
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/setup.py +1 -1
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/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.5}/MANIFEST.in +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/README.md +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/cli.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/__init__.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/balance_sheet.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/month_revenue.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/fetchers/profit_lose.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/main.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/tools/finance_overview_dict.yaml +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/tools/profit_lose.yaml +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/tools/seasonal_data_field_dict.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/utils/data_process.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/utils/datetime.py +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API.egg-info/SOURCES.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API.egg-info/dependency_links.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API.egg-info/top_level.txt +0 -0
- {neurostats_API-0.0.4 → neurostats_api-0.0.5}/setup.cfg +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
__version__='0.0.5'
|
@@ -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,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
|
File without changes
|
{neurostats_API-0.0.4 → neurostats_api-0.0.5}/neurostats_API/tools/finance_overview_dict.yaml
RENAMED
File without changes
|
File without changes
|
{neurostats_API-0.0.4 → neurostats_api-0.0.5}/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
|