mns-common 1.4.3.3__py3-none-any.whl → 1.4.3.5__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.
Potentially problematic release.
This version of mns-common might be problematic. Click here for more details.
- mns_common/api/em/gd/east_money_stock_gdfx_free_top_10_api.py +2 -0
- mns_common/component/us/__init__.py +7 -0
- mns_common/component/us/us_stock_etf_info_api.py +125 -0
- {mns_common-1.4.3.3.dist-info → mns_common-1.4.3.5.dist-info}/METADATA +1 -1
- {mns_common-1.4.3.3.dist-info → mns_common-1.4.3.5.dist-info}/RECORD +7 -5
- {mns_common-1.4.3.3.dist-info → mns_common-1.4.3.5.dist-info}/WHEEL +0 -0
- {mns_common-1.4.3.3.dist-info → mns_common-1.4.3.5.dist-info}/top_level.txt +0 -0
|
@@ -38,6 +38,8 @@ def get_stock_gdfx_free_top_10_em_api(str_day, symbol):
|
|
|
38
38
|
return None
|
|
39
39
|
stock_gdfx_free_top_10_em_df = stock_gdfx_free_top_10_em_df.fillna(0)
|
|
40
40
|
stock_gdfx_free_top_10_em_df.index = stock_gdfx_free_top_10_em_df.index.astype(str)
|
|
41
|
+
stock_gdfx_free_top_10_em_df.drop_duplicates('shareholder_name', keep='last', inplace=True)
|
|
42
|
+
|
|
41
43
|
return stock_gdfx_free_top_10_em_df
|
|
42
44
|
|
|
43
45
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
file_path = os.path.abspath(__file__)
|
|
5
|
+
end = file_path.index('mns') + 21
|
|
6
|
+
project_path = file_path[0:end]
|
|
7
|
+
sys.path.append(project_path)
|
|
8
|
+
from loguru import logger
|
|
9
|
+
import csv
|
|
10
|
+
import requests
|
|
11
|
+
import pandas as pd
|
|
12
|
+
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
13
|
+
from functools import lru_cache
|
|
14
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@lru_cache()
|
|
18
|
+
def get_us_stock_info():
|
|
19
|
+
# 东财美股列表
|
|
20
|
+
em_us_stock_info_df = em_stock_info_api.get_us_stock_info()
|
|
21
|
+
em_us_stock_info_df['symbol'] = em_us_stock_info_df['symbol'].str.replace('_', '-')
|
|
22
|
+
em_us_stock_info_df = em_us_stock_info_df.loc[em_us_stock_info_df['total_mv'] != 0]
|
|
23
|
+
|
|
24
|
+
if data_frame_util.is_not_empty(em_us_stock_info_df):
|
|
25
|
+
em_us_stock_info_df.fillna({'list_date': 10000101}, inplace=True)
|
|
26
|
+
em_us_stock_info_df = em_us_stock_info_df[['symbol', 'name', 'list_date']]
|
|
27
|
+
|
|
28
|
+
# alpha 股票名单
|
|
29
|
+
alpha_us_stock_info = get_us_alpha_stock_list()
|
|
30
|
+
alpha_us_stock_info = alpha_us_stock_info.loc[alpha_us_stock_info['assetType'] == 'Stock']
|
|
31
|
+
if data_frame_util.is_not_empty(alpha_us_stock_info):
|
|
32
|
+
alpha_us_stock_info.fillna({'list_date': '1000-01-01'}, inplace=True)
|
|
33
|
+
alpha_us_stock_info = alpha_us_stock_info[['symbol', 'name', 'list_date']]
|
|
34
|
+
|
|
35
|
+
alpha_us_stock_info['list_date'] = alpha_us_stock_info['list_date'].astype(str).str.replace('-', '').astype(int)
|
|
36
|
+
|
|
37
|
+
us_stock_result_df = pd.concat([alpha_us_stock_info, em_us_stock_info_df])
|
|
38
|
+
us_stock_result_df.drop_duplicates(subset=['symbol'], inplace=True)
|
|
39
|
+
|
|
40
|
+
return us_stock_result_df
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@lru_cache()
|
|
44
|
+
def get_us_etf_info():
|
|
45
|
+
us_etf_info_df = em_stock_info_api.get_us_etf_info()
|
|
46
|
+
if data_frame_util.is_not_empty(us_etf_info_df):
|
|
47
|
+
us_etf_info_df.fillna({'list_date': 10000101}, inplace=True)
|
|
48
|
+
us_etf_info_df = us_etf_info_df[['symbol', 'name', 'list_date']]
|
|
49
|
+
|
|
50
|
+
# alpha ETF名单
|
|
51
|
+
alpha_us_etf_info = get_us_alpha_stock_list()
|
|
52
|
+
alpha_us_etf_info = alpha_us_etf_info.loc[alpha_us_etf_info['assetType'] == 'ETF']
|
|
53
|
+
if data_frame_util.is_not_empty(alpha_us_etf_info):
|
|
54
|
+
alpha_us_etf_info.fillna({'list_date': '1000-01-01'}, inplace=True)
|
|
55
|
+
alpha_us_etf_info = alpha_us_etf_info[['symbol', 'name', 'list_date']]
|
|
56
|
+
|
|
57
|
+
alpha_us_etf_info['list_date'] = alpha_us_etf_info['list_date'].astype(str).str.replace('-', '').astype(int)
|
|
58
|
+
us_etf_result_df = pd.concat([us_etf_info_df, alpha_us_etf_info])
|
|
59
|
+
us_etf_result_df.drop_duplicates(subset=['symbol'], inplace=True)
|
|
60
|
+
|
|
61
|
+
return us_etf_result_df
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# 退市 https://www.alphavantage.co/query?function=LISTING_STATUS&date=2012-07-10&state=delisted&apikey=QODR3TBYB2U4M9YR
|
|
65
|
+
@lru_cache()
|
|
66
|
+
def get_us_alpha_stock_list():
|
|
67
|
+
try:
|
|
68
|
+
# replace the "demo" apikey below with your own key from https://www.alphavantage.co/support/#api-key
|
|
69
|
+
CSV_URL = 'https://www.alphavantage.co/query?function=LISTING_STATUS&apikey=demo'
|
|
70
|
+
with requests.Session() as s:
|
|
71
|
+
download = s.get(CSV_URL)
|
|
72
|
+
decoded_content = download.content.decode('utf-8')
|
|
73
|
+
cr = csv.reader(decoded_content.splitlines(), delimiter=',')
|
|
74
|
+
my_list = list(cr)
|
|
75
|
+
# 提取列名(第1行)
|
|
76
|
+
columns = my_list[0]
|
|
77
|
+
# 提取数据(第2行及以后)
|
|
78
|
+
values = my_list[1:]
|
|
79
|
+
|
|
80
|
+
# 转换为 DataFrame
|
|
81
|
+
df = pd.DataFrame(values, columns=columns)
|
|
82
|
+
df = df.rename(columns={'ipoDate': 'list_date'})
|
|
83
|
+
if data_frame_util.is_not_empty(df):
|
|
84
|
+
df.to_csv(r'D:\mns\mns-common\mns_common\component\us\listing_status.csv', index=False, encoding='gbk')
|
|
85
|
+
return df
|
|
86
|
+
except BaseException as e:
|
|
87
|
+
logger.error("下载出现异常:{},", e)
|
|
88
|
+
df = pd.read_csv(r'D:\mns\mns-common\mns_common\component\us\listing_status.csv', encoding='utf-8')
|
|
89
|
+
df = df.rename(columns={'ipoDate': 'list_date'})
|
|
90
|
+
return df
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def get_us_alpha_stock_de_list():
|
|
94
|
+
try:
|
|
95
|
+
# replace the "demo" apikey below with your own key from https://www.alphavantage.co/support/#api-key
|
|
96
|
+
CSV_URL = 'https://www.alphavantage.co/query?function=LISTING_STATUS&date=2025-08-02&state=delisted&apikey=QODR3TBYB2U4M9YR'
|
|
97
|
+
with requests.Session() as s:
|
|
98
|
+
download = s.get(CSV_URL)
|
|
99
|
+
decoded_content = download.content.decode('utf-8')
|
|
100
|
+
cr = csv.reader(decoded_content.splitlines(), delimiter=',')
|
|
101
|
+
my_list = list(cr)
|
|
102
|
+
# 提取列名(第1行)
|
|
103
|
+
columns = my_list[0]
|
|
104
|
+
# 提取数据(第2行及以后)
|
|
105
|
+
values = my_list[1:]
|
|
106
|
+
|
|
107
|
+
# 转换为 DataFrame
|
|
108
|
+
df = pd.DataFrame(values, columns=columns)
|
|
109
|
+
df = df.rename(columns={'ipoDate': 'list_date'})
|
|
110
|
+
if data_frame_util.is_not_empty(df):
|
|
111
|
+
df.to_csv(r'D:\mns\mns-common\mns_common\component\us\de_list_status.csv', index=False, encoding='gbk')
|
|
112
|
+
return df
|
|
113
|
+
except BaseException as e:
|
|
114
|
+
logger.error("下载出现异常:{},", e)
|
|
115
|
+
df = pd.read_csv(r'D:\mns\mns-common\mns_common\component\us\de_list_status.csv', encoding='utf-8')
|
|
116
|
+
df = df.rename(columns={'ipoDate': 'list_date'})
|
|
117
|
+
return df
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == '__main__':
|
|
121
|
+
# get_us_alpha_stock_de_list()
|
|
122
|
+
df_test = get_us_stock_info()
|
|
123
|
+
df_test.drop_duplicates(subset=['symbol'], inplace=True)
|
|
124
|
+
print(df_test)
|
|
125
|
+
get_us_alpha_stock_de_list()
|
|
@@ -11,7 +11,7 @@ mns_common/api/em/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0
|
|
|
11
11
|
mns_common/api/em/concept/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
12
12
|
mns_common/api/em/concept/em_concept_index_api.py,sha256=PP87ES8a_y0o3SKLzBsPrc7DCPI3MBCD-4SmoUUirl0,8285
|
|
13
13
|
mns_common/api/em/gd/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
14
|
-
mns_common/api/em/gd/east_money_stock_gdfx_free_top_10_api.py,sha256=
|
|
14
|
+
mns_common/api/em/gd/east_money_stock_gdfx_free_top_10_api.py,sha256=0knGM6yrqH8ajX92l3RK_y2rdf8dJPI-scQxyD7d4i8,9279
|
|
15
15
|
mns_common/api/em/real_time/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
16
16
|
mns_common/api/em/real_time/east_money_debt_api.py,sha256=jMvMZtlrDfExl_4jZ1hepHX8rUoeVLoLSOIhRBjkUGk,14753
|
|
17
17
|
mns_common/api/em/real_time/east_money_etf_api.py,sha256=tCyH4fNx-KfVRFuNGkgM8d_xkvR0oAfr8T3e7_XrjTM,14414
|
|
@@ -130,6 +130,8 @@ mns_common/component/tfp/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNd
|
|
|
130
130
|
mns_common/component/tfp/stock_tfp_api.py,sha256=_iScNNUmzEXeZ32PFQ_bFs3CErQk_188ESS3hUgCH7E,4455
|
|
131
131
|
mns_common/component/trade_date/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
132
132
|
mns_common/component/trade_date/trade_date_common_service_api.py,sha256=PHrcUjgLdNKbqyMGot0poKtiLBys_wRZoheMhPJE-U4,3032
|
|
133
|
+
mns_common/component/us/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
134
|
+
mns_common/component/us/us_stock_etf_info_api.py,sha256=lwlMsjp2pwJVBHcNz0jwdfED-FTQgawSg06VIoDXt6s,5565
|
|
133
135
|
mns_common/component/zt/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
134
136
|
mns_common/component/zt/zt_common_service_api.py,sha256=6pHRLLJjKcLLBA-xXkAU8SE6DZ5dgVFBRVjJmhkL0II,11945
|
|
135
137
|
mns_common/constant/__init__.py,sha256=xu36nA6MJTauswUWPfKIKH0E-lpOAHTw2TL5QI_6TeY,165
|
|
@@ -154,7 +156,7 @@ mns_common/utils/date_handle_util.py,sha256=XS-MyA8_7k35LOCFAYOHgVcVkMft_Kc4Wa9U
|
|
|
154
156
|
mns_common/utils/db_util.py,sha256=hSmfNAN4vEeEaUva6_cicZEhb2jSnib-Gvk2reke1vc,2590
|
|
155
157
|
mns_common/utils/file_util.py,sha256=egWu6PenGPRp_ixrNTHKarT4dAnOT6FETR82EHUZJnQ,1042
|
|
156
158
|
mns_common/utils/ip_util.py,sha256=UTcYfz_uytB__6nlBf7T-izuI7hi4XdB6ET0sJgEel4,969
|
|
157
|
-
mns_common-1.4.3.
|
|
158
|
-
mns_common-1.4.3.
|
|
159
|
-
mns_common-1.4.3.
|
|
160
|
-
mns_common-1.4.3.
|
|
159
|
+
mns_common-1.4.3.5.dist-info/METADATA,sha256=lArxB32PFjYEdw7_YKz6BoHt8oBVx-VlIr1_Cl4dca0,61
|
|
160
|
+
mns_common-1.4.3.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
161
|
+
mns_common-1.4.3.5.dist-info/top_level.txt,sha256=ZC58kAR-8Hvc6U2xhYNBNLAh3mb6sZazbdj5nZpvEkQ,11
|
|
162
|
+
mns_common-1.4.3.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|