mns-common 1.3.3.5__py3-none-any.whl → 1.5.7.2__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.
Files changed (76) hide show
  1. mns_common/api/akshare/__init__.py +0 -1
  2. mns_common/api/akshare/k_line_api.py +20 -82
  3. mns_common/api/akshare/stock_bid_ask_api.py +22 -97
  4. mns_common/api/akshare/stock_zb_pool.py +2 -0
  5. mns_common/api/akshare/stock_zt_pool_api.py +1 -1
  6. mns_common/api/em/gd/__init__.py +7 -0
  7. mns_common/api/em/{east_money_stock_gdfx_free_top_10_api.py → gd/east_money_stock_gdfx_free_top_10_api.py} +64 -9
  8. mns_common/api/em/real_time/__init__.py +7 -0
  9. mns_common/api/em/{east_money_debt_api.py → real_time/east_money_debt_api.py} +154 -69
  10. mns_common/api/em/{east_money_etf_api.py → real_time/east_money_etf_api.py} +149 -27
  11. mns_common/api/em/real_time/east_money_stock_a_api.py +301 -0
  12. mns_common/api/em/real_time/east_money_stock_a_v2_api.py +340 -0
  13. mns_common/api/em/real_time/east_money_stock_common_api.py +174 -0
  14. mns_common/api/em/real_time/east_money_stock_hk_api.py +288 -0
  15. mns_common/api/em/real_time/east_money_stock_hk_gtt_api.py +260 -0
  16. mns_common/api/em/real_time/east_money_stock_multi_thread_api_v3.py +154 -0
  17. mns_common/api/em/{east_money_stock_us_api.py → real_time/east_money_stock_us_api.py} +149 -72
  18. mns_common/api/em/real_time/real_time_quotes_repeat_api.py +195 -0
  19. mns_common/api/k_line/stock_k_line_data_api.py +11 -1
  20. mns_common/api/k_line/stock_minute_data_api.py +1 -0
  21. mns_common/api/kpl/common/kpl_common_api.py +35 -0
  22. mns_common/api/kpl/symbol/symbol_his_quotes_api.py +1 -1
  23. mns_common/api/proxies/__init__.py +7 -0
  24. mns_common/api/proxies/liu_guan_proxy_api.py +115 -0
  25. mns_common/api/ths/company/company_product_area_industry_index_query.py +46 -0
  26. mns_common/api/ths/company/ths_company_info_api.py +13 -9
  27. mns_common/api/ths/company/ths_company_info_web.py +159 -0
  28. mns_common/api/ths/concept/app/ths_concept_index_app.py +3 -1
  29. mns_common/api/ths/wen_cai/ths_wen_cai_api.py +10 -7
  30. mns_common/api/ths/zt/ths_stock_zt_pool_api.py +21 -4
  31. mns_common/api/ths/zt/ths_stock_zt_pool_v2_api.py +111 -40
  32. mns_common/api/xueqiu/__init__.py +7 -0
  33. mns_common/api/xueqiu/xue_qiu_k_line_api.py +83 -0
  34. mns_common/component/__init__.py +1 -1
  35. mns_common/component/classify/symbol_classify_api.py +7 -7
  36. mns_common/component/common_service_fun_api.py +66 -6
  37. mns_common/component/company/company_common_service_api.py +21 -1
  38. mns_common/component/company/company_common_service_new_api.py +4 -1
  39. mns_common/component/cookie/cookie_enum.py +15 -0
  40. mns_common/component/cookie/cookie_info_service.py +9 -4
  41. mns_common/component/data/data_init_api.py +13 -8
  42. mns_common/component/deal/deal_service_api.py +70 -8
  43. mns_common/component/deal/deal_service_v2_api.py +167 -0
  44. mns_common/component/em/__init__.py +7 -0
  45. mns_common/component/em/em_real_time_quotes_api.py +56 -0
  46. mns_common/component/em/em_stock_info_api.py +48 -0
  47. mns_common/component/exception/ExceptionMonitor.py +86 -0
  48. mns_common/component/exception/__init__.py +7 -0
  49. mns_common/component/k_line/common/k_line_common_service_api.py +4 -0
  50. mns_common/component/main_line/__init__.py +7 -0
  51. mns_common/component/main_line/main_line_zt_reason_service.py +237 -0
  52. mns_common/component/proxies/__init__.py +7 -0
  53. mns_common/component/proxies/proxy_common_api.py +252 -0
  54. mns_common/component/self_choose/__init__.py +13 -0
  55. mns_common/component/tfp/stock_tfp_api.py +82 -12
  56. mns_common/component/us/__init__.py +7 -0
  57. mns_common/component/us/us_stock_etf_info_api.py +125 -0
  58. mns_common/constant/__init__.py +1 -0
  59. mns_common/constant/db_name_constant.py +65 -34
  60. mns_common/constant/extra_income_db_name.py +154 -0
  61. mns_common/constant/strategy_classify.py +72 -0
  62. mns_common/db/MongodbUtil.py +2 -1
  63. mns_common/db/MongodbUtilLocal.py +1 -0
  64. mns_common/db/v2/MongodbUtilV2.py +0 -4
  65. mns_common-1.5.7.2.dist-info/METADATA +4 -0
  66. {mns_common-1.3.3.5.dist-info → mns_common-1.5.7.2.dist-info}/RECORD +70 -45
  67. {mns_common-1.3.3.5.dist-info → mns_common-1.5.7.2.dist-info}/WHEEL +1 -1
  68. mns_common/api/em/east_money_stock_api.py +0 -222
  69. mns_common/api/em/east_money_stock_hk_api.py +0 -318
  70. mns_common/api/em/east_money_stock_v2_api.py +0 -219
  71. mns_common/api/ths/concept/web/ths_company_info_web.py +0 -163
  72. mns_common/component/qmt/qmt_buy_service.py +0 -172
  73. mns_common-1.3.3.5.dist-info/METADATA +0 -4
  74. /mns_common/{component/qmt → api/em/concept}/__init__.py +0 -0
  75. /mns_common/api/em/{em_concept_index_api.py → concept/em_concept_index_api.py} +0 -0
  76. {mns_common-1.3.3.5.dist-info → mns_common-1.5.7.2.dist-info}/top_level.txt +0 -0
@@ -5,4 +5,3 @@ file_path = os.path.abspath(__file__)
5
5
  end = file_path.index('mns') + 14
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
-
@@ -9,93 +9,16 @@ import requests
9
9
  import pandas as pd
10
10
  import mns_common.component.common_service_fun_api as common_service_fun_api
11
11
  from datetime import datetime
12
- from functools import lru_cache
13
12
  import numpy as np
14
13
 
15
14
 
16
- @lru_cache(maxsize=None)
17
- def code_id_map_em() -> dict:
18
- """
19
- 东方财富-股票和市场代码
20
- http://quote.eastmoney.com/center/gridlist.html#hs_a_board
21
- :return: 股票和市场代码
22
- :rtype: dict
23
- """
24
- url = "http://80.push2.eastmoney.com/api/qt/clist/get"
25
- params = {
26
- "pn": "1",
27
- "pz": "5000",
28
- "po": "1",
29
- "np": "3",
30
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
31
- "fltt": "2",
32
- "invt": "2",
33
- "fid": "f3",
34
- "fs": "m:1 t:2,m:1 t:23",
35
- "fields": "f12",
36
- "_": "1623833739532",
37
- }
38
- r = requests.get(url, params=params)
39
- data_json = r.json()
40
- if not data_json["data"]["diff"]:
41
- return pd.DataFrame()
42
- temp_df = pd.DataFrame(data_json["data"]["diff"])
43
- temp_df["market_id"] = 1
44
- temp_df.columns = ["sh_code", "sh_id"]
45
- code_id_dict = dict(zip(temp_df["sh_code"], temp_df["sh_id"]))
46
- params = {
47
- "pn": "1",
48
- "pz": "5000",
49
- "po": "1",
50
- "np": "3",
51
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
52
- "fltt": "2",
53
- "invt": "2",
54
- "fid": "f3",
55
- "fs": "m:0 t:6,m:0 t:80",
56
- "fields": "f12",
57
- "_": "1623833739532",
58
- }
59
- r = requests.get(url, params=params)
60
- data_json = r.json()
61
- if not data_json["data"]["diff"]:
62
- return pd.DataFrame()
63
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
64
- temp_df_sz["sz_id"] = 0
65
- code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["sz_id"])))
66
- now_date = datetime.now()
67
- now_time = int(now_date.timestamp() * 1000)
68
- now_time = str(now_time)
69
-
70
- params = {
71
- "pn": "1",
72
- "pz": "5000",
73
- "po": "1",
74
- "np": "3",
75
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
76
- "fltt": "2",
77
- "invt": "2",
78
- "fid": "f3",
79
- "fs": "m:0 t:81 s:2048",
80
- "fields": "f12",
81
- "_": now_time,
82
- }
83
- r = requests.get(url, params=params)
84
- data_json = r.json()
85
- if not data_json["data"]["diff"]:
86
- return pd.DataFrame()
87
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
88
- temp_df_sz["bj_id"] = 0
89
- code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["bj_id"])))
90
- return code_id_dict
91
-
92
-
93
15
  def stock_zh_a_hist(
94
- symbol: str = "000001",
16
+ symbol: str = "0.000001",
95
17
  period: str = 'daily',
96
18
  start_date: str = "19700101",
97
19
  end_date: str = "22220101",
98
20
  adjust: str = "",
21
+ proxies: str = None
99
22
  ) -> pd.DataFrame:
100
23
  """
101
24
  东方财富网-行情首页-沪深京 A 股-每日行情
@@ -110,10 +33,12 @@ def stock_zh_a_hist(
110
33
  :type end_date: str
111
34
  :param adjust: choice of {"qfq": "前复权", "hfq": "后复权", "": "不复权"}
112
35
  :type adjust: str
36
+ :param proxies: 代理ip
37
+ :type proxies: str
38
+
113
39
  :return: 每日行情
114
40
  :rtype: pandas.DataFrame
115
41
  """
116
- code_id_dict = code_id_map_em()
117
42
  adjust_dict = {"qfq": "1", "hfq": "2", "": "0"}
118
43
  period_dict = {'daily': '101', 'weekly': '102', 'monthly': '103'}
119
44
  url = "http://push2his.eastmoney.com/api/qt/stock/kline/get"
@@ -132,7 +57,12 @@ def stock_zh_a_hist(
132
57
  "end": "20500000",
133
58
  "_": now_time,
134
59
  }
135
- r = requests.get(url, params=params)
60
+
61
+ if proxies is None:
62
+ r = requests.get(url, params=params)
63
+ else:
64
+ r = requests.get(url, params=params, proxies=proxies)
65
+
136
66
  data_json = r.json()
137
67
  temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]["klines"]])
138
68
  temp_df.columns = [
@@ -179,7 +109,15 @@ def stock_zh_a_hist(
179
109
  return temp_df
180
110
 
181
111
 
112
+ import mns_common.component.proxies.proxy_common_api as proxy_common_api
113
+
182
114
  if __name__ == '__main__':
183
115
  while True:
184
- df = stock_zh_a_hist()
116
+ proxy_ip = proxy_common_api.get_proxy_ip(5)
117
+ df = stock_zh_a_hist("0.000001",
118
+ 'daily',
119
+ "19700101",
120
+ "22220101",
121
+ "",
122
+ proxy_ip)
185
123
  print(df)
@@ -6,91 +6,10 @@ end = file_path.index('mns') + 7
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
8
  import pandas as pd
9
- from functools import lru_cache
10
9
  import requests
11
10
 
12
- fields_all = "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f22,f23,f24,f25,f26,f27,f28,f29,f30,f31,f32,f33,f34,f35,f36,f37,f38,f39,f40,f41,f42,f43,f44,f45,f46,f47,f48,f49,f50,f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65,f66,f67,f68,f69,f70,f71,f72,f73,f74,f75,f76,f77,f78,f79,f80,f81,f82,f83,f84,f85,f86,f87,f88,f89,f90,f91,f92,f93,f94,f95,f96,f97,f98,f99,f100,f101,f102,f103,f104,f105,f106,f107,f108" \
13
- ",f109,f110,f111,f112,f113,f114,f115,f116,f117,f118,f119,f120,f121,f122,f123,f124,f125,f126,f127,f128,f129,f130,f131,f132,f133,f134,f135,f136,f137,f138,f139,f140,f141,f142,f143,f144,f145,f146,f147,f148,f149,f150,f151,f152,f153,f154,f155,f156,f157,f158,f159,f160,f161,f162,f163,f164,f165,f166,f167,f168,f169,f170,f171,f172,f173,f174,f175,f176,f177,f178,f179,f180,f181,f182,f183,f184,f185,f186,f187,f188,f189,f190,f191,f192,f193,f194,f195,f196,f197,f198,f199,f200" \
14
- ",f209,f210,f212,f213,f214,f215,f216,f217,f218,f219,f220,f221,f222,f223,f224,f225,f226,f227,f228,f229,f230,f231,f232,f233,f234,f235,f236,f237,f238,f239,f240,f241,f242,f243,f244,f245,f246,f247,f248,f249,f250,f251,f252,f253,f254,f255,f256,f257,f258,f259,f260,f261,f262,f263,f264,f265,f266,f267,f268,f269,f270,f271,f272,f273,f274,f275,f276,f277,f278,f279,f280,f281,f282,f283,f284,f285,f286,f287,f288,f289,f290,f291,f292,f293,f294,f295,f296,f297,f298,f299,f300" \
15
- ",f309,f310,f312,f313,f314,f315,f316,f317,f318,f319,f320,f321,f322,f323,f324,f325,f326,f327,f328,f329,f330,f331,f332,f333,f334,f335,f336,f337,f338,f339,f340,f341,f342,f343,f344,f345,f346,f347,f348,f349,f350,f351,f352,f353,f354,f355,f356,f357,f358,f359,f360,f361,f362,f363,f364,f365,f366,f367,f368,f369,f370,f371,f372,f373,f374,f375,f376,f377,f378,f379,f380,f381,f382,f383,f384,f385,f386,f387,f388,f389,f390,f391,f392,f393,f394,f395,f396,f397,f398,f399,f401"
16
11
 
17
-
18
- # 行情报价接口
19
-
20
- @lru_cache()
21
- def __code_id_map_em() -> dict:
22
- """
23
- 东方财富-股票和市场代码
24
- https://quote.eastmoney.com/center/gridlist.html#hs_a_board
25
- :return: 股票和市场代码
26
- :rtype: dict
27
- """
28
- url = "http://80.push2.eastmoney.com/api/qt/clist/get"
29
- params = {
30
- "pn": "1",
31
- "pz": "50000",
32
- "po": "1",
33
- "np": "3",
34
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
35
- "fltt": "2",
36
- "invt": "2",
37
- "fid": "f3",
38
- "fs": "m:1 t:2,m:1 t:23",
39
- "fields": "f12",
40
- "_": "1623833739532",
41
- }
42
- r = requests.get(url, params=params)
43
- data_json = r.json()
44
- if not data_json["data"]["diff"]:
45
- return dict()
46
- temp_df = pd.DataFrame(data_json["data"]["diff"])
47
- temp_df["market_id"] = 1
48
- temp_df.columns = ["sh_code", "sh_id"]
49
- code_id_dict = dict(zip(temp_df["sh_code"], temp_df["sh_id"]))
50
- params = {
51
- "pn": "1",
52
- "pz": "50000",
53
- "po": "1",
54
- "np": "3",
55
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
56
- "fltt": "2",
57
- "invt": "2",
58
- "fid": "f3",
59
- "fs": "m:0 t:6,m:0 t:80",
60
- "fields": "f12",
61
- "_": "1623833739532",
62
- }
63
- r = requests.get(url, params=params)
64
- data_json = r.json()
65
- if not data_json["data"]["diff"]:
66
- return dict()
67
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
68
- temp_df_sz["sz_id"] = 0
69
- code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["sz_id"])))
70
- params = {
71
- "pn": "1",
72
- "pz": "50000",
73
- "po": "1",
74
- "np": "3",
75
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
76
- "fltt": "2",
77
- "invt": "2",
78
- "fid": "f3",
79
- "fs": "m:0 t:81 s:2048",
80
- "fields": "f12",
81
- "_": "1623833739532",
82
- }
83
- r = requests.get(url, params=params)
84
- data_json = r.json()
85
- if not data_json["data"]["diff"]:
86
- return dict()
87
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
88
- temp_df_sz["bj_id"] = 0
89
- code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["bj_id"])))
90
- return code_id_dict
91
-
92
-
93
- def stock_bid_ask_em(symbol: str = "000001") -> dict:
12
+ def stock_bid_ask_em(symbol: str = "000001") -> pd.DataFrame:
94
13
  """
95
14
  东方财富-行情报价
96
15
  https://quote.eastmoney.com/sz000001.html
@@ -100,13 +19,19 @@ def stock_bid_ask_em(symbol: str = "000001") -> dict:
100
19
  :rtype: pandas.DataFrame
101
20
  """
102
21
  url = "https://push2.eastmoney.com/api/qt/stock/get"
103
- code_id_map_em_dict = __code_id_map_em()
104
22
  params = {
105
23
  "fltt": "2",
106
24
  "invt": "2",
107
- "fields": "f43,f51,f52,f191,f120,f121,f122,f174,f175,f59,f163,f43,f57,f58,f169,f170,f46,f44,f51,f168,f47,f164,f116,f60,f45,f52,f50,f48,f167,f117,f71,f161,f49,f530,f135,f136,f137,f138,f139,f141,f142,f144,f145,f147,f148,f140,f143,f146,f149,f55,f62,f162,f92,f173,f104,f105,f84,f85,f183,f184,f185,f186,f187,f188,f189,f190,f191,f192,f107,f111,f86,f177,f78,f110,f262,f263,f264,f267,f268,f255,f256,f257,f258,f127,f199,f128,f198,f259,f260,f261,f171,f277,f278,f279,f288,f152,f250,f251,f252,f253,f254,f269,f270,f271,f272,f273,f274,f275,f276,f265,f266,f289,f290,f286,f285,f292,f293,f294,f295",
108
- # "fields" :fields_02,
109
- "secid": f"{code_id_map_em_dict[symbol]}.{symbol}",
25
+ "fields": "f120,f121,f122,f174,f175,f59,f163,f43,f57,f58,f169,f170,f46,f44,f51,"
26
+ "f168,f47,f164,f116,f60,f45,f52,f50,f48,f167,f117,f71,f161,f49,f530,"
27
+ "f135,f136,f137,f138,f139,f141,f142,f144,f145,f147,f148,f140,f143,f146,"
28
+ "f149,f55,f62,f162,f92,f173,f104,f105,f84,f85,f183,f184,f185,f186,f187,"
29
+ "f188,f189,f190,f191,f192,f107,f111,f86,f177,f78,f110,f262,f263,f264,f267,"
30
+ "f268,f255,f256,f257,f258,f127,f199,f128,f198,f259,f260,f261,f171,f277,f278,"
31
+ "f279,f288,f152,f250,f251,f252,f253,f254,f269,f270,f271,f272,f273,f274,f275,"
32
+ "f276,f265,f266,f289,f290,f286,f285,f292,f293,f294,f295",
33
+
34
+ "secid": symbol,
110
35
  }
111
36
  r = requests.get(url, params=params)
112
37
  data_json = r.json()
@@ -139,25 +64,25 @@ def stock_bid_ask_em(symbol: str = "000001") -> dict:
139
64
  temp_df = pd.DataFrame(tick_dict, index=[1])
140
65
  temp_df.reset_index(inplace=True)
141
66
  temp_df.loc[temp_df['wei_bi'] == '-', 'wei_bi'] = 0
142
- temp_df.loc[temp_df['sell_5'] == '-', 'sell_5_vol'] = 0
67
+ temp_df.loc[temp_df['sell_5_vol'] == '-', 'sell_5_vol'] = 0
143
68
  temp_df.loc[temp_df['sell_5'] == '-', 'sell_5'] = 0
144
- temp_df.loc[temp_df['sell_4'] == '-', 'sell_4_vol'] = 0
69
+ temp_df.loc[temp_df['sell_4_vol'] == '-', 'sell_4_vol'] = 0
145
70
  temp_df.loc[temp_df['sell_4'] == '-', 'sell_4'] = 0
146
- temp_df.loc[temp_df['sell_3'] == '-', 'sell_3_vol'] = 0
71
+ temp_df.loc[temp_df['sell_3_vol'] == '-', 'sell_3_vol'] = 0
147
72
  temp_df.loc[temp_df['sell_3'] == '-', 'sell_3'] = 0
148
- temp_df.loc[temp_df['sell_2'] == '-', 'sell_2_vol'] = 0
73
+ temp_df.loc[temp_df['sell_2_vol'] == '-', 'sell_2_vol'] = 0
149
74
  temp_df.loc[temp_df['sell_2'] == '-', 'sell_2'] = 0
150
- temp_df.loc[temp_df['sell_1'] == '-', 'sell_1_vol'] = 0
75
+ temp_df.loc[temp_df['sell_1_vol'] == '-', 'sell_1_vol'] = 0
151
76
  temp_df.loc[temp_df['sell_1'] == '-', 'sell_1'] = 0
152
- temp_df.loc[temp_df['buy_1'] == '-', 'buy_1_vol'] = 0
77
+ temp_df.loc[temp_df['buy_1_vol'] == '-', 'buy_1_vol'] = 0
153
78
  temp_df.loc[temp_df['buy_1'] == '-', 'buy_1'] = 0
154
- temp_df.loc[temp_df['buy_2'] == '-', 'buy_2_vol'] = 0
79
+ temp_df.loc[temp_df['buy_2_vol'] == '-', 'buy_2_vol'] = 0
155
80
  temp_df.loc[temp_df['buy_2'] == '-', 'buy_2'] = 0
156
- temp_df.loc[temp_df['buy_3'] == '-', 'buy_3_vol'] = 0
81
+ temp_df.loc[temp_df['buy_3_vol'] == '-', 'buy_3_vol'] = 0
157
82
  temp_df.loc[temp_df['buy_3'] == '-', 'buy_3'] = 0
158
- temp_df.loc[temp_df['buy_4'] == '-', 'buy_4_vol'] = 0
83
+ temp_df.loc[temp_df['buy_4_vol'] == '-', 'buy_4_vol'] = 0
159
84
  temp_df.loc[temp_df['buy_4'] == '-', 'buy_4'] = 0
160
- temp_df.loc[temp_df['buy_5'] == '-', 'buy_5_vol'] = 0
85
+ temp_df.loc[temp_df['buy_5_vol'] == '-', 'buy_5_vol'] = 0
161
86
  temp_df.loc[temp_df['buy_5'] == '-', 'buy_5'] = 0
162
87
  temp_df['symbol'] = symbol
163
88
  return temp_df
@@ -165,5 +90,5 @@ def stock_bid_ask_em(symbol: str = "000001") -> dict:
165
90
 
166
91
  if __name__ == '__main__':
167
92
  while True:
168
- df = stock_bid_ask_em('301082')
93
+ df = stock_bid_ask_em('0.000001')
169
94
  print(df)
@@ -32,6 +32,8 @@ def stock_zb_pool_df(date):
32
32
  "首次封板时间": "first_closure_time",
33
33
  "炸板次数": "frying_plates_numbers",
34
34
  "炸板股统计": "statistics",
35
+ "涨停统计": "zt_statistics",
36
+ "涨停价": "zt_price",
35
37
  "振幅": "pct_chg",
36
38
  "所属行业": "industry"
37
39
  }, inplace=True)
@@ -43,5 +43,5 @@ def stock_em_zt_pool_df(date):
43
43
 
44
44
 
45
45
  if __name__ == '__main__':
46
- df = stock_em_zt_pool_df('2024-09-04')
46
+ df = stock_em_zt_pool_df('2025-10-24')
47
47
  print(df)
@@ -0,0 +1,7 @@
1
+ import sys
2
+ import os
3
+
4
+ file_path = os.path.abspath(__file__)
5
+ end = file_path.index('mns') + 16
6
+ project_path = file_path[0:end]
7
+ sys.path.append(project_path)
@@ -9,10 +9,11 @@ import akshare as ak
9
9
  import mns_common.component.common_service_fun_api as common_service_fun_api
10
10
  import mns_common.utils.date_handle_util as date_handle_util
11
11
  from loguru import logger
12
- import mns_common.api.em.east_money_stock_api as east_money_stock_api
12
+ import mns_common.component.em.em_stock_info_api as em_stock_info_api
13
13
  from mns_common.db.MongodbUtil import MongodbUtil
14
14
  import mns_common.constant.db_name_constant as db_name_constant
15
15
  import mns_common.component.company.company_common_service_new_api as company_common_service_new_api
16
+ from datetime import datetime
16
17
 
17
18
  mongodb_util = MongodbUtil('27017')
18
19
 
@@ -38,6 +39,8 @@ def get_stock_gdfx_free_top_10_em_api(str_day, symbol):
38
39
  return None
39
40
  stock_gdfx_free_top_10_em_df = stock_gdfx_free_top_10_em_df.fillna(0)
40
41
  stock_gdfx_free_top_10_em_df.index = stock_gdfx_free_top_10_em_df.index.astype(str)
42
+ stock_gdfx_free_top_10_em_df.drop_duplicates('shareholder_name', keep='last', inplace=True)
43
+
41
44
  return stock_gdfx_free_top_10_em_df
42
45
 
43
46
 
@@ -58,6 +61,7 @@ def get_stock_gdfx_top_10_em_api(str_day, symbol):
58
61
  return None
59
62
  stock_gdfx_top_10_em_df = stock_gdfx_top_10_em_df.fillna(0)
60
63
  stock_gdfx_top_10_em_df.index = stock_gdfx_top_10_em_df.index.astype(str)
64
+ stock_gdfx_top_10_em_df.drop_duplicates('shareholder_name', keep='last', inplace=True)
61
65
  return stock_gdfx_top_10_em_df
62
66
 
63
67
 
@@ -159,10 +163,34 @@ def get_stock_gdfx_free_top_10_em(str_day, symbol):
159
163
  # 保存10大流通股东
160
164
  def sync_stock_gdfx_free_top_10(stock_gdfx_free_top_10_em_df, period, symbol, str_day):
161
165
  if stock_gdfx_free_top_10_em_df is not None and stock_gdfx_free_top_10_em_df.shape[0] > 0:
166
+ # 更新日期
162
167
  stock_gdfx_free_top_10_em_df['str_day'] = str_day
168
+
163
169
  stock_gdfx_free_top_10_em_df['symbol'] = symbol
164
- stock_gdfx_free_top_10_em_df['_id'] = symbol + '_' + stock_gdfx_free_top_10_em_df.index + '_' + period
170
+
171
+ stock_gdfx_free_top_10_em_df['shares_number_str'] = stock_gdfx_free_top_10_em_df['shares_number'].astype(str)
172
+
173
+ stock_gdfx_free_top_10_em_df[
174
+ '_id'] = symbol + '_' + period + '_' + stock_gdfx_free_top_10_em_df.shares_number_str
165
175
  stock_gdfx_free_top_10_em_df['period'] = period
176
+
177
+ query_exist = {'symbol': symbol, 'period': period}
178
+ exist_df = mongodb_util.find_query_data(db_name_constant.STOCK_GDFX_FREE_TOP_10, query_exist)
179
+ now_date = datetime.now()
180
+ str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
181
+ # 不存在的时候更新创建时间
182
+ if exist_df.shape[0] == 0:
183
+ stock_gdfx_free_top_10_em_df['create_day'] = str_day
184
+ stock_gdfx_free_top_10_em_df['sync_time'] = str_now_date
185
+ else:
186
+ if 'create_day' in exist_df.columns:
187
+ stock_gdfx_free_top_10_em_df['create_day'] = list(exist_df['create_day'])[0]
188
+ else:
189
+ stock_gdfx_free_top_10_em_df['create_day'] = str_day
190
+ if 'sync_time' in exist_df.columns:
191
+ stock_gdfx_free_top_10_em_df['sync_time'] = list(exist_df['sync_time'])[0]
192
+ else:
193
+ stock_gdfx_free_top_10_em_df['sync_time'] = str_now_date
166
194
  mongodb_util.save_mongo(stock_gdfx_free_top_10_em_df, db_name_constant.STOCK_GDFX_FREE_TOP_10)
167
195
 
168
196
 
@@ -171,27 +199,54 @@ def sync_stock_gdfx_top_10(stock_gdfx_top_10_em_df, period, symbol, str_day):
171
199
  if stock_gdfx_top_10_em_df is not None and stock_gdfx_top_10_em_df.shape[0] > 0:
172
200
  stock_gdfx_top_10_em_df['str_day'] = str_day
173
201
  stock_gdfx_top_10_em_df['symbol'] = symbol
174
- stock_gdfx_top_10_em_df['_id'] = symbol + '_' + stock_gdfx_top_10_em_df.index + '_' + period
202
+
203
+ stock_gdfx_top_10_em_df['shares_number_str'] = stock_gdfx_top_10_em_df['shares_number'].astype(str)
204
+
205
+ stock_gdfx_top_10_em_df['_id'] = symbol + '_' + period + '_' + stock_gdfx_top_10_em_df.shares_number_str
175
206
  stock_gdfx_top_10_em_df['period'] = period
207
+
208
+ query_exist = {'symbol': symbol, 'period': period}
209
+ exist_df = mongodb_util.find_query_data(db_name_constant.STOCK_GDFX_TOP_10, query_exist)
210
+ now_date = datetime.now()
211
+ str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
212
+
213
+ # 不存在的时候更新创建时间
214
+ if exist_df.shape[0] == 0:
215
+ stock_gdfx_top_10_em_df['create_day'] = str_day
216
+ stock_gdfx_top_10_em_df['sync_time'] = str_now_date
217
+ else:
218
+ if 'create_day' in exist_df.columns:
219
+ stock_gdfx_top_10_em_df['create_day'] = list(exist_df['create_day'])[0]
220
+
221
+
222
+ else:
223
+ stock_gdfx_top_10_em_df['create_day'] = str_day
224
+
225
+ if 'sync_time' in exist_df.columns:
226
+ stock_gdfx_top_10_em_df['sync_time'] = list(exist_df['sync_time'])[0]
227
+ else:
228
+ stock_gdfx_top_10_em_df['sync_time'] = str_now_date
229
+
176
230
  mongodb_util.save_mongo(stock_gdfx_top_10_em_df, db_name_constant.STOCK_GDFX_TOP_10)
177
231
 
178
232
 
179
233
  # 十大股东+十大流通股东
180
234
  def sync_stock_gdfx_free_top_10_one_day(str_day):
181
- real_time_quotes = east_money_stock_api.get_real_time_quotes_all_stocks()
235
+ real_time_quotes = em_stock_info_api.get_a_stock_info()
182
236
  real_time_quotes = real_time_quotes.loc[~(
183
237
  real_time_quotes['symbol'].isin(company_common_service_new_api.get_de_list_company()))]
184
238
  for real_time_one in real_time_quotes.itertuples():
185
239
  try:
186
240
  get_stock_gdfx_free_top_10_em(str_day, real_time_one.symbol)
241
+ logger.info('同步股票前十大流通东:{},{}', real_time_one.symbol, real_time_one.name)
187
242
  except BaseException as e:
188
243
  logger.error('同步所有股票前十大流通股本异常:{},{}', real_time_one.symbol, e)
244
+ logger.info('同步所有股票股东列表完成:{}', str_day)
189
245
 
190
246
 
191
- from datetime import datetime
192
-
193
247
  if __name__ == '__main__':
194
- now_date = datetime.now()
195
- str_day_test = now_date.strftime('%Y-%m-%d')
248
+ get_stock_gdfx_free_top_10_em('20250930', '300697')
249
+ now_date_test = datetime.now()
250
+ str_day_test = now_date_test.strftime('%Y-%m-%d')
196
251
  logger.info('同步所有股票前十大流通股本')
197
- get_stock_gdfx_free_top_10_em(str_day_test, '833580')
252
+ sync_stock_gdfx_free_top_10_one_day(str_day_test)
@@ -0,0 +1,7 @@
1
+ import sys
2
+ import os
3
+
4
+ file_path = os.path.abspath(__file__)
5
+ end = file_path.index('mns') + 16
6
+ project_path = file_path[0:end]
7
+ sys.path.append(project_path)