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.
- mns_common/api/akshare/__init__.py +0 -1
- mns_common/api/akshare/k_line_api.py +20 -82
- mns_common/api/akshare/stock_bid_ask_api.py +22 -97
- mns_common/api/akshare/stock_zb_pool.py +2 -0
- mns_common/api/akshare/stock_zt_pool_api.py +1 -1
- mns_common/api/em/gd/__init__.py +7 -0
- 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
- mns_common/api/em/real_time/__init__.py +7 -0
- mns_common/api/em/{east_money_debt_api.py → real_time/east_money_debt_api.py} +154 -69
- mns_common/api/em/{east_money_etf_api.py → real_time/east_money_etf_api.py} +149 -27
- mns_common/api/em/real_time/east_money_stock_a_api.py +301 -0
- mns_common/api/em/real_time/east_money_stock_a_v2_api.py +340 -0
- mns_common/api/em/real_time/east_money_stock_common_api.py +174 -0
- mns_common/api/em/real_time/east_money_stock_hk_api.py +288 -0
- mns_common/api/em/real_time/east_money_stock_hk_gtt_api.py +260 -0
- mns_common/api/em/real_time/east_money_stock_multi_thread_api_v3.py +154 -0
- mns_common/api/em/{east_money_stock_us_api.py → real_time/east_money_stock_us_api.py} +149 -72
- mns_common/api/em/real_time/real_time_quotes_repeat_api.py +195 -0
- mns_common/api/k_line/stock_k_line_data_api.py +11 -1
- mns_common/api/k_line/stock_minute_data_api.py +1 -0
- mns_common/api/kpl/common/kpl_common_api.py +35 -0
- mns_common/api/kpl/symbol/symbol_his_quotes_api.py +1 -1
- mns_common/api/proxies/__init__.py +7 -0
- mns_common/api/proxies/liu_guan_proxy_api.py +115 -0
- mns_common/api/ths/company/company_product_area_industry_index_query.py +46 -0
- mns_common/api/ths/company/ths_company_info_api.py +13 -9
- mns_common/api/ths/company/ths_company_info_web.py +159 -0
- mns_common/api/ths/concept/app/ths_concept_index_app.py +3 -1
- mns_common/api/ths/wen_cai/ths_wen_cai_api.py +10 -7
- mns_common/api/ths/zt/ths_stock_zt_pool_api.py +21 -4
- mns_common/api/ths/zt/ths_stock_zt_pool_v2_api.py +111 -40
- mns_common/api/xueqiu/__init__.py +7 -0
- mns_common/api/xueqiu/xue_qiu_k_line_api.py +83 -0
- mns_common/component/__init__.py +1 -1
- mns_common/component/classify/symbol_classify_api.py +7 -7
- mns_common/component/common_service_fun_api.py +66 -6
- mns_common/component/company/company_common_service_api.py +21 -1
- mns_common/component/company/company_common_service_new_api.py +4 -1
- mns_common/component/cookie/cookie_enum.py +15 -0
- mns_common/component/cookie/cookie_info_service.py +9 -4
- mns_common/component/data/data_init_api.py +13 -8
- mns_common/component/deal/deal_service_api.py +70 -8
- mns_common/component/deal/deal_service_v2_api.py +167 -0
- mns_common/component/em/__init__.py +7 -0
- mns_common/component/em/em_real_time_quotes_api.py +56 -0
- mns_common/component/em/em_stock_info_api.py +48 -0
- mns_common/component/exception/ExceptionMonitor.py +86 -0
- mns_common/component/exception/__init__.py +7 -0
- mns_common/component/k_line/common/k_line_common_service_api.py +4 -0
- mns_common/component/main_line/__init__.py +7 -0
- mns_common/component/main_line/main_line_zt_reason_service.py +237 -0
- mns_common/component/proxies/__init__.py +7 -0
- mns_common/component/proxies/proxy_common_api.py +252 -0
- mns_common/component/self_choose/__init__.py +13 -0
- mns_common/component/tfp/stock_tfp_api.py +82 -12
- mns_common/component/us/__init__.py +7 -0
- mns_common/component/us/us_stock_etf_info_api.py +125 -0
- mns_common/constant/__init__.py +1 -0
- mns_common/constant/db_name_constant.py +65 -34
- mns_common/constant/extra_income_db_name.py +154 -0
- mns_common/constant/strategy_classify.py +72 -0
- mns_common/db/MongodbUtil.py +2 -1
- mns_common/db/MongodbUtilLocal.py +1 -0
- mns_common/db/v2/MongodbUtilV2.py +0 -4
- mns_common-1.5.7.2.dist-info/METADATA +4 -0
- {mns_common-1.3.3.5.dist-info → mns_common-1.5.7.2.dist-info}/RECORD +70 -45
- {mns_common-1.3.3.5.dist-info → mns_common-1.5.7.2.dist-info}/WHEEL +1 -1
- mns_common/api/em/east_money_stock_api.py +0 -222
- mns_common/api/em/east_money_stock_hk_api.py +0 -318
- mns_common/api/em/east_money_stock_v2_api.py +0 -219
- mns_common/api/ths/concept/web/ths_company_info_web.py +0 -163
- mns_common/component/qmt/qmt_buy_service.py +0 -172
- mns_common-1.3.3.5.dist-info/METADATA +0 -4
- /mns_common/{component/qmt → api/em/concept}/__init__.py +0 -0
- /mns_common/api/em/{em_concept_index_api.py → concept/em_concept_index_api.py} +0 -0
- {mns_common-1.3.3.5.dist-info → mns_common-1.5.7.2.dist-info}/top_level.txt +0 -0
|
@@ -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()
|
mns_common/constant/__init__.py
CHANGED
|
@@ -5,6 +5,28 @@ 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
|
+
# 东方财富a股信息
|
|
10
|
+
EM_A_STOCK_INFO = 'em_a_stock_info'
|
|
11
|
+
|
|
12
|
+
# 东方财富ETF信息
|
|
13
|
+
EM_ETF_INFO = 'em_etf_info'
|
|
14
|
+
|
|
15
|
+
# 东方财富KZZ信息
|
|
16
|
+
EM_KZZ_INFO = 'em_kzz_info'
|
|
17
|
+
|
|
18
|
+
# 东方财富HK股信息
|
|
19
|
+
EM_HK_STOCK_INFO = 'em_hk_stock_info'
|
|
20
|
+
|
|
21
|
+
# 东方财富US股信息
|
|
22
|
+
EM_US_STOCK_INFO = 'em_us_stock_info'
|
|
23
|
+
|
|
24
|
+
# ip代理池
|
|
25
|
+
IP_PROXY_POOL = 'ip_proxy_pool'
|
|
26
|
+
|
|
27
|
+
# ip代理城市信息
|
|
28
|
+
IP_PROXY_CITY_PROVINCE = 'ip_proxy_city_province'
|
|
29
|
+
|
|
8
30
|
# 大单同步表
|
|
9
31
|
BIG_DEAL_NAME = "ths_big_deal_fund"
|
|
10
32
|
# 大单选择表
|
|
@@ -35,14 +57,10 @@ THS_STOCK_CONCEPT_DETAIL_APP = "ths_stock_concept_detail_app"
|
|
|
35
57
|
|
|
36
58
|
# 今日排除买入股票
|
|
37
59
|
TODAY_EXCLUDE_STOCK = "today_exclude_stocks"
|
|
60
|
+
|
|
38
61
|
# 今日买入股票
|
|
39
62
|
BUY_STOCK_NAME = 'trade_stocks'
|
|
40
63
|
|
|
41
|
-
# 公司信息表
|
|
42
|
-
COMPANY_INFO = 'company_info'
|
|
43
|
-
# 公司信息历史表
|
|
44
|
-
COMPANY_INFO_HIS = 'company_info_his'
|
|
45
|
-
|
|
46
64
|
# TODAY_NEW_CONCEPT_LIST
|
|
47
65
|
TODAY_NEW_CONCEPT_LIST = 'today_new_concept_list'
|
|
48
66
|
|
|
@@ -55,11 +73,14 @@ KPL_BEST_CHOOSE_DAILY = 'kpl_best_choose_daily'
|
|
|
55
73
|
# 当前持仓股票
|
|
56
74
|
POSITION_STOCK = 'position_stock'
|
|
57
75
|
|
|
76
|
+
# 订单委托表
|
|
77
|
+
STOCK_TRADE_ORDERS = 'stock_trade_orders'
|
|
78
|
+
|
|
58
79
|
# 个股黑名单
|
|
59
80
|
SELF_BLACK_STOCK = 'self_black_stock'
|
|
60
|
-
#
|
|
81
|
+
# 长期自选板块
|
|
61
82
|
SELF_CHOOSE_PLATE = 'self_choose_plate'
|
|
62
|
-
#
|
|
83
|
+
# 长期自选个股
|
|
63
84
|
SELF_CHOOSE_STOCK = 'self_choose_stock'
|
|
64
85
|
|
|
65
86
|
# 今日自选个股
|
|
@@ -97,7 +118,10 @@ STOCK_INTERACTIVE_QUESTION = 'stock_interactive_question'
|
|
|
97
118
|
|
|
98
119
|
# 上交所 互动ID映射代码
|
|
99
120
|
|
|
100
|
-
|
|
121
|
+
SH_INFO_UID = 'sh_info_uid'
|
|
122
|
+
|
|
123
|
+
# 深交所 互动ID映射代码
|
|
124
|
+
SZ_INFO_UID = 'sz_info_uid'
|
|
101
125
|
|
|
102
126
|
# kcx 高涨幅>9.5 当天开盘数据
|
|
103
127
|
KCX_HIGH_CHG_OPEN_DATA = 'realtime_quotes_now_zt_new_kc_open'
|
|
@@ -116,9 +140,6 @@ KZZ_DEBT_INFO = 'kzz_debt_info'
|
|
|
116
140
|
# 交易配置信息
|
|
117
141
|
TRADE_CONFIG_INFO = 'trade_config_info'
|
|
118
142
|
|
|
119
|
-
# 公司备注信息
|
|
120
|
-
COMPANY_REMARK_INFO = 'company_remark_info'
|
|
121
|
-
|
|
122
143
|
# 打板待选
|
|
123
144
|
DA_BAN_SELF_CHOOSE = 'da_ban_self_choose'
|
|
124
145
|
# 打板排除
|
|
@@ -127,11 +148,28 @@ DA_BAN_SELF_EXCLUDE = 'da_ban_self_exclude'
|
|
|
127
148
|
# 港股公司行业列表
|
|
128
149
|
HK_COMPANY_INDUSTRY = 'hk_company_industry'
|
|
129
150
|
|
|
151
|
+
# 公司基本信息
|
|
152
|
+
COMPANY_BASE_INFO = 'company_base_info'
|
|
153
|
+
|
|
130
154
|
# 公司控股信息 子孙公司 联营公司
|
|
131
155
|
COMPANY_HOLDING_INFO = 'company_holding_info'
|
|
156
|
+
# 公司业务组成
|
|
157
|
+
COMPANY_BUSINESS_INFO = 'company_business_info'
|
|
158
|
+
|
|
132
159
|
# 公司公告信息
|
|
133
160
|
COMPANY_ANNOUNCE_INFO = 'company_announce_info'
|
|
134
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
|
+
|
|
135
173
|
# 行业和概念自己的备注
|
|
136
174
|
INDUSTRY_CONCEPT_REMARK = 'industry_concept_remark'
|
|
137
175
|
|
|
@@ -144,9 +182,6 @@ FU_PAN_NOTE = 'fu_pan_note'
|
|
|
144
182
|
# 公司停复牌
|
|
145
183
|
STOCK_TFP_INFO = 'stock_tfp_info'
|
|
146
184
|
|
|
147
|
-
# 公司停复牌
|
|
148
|
-
STOCK_TFP_INFO = 'stock_tfp_info'
|
|
149
|
-
|
|
150
185
|
# 隔夜打板
|
|
151
186
|
OVER_NIGHT_DA_BAN = 'over_night_da_ban'
|
|
152
187
|
|
|
@@ -162,27 +197,23 @@ THS_INDUSTRY_LIST = 'ths_industry_list'
|
|
|
162
197
|
# 同花顺行业股票详情
|
|
163
198
|
THS_STOCK_INDUSTRY_DETAIL = 'ths_stock_industry_detail'
|
|
164
199
|
|
|
165
|
-
#
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
# 北交所分钟集合数据
|
|
169
|
-
ONE_MINUTE_K_LINE_BFQ_BJ = 'one_minute_k_line_bfq_bj'
|
|
170
|
-
|
|
171
|
-
# 上海主板分钟集合数据
|
|
172
|
-
ONE_MINUTE_K_LINE_BFQ_H = 'one_minute_k_line_bfq_h'
|
|
200
|
+
# 年k线前复权
|
|
201
|
+
STOCK_QFQ_YEAR = 'stock_qfq_year'
|
|
173
202
|
|
|
174
|
-
#
|
|
175
|
-
|
|
203
|
+
# 涨停原因 详情
|
|
204
|
+
ZT_REASON_ANALYSIS = 'zt_reason_analysis'
|
|
205
|
+
# 主线详情
|
|
206
|
+
MAIN_LINE_DETAIL = 'main_line_detail'
|
|
176
207
|
|
|
177
|
-
#
|
|
178
|
-
|
|
208
|
+
# 主线龙头
|
|
209
|
+
MAIN_LINE_LEADER = 'main_line_leader'
|
|
179
210
|
|
|
180
|
-
#
|
|
181
|
-
|
|
211
|
+
# 自选主线列表
|
|
212
|
+
MAIN_LINE_LIST = 'main_line_list'
|
|
182
213
|
|
|
183
|
-
#
|
|
184
|
-
|
|
185
|
-
#
|
|
186
|
-
|
|
187
|
-
#
|
|
188
|
-
|
|
214
|
+
# 整体选择表
|
|
215
|
+
STRATEGY_TOTAL_CHOOSE_PARAM = 'strategy_total_choose_param'
|
|
216
|
+
# k 线参数表
|
|
217
|
+
STRATEGY_K_LINE_PARAM = 'strategy_k_line_param'
|
|
218
|
+
# 评分参数
|
|
219
|
+
STRATEGY_SCORE_PARAM = 'strategy_score_param'
|
|
@@ -0,0 +1,154 @@
|
|
|
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)
|
|
8
|
+
|
|
9
|
+
# db_name
|
|
10
|
+
######################################[数据库]##############################################################
|
|
11
|
+
EXTRA_INCOME = 'extraIncome'
|
|
12
|
+
|
|
13
|
+
# us_stock 美股信息数据表
|
|
14
|
+
US_STOCK = 'us_stock'
|
|
15
|
+
# a股数据表
|
|
16
|
+
A_STOCK = 'a_stock'
|
|
17
|
+
# hk股票数据
|
|
18
|
+
HK_STOCK = 'hk_stock'
|
|
19
|
+
######################################[集合表]##############################################################
|
|
20
|
+
# 东方财富a股信息
|
|
21
|
+
EM_A_STOCK_INFO = 'em_a_stock_info'
|
|
22
|
+
|
|
23
|
+
# 东方财富A股 ETF信息
|
|
24
|
+
EM_ETF_INFO = 'em_etf_info'
|
|
25
|
+
|
|
26
|
+
# 东方财富A股 KZZ信息
|
|
27
|
+
EM_KZZ_INFO = 'em_kzz_info'
|
|
28
|
+
|
|
29
|
+
# 东方财富HK股信息
|
|
30
|
+
EM_HK_STOCK_INFO = 'em_hk_stock_info'
|
|
31
|
+
|
|
32
|
+
# 东方财富港股通信息
|
|
33
|
+
EM_HK_GGT_STOCK_INFO = 'em_hk_ggt_stock_info'
|
|
34
|
+
|
|
35
|
+
# 创业板分钟集合数据
|
|
36
|
+
ONE_MINUTE_K_LINE_BFQ_C = 'one_minute_k_line_bfq_c'
|
|
37
|
+
|
|
38
|
+
# 北交所分钟集合数据
|
|
39
|
+
ONE_MINUTE_K_LINE_BFQ_BJ = 'one_minute_k_line_bfq_bj'
|
|
40
|
+
|
|
41
|
+
# 上海主板分钟集合数据
|
|
42
|
+
ONE_MINUTE_K_LINE_BFQ_H = 'one_minute_k_line_bfq_h'
|
|
43
|
+
|
|
44
|
+
# 科创板分钟集合数据
|
|
45
|
+
ONE_MINUTE_K_LINE_BFQ_K = 'one_minute_k_line_bfq_k'
|
|
46
|
+
|
|
47
|
+
# 深圳主板分钟集合数据
|
|
48
|
+
ONE_MINUTE_K_LINE_BFQ_S = 'one_minute_k_line_bfq_s'
|
|
49
|
+
|
|
50
|
+
# 可转债分钟集合数据
|
|
51
|
+
ONE_MINUTE_K_LINE_BFQ_KZZ = 'one_minute_k_line_bfq_kzz'
|
|
52
|
+
|
|
53
|
+
# ETF分钟集合数据
|
|
54
|
+
ONE_MINUTE_K_LINE_BFQ_ETF = 'one_minute_k_line_bfq_etf'
|
|
55
|
+
|
|
56
|
+
# 沪深主要指数分钟集合数据
|
|
57
|
+
ONE_MINUTE_K_LINE_BFQ_MAIN_INDEX = 'one_minute_k_line_bfq_main_index'
|
|
58
|
+
# 沪深主要指数前复权k线
|
|
59
|
+
INDEX_QFQ_DAILY = 'index_qfq_daily'
|
|
60
|
+
|
|
61
|
+
# 可转债qfq 日k线
|
|
62
|
+
KZZ_QFQ_DAILY = 'kzz_qfq_daily'
|
|
63
|
+
# ETF qfq 日k线
|
|
64
|
+
ETF_QFQ_DAILY = 'etf_qfq_daily'
|
|
65
|
+
|
|
66
|
+
# 一分钟同步失败集合
|
|
67
|
+
|
|
68
|
+
ONE_MINUTE_SYNC_FAIL = 'one_minute_sync_fail'
|
|
69
|
+
|
|
70
|
+
# us stock daily_k_line
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# 雪球利润表
|
|
74
|
+
XUE_QIU_LRB_INCOME = 'xue_qiu_lrb_income'
|
|
75
|
+
|
|
76
|
+
# 雪球资产负债表
|
|
77
|
+
XUE_QIU_ASSET_DEBT = 'xue_qiu_asset_debt'
|
|
78
|
+
|
|
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'
|
|
101
|
+
|
|
102
|
+
# hk stock daily_k_line
|
|
103
|
+
HK_STOCK_DAILY_QFQ_K_LINE = 'hk_stock_daily_qfq_k_line'
|
|
104
|
+
# hk stock 1分钟集合数据
|
|
105
|
+
HK_STOCK_MINUTE_K_LINE_BFQ = 'hk_stock_one_minute_k_line_bfq'
|
|
106
|
+
|
|
107
|
+
# hk etf 1分钟集合数据
|
|
108
|
+
HK_ETF_MINUTE_K_LINE_BFQ = 'hk_etf_one_minute_k_line_bfq'
|
|
109
|
+
|
|
110
|
+
# todo US 美股
|
|
111
|
+
# 东方财富US股信息
|
|
112
|
+
US_STOCK_INFO_EM = 'us_stock_info_em'
|
|
113
|
+
|
|
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'
|
|
145
|
+
|
|
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'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class StrategyClassify(Enum):
|
|
5
|
+
# 731 到无穷天的股票 kc
|
|
6
|
+
KC_NORMAL = ('kc_normal', 'kc_normal')
|
|
7
|
+
|
|
8
|
+
# 365 到730的股票 kc
|
|
9
|
+
KC_NORMAL_SUB = ('kc_normal_sub', 'kc_normal_sub')
|
|
10
|
+
|
|
11
|
+
# 100 到 365 天的股票 kc
|
|
12
|
+
KC_SUB = ('kc_sub', 'kc_sub')
|
|
13
|
+
|
|
14
|
+
# 6 到 100的股票 kc
|
|
15
|
+
KC_SUB_NEW = ('kc_sub_new', 'kc_sub_new')
|
|
16
|
+
|
|
17
|
+
# 731 到无穷天的股票 sh
|
|
18
|
+
SH_NORMAL = ('sh_normal', 'sh_normal')
|
|
19
|
+
|
|
20
|
+
# 365 到730的股票 sh
|
|
21
|
+
SH_NORMAL_SUB = ('sh_normal_sub', 'sh_normal_sub')
|
|
22
|
+
|
|
23
|
+
# 100 到 365天的股票 sh
|
|
24
|
+
SH_SUB = ('sh_sub', 'sh_sub')
|
|
25
|
+
|
|
26
|
+
# 6 到 100的股票 sh
|
|
27
|
+
SH_SUB_NEW = ('sh_sub_new', 'sh_sub_new')
|
|
28
|
+
|
|
29
|
+
# 北交所股票 普通
|
|
30
|
+
BJS_NORMAL = ('bjs_normal', 'bjs_normal')
|
|
31
|
+
|
|
32
|
+
# 北交所股票 次新
|
|
33
|
+
BJS_SUB_NEW = ('bjs_sub_new', 'bjs_sub_new')
|
|
34
|
+
|
|
35
|
+
# 上市交易 1-5天的股票
|
|
36
|
+
NEW_STOCK = ('new_stock', 'new_stock')
|
|
37
|
+
|
|
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')
|
|
46
|
+
|
|
47
|
+
# 所有策略
|
|
48
|
+
ALL = ('all', '所有')
|
|
49
|
+
|
|
50
|
+
def __init__(self, strategy_code, strategy_name):
|
|
51
|
+
self.strategy_name = strategy_name
|
|
52
|
+
self.strategy_code = strategy_code
|
|
53
|
+
|
|
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
|
+
|
|
60
|
+
class StrategyTimePeriod(Enum):
|
|
61
|
+
# 第一阶段
|
|
62
|
+
FIRST_PERIOD = ('first_period', 'first_period')
|
|
63
|
+
# 第二阶段
|
|
64
|
+
SECOND_PERIOD = ('second_period', 'second_period')
|
|
65
|
+
# 第三阶段
|
|
66
|
+
THIRD_PERIOD = ('third_period', 'third_period')
|
|
67
|
+
# 集合竞价阶段
|
|
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
|
mns_common/db/MongodbUtil.py
CHANGED
|
@@ -10,11 +10,12 @@ import pymongo
|
|
|
10
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
|
+
# 忽略所有警告
|
|
15
17
|
warnings.filterwarnings("ignore")
|
|
16
18
|
|
|
17
|
-
|
|
18
19
|
class MongodbUtil:
|
|
19
20
|
def __init__(self, port):
|
|
20
21
|
self.port = port
|
|
@@ -10,9 +10,6 @@ import pymongo
|
|
|
10
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
|
-
import warnings
|
|
14
|
-
|
|
15
|
-
warnings.filterwarnings("ignore")
|
|
16
13
|
|
|
17
14
|
|
|
18
15
|
class MongodbUtilV2:
|
|
@@ -272,7 +269,6 @@ from io import StringIO
|
|
|
272
269
|
import re
|
|
273
270
|
|
|
274
271
|
if __name__ == '__main__':
|
|
275
|
-
mongodb_util = MongodbUtil('27017')
|
|
276
272
|
#
|
|
277
273
|
# kpl_best_choose_index_df = mongodb_util.find_page_skip_data('kpl_best_choose_index', {"index_class": "sub_index"},
|
|
278
274
|
# 1, 100, 'create_time', True)
|