mns-common 1.4.1.8__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 (50) hide show
  1. mns_common/api/akshare/__init__.py +0 -1
  2. mns_common/api/akshare/k_line_api.py +19 -2
  3. mns_common/api/akshare/stock_bid_ask_api.py +10 -3
  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/east_money_stock_gdfx_free_top_10_api.py +62 -7
  7. mns_common/api/em/real_time/__init__.py +1 -1
  8. mns_common/api/em/real_time/east_money_debt_api.py +140 -70
  9. mns_common/api/em/real_time/east_money_etf_api.py +138 -27
  10. mns_common/api/em/real_time/east_money_stock_a_api.py +24 -28
  11. mns_common/api/em/real_time/east_money_stock_a_v2_api.py +97 -53
  12. mns_common/api/em/real_time/east_money_stock_common_api.py +174 -0
  13. mns_common/api/em/real_time/east_money_stock_hk_api.py +223 -272
  14. mns_common/api/em/real_time/east_money_stock_hk_gtt_api.py +260 -0
  15. mns_common/api/em/real_time/east_money_stock_multi_thread_api_v3.py +154 -0
  16. mns_common/api/em/real_time/east_money_stock_us_api.py +146 -82
  17. mns_common/api/em/real_time/real_time_quotes_repeat_api.py +195 -0
  18. mns_common/api/k_line/stock_k_line_data_api.py +11 -1
  19. mns_common/api/kpl/common/kpl_common_api.py +35 -0
  20. mns_common/api/proxies/liu_guan_proxy_api.py +55 -5
  21. mns_common/api/ths/company/company_product_area_industry_index_query.py +46 -0
  22. mns_common/api/ths/company/ths_company_info_api.py +2 -1
  23. mns_common/api/ths/company/ths_company_info_web.py +159 -0
  24. mns_common/api/ths/concept/app/ths_concept_index_app.py +3 -1
  25. mns_common/api/ths/wen_cai/ths_wen_cai_api.py +1 -1
  26. mns_common/api/ths/zt/ths_stock_zt_pool_api.py +20 -1
  27. mns_common/api/ths/zt/ths_stock_zt_pool_v2_api.py +105 -29
  28. mns_common/api/xueqiu/xue_qiu_k_line_api.py +2 -2
  29. mns_common/component/common_service_fun_api.py +26 -6
  30. mns_common/component/data/data_init_api.py +13 -8
  31. mns_common/component/deal/deal_service_api.py +70 -8
  32. mns_common/component/deal/deal_service_v2_api.py +167 -0
  33. mns_common/component/em/em_stock_info_api.py +9 -3
  34. mns_common/component/main_line/main_line_zt_reason_service.py +237 -0
  35. mns_common/component/proxies/proxy_common_api.py +141 -45
  36. mns_common/component/us/us_stock_etf_info_api.py +125 -0
  37. mns_common/constant/db_name_constant.py +40 -16
  38. mns_common/constant/extra_income_db_name.py +79 -19
  39. mns_common/constant/strategy_classify.py +17 -2
  40. mns_common/db/MongodbUtil.py +3 -0
  41. mns_common/db/MongodbUtilLocal.py +3 -0
  42. {mns_common-1.4.1.8.dist-info → mns_common-1.5.7.2.dist-info}/METADATA +1 -1
  43. {mns_common-1.4.1.8.dist-info → mns_common-1.5.7.2.dist-info}/RECORD +47 -41
  44. mns_common/api/ths/concept/web/ths_company_info_web.py +0 -163
  45. mns_common/component/qmt/qmt_buy_service.py +0 -172
  46. mns_common/component/task/real_time_data_sync_check.py +0 -110
  47. /mns_common/component/{qmt → main_line}/__init__.py +0 -0
  48. /mns_common/component/{task → us}/__init__.py +0 -0
  49. {mns_common-1.4.1.8.dist-info → mns_common-1.5.7.2.dist-info}/WHEEL +0 -0
  50. {mns_common-1.4.1.8.dist-info → mns_common-1.5.7.2.dist-info}/top_level.txt +0 -0
@@ -12,7 +12,6 @@ import mns_common.utils.data_frame_util as data_frame_util
12
12
  from mns_common.db.MongodbUtil import MongodbUtil
13
13
  import mns_common.constant.db_name_constant as db_name_constant
14
14
  import datetime
15
- import requests
16
15
  import time
17
16
  from loguru import logger
18
17
  from functools import lru_cache
@@ -21,71 +20,81 @@ import threading
21
20
 
22
21
  mongodb_util = MongodbUtil('27017')
23
22
 
23
+ IP_POOL = 'ip_pool'
24
+ ONE_IP = 'one_ip'
25
+ query_one = {'ip_type': ONE_IP}
26
+ query_pool = {'ip_type': IP_POOL}
27
+
24
28
 
25
29
  def query_liu_guan_proxy_ip():
26
- ip_proxy_pool = mongodb_util.find_all_data(db_name_constant.IP_PROXY_POOL)
30
+ ip_proxy_pool = mongodb_util.find_query_data(db_name_constant.IP_PROXY_POOL, query_one)
27
31
  return ip_proxy_pool
28
32
 
29
33
 
30
- def remove_proxy_ip():
31
- mongodb_util.remove_data({}, db_name_constant.IP_PROXY_POOL)
34
+ def remove_one_proxy_ip():
35
+ mongodb_util.remove_data(query_one, db_name_constant.IP_PROXY_POOL)
32
36
 
33
37
 
34
38
  def check_valid(ip_proxy_pool):
35
39
  effect_time = list(ip_proxy_pool['effect_time'])[0]
36
-
37
40
  now_date = datetime.datetime.now()
38
-
39
41
  str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
40
-
41
42
  if effect_time > str_now_date:
42
43
  return True
43
44
  else:
44
- remove_proxy_ip()
45
+ remove_one_proxy_ip()
45
46
  return False
46
47
 
47
48
 
48
49
  @lru_cache(maxsize=None)
49
50
  def get_account_cache():
50
- query = {"type": "liu_guan_proxy", }
51
+ query = {"type": "liu_guan_proxy"}
51
52
  return mongodb_util.find_query_data(db_name_constant.STOCK_ACCOUNT_INFO, query)
52
53
 
53
54
 
54
55
  def generate_proxy_ip_api(minutes):
55
- stock_account_info = get_account_cache()
56
- order_id = list(stock_account_info['password'])[0]
57
- secret = list(stock_account_info['account'])[0]
58
- # 获取10分钟动态ip
59
- ip = liu_guan_proxy_api.get_proxy_api(order_id, secret, str(60 * minutes))
60
- return ip
56
+ try_numer = 3
57
+ while try_numer > 0:
58
+ try:
59
+ stock_account_info = get_account_cache()
60
+ order_id = list(stock_account_info['password'])[0]
61
+ secret = list(stock_account_info['account'])[0]
62
+ # 获取10分钟动态ip
63
+ liu_guan_ip = liu_guan_proxy_api.get_proxy_api(order_id, secret, str(60 * minutes))
64
+ try_numer = try_numer
65
+ logger.info("生成新的ip:{}", liu_guan_ip)
66
+ return liu_guan_ip
67
+ except BaseException as e:
68
+ logger.error("获取ip失败:{}", str(e))
69
+ time.sleep(1)
70
+ continue
61
71
 
62
72
 
63
73
  def generate_proxy_ip(minutes):
64
- ip_proxy_pool = mongodb_util.find_all_data(db_name_constant.IP_PROXY_POOL)
74
+ ip_proxy_pool = query_liu_guan_proxy_ip()
65
75
  if data_frame_util.is_not_empty(ip_proxy_pool):
66
76
  return list(ip_proxy_pool['ip'])[0]
67
77
  else:
68
- remove_proxy_ip()
78
+ remove_one_proxy_ip()
69
79
  now_date = datetime.datetime.now()
70
80
  # 加上分钟
71
81
  time_to_add = datetime.timedelta(minutes=minutes)
72
82
  new_date = now_date + time_to_add
73
83
  str_now_date = new_date.strftime('%Y-%m-%d %H:%M:%S')
74
- # 获取10分钟动态ip
75
- while True:
76
- remove_proxy_ip()
77
- ip = generate_proxy_ip_api(minutes)
78
- if check_proxy(ip):
79
- result_dict = {"_id": ip,
80
- 'effect_time': str_now_date,
81
- 'ip': ip}
82
- result_df = pd.DataFrame(result_dict, index=[1])
83
-
84
- mongodb_util.insert_mongo(result_df, db_name_constant.IP_PROXY_POOL)
85
- break
86
- else:
87
- time.sleep(0.5)
88
- return ip
84
+ try:
85
+ ip_proxy = generate_proxy_ip_api(minutes)
86
+
87
+ result_dict = {"_id": ip_proxy,
88
+ 'ip_type': ONE_IP,
89
+ 'effect_time': str_now_date,
90
+ 'ip': ip_proxy}
91
+ result_df = pd.DataFrame(result_dict, index=[1])
92
+
93
+ mongodb_util.insert_mongo(result_df, db_name_constant.IP_PROXY_POOL)
94
+ except BaseException as e:
95
+ logger.error("获取ip失败:{}", str(e))
96
+
97
+ return ip_proxy
89
98
 
90
99
 
91
100
  def get_proxy_ip(minutes):
@@ -99,18 +108,86 @@ def get_proxy_ip(minutes):
99
108
  return generate_proxy_ip(minutes)
100
109
 
101
110
 
102
- def check_proxy(proxy_ip):
103
- try:
104
- # 两秒超时
105
- test_df = call_with_timeout(get_em_real_time_data, proxy_ip, timeout=2)
106
- if data_frame_util.is_not_empty(test_df):
107
- logger.info("可用代理ip:{}", proxy_ip)
108
- return True
111
+ #
112
+ # def check_proxy(proxy_ip):
113
+ # try:
114
+ # # 两秒超时
115
+ # test_df = call_with_timeout(get_em_real_time_data, proxy_ip, timeout=2)
116
+ # if data_frame_util.is_not_empty(test_df):
117
+ # logger.info("可用代理ip:{}", proxy_ip)
118
+ # return True
119
+ # else:
120
+ # return False
121
+ # except Exception as e:
122
+ # logger.error("代理ip不可用:{},{}", proxy_ip, e)
123
+ # return False
124
+
125
+
126
+ # 查询ip池子
127
+ def query_liu_guan_proxy_ip_pool():
128
+ ip_proxy_pool = mongodb_util.find_query_data(db_name_constant.IP_PROXY_POOL, query_pool)
129
+ return ip_proxy_pool
130
+
131
+
132
+ def remove_proxy_ip_pool():
133
+ mongodb_util.remove_data(query_pool, db_name_constant.IP_PROXY_POOL)
134
+
135
+
136
+ def generate_proxy_ip_pool_api(minutes, ip_num):
137
+ stock_account_info = get_account_cache()
138
+ order_id = list(stock_account_info['password'])[0]
139
+ secret = list(stock_account_info['account'])[0]
140
+ # 获取10分钟动态ip
141
+ ip_pool = liu_guan_proxy_api.get_proxy_pool_api(order_id, secret, str(60 * minutes), ip_num)
142
+ return ip_pool
143
+
144
+
145
+ def get_proxy_ip_pool(minutes, seconds, ip_num):
146
+ ip_proxy_pool = query_liu_guan_proxy_ip_pool()
147
+ if data_frame_util.is_empty(ip_proxy_pool):
148
+ return generate_proxy_ip_pool(minutes, seconds, ip_num)
149
+ else:
150
+ if check_valid(ip_proxy_pool):
151
+ ip_pool = list(ip_proxy_pool['ip_pool'])[0]
152
+ effect_time = list(ip_proxy_pool['effect_time'])[0]
153
+ result = {'ip_pool': ip_pool,
154
+ 'effect_time': effect_time}
155
+ return result
109
156
  else:
110
- return False
111
- except Exception as e:
112
- logger.error("代理ip不可用:{},{}", proxy_ip, e)
113
- return False
157
+ # 已经失效 移除ip pool
158
+ remove_proxy_ip_pool()
159
+ # 重新生成
160
+ return generate_proxy_ip_pool(minutes, seconds, ip_num)
161
+
162
+
163
+ # seconds 有效秒数,minutes 需要减1
164
+ def generate_proxy_ip_pool(minutes, seconds, ip_num):
165
+ ip_proxy_pool = query_liu_guan_proxy_ip_pool()
166
+ if data_frame_util.is_not_empty(ip_proxy_pool):
167
+ ip_pool = list(ip_proxy_pool['ip_pool'])[0]
168
+ effect_time = list(ip_proxy_pool['effect_time'])[0]
169
+
170
+
171
+ else:
172
+ remove_proxy_ip_pool()
173
+ now_date = datetime.datetime.now()
174
+ # 加上分钟 少10秒
175
+ time_to_add = datetime.timedelta(minutes=minutes - 1, seconds=seconds)
176
+ new_date = now_date + time_to_add
177
+ effect_time = new_date.strftime('%Y-%m-%d %H:%M:%S')
178
+ ip_pool = generate_proxy_ip_pool_api(minutes, ip_num)
179
+ result_dict = {
180
+ "_id": [IP_POOL],
181
+ 'ip_type': [IP_POOL],
182
+ 'effect_time': [effect_time],
183
+ 'ip_pool': [ip_pool] # 每个字段都包装成列表
184
+ }
185
+ result_df = pd.DataFrame(result_dict)
186
+
187
+ mongodb_util.insert_mongo(result_df, db_name_constant.IP_PROXY_POOL)
188
+ result = {'ip_pool': ip_pool,
189
+ 'effect_time': effect_time}
190
+ return result
114
191
 
115
192
 
116
193
  def get_em_real_time_data(proxy_ip):
@@ -118,7 +195,7 @@ def get_em_real_time_data(proxy_ip):
118
195
  "http": proxy_ip,
119
196
  "https": proxy_ip
120
197
  }
121
- return east_money_stock_a_api.get_stock_page_data(1, proxies, 20)
198
+ return east_money_stock_a_api.get_stock_page_data(1, proxies, 20, 10)
122
199
 
123
200
 
124
201
  # 定义一个带超时的函数调用
@@ -152,5 +229,24 @@ def call_with_timeout(func, *args, timeout=2, **kwargs):
152
229
  return result
153
230
 
154
231
 
232
+ @lru_cache(maxsize=None)
233
+ def query_province_and_city_info():
234
+ return mongodb_util.find_all_data(db_name_constant.IP_PROXY_CITY_PROVINCE)
235
+
236
+
237
+ def import_province_and_city():
238
+ # 设置文件夹路径
239
+ folder_path = r'E:\province-and-city.xlsx'
240
+ df = pd.read_excel(folder_path)
241
+ df['_id'] = df['cid']
242
+
243
+ mongodb_util.save_mongo(df, db_name_constant.IP_PROXY_CITY_PROVINCE)
244
+ return df
245
+
246
+
155
247
  if __name__ == "__main__":
156
- generate_proxy_ip(1)
248
+ stock_account_info_test = get_account_cache()
249
+ order_id_test = list(stock_account_info_test['password'])[0]
250
+ secret_test = list(stock_account_info_test['account'])[0]
251
+ # 获取10分钟动态ip
252
+ ip = liu_guan_proxy_api.get_proxy_api(order_id_test, secret_test, str(60 * 1))
@@ -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()
@@ -24,6 +24,9 @@ EM_US_STOCK_INFO = 'em_us_stock_info'
24
24
  # ip代理池
25
25
  IP_PROXY_POOL = 'ip_proxy_pool'
26
26
 
27
+ # ip代理城市信息
28
+ IP_PROXY_CITY_PROVINCE = 'ip_proxy_city_province'
29
+
27
30
  # 大单同步表
28
31
  BIG_DEAL_NAME = "ths_big_deal_fund"
29
32
  # 大单选择表
@@ -54,14 +57,10 @@ THS_STOCK_CONCEPT_DETAIL_APP = "ths_stock_concept_detail_app"
54
57
 
55
58
  # 今日排除买入股票
56
59
  TODAY_EXCLUDE_STOCK = "today_exclude_stocks"
60
+
57
61
  # 今日买入股票
58
62
  BUY_STOCK_NAME = 'trade_stocks'
59
63
 
60
- # 公司信息表
61
- COMPANY_INFO = 'company_info'
62
- # 公司信息历史表
63
- COMPANY_INFO_HIS = 'company_info_his'
64
-
65
64
  # TODAY_NEW_CONCEPT_LIST
66
65
  TODAY_NEW_CONCEPT_LIST = 'today_new_concept_list'
67
66
 
@@ -74,11 +73,14 @@ KPL_BEST_CHOOSE_DAILY = 'kpl_best_choose_daily'
74
73
  # 当前持仓股票
75
74
  POSITION_STOCK = 'position_stock'
76
75
 
76
+ # 订单委托表
77
+ STOCK_TRADE_ORDERS = 'stock_trade_orders'
78
+
77
79
  # 个股黑名单
78
80
  SELF_BLACK_STOCK = 'self_black_stock'
79
- # 自选板块
81
+ # 长期自选板块
80
82
  SELF_CHOOSE_PLATE = 'self_choose_plate'
81
- # 自选个股
83
+ # 长期自选个股
82
84
  SELF_CHOOSE_STOCK = 'self_choose_stock'
83
85
 
84
86
  # 今日自选个股
@@ -116,7 +118,10 @@ STOCK_INTERACTIVE_QUESTION = 'stock_interactive_question'
116
118
 
117
119
  # 上交所 互动ID映射代码
118
120
 
119
- SSE_INFO_UID = 'sse_info_uid'
121
+ SH_INFO_UID = 'sh_info_uid'
122
+
123
+ # 深交所 互动ID映射代码
124
+ SZ_INFO_UID = 'sz_info_uid'
120
125
 
121
126
  # kcx 高涨幅>9.5 当天开盘数据
122
127
  KCX_HIGH_CHG_OPEN_DATA = 'realtime_quotes_now_zt_new_kc_open'
@@ -135,9 +140,6 @@ KZZ_DEBT_INFO = 'kzz_debt_info'
135
140
  # 交易配置信息
136
141
  TRADE_CONFIG_INFO = 'trade_config_info'
137
142
 
138
- # 公司备注信息
139
- COMPANY_REMARK_INFO = 'company_remark_info'
140
-
141
143
  # 打板待选
142
144
  DA_BAN_SELF_CHOOSE = 'da_ban_self_choose'
143
145
  # 打板排除
@@ -146,11 +148,28 @@ DA_BAN_SELF_EXCLUDE = 'da_ban_self_exclude'
146
148
  # 港股公司行业列表
147
149
  HK_COMPANY_INDUSTRY = 'hk_company_industry'
148
150
 
151
+ # 公司基本信息
152
+ COMPANY_BASE_INFO = 'company_base_info'
153
+
149
154
  # 公司控股信息 子孙公司 联营公司
150
155
  COMPANY_HOLDING_INFO = 'company_holding_info'
156
+ # 公司业务组成
157
+ COMPANY_BUSINESS_INFO = 'company_business_info'
158
+
151
159
  # 公司公告信息
152
160
  COMPANY_ANNOUNCE_INFO = 'company_announce_info'
153
161
 
162
+ # 公司行业信息
163
+ COMPANY_INDUSTRY_INFO = 'company_industry_info'
164
+
165
+ # 公司信息临时表
166
+ COMPANY_INFO_TEMP = 'company_info_temp'
167
+
168
+ # 公司信息表
169
+ COMPANY_INFO = 'company_info'
170
+ # 公司信息历史表
171
+ COMPANY_INFO_HIS = 'company_info_his'
172
+
154
173
  # 行业和概念自己的备注
155
174
  INDUSTRY_CONCEPT_REMARK = 'industry_concept_remark'
156
175
 
@@ -163,9 +182,6 @@ FU_PAN_NOTE = 'fu_pan_note'
163
182
  # 公司停复牌
164
183
  STOCK_TFP_INFO = 'stock_tfp_info'
165
184
 
166
- # 公司停复牌
167
- STOCK_TFP_INFO = 'stock_tfp_info'
168
-
169
185
  # 隔夜打板
170
186
  OVER_NIGHT_DA_BAN = 'over_night_da_ban'
171
187
 
@@ -184,12 +200,20 @@ THS_STOCK_INDUSTRY_DETAIL = 'ths_stock_industry_detail'
184
200
  # 年k线前复权
185
201
  STOCK_QFQ_YEAR = 'stock_qfq_year'
186
202
 
187
- # 主线集合
188
- MAIN_LINE_LIST = 'main_line_list'
203
+ # 涨停原因 详情
204
+ ZT_REASON_ANALYSIS = 'zt_reason_analysis'
189
205
  # 主线详情
190
206
  MAIN_LINE_DETAIL = 'main_line_detail'
191
207
 
208
+ # 主线龙头
209
+ MAIN_LINE_LEADER = 'main_line_leader'
210
+
211
+ # 自选主线列表
212
+ MAIN_LINE_LIST = 'main_line_list'
213
+
192
214
  # 整体选择表
193
215
  STRATEGY_TOTAL_CHOOSE_PARAM = 'strategy_total_choose_param'
194
216
  # k 线参数表
195
217
  STRATEGY_K_LINE_PARAM = 'strategy_k_line_param'
218
+ # 评分参数
219
+ STRATEGY_SCORE_PARAM = 'strategy_score_param'
@@ -7,9 +7,16 @@ project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
8
 
9
9
  # db_name
10
-
10
+ ######################################[数据库]##############################################################
11
11
  EXTRA_INCOME = 'extraIncome'
12
12
 
13
+ # us_stock 美股信息数据表
14
+ US_STOCK = 'us_stock'
15
+ # a股数据表
16
+ A_STOCK = 'a_stock'
17
+ # hk股票数据
18
+ HK_STOCK = 'hk_stock'
19
+ ######################################[集合表]##############################################################
13
20
  # 东方财富a股信息
14
21
  EM_A_STOCK_INFO = 'em_a_stock_info'
15
22
 
@@ -22,11 +29,8 @@ EM_KZZ_INFO = 'em_kzz_info'
22
29
  # 东方财富HK股信息
23
30
  EM_HK_STOCK_INFO = 'em_hk_stock_info'
24
31
 
25
- # 东方财富US股信息
26
- EM_US_STOCK_INFO = 'em_us_stock_info'
27
-
28
- # 东方财富US ETF信息
29
- EM_US_ETF_INFO = 'em_us_etf_info'
32
+ # 东方财富港股通信息
33
+ EM_HK_GGT_STOCK_INFO = 'em_hk_ggt_stock_info'
30
34
 
31
35
  # 创业板分钟集合数据
32
36
  ONE_MINUTE_K_LINE_BFQ_C = 'one_minute_k_line_bfq_c'
@@ -65,16 +69,35 @@ ONE_MINUTE_SYNC_FAIL = 'one_minute_sync_fail'
65
69
 
66
70
  # us stock daily_k_line
67
71
 
68
- US_STOCK_DAILY_QFQ_K_LINE = 'us_stock_daily_qfq_k_line'
69
72
 
70
- # us stock 1分钟集合数据
71
- US_STOCK_MINUTE_K_LINE_BFQ = 'us_stock_one_minute_k_line_bfq'
73
+ # 雪球利润表
74
+ XUE_QIU_LRB_INCOME = 'xue_qiu_lrb_income'
72
75
 
73
- # us etf 1分钟集合数据
74
- US_ETF_MINUTE_K_LINE_BFQ = 'us_etf_one_minute_k_line_bfq'
76
+ # 雪球资产负债表
77
+ XUE_QIU_ASSET_DEBT = 'xue_qiu_asset_debt'
75
78
 
76
- # us 主要etf 1分钟集合数据
77
- US_MAIN_ETF_MINUTE_K_LINE_BFQ = 'us_main_etf_one_minute_k_line_bfq'
79
+ # 雪球资产现金流量表
80
+ XUE_QIU_CASH_FLOW = 'xue_qiu_cash_flow'
81
+
82
+ # todo A股日k线
83
+ # A 可转债前复权日k线
84
+ A_KZZ_QFQ_DAILY = 'a_kzz_qfq_daily'
85
+
86
+ # A ETF前复权日k线
87
+ A_ETF_QFQ_DAILY = 'a_etf_qfq_daily'
88
+
89
+ # A 股票前复权日k线
90
+ A_STOCK_QFQ_DAILY = 'a_stock_qfq_daily'
91
+
92
+ # A 指数前复权日k线
93
+ A_INDEX_QFQ_DAILY = 'a_index_qfq_daily'
94
+
95
+ # todo 港股
96
+ # HK ETF前复权日k线
97
+ HK_ETF_QFQ_DAILY = 'hk_etf_qfq_daily'
98
+
99
+ # HK 股票前复权日k线
100
+ HK_STOCK_QFQ_DAILY = 'hk_stock_qfq_daily'
78
101
 
79
102
  # hk stock daily_k_line
80
103
  HK_STOCK_DAILY_QFQ_K_LINE = 'hk_stock_daily_qfq_k_line'
@@ -84,11 +107,48 @@ HK_STOCK_MINUTE_K_LINE_BFQ = 'hk_stock_one_minute_k_line_bfq'
84
107
  # hk etf 1分钟集合数据
85
108
  HK_ETF_MINUTE_K_LINE_BFQ = 'hk_etf_one_minute_k_line_bfq'
86
109
 
87
- # 雪球利润表
88
- XUE_QIU_LRB_INCOME = 'xue_qiu_lrb_income'
110
+ # todo US 美股
111
+ # 东方财富US股信息
112
+ US_STOCK_INFO_EM = 'us_stock_info_em'
89
113
 
90
- # 雪球资产负债表
91
- XUE_QIU_ASSET_DEBT = 'xue_qiu_asset_debt'
114
+ # 东方财富US ETF信息
115
+ US_ETF_INFO_EM = 'us_etf_info_em'
116
+
117
+ # alpha_vantage US股票信息
118
+ US_STOCK_INFO_ALPHA_VANTAGE = 'us_stock_info_alpha_vantage'
119
+
120
+ # alpha_vantage US ETF信息
121
+ US_STOCK_INFO_ALPHA_VANTAGE = 'us_etf_info_alpha_vantage'
122
+ # 美股公司信息 清洗表
123
+ US_STOCK_LIST = 'us_stock_list'
124
+ # 美ETF信息 清洗表
125
+ US_ETF_LIST = 'us_etf_list'
126
+ # 美股所属行业信息
127
+ US_STOCK_INDUSTRY_LIST = 'us_stock_industry_list'
128
+ # 美股所属概念信息
129
+ US_STOCK_CONCEPT_LIST = 'us_stock_concept_list'
130
+
131
+ # todo 日k线集合
132
+ # US ETF前复权日k线
133
+ US_ETF_QFQ_DAILY = 'us_etf_qfq_daily'
134
+ # US ETF不复权日k线
135
+ US_ETF_BFQ_DAILY = 'us_etf_bfq_daily'
136
+ # US ETF后复权日k线
137
+ US_ETF_HFQ_DAILY = 'us_etf_hfq_daily'
138
+
139
+ # us stock 日k线前复权
140
+ US_STOCK_DAILY_QFQ_K_LINE = 'us_stock_daily_qfq_k_line'
141
+ # us stock 日k线不复权
142
+ US_STOCK_DAILY_BFQ_K_LINE = 'us_stock_daily_bfq_k_line'
143
+ # us stock 日k线后复权
144
+ US_STOCK_DAILY_HFQ_K_LINE = 'us_stock_daily_hfq_k_line'
92
145
 
93
- # 雪球资产现金流量表
94
- XUE_QIU_CASH_FLOW = 'xue_qiu_cash_flow'
146
+ # todo 一分钟集合
147
+ # us stock 1分钟集合数据
148
+ US_STOCK_MINUTE_K_LINE_BFQ = 'us_stock_one_minute_k_line_bfq'
149
+
150
+ # us etf 1分钟集合数据
151
+ US_ETF_MINUTE_K_LINE_BFQ = 'us_etf_one_minute_k_line_bfq'
152
+
153
+ # us 主要etf 1分钟集合数据
154
+ US_MAIN_ETF_MINUTE_K_LINE_BFQ = 'us_main_etf_one_minute_k_line_bfq'
@@ -35,8 +35,14 @@ class StrategyClassify(Enum):
35
35
  # 上市交易 1-5天的股票
36
36
  NEW_STOCK = ('new_stock', 'new_stock')
37
37
 
38
- # 集合竞价 高外盘买入
39
- HIGH_OUT_DISK_BUY = ('high_out_disk_buy', 'high_out_disk_buy')
38
+ # 集合竞价 高外盘买入 科创
39
+ HIGH_OUT_DISK_BUY_KC = ('high_out_disk_buy_kc', 'high_out_disk_buy_kc')
40
+
41
+ # 集合竞价 高外盘买入 沪深
42
+ HIGH_OUT_DISK_BUY_SH = ('high_out_disk_buy_sh', 'high_out_disk_buy_sh')
43
+
44
+ # 集合竞价 高外盘买入 北交所
45
+ HIGH_OUT_DISK_BUY_BJS = ('high_out_disk_buy_bjs', 'high_out_disk_buy_bjs')
40
46
 
41
47
  # 所有策略
42
48
  ALL = ('all', '所有')
@@ -46,6 +52,11 @@ class StrategyClassify(Enum):
46
52
  self.strategy_code = strategy_code
47
53
 
48
54
 
55
+ # 获取策略分类
56
+ def get_strategy_classify(strategy_code, data_choose_df):
57
+ return data_choose_df.loc[data_choose_df['strategy_code'] == strategy_code]
58
+
59
+
49
60
  class StrategyTimePeriod(Enum):
50
61
  # 第一阶段
51
62
  FIRST_PERIOD = ('first_period', 'first_period')
@@ -55,3 +66,7 @@ class StrategyTimePeriod(Enum):
55
66
  THIRD_PERIOD = ('third_period', 'third_period')
56
67
  # 集合竞价阶段
57
68
  CALL_AUCTION_PERIOD = ('call_auction_period', 'call_auction_period')
69
+
70
+ def __init__(self, time_code, time_name):
71
+ self.time_name = time_name
72
+ self.time_code = time_code
@@ -11,7 +11,10 @@ from mns_common.utils.async_fun import async_fun
11
11
  from loguru import logger
12
12
  import mns_common.utils.ip_util as ip_util
13
13
 
14
+ import warnings
14
15
 
16
+ # 忽略所有警告
17
+ warnings.filterwarnings("ignore")
15
18
 
16
19
  class MongodbUtil:
17
20
  def __init__(self, port):