neurostats-API 1.0.1rc1__py3-none-any.whl → 1.0.2rc1__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 +3 -2
- neurostats_API/async_mode/__init__.py +2 -1
- neurostats_API/async_mode/db_extractors/__init__.py +2 -2
- neurostats_API/async_mode/db_extractors/daily/__init__.py +1 -1
- neurostats_API/async_mode/db_extractors/daily/us_chip.py +67 -1
- neurostats_API/async_mode/fetchers/__init__.py +1 -1
- neurostats_API/async_mode/fetchers/us_chip.py +25 -2
- neurostats_API/transformers/__init__.py +2 -1
- neurostats_API/transformers/daily_chip/__init__.py +1 -1
- neurostats_API/transformers/daily_chip/us.py +26 -1
- {neurostats_API-1.0.1rc1.dist-info → neurostats_API-1.0.2rc1.dist-info}/METADATA +2 -2
- {neurostats_API-1.0.1rc1.dist-info → neurostats_API-1.0.2rc1.dist-info}/RECORD +14 -14
- {neurostats_API-1.0.1rc1.dist-info → neurostats_API-1.0.2rc1.dist-info}/WHEEL +0 -0
- {neurostats_API-1.0.1rc1.dist-info → neurostats_API-1.0.2rc1.dist-info}/top_level.txt +0 -0
neurostats_API/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
__version__='1.0.
|
1
|
+
__version__='1.0.2rc1'
|
2
2
|
|
3
3
|
from .fetchers import (
|
4
4
|
AgentFinanceOverviewFetcher,
|
@@ -25,5 +25,6 @@ from .async_mode import (
|
|
25
25
|
AsyncTEJSeasonalFetcher,
|
26
26
|
AsyncTWSEInstitutionFetcher,
|
27
27
|
AsyncTWSEMarginFetcher,
|
28
|
-
AsyncTWSEStatsValueFetcher
|
28
|
+
AsyncTWSEStatsValueFetcher,
|
29
|
+
AsyncUSCelebrityFetcher
|
29
30
|
)
|
@@ -4,7 +4,7 @@ from .base import BaseDailyTechDBExtractor
|
|
4
4
|
from neurostats_API.utils import (
|
5
5
|
NotSupportedError, StatsProcessor
|
6
6
|
)
|
7
|
-
|
7
|
+
from pymongo import AsyncMongoClient
|
8
8
|
|
9
9
|
class AsyncUS_F13DBExtractor(BaseDailyTechDBExtractor):
|
10
10
|
|
@@ -64,3 +64,69 @@ class AsyncUS_F13DBExtractor(BaseDailyTechDBExtractor):
|
|
64
64
|
result = await super().query_data(start_date, end_date, get_latest)
|
65
65
|
|
66
66
|
return result
|
67
|
+
|
68
|
+
class AsyncUS_CelebrityDBExtractor(AsyncUS_F13DBExtractor):
|
69
|
+
"""
|
70
|
+
用於查詢美國名人持股的專用extractor
|
71
|
+
"""
|
72
|
+
def __init__(self, client:AsyncMongoClient, manager_name=None):
|
73
|
+
"""
|
74
|
+
manager_name: 名人名稱
|
75
|
+
"""
|
76
|
+
self.client = client
|
77
|
+
self.zone = "us"
|
78
|
+
self.manager = manager_name
|
79
|
+
self.collection_name_map = {"us": "us_F13"}
|
80
|
+
self.collection = self.client.get_database("company_us").get_collection("us_F13")
|
81
|
+
|
82
|
+
|
83
|
+
def _get_collection_name(self):
|
84
|
+
|
85
|
+
return self.collection_name_map.get(self.zone, None)
|
86
|
+
|
87
|
+
def _prepare_query(
|
88
|
+
self, start_date=None, end_date=None, get_latest=False,
|
89
|
+
value_throshold=None, title=None
|
90
|
+
):
|
91
|
+
|
92
|
+
start_date = self._transform_date(start_date)
|
93
|
+
end_date = self._transform_date(end_date)
|
94
|
+
|
95
|
+
query = {
|
96
|
+
"manager": self.manager,
|
97
|
+
"reportDate": {"$gte": start_date, "$lte": end_date}
|
98
|
+
}
|
99
|
+
|
100
|
+
if value_throshold:
|
101
|
+
query["value"] = {"$gt": value_throshold}
|
102
|
+
|
103
|
+
if title:
|
104
|
+
query["titleOfClass"] = title
|
105
|
+
|
106
|
+
projection = {"_id": 0}
|
107
|
+
|
108
|
+
if (get_latest):
|
109
|
+
sort = [("reportDate", DESCENDING)]
|
110
|
+
else:
|
111
|
+
sort = [("reportDate", ASCENDING)]
|
112
|
+
|
113
|
+
return query, projection, sort
|
114
|
+
|
115
|
+
async def query_data(
|
116
|
+
self, start_date=None, end_date=None, get_latest=False,
|
117
|
+
value_throshold=None, title=None
|
118
|
+
):
|
119
|
+
query, projection, sort = self._prepare_query(
|
120
|
+
start_date=start_date, end_date=end_date, get_latest=get_latest,
|
121
|
+
value_throshold=value_throshold, title=title
|
122
|
+
)
|
123
|
+
|
124
|
+
if (get_latest):
|
125
|
+
cursor = self.collection.find(query, projection).sort(sort).limit(1)
|
126
|
+
else:
|
127
|
+
cursor = self.collection.find(query, projection).sort(sort)
|
128
|
+
|
129
|
+
fetched_data = [data async for data in cursor]
|
130
|
+
|
131
|
+
return fetched_data
|
132
|
+
|
@@ -8,4 +8,4 @@ from .month_revenue import AsyncMonthlyRevenueFetcher
|
|
8
8
|
from .profit_lose import AsyncProfitLoseFetcher
|
9
9
|
from .value import AsyncTWSEStatsValueFetcher
|
10
10
|
from .tej import AsyncTEJDailyTechFetcher, AsyncTEJSeasonalFetcher
|
11
|
-
from .us_chip import AsyncUSChipF13Fetcher
|
11
|
+
from .us_chip import AsyncUSChipF13Fetcher, AsyncUSCelebrityFetcher
|
@@ -1,9 +1,9 @@
|
|
1
1
|
from .base import AsyncBaseFetcher
|
2
2
|
from ..db_extractors import (
|
3
|
-
AsyncDailyValueDBExtractor, AsyncTEJDailyValueDBExtractor
|
3
|
+
AsyncDailyValueDBExtractor, AsyncTEJDailyValueDBExtractor, AsyncUS_CelebrityDBExtractor
|
4
4
|
)
|
5
5
|
from neurostats_API.async_mode.factory import get_extractor
|
6
|
-
from neurostats_API.transformers import US_F13_Transformer
|
6
|
+
from neurostats_API.transformers import US_F13_Transformer, US_CelebrityTransformer
|
7
7
|
from neurostats_API.utils import NotSupportedError
|
8
8
|
|
9
9
|
|
@@ -44,3 +44,26 @@ class AsyncUSChipF13Fetcher(AsyncBaseFetcher):
|
|
44
44
|
)
|
45
45
|
|
46
46
|
return transformed_data
|
47
|
+
|
48
|
+
class AsyncUSCelebrityFetcher(AsyncBaseFetcher):
|
49
|
+
|
50
|
+
def __init__(self, client, manager_name):
|
51
|
+
self.manager_name = manager_name
|
52
|
+
self.extractor = AsyncUS_CelebrityDBExtractor(client, manager_name)
|
53
|
+
self.transformer = US_CelebrityTransformer()
|
54
|
+
|
55
|
+
async def query_data(
|
56
|
+
self, start_date=None, end_date=None, get_latest=False,
|
57
|
+
value_threshold=None, title=None, strftime=None
|
58
|
+
):
|
59
|
+
fetched_data = await self.extractor.query_data(
|
60
|
+
start_date, end_date, get_latest,
|
61
|
+
value_throshold=value_threshold, title=title
|
62
|
+
)
|
63
|
+
|
64
|
+
transformed_data = self.transformer.process_transform(
|
65
|
+
fetched_datas = list(fetched_data),
|
66
|
+
strftime = strftime
|
67
|
+
)
|
68
|
+
|
69
|
+
return transformed_data
|
@@ -1,2 +1,2 @@
|
|
1
1
|
from .twse_chip import TWSEChipTransformer
|
2
|
-
from .us import US_F13_Transformer
|
2
|
+
from .us import US_F13_Transformer, US_CelebrityTransformer
|
@@ -4,6 +4,8 @@ import inspect
|
|
4
4
|
import numpy as np
|
5
5
|
import pandas as pd
|
6
6
|
from neurostats_API.utils import StatsProcessor
|
7
|
+
from collections import defaultdict
|
8
|
+
from typing import List, Optional, Union
|
7
9
|
|
8
10
|
class US_F13_Transformer(BaseChipTransformer):
|
9
11
|
def __init__(self, ticker, company_name, zone):
|
@@ -37,4 +39,27 @@ class US_F13_Transformer(BaseChipTransformer):
|
|
37
39
|
|
38
40
|
return return_dict
|
39
41
|
|
40
|
-
|
42
|
+
class US_CelebrityTransformer():
|
43
|
+
|
44
|
+
def __init__(self):
|
45
|
+
pass
|
46
|
+
|
47
|
+
def process_transform(
|
48
|
+
self,
|
49
|
+
fetched_datas: List[dict],
|
50
|
+
strftime: Optional[str] = None
|
51
|
+
) -> dict[str, dict[Union[str, datetime], float]]:
|
52
|
+
|
53
|
+
result = defaultdict(lambda: defaultdict(dict))
|
54
|
+
|
55
|
+
for record in fetched_datas:
|
56
|
+
ticker = record.get("issuerTicker")
|
57
|
+
report_date = record.get("reportDate")
|
58
|
+
value = record.get("value")
|
59
|
+
title = record.get("titleOfClass")
|
60
|
+
|
61
|
+
if ticker and report_date and title:
|
62
|
+
key = report_date.strftime(strftime) if strftime else report_date
|
63
|
+
result.setdefault(ticker, {}).setdefault(title, {})[key] = value
|
64
|
+
|
65
|
+
return dict(result)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: neurostats_API
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.2rc1
|
4
4
|
Summary: The service of NeuroStats website
|
5
5
|
Home-page: https://github.com/NeurowattStats/NeuroStats_API.git
|
6
6
|
Author: JasonWang@Neurowatt
|
@@ -71,7 +71,7 @@ pip install neurostats-API
|
|
71
71
|
```Python
|
72
72
|
>>> import neurostats_API
|
73
73
|
>>> print(neurostats_API.__version__)
|
74
|
-
1.0.
|
74
|
+
1.0.2rc1
|
75
75
|
```
|
76
76
|
|
77
77
|
### 下載舊版
|
@@ -1,20 +1,20 @@
|
|
1
|
-
neurostats_API/__init__.py,sha256=
|
1
|
+
neurostats_API/__init__.py,sha256=rYPiKrSMClreRwkPjRz5Rfn1wyJ82TiNAkOvNUUamEY,704
|
2
2
|
neurostats_API/cli.py,sha256=UJSWLIw03P24p-gkBb6JSEI5dW5U12UvLf1L8HjQD-o,873
|
3
3
|
neurostats_API/main.py,sha256=QcsfmWivg2Dnqw3MTJWiI0QvEiRs0VuH-BjwQHFCv00,677
|
4
|
-
neurostats_API/async_mode/__init__.py,sha256=
|
4
|
+
neurostats_API/async_mode/__init__.py,sha256=8tsW_UDLJXuwzWdZJSacOqZatwzqr7v60hRk0PbgB-w,377
|
5
5
|
neurostats_API/async_mode/db/__init__.py,sha256=7g0OJXgPsIDWRmH25h666cLlvVYpEDyWGXAVCHsNht0,86
|
6
6
|
neurostats_API/async_mode/db/base.py,sha256=63kW2cKBSrs0B4RJaX_3Jv12UYD2APH8sRh2UEVKucw,676
|
7
7
|
neurostats_API/async_mode/db/tej.py,sha256=ku7CfhrSJ8gfUQ_NRjyjSz-OFmqyCGGnXz8Tpue5gP0,324
|
8
8
|
neurostats_API/async_mode/db/twse.py,sha256=YZA-NUZ01EAUKPsaNEaZn3cuzeL9n1fi03aBiHUJGAA,220
|
9
9
|
neurostats_API/async_mode/db/us.py,sha256=SgoU_OpSkpmrlBiNvy5xgyssb7-xK8ptezi4SR00t4I,271
|
10
|
-
neurostats_API/async_mode/db_extractors/__init__.py,sha256=
|
10
|
+
neurostats_API/async_mode/db_extractors/__init__.py,sha256=S6-lz6SZGzsSem-Kicr8UKsbPcuUA3Wyu276yMJN0tg,512
|
11
11
|
neurostats_API/async_mode/db_extractors/base.py,sha256=3Xgdl6A5x93Qg7zMyJJFdE9ZMxsSDFtmXQ-i3gmnpjQ,1831
|
12
|
-
neurostats_API/async_mode/db_extractors/daily/__init__.py,sha256=
|
12
|
+
neurostats_API/async_mode/db_extractors/daily/__init__.py,sha256=8vw8W8AZ_zi_hSshlobN4ITK9qaFVoNy66OmOT7cNj4,306
|
13
13
|
neurostats_API/async_mode/db_extractors/daily/base.py,sha256=ePvYxqOypy0F9VI33nSJQGpG5zMNO_EGZ3owVUeKFLw,3204
|
14
14
|
neurostats_API/async_mode/db_extractors/daily/tej_chip.py,sha256=Ywc0iIIPWw1VdtVc2_s1CNrgj0_G1wOaGzrgyVTN2k8,414
|
15
15
|
neurostats_API/async_mode/db_extractors/daily/tej_tech.py,sha256=M3k1pmv48DfiUaIfDKx5gk85C5JpmuXdQhRcNzgOhPI,349
|
16
16
|
neurostats_API/async_mode/db_extractors/daily/twse_chip.py,sha256=WICwcsy2m_2ua9UnIjs_SZGFq7m2-UByx9x7TCk_rlY,1490
|
17
|
-
neurostats_API/async_mode/db_extractors/daily/us_chip.py,sha256=
|
17
|
+
neurostats_API/async_mode/db_extractors/daily/us_chip.py,sha256=CMaKFsL5ryohvvmoq1jOrSE4DLWDD0nXeGCuXJc2gZo,3936
|
18
18
|
neurostats_API/async_mode/db_extractors/daily/value.py,sha256=j5QjFOhmvVum0D10prcZZ7_sxrojA-b8sP72Ge9lOnY,2859
|
19
19
|
neurostats_API/async_mode/db_extractors/daily/yf.py,sha256=GewIRJ7_baBc9QL7BHVdnxQ0uXYpFNeiPuwKxzByULg,377
|
20
20
|
neurostats_API/async_mode/db_extractors/month_revenue/__init__.py,sha256=VXjEn4xnXsPpt8lq7egSM_3sLnhtOIQG2lNedDC_Shw,50
|
@@ -29,7 +29,7 @@ neurostats_API/async_mode/db_extractors/seasonal/tej.py,sha256=SqObDqR3uOnxXGF12
|
|
29
29
|
neurostats_API/async_mode/factory/__init__.py,sha256=7dw36HPjV9JHfEBF7n1pA8i4f-07ACKREnGMUHxh7KY,45
|
30
30
|
neurostats_API/async_mode/factory/extractor_factory.py,sha256=NlCH2zM8Qq4zObQG9n4rixCcuFBQmkJz7dS-LARPwXA,4774
|
31
31
|
neurostats_API/async_mode/factory/transformer_factory.py,sha256=atw_-wPz2JZpJscPVE2jvFB6QNwwmcRNKQH9iai-13E,4942
|
32
|
-
neurostats_API/async_mode/fetchers/__init__.py,sha256=
|
32
|
+
neurostats_API/async_mode/fetchers/__init__.py,sha256=cn8AfSsqoZ_AntE3x4A1-0zu3KQUNy4OdpHpNJpRyT0,605
|
33
33
|
neurostats_API/async_mode/fetchers/balance_sheet.py,sha256=wzlXW5gPh5S5MD5jIUB_yeEL_aW2_CeX2DNKBio0-EA,1129
|
34
34
|
neurostats_API/async_mode/fetchers/base.py,sha256=fWlPmvsQWHcgv8z36BsXj8Y92-VKmr8cUW1EjkqI3_8,1785
|
35
35
|
neurostats_API/async_mode/fetchers/cash_flow.py,sha256=uj2JEbilgn595yJcMNvlTZHdkvu7E9y2e7rqs_ne270,2130
|
@@ -39,7 +39,7 @@ neurostats_API/async_mode/fetchers/profit_lose.py,sha256=-YMqO6hEbGntAeAf9y66LX5
|
|
39
39
|
neurostats_API/async_mode/fetchers/tech.py,sha256=xj6LRnexMePi4Nc9P0lduAjJwjcVOp1xInIFjrRMrbM,6686
|
40
40
|
neurostats_API/async_mode/fetchers/twse_institution.py,sha256=DKyecoIa_2-CUfDXKp2dBFJk0lfCBIr2steVVa-jq9o,2055
|
41
41
|
neurostats_API/async_mode/fetchers/twse_margin.py,sha256=wra84uFh9ooCoyFWhRuV4vP3Uhojc13XHx51UD90uYo,3173
|
42
|
-
neurostats_API/async_mode/fetchers/us_chip.py,sha256=
|
42
|
+
neurostats_API/async_mode/fetchers/us_chip.py,sha256=1C7wsdgXkf4SOHUyqGKNEsr0Ijds7l4jLLsPMYyMRQo,2365
|
43
43
|
neurostats_API/async_mode/fetchers/value.py,sha256=7FpO0_BOOvq4ZlwwaIfSD8xO_s1O8ykxz147fkiZIt4,2883
|
44
44
|
neurostats_API/async_mode/fetchers/tej/__init__.py,sha256=QNXGg1gE_bnkZWybulRZXtcCPWV6Aj1nLz7r0Mo4BN0,93
|
45
45
|
neurostats_API/async_mode/fetchers/tej/seasonal_data.py,sha256=oeMpj4GMzw22KHjVDTcVO2hwVfxmnO291N6O_dKp0sw,2836
|
@@ -70,7 +70,7 @@ neurostats_API/fetchers/profit_lose.py,sha256=MUTPPXHWZhhvcq1YzrY1dalFIXljUUG3Uu
|
|
70
70
|
neurostats_API/fetchers/tech.py,sha256=TsS8m25Otc3_2jTYITFe-wNHlDWcfWsHIxhOrqL8qMY,16016
|
71
71
|
neurostats_API/fetchers/tej_finance_report.py,sha256=mlIm2Qzs8-Xlzeb8uET8qGPWD3VGUx3g8qFFcY4UbAw,13022
|
72
72
|
neurostats_API/fetchers/value_invest.py,sha256=QxQS2GcoLIU9ZBDEo8iRK2yHd8YLmBS70Bq42F3IsSw,8295
|
73
|
-
neurostats_API/transformers/__init__.py,sha256=
|
73
|
+
neurostats_API/transformers/__init__.py,sha256=sePY-KavG_7xMA-dvWiC_Z6gXGZUmoCoMeuJCcZSe6A,729
|
74
74
|
neurostats_API/transformers/base.py,sha256=gFRuLmFzZl0HObEtMr78oscFP3ePBseMW7tB4s51-_c,4795
|
75
75
|
neurostats_API/transformers/balance_sheet/__init__.py,sha256=RCScBsR3zeC5UdyuiHD1CGRQufoFL5LkN8WbtI5JeA4,87
|
76
76
|
neurostats_API/transformers/balance_sheet/base.py,sha256=sEap9uHe-nri8F4gPV_FCVm0Qe6KWgpHt6a2ryAPd_8,1676
|
@@ -80,11 +80,11 @@ neurostats_API/transformers/cash_flow/__init__.py,sha256=KJs5kfjRV0ahy842ZVLvQuZ
|
|
80
80
|
neurostats_API/transformers/cash_flow/base.py,sha256=6Lt44O-xg658-jEFYBHOF2cgD0PGiKK43257uQMSetk,4392
|
81
81
|
neurostats_API/transformers/cash_flow/twse.py,sha256=srrmTmFheJig3el5jQIW8YBgpZVUOq-Af2zM4NxLm7s,2432
|
82
82
|
neurostats_API/transformers/cash_flow/us.py,sha256=nRJajeDz4HNkv42NosoP0Jir4tIA0ybhIZu9zHkjAEM,1304
|
83
|
-
neurostats_API/transformers/daily_chip/__init__.py,sha256
|
83
|
+
neurostats_API/transformers/daily_chip/__init__.py,sha256=-9y52t5cSvLq3ve9STe_Qhqa6iiCO0x78UUNG9qJ-IU,102
|
84
84
|
neurostats_API/transformers/daily_chip/base.py,sha256=KBsnpACakJh2W-k4Kvv-dVNnSNbUCGMeqvQsTQkz-aE,184
|
85
85
|
neurostats_API/transformers/daily_chip/tej.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
86
86
|
neurostats_API/transformers/daily_chip/twse_chip.py,sha256=miMu5Si0tFndznf7E_T26c1hYtNqwHplbuB3htVzeGQ,14655
|
87
|
-
neurostats_API/transformers/daily_chip/us.py,sha256=
|
87
|
+
neurostats_API/transformers/daily_chip/us.py,sha256=t1vGcdXu5ZlyMYO7sKW-NX4akd_hrvsZo0cQYDdqvbU,1966
|
88
88
|
neurostats_API/transformers/daily_chip/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
89
89
|
neurostats_API/transformers/daily_chip/utils/institution.py,sha256=1Zj9mxIhvwkmA599a1OYmdorPEAN_U3sl8uhvddxUW0,3384
|
90
90
|
neurostats_API/transformers/daily_chip/utils/margin_trading.py,sha256=oVY_OW63pcSc1TyM_jSPNAoj4HLyZCRshkdsHQsnxyk,38
|
@@ -119,7 +119,7 @@ neurostats_API/utils/datetime.py,sha256=XJya4G8b_-ZOaBbMXgQjWh2MC4wc-o6goQ7EQJQM
|
|
119
119
|
neurostats_API/utils/db_client.py,sha256=OYe6yazcR4Aa6jYmy47JrryUeh2NnKGqY2K_lSZe6i8,455
|
120
120
|
neurostats_API/utils/exception.py,sha256=yv92GVh5uHV1BgRmO4DwJcX_PtE0-TSgQoo3VnZ5hOQ,277
|
121
121
|
neurostats_API/utils/logger.py,sha256=egBiiPGTi5l1FoX_o6EvdGh81R0_k8hFPctSxq8RCoo,693
|
122
|
-
neurostats_API-1.0.
|
123
|
-
neurostats_API-1.0.
|
124
|
-
neurostats_API-1.0.
|
125
|
-
neurostats_API-1.0.
|
122
|
+
neurostats_API-1.0.2rc1.dist-info/METADATA,sha256=3wWTuXmARFNpWZvrk1lwRdcVVWOAJ62UXeaLXX-sD_8,2964
|
123
|
+
neurostats_API-1.0.2rc1.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
124
|
+
neurostats_API-1.0.2rc1.dist-info/top_level.txt,sha256=nSlQPMG0VtXivJyedp4Bkf86EOy2TpW10VGxolXrqnU,15
|
125
|
+
neurostats_API-1.0.2rc1.dist-info/RECORD,,
|
File without changes
|
File without changes
|