mns-scheduler 1.0.8.7__py3-none-any.whl → 1.4.3.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_scheduler/__init__.py +1 -3
- mns_scheduler/company_info/announce/company_announce_sync_service.py +65 -0
- mns_scheduler/company_info/{company_info_sync_api.py → base/sync_company_base_info_api.py} +239 -227
- mns_scheduler/company_info/base/sync_company_hold_info_api.py +37 -0
- mns_scheduler/company_info/base/sync_company_product_area_industry.py +161 -0
- mns_scheduler/company_info/clean/company_info_clean_api.py +133 -0
- mns_scheduler/company_info/constant/company_constant_data.py +497 -0
- mns_scheduler/company_info/{de_list_stock_service.py → de_list_stock/de_list_stock_service.py} +1 -1
- mns_scheduler/company_info/em_stock_info/__init__.py +7 -0
- mns_scheduler/company_info/em_stock_info/sync_em_stock_info_sync.py +80 -0
- mns_scheduler/company_info/remark/__init__.py +7 -0
- mns_scheduler/company_info/remark/company_remark_info_sync.py +46 -0
- mns_scheduler/concept/clean/kpl_concept_clean_api.py +1 -1
- mns_scheduler/concept/clean/ths_concept_clean_api.py +74 -51
- mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py +112 -56
- mns_scheduler/concept/ths/common/ths_concept_update_common_api.py +6 -6
- mns_scheduler/concept/ths/detaill/__init__.py +0 -0
- mns_scheduler/concept/ths/detaill/ths_concept_detail_api.py +226 -0
- mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py +169 -0
- mns_scheduler/concept/ths/update_concept_info/sync_one_concept_all_symbols_api.py +11 -23
- mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py +19 -15
- mns_scheduler/db/col_move_service.py +10 -7
- mns_scheduler/db/db_status.py +1 -1
- mns_scheduler/db/script/__init__.py +7 -0
- mns_scheduler/db/script/col_move_script.py +45 -0
- mns_scheduler/db/script/db_move/__init__.py +7 -0
- mns_scheduler/db/script/db_move/col_move_one_service.py +34 -0
- mns_scheduler/db/script/sync/__init__.py +7 -0
- mns_scheduler/db/script/sync/local_mongo_util.py +231 -0
- mns_scheduler/db/script/sync/remote_data_sync_to_local.py +105 -0
- mns_scheduler/db/script/sync/remote_mongo_util.py +306 -0
- mns_scheduler/db/script/sync/sync_hui_ce_test_data.py +80 -0
- mns_scheduler/db/script/sync/sync_hui_ce_test_data_01.py +69 -0
- mns_scheduler/db/script/update/__init__.py +7 -0
- mns_scheduler/db/script/update/update_col_field.py +36 -0
- mns_scheduler/finance/__init__.py +1 -1
- mns_scheduler/finance/{em_financial_asset_liability_sync_service_api.py → em/em_financial_asset_liability_sync_service_api.py} +3 -3
- mns_scheduler/finance/{em_financial_profit_sync_service_api.py → em/em_financial_profit_sync_service_api.py} +30 -25
- mns_scheduler/finance/{finance_common_api.py → em/finance_common_api.py} +4 -4
- mns_scheduler/finance/sync_financial_report_service_task.py +202 -0
- mns_scheduler/finance/xue_qiu/down_load_xueqiu_report_api.py +77 -0
- mns_scheduler/finance/xue_qiu/sync_xue_qiu_fiance_data.py +161 -0
- mns_scheduler/hk/__init__.py +1 -1
- mns_scheduler/hk/hk_company_info_sync_service_api.py +49 -5
- mns_scheduler/hk/hk_industry_info_sync_service_api.py +68 -0
- mns_scheduler/industry/__init__.py +7 -0
- mns_scheduler/industry/ths/__init__.py +7 -0
- mns_scheduler/industry/ths/ths_industry_index_service.py +58 -0
- mns_scheduler/industry/ths/ths_industry_sync_service.py +68 -0
- mns_scheduler/irm/__init__.py +1 -1
- mns_scheduler/irm/api/__init__.py +1 -1
- mns_scheduler/irm/api/sh_stock_sns_sse_info_api.py +1 -1
- mns_scheduler/irm/api/sz_stock_sns_sse_info_api.py +1 -1
- mns_scheduler/irm/stock_irm_cninfo_service.py +15 -13
- mns_scheduler/k_line/clean/daily/__init__.py +1 -1
- mns_scheduler/k_line/clean/daily/daily_k_line_clean_common_service.py +57 -7
- mns_scheduler/k_line/clean/daily/daily_k_line_service.py +16 -3
- mns_scheduler/k_line/clean/k_line_info_clean_impl.py +3 -2
- mns_scheduler/k_line/clean/k_line_info_clean_task.py +42 -31
- mns_scheduler/k_line/clean/week_month/__init__.py +1 -1
- mns_scheduler/k_line/clean/week_month/normal_week_month_k_line_service.py +125 -27
- mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py +72 -17
- mns_scheduler/k_line/common/__init__.py +7 -0
- mns_scheduler/k_line/common/k_line_common_api.py +188 -0
- mns_scheduler/k_line/hot_stocks/__init__.py +1 -1
- mns_scheduler/k_line/hot_stocks/recent_hot_stocks_clean_service.py +1 -1
- mns_scheduler/k_line/month_week_daily/bfq_k_line_sync.py +77 -0
- mns_scheduler/k_line/{sync → month_week_daily}/daily_week_month_line_sync.py +14 -14
- mns_scheduler/k_line/sync_status/__init__.py +7 -0
- mns_scheduler/k_line/sync_status/k_line_sync_status_check.py +54 -0
- mns_scheduler/k_line/test/__init__.py +7 -0
- mns_scheduler/k_line/test/k_line_info_clean_his_data.py +41 -0
- mns_scheduler/k_line/year_quarter/__init__.py +7 -0
- mns_scheduler/k_line/year_quarter/year_quarter_line_sync.py +76 -0
- mns_scheduler/kpl/selection/symbol/sync_best_choose_symbol.py +4 -2
- mns_scheduler/kpl/selection/symbol/sync_kpl_concept_symbol_choose_reason_api.py +108 -0
- mns_scheduler/kpl/selection/total/sync_kpl_best_total_sync_api.py +12 -7
- mns_scheduler/lhb/__init__.py +1 -1
- mns_scheduler/lhb/stock_lhb_sync_service.py +1 -1
- mns_scheduler/open/__init__.py +1 -1
- mns_scheduler/open/sync_one_day_open_data_to_db_service.py +6 -22
- mns_scheduler/risk/__init__.py +1 -1
- mns_scheduler/risk/compliance/__init__.py +0 -0
- mns_scheduler/risk/compliance/undisclosed_annual_report_api.py +71 -0
- mns_scheduler/risk/financial/__init__.py +0 -0
- mns_scheduler/risk/financial/annual_report_audit_check_api.py +54 -0
- mns_scheduler/risk/financial/net_assets_check_api.py +75 -0
- mns_scheduler/risk/financial/profit_income_check_api.py +80 -0
- mns_scheduler/risk/financial/stock_equity_mortgage_check_api.py +1 -0
- mns_scheduler/risk/financial_report_risk_check_api.py +42 -0
- mns_scheduler/risk/major_violations/__init__.py +0 -0
- mns_scheduler/risk/{register_and_investigate_stock_sync_api.py → major_violations/register_and_investigate_stock_sync_api.py} +17 -8
- mns_scheduler/risk/self/__init__.py +0 -0
- mns_scheduler/risk/{wei_pan_stock_api.py → self/wei_pan_stock_api.py} +10 -4
- mns_scheduler/risk/test/__init__.py +7 -0
- mns_scheduler/{finance → risk}/test/fix_blask_list.py +6 -10
- mns_scheduler/risk/transactions/__init__.py +0 -0
- mns_scheduler/risk/transactions/transactions_check_api.py +183 -0
- mns_scheduler/self_choose/__init__.py +7 -0
- mns_scheduler/self_choose/ths_self_choose_service.py +158 -0
- mns_scheduler/trade/auto_ipo_buy_api.py +2 -2
- mns_scheduler/trade/auto_login/__init__.py +7 -0
- mns_scheduler/trade/auto_login/trader_auto_service.py +32 -0
- mns_scheduler/trade/auto_sell_service_api.py +10 -8
- mns_scheduler/trade/balance/__init__.py +7 -0
- mns_scheduler/trade/balance/ths_account_balance_service.py +7 -0
- mns_scheduler/trade/sync_position_api.py +41 -8
- mns_scheduler/trade/task/__init__.py +7 -0
- mns_scheduler/trade/task/trader_task_service.py +65 -0
- mns_scheduler/trade/tfp/__init__.py +7 -0
- mns_scheduler/trade/tfp/stock_tfp_info_sync.py +56 -0
- mns_scheduler/zb/stock_zb_pool_sync.py +1 -15
- mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py +2 -3
- mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py +12 -8
- mns_scheduler/zt/open_data/kcx_high_chg_open_data_sync.py +10 -25
- mns_scheduler/zt/script/__init__.py +1 -1
- mns_scheduler/zt/script/fix_error_deal_day.py +41 -0
- mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py +2 -11
- mns_scheduler/zt/script/sync_high_chg_pool_his_data.py +2 -2
- mns_scheduler/zt/script/sync_now_higt_chg_zt.py +43 -0
- mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py +413 -0
- mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py +193 -0
- mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py +58 -0
- mns_scheduler/zz_task/compensation/__init__.py +0 -0
- mns_scheduler/zz_task/compensation/compensate_task.py +161 -0
- mns_scheduler/zz_task/compensation/compensate_task_one_day.py +142 -0
- mns_scheduler/zz_task/data_sync_task.py +271 -121
- {mns_scheduler-1.0.8.7.dist-info → mns_scheduler-1.4.3.2.dist-info}/METADATA +1 -1
- mns_scheduler-1.4.3.2.dist-info/RECORD +169 -0
- {mns_scheduler-1.0.8.7.dist-info → mns_scheduler-1.4.3.2.dist-info}/WHEEL +1 -1
- mns_scheduler/backup/app/ths_new_concept_sync_app.py +0 -122
- mns_scheduler/backup/em/em_new_concept_his_sync.py +0 -99
- mns_scheduler/backup/em/em_new_concept_sync_common_api.py +0 -139
- mns_scheduler/backup/em/em_new_concept_sync_web.py +0 -55
- mns_scheduler/backup/wen_cai/wen_cai_concept_sync.py +0 -51
- mns_scheduler/big_deal/ths_big_deal_sync.py +0 -98
- mns_scheduler/company_info/company_constant_data.py +0 -322
- mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_by_ak_api.py +0 -103
- mns_scheduler/concept/ths/sync_new_index/sync_ths_new_concept_by_web_api.py +0 -89
- mns_scheduler/finance/financial_high_risk_stock_clean_service_api.py +0 -202
- mns_scheduler/finance/sync_financial_report_service_api.py +0 -113
- mns_scheduler/real_time/realtime_quotes_now_create_db_index.py +0 -27
- mns_scheduler/real_time/realtime_quotes_now_sync.py +0 -232
- mns_scheduler/risk/stock_equity_mortgage_sync_api.py +0 -32
- mns_scheduler/zt/zt_pool/zt_pool_sync_api.py +0 -151
- mns_scheduler/zz_task/sync_realtime_quotes_task.py +0 -28
- mns_scheduler-1.0.8.7.dist-info/RECORD +0 -112
- /mns_scheduler/{backup/app → company_info/announce}/__init__.py +0 -0
- /mns_scheduler/{backup/em → company_info/base}/__init__.py +0 -0
- /mns_scheduler/{backup/wen_cai → company_info/clean}/__init__.py +0 -0
- /mns_scheduler/{big_deal → company_info/constant}/__init__.py +0 -0
- /mns_scheduler/{real_time → company_info/de_list_stock}/__init__.py +0 -0
- /mns_scheduler/{backup → finance/em}/__init__.py +0 -0
- /mns_scheduler/finance/{test → xue_qiu}/__init__.py +0 -0
- /mns_scheduler/k_line/{sync → month_week_daily}/__init__.py +0 -0
- {mns_scheduler-1.0.8.7.dist-info → mns_scheduler-1.4.3.2.dist-info}/top_level.txt +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') + 17
|
|
6
|
-
project_path = file_path[0:end]
|
|
7
|
-
sys.path.append(project_path)
|
|
8
|
-
import mns_common.utils.date_handle_util as date_handle_util
|
|
9
|
-
from datetime import datetime, time, timedelta
|
|
10
|
-
from loguru import logger
|
|
11
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
12
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
13
|
-
import mns_common.api.ths.ths_big_deal_api as ths_big_deal_api
|
|
14
|
-
import time as sleep_time
|
|
15
|
-
import mns_common.constant.db_name_constant as db_name_constant
|
|
16
|
-
|
|
17
|
-
mongodb_util = MongodbUtil('27017')
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
def get_last_number(str_day):
|
|
22
|
-
query = {'str_day': str_day}
|
|
23
|
-
big_deal_df = mongodb_util.descend_query(query, db_name_constant.BIG_DEAL_NAME, "number", 1)
|
|
24
|
-
if data_frame_util.is_empty(big_deal_df):
|
|
25
|
-
return 1
|
|
26
|
-
else:
|
|
27
|
-
return list(big_deal_df['number'])[0]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def create_index():
|
|
31
|
-
mongodb_util.create_index(db_name_constant.BIG_DEAL_NAME, [("symbol", 1)])
|
|
32
|
-
mongodb_util.create_index(db_name_constant.BIG_DEAL_NAME, [("str_day", 1)])
|
|
33
|
-
mongodb_util.create_index(db_name_constant.BIG_DEAL_NAME, [("symbol", 1), ("str_day", 1)])
|
|
34
|
-
mongodb_util.create_index(db_name_constant.BIG_DEAL_NAME, [("number", 1), ("str_day", 1)])
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def sync_ths_big_deal(tag):
|
|
38
|
-
create_index()
|
|
39
|
-
now_date_begin = datetime.now()
|
|
40
|
-
str_day_begin = now_date_begin.strftime('%Y-%m-%d')
|
|
41
|
-
number = get_last_number(str_day_begin)
|
|
42
|
-
while True:
|
|
43
|
-
now_date = datetime.now()
|
|
44
|
-
begin_date = now_date + timedelta(minutes=-2)
|
|
45
|
-
if tag or date_handle_util.is_trade_time(now_date):
|
|
46
|
-
try:
|
|
47
|
-
str_day = now_date.strftime('%Y-%m-%d')
|
|
48
|
-
str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
49
|
-
|
|
50
|
-
begin_str_date = begin_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
51
|
-
|
|
52
|
-
target_time_09_30 = time(9, 30)
|
|
53
|
-
if now_date.time() < target_time_09_30:
|
|
54
|
-
continue
|
|
55
|
-
ths_big_deal_df = ths_big_deal_api.stock_fund_flow_big_deal(begin_str_date, str_now_date)
|
|
56
|
-
if data_frame_util.is_empty(ths_big_deal_df):
|
|
57
|
-
sleep_time.sleep(10)
|
|
58
|
-
continue
|
|
59
|
-
ths_big_deal_df['str_day'] = ths_big_deal_df['deal_time'].str.slice(0, 10)
|
|
60
|
-
ths_big_deal_df = ths_big_deal_df.loc[ths_big_deal_df['str_day'] == str_day]
|
|
61
|
-
ths_big_deal_df['number'] = number
|
|
62
|
-
ths_big_deal_df['amount_str'] = ths_big_deal_df.amount.astype(str)
|
|
63
|
-
ths_big_deal_df['type'] = ths_big_deal_df['type'].replace('买盘', 'buy')
|
|
64
|
-
ths_big_deal_df['type'] = ths_big_deal_df['type'].replace("卖盘", "sell")
|
|
65
|
-
|
|
66
|
-
ths_big_deal_df["_id"] = (ths_big_deal_df['deal_time'] + "-" + ths_big_deal_df['symbol'] + "-"
|
|
67
|
-
+ ths_big_deal_df['amount_str'] + "-" + ths_big_deal_df['type'])
|
|
68
|
-
ths_big_deal_df.drop_duplicates('_id', keep='last', inplace=True)
|
|
69
|
-
ths_big_deal_df['sync_str_date'] = str_now_date
|
|
70
|
-
# 设置卖盘为负数
|
|
71
|
-
ths_big_deal_df.loc[ths_big_deal_df['type'] == 'sell', 'amount'] = -ths_big_deal_df.loc[
|
|
72
|
-
ths_big_deal_df['type'] == 'sell', 'amount']
|
|
73
|
-
|
|
74
|
-
ths_big_deal_df['chg'] = ths_big_deal_df['chg'].str.replace('%', '')
|
|
75
|
-
ths_big_deal_df['chg'] = ths_big_deal_df['chg'].astype(float)
|
|
76
|
-
|
|
77
|
-
del ths_big_deal_df['amount_str']
|
|
78
|
-
exist_code_df = mongodb_util.find_query_data_choose_field(db_name_constant.BIG_DEAL_NAME,
|
|
79
|
-
{},
|
|
80
|
-
{"_id": 1})
|
|
81
|
-
if data_frame_util.is_empty(exist_code_df):
|
|
82
|
-
new_df = ths_big_deal_df
|
|
83
|
-
else:
|
|
84
|
-
exist_code_list = list(exist_code_df['_id'])
|
|
85
|
-
new_df = ths_big_deal_df.loc[~(ths_big_deal_df['_id'].isin(exist_code_list))]
|
|
86
|
-
|
|
87
|
-
if data_frame_util.is_empty(new_df):
|
|
88
|
-
continue
|
|
89
|
-
mongodb_util.insert_mongo(new_df, db_name_constant.BIG_DEAL_NAME)
|
|
90
|
-
number = number + 1
|
|
91
|
-
except Exception as e:
|
|
92
|
-
logger.error('策略执行异常:{}', e)
|
|
93
|
-
elif date_handle_util.is_close_time(now_date):
|
|
94
|
-
break
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if __name__ == '__main__':
|
|
98
|
-
sync_ths_big_deal(False)
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') + 17
|
|
6
|
-
project_path = file_path[0:end]
|
|
7
|
-
sys.path.append(project_path)
|
|
8
|
-
import pandas as pd
|
|
9
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
10
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
11
|
-
|
|
12
|
-
mongodb_util = MongodbUtil('27017')
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def get_fix_symbol_industry():
|
|
16
|
-
return pd.DataFrame([['688480', '赛恩斯', '760103', '环境治理'],
|
|
17
|
-
['000032', '深桑达A', '730200', '通信网络设备及器件'],
|
|
18
|
-
['688480', '赛恩斯', '640704', '自动化设备'],
|
|
19
|
-
['603260', '合盛硅业', '220316', '有机硅'],
|
|
20
|
-
['300559', '佳发教育', '461102', '培训教育'],
|
|
21
|
-
['300836', '佰奥智能', '640701', '机器人'],
|
|
22
|
-
['300293', '蓝英装备', '640701', '机器人'],
|
|
23
|
-
['688630', '芯碁微装', '270108', '半导体设备'],
|
|
24
|
-
['001309', '德明利', '270108', '半导体设备'],
|
|
25
|
-
['600338', '西藏珠峰', '240603', '锂'],
|
|
26
|
-
['300042', '朗科科技', '270108', '半导体设备'],
|
|
27
|
-
['688507', '索辰科技', '710402', '横向通用软件'],
|
|
28
|
-
['301387', '光大同创', '270504', '消费电子零部件及组装'],
|
|
29
|
-
['300295', '三六五网', '430300', '物业管理'],
|
|
30
|
-
['300947', '德必集团', '430300', '物业管理'],
|
|
31
|
-
['300483', '首华燃气', '410301', '燃气Ⅲ'],
|
|
32
|
-
['300215', '电科院', '410110', '电能综合服务'],
|
|
33
|
-
# 持有上海微电子装备有限公司10%的股份 国产光刻机 主要炒作在芯片概念 不在房地产
|
|
34
|
-
['600895', '张江高科', '270108', '半导体设备'],
|
|
35
|
-
|
|
36
|
-
],
|
|
37
|
-
columns=['symbol', 'name', 'new_industry_code', 'new_industry'])
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def get_industry_final_fix_df():
|
|
41
|
-
return pd.DataFrame([
|
|
42
|
-
# 汽车
|
|
43
|
-
['汽车零部件', '汽车零部件'],
|
|
44
|
-
['汽车服务', '汽车服务'],
|
|
45
|
-
['乘用车', '汽车整车'], # = merge 汽车整车
|
|
46
|
-
['商用车', '汽车整车'],
|
|
47
|
-
|
|
48
|
-
# 医药生物
|
|
49
|
-
['化学制药', '化学制药'],
|
|
50
|
-
['生物制品', '生物制品'],
|
|
51
|
-
['中药Ⅱ', '中药'],
|
|
52
|
-
['医疗器械', '医疗器械'],
|
|
53
|
-
['医疗服务', '医疗服务'],
|
|
54
|
-
['医药商业', '医药商业'],
|
|
55
|
-
|
|
56
|
-
# 电力设备
|
|
57
|
-
['电网设备', '电网设备'],
|
|
58
|
-
['电池', '电池'],
|
|
59
|
-
['电机Ⅱ', '电机'], #
|
|
60
|
-
['光伏设备', '光伏设备'],
|
|
61
|
-
['风电设备', '风电设备'],
|
|
62
|
-
['其他电源设备Ⅱ', '其他电源设备'],
|
|
63
|
-
|
|
64
|
-
# 房地产
|
|
65
|
-
['房地产开发', '房地产'],
|
|
66
|
-
['房地产服务', '房地产'],
|
|
67
|
-
|
|
68
|
-
# 计算机 联动板块
|
|
69
|
-
['计算机设备', '计算机设备'],
|
|
70
|
-
['IT服务Ⅱ', 'IT服务'],
|
|
71
|
-
['软件开发', '软件开发'],
|
|
72
|
-
|
|
73
|
-
# 环保
|
|
74
|
-
['环境治理', '环保'], # merge, 环保
|
|
75
|
-
['环保设备Ⅱ', '环保'], # merge '环保'
|
|
76
|
-
|
|
77
|
-
# 电子
|
|
78
|
-
['半导体', '半导体'],
|
|
79
|
-
['电子化学品Ⅱ', '电子化学品'],
|
|
80
|
-
['光学光电子', '光学光电子'],
|
|
81
|
-
['消费电子', '消费电子'],
|
|
82
|
-
['元件', '元件'],
|
|
83
|
-
['其他电子Ⅱ', '其他电子'], #
|
|
84
|
-
|
|
85
|
-
# 国防
|
|
86
|
-
['军工电子Ⅱ', '军工电子'], # todo merge 国防
|
|
87
|
-
['地面兵装Ⅱ', '地面兵装'], # todo merge 国防
|
|
88
|
-
['航天装备Ⅱ', '航天装备'],
|
|
89
|
-
['航空装备Ⅱ', '航空装备'], # todo merge 国防
|
|
90
|
-
['航海装备Ⅱ', '航海装备'],
|
|
91
|
-
|
|
92
|
-
# 金融 互联网金融 参股券商
|
|
93
|
-
['证券Ⅱ', '证券'],
|
|
94
|
-
['国有大型银行Ⅱ', '银行'], # merge to 银行
|
|
95
|
-
['城商行Ⅱ', '银行'], #
|
|
96
|
-
['农商行Ⅱ', '银行'], # merge 银行
|
|
97
|
-
['股份制银行Ⅱ', '银行'], # merge to 银行
|
|
98
|
-
['保险Ⅱ', '保险'],
|
|
99
|
-
['多元金融', '多元金融'],
|
|
100
|
-
|
|
101
|
-
# 通信
|
|
102
|
-
['通信服务', '通信服务'],
|
|
103
|
-
['通信设备', '通信设备'],
|
|
104
|
-
|
|
105
|
-
# 酒 喝死你
|
|
106
|
-
['白酒Ⅱ', '酒类'], # merge '酒类'
|
|
107
|
-
['非白酒', '酒类'], # merge '酒类'
|
|
108
|
-
|
|
109
|
-
# 轻工制造
|
|
110
|
-
['造纸', '造纸'],
|
|
111
|
-
['包装印刷', '包装印刷'], #
|
|
112
|
-
['文娱用品', '文娱用品'], #
|
|
113
|
-
['家居用品', '家居用品'],
|
|
114
|
-
|
|
115
|
-
# 纺织服装
|
|
116
|
-
['服装家纺', '纺织服装'], # merge 纺织服装
|
|
117
|
-
['纺织制造', '纺织服装'], # merge 纺织服装
|
|
118
|
-
['饰品', '饰品'], # todo exclude
|
|
119
|
-
|
|
120
|
-
# 美容护理
|
|
121
|
-
['化妆品', '美容护理'], # merge to 美容护理
|
|
122
|
-
['医疗美容', '美容护理'], # merge 美容护理
|
|
123
|
-
['个护用品', '个护用品'],
|
|
124
|
-
|
|
125
|
-
# 食品饮料
|
|
126
|
-
['饮料乳品', '饮料乳品'], # merge 食品饮料
|
|
127
|
-
['食品加工', '食品加工'], # merge 食品饮料
|
|
128
|
-
['调味发酵品Ⅱ', '调味发酵品'], # merge to 食品饮料
|
|
129
|
-
['休闲食品', '休闲食品'], # merge '食品饮料'
|
|
130
|
-
|
|
131
|
-
# 石油石化
|
|
132
|
-
['炼化及贸易', '石油行业'], # merge 石油行业
|
|
133
|
-
['油服工程', '采掘行业'], # merge '采掘行业'
|
|
134
|
-
['油气开采Ⅱ', '石油行业'], # merge to 石油行业
|
|
135
|
-
|
|
136
|
-
# 钢铁
|
|
137
|
-
['普钢', '钢铁'], # merge 钢铁
|
|
138
|
-
['特钢Ⅱ', '钢铁'], # merge '钢铁'
|
|
139
|
-
['冶钢原料', '钢铁'], # merge to 钢铁
|
|
140
|
-
|
|
141
|
-
# 有色金属
|
|
142
|
-
['能源金属', '能源金属'], # merge
|
|
143
|
-
['小金属', '小金属'],
|
|
144
|
-
['贵金属', '贵金属'], #
|
|
145
|
-
['金属新材料', '金属新材料'],
|
|
146
|
-
# 铅锌 铝 铜
|
|
147
|
-
['工业金属', '工业金属'],
|
|
148
|
-
|
|
149
|
-
# 建筑装饰
|
|
150
|
-
['基础建设', '工程建设'],
|
|
151
|
-
['房屋建设Ⅱ', '工程建设'], # merge 工程建设
|
|
152
|
-
['工程咨询服务Ⅱ', '工程咨询服务'],
|
|
153
|
-
['专业工程', '建筑工程'],
|
|
154
|
-
['装修装饰Ⅱ', '装修装饰'],
|
|
155
|
-
['工程机械', '工程机械'],
|
|
156
|
-
|
|
157
|
-
# 建筑材料
|
|
158
|
-
['装修建材', '装修建材'], #
|
|
159
|
-
['建筑建材', '装修建材'], #
|
|
160
|
-
['玻璃玻纤', '玻璃玻纤'],
|
|
161
|
-
['水泥', '水泥'],
|
|
162
|
-
|
|
163
|
-
# 家用电器
|
|
164
|
-
['白色家电', '家用电器'], # merge 家用电器
|
|
165
|
-
['照明设备Ⅱ', '家用电器'], # merge 家用电器
|
|
166
|
-
['其他家电Ⅱ', '家用电器'], # merge 家用电器
|
|
167
|
-
['家电零部件Ⅱ', '家用电器'], # merge 家用电器
|
|
168
|
-
['小家电', '家用电器'], # merge '家用电器'
|
|
169
|
-
['黑色家电', '家用电器'], # merge 家用电器
|
|
170
|
-
['厨卫电器', '家用电器'], # merge 家用电器
|
|
171
|
-
|
|
172
|
-
# 基础化工
|
|
173
|
-
['化学制品', '化学制品'],
|
|
174
|
-
['化学原料', '化学原料'],
|
|
175
|
-
['化学纤维', '化学纤维'],
|
|
176
|
-
['农化制品', '化肥农药'],
|
|
177
|
-
['塑料', '塑料'],
|
|
178
|
-
['橡胶', '橡胶'], # todo exclude
|
|
179
|
-
['非金属材料Ⅱ', '非金属材料'],
|
|
180
|
-
|
|
181
|
-
# 商贸零售
|
|
182
|
-
['一般零售', '一般零售'],
|
|
183
|
-
['互联网电商', '互联网电商'],
|
|
184
|
-
['贸易Ⅱ', '贸易'], #
|
|
185
|
-
|
|
186
|
-
# 农林牧渔
|
|
187
|
-
['养殖业', '农林牧渔'], # merge 农林牧渔
|
|
188
|
-
['农产品加工', '农林牧渔'], # merge 农林牧渔
|
|
189
|
-
['饲料', '农林牧渔'], # merge to 饲料
|
|
190
|
-
['渔业', '农林牧渔'], # merge to 渔业
|
|
191
|
-
['种植业', '种植业'], # merge 种植业
|
|
192
|
-
['动物保健Ⅱ', '动物保健'], # todo exclude
|
|
193
|
-
|
|
194
|
-
# 公用事业
|
|
195
|
-
['燃气Ⅱ', '燃气'],
|
|
196
|
-
['电力', '电力'],
|
|
197
|
-
|
|
198
|
-
# 传媒
|
|
199
|
-
['数字媒体', '数字媒体'],
|
|
200
|
-
['电视广播Ⅱ', '电视广播'],
|
|
201
|
-
['游戏Ⅱ', '游戏'],
|
|
202
|
-
['出版', '出版'],
|
|
203
|
-
['影视院线', '影视院线'],
|
|
204
|
-
['广告营销', '广告营销'],
|
|
205
|
-
|
|
206
|
-
# 交通运输
|
|
207
|
-
['物流', '物流'],
|
|
208
|
-
['铁路公路', '铁路公路'],
|
|
209
|
-
['航运港口', '航运港口'],
|
|
210
|
-
['航空机场', '航空机场'],
|
|
211
|
-
|
|
212
|
-
# 旅游酒店
|
|
213
|
-
['酒店餐饮', '旅游酒店'], # merge to 旅游酒店
|
|
214
|
-
['旅游零售Ⅱ', '旅游酒店'], # merge 旅游酒店 中国中免
|
|
215
|
-
['旅游及景区', '旅游酒店'], # merge 旅游酒店
|
|
216
|
-
|
|
217
|
-
# 煤炭
|
|
218
|
-
['焦炭Ⅱ', '煤炭'], # merge to 煤炭
|
|
219
|
-
['煤炭开采', '煤炭'], # merge 煤炭
|
|
220
|
-
|
|
221
|
-
['教育', '教育'],
|
|
222
|
-
|
|
223
|
-
['自动化设备', '自动化设备'],
|
|
224
|
-
['轨交设备Ⅱ', '轨交设备'],
|
|
225
|
-
|
|
226
|
-
# 机械设备 仪器仪表 农用机械 制冷空调设备 印刷包装机械 机床工具
|
|
227
|
-
# 楼宇设备 磨具磨料 纺织服装设备 能源及重型设备 金属制品
|
|
228
|
-
['专用设备', '专用设备'], # todo exclude
|
|
229
|
-
['通用设备', '通用设备'], # todo exclude
|
|
230
|
-
['专业服务', '专业服务'], # todo exclude 无法具体分类
|
|
231
|
-
['摩托车及其他', '摩托车及其他'], # todo exclude
|
|
232
|
-
['专业连锁Ⅱ', '综合'], # merge 综合Ⅱ
|
|
233
|
-
['林业Ⅱ', '综合'], # merge 综合Ⅱ
|
|
234
|
-
['农业综合Ⅱ', '综合'], # merge 综合Ⅱ
|
|
235
|
-
['体育Ⅱ', '综合'], # merge 综合Ⅱ
|
|
236
|
-
['综合Ⅱ', '综合'] # todo exclude
|
|
237
|
-
|
|
238
|
-
], columns=['second_sw_industry', 'industry'])
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
# 第三行业作为筛选行业
|
|
242
|
-
def fix_industry_use_sw_third(company_info_df):
|
|
243
|
-
# 细分工业金属行业
|
|
244
|
-
company_info = company_info_df.copy()
|
|
245
|
-
company_info.loc[company_info.third_industry_code == '240303', 'industry'] = '铅锌'
|
|
246
|
-
company_info.loc[company_info.third_industry_code == '240301', 'industry'] = '铝'
|
|
247
|
-
company_info.loc[company_info.third_industry_code == '240302', 'industry'] = '铜'
|
|
248
|
-
# 细分专业设备
|
|
249
|
-
company_info.loc[company_info.third_industry_code == '640203', 'industry'] = '能源及重型设备'
|
|
250
|
-
company_info.loc[company_info.third_industry_code == '640204', 'industry'] = '楼宇设备'
|
|
251
|
-
company_info.loc[company_info.third_industry_code == '640206', 'industry'] = '纺织服装设备'
|
|
252
|
-
company_info.loc[company_info.third_industry_code == '640207', 'industry'] = '农用机械'
|
|
253
|
-
company_info.loc[company_info.third_industry_code == '640208', 'industry'] = '印刷包装机械'
|
|
254
|
-
# todo 细分
|
|
255
|
-
company_info.loc[company_info.third_industry_code == '640209', 'industry'] = '专用设备'
|
|
256
|
-
company_info.loc[company_info.third_industry_code == '630402', 'industry'] = '专用设备'
|
|
257
|
-
company_info.loc[company_info.third_industry_code == '220702', 'industry'] = '非金属材料'
|
|
258
|
-
# 细分通用设备
|
|
259
|
-
company_info.loc[company_info.third_industry_code == '640101', 'industry'] = '机床工具'
|
|
260
|
-
company_info.loc[company_info.third_industry_code == '640103', 'industry'] = '磨具磨料'
|
|
261
|
-
company_info.loc[company_info.third_industry_code == '640105', 'industry'] = '制冷空调设备'
|
|
262
|
-
company_info.loc[company_info.third_industry_code == '640106', 'industry'] = '通用设备'
|
|
263
|
-
company_info.loc[company_info.third_industry_code == '640107', 'industry'] = '仪器仪表'
|
|
264
|
-
company_info.loc[company_info.third_industry_code == '640301', 'industry'] = '仪器仪表'
|
|
265
|
-
# todo 细分
|
|
266
|
-
company_info.loc[company_info.third_industry_code == '640108', 'industry'] = '金属制品'
|
|
267
|
-
return company_info
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
def find_sw_third_industry(industry_id):
|
|
271
|
-
sw_third_industry = mongodb_util.find_query_data('sw_industry', query={"_id": industry_id})
|
|
272
|
-
first_sw_industry_name = list(sw_third_industry['first_sw_industry'])[0]
|
|
273
|
-
second_sw_industry_name = list(sw_third_industry['second_sw_industry'])[0]
|
|
274
|
-
|
|
275
|
-
first_sw_industry = mongodb_util.find_query_data('sw_industry', query={'first_sw_industry': first_sw_industry_name,
|
|
276
|
-
"second_sw_industry": 0,
|
|
277
|
-
"third_sw_industry": 0
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
second_sw_industry = mongodb_util.find_query_data('sw_industry',
|
|
281
|
-
query={'second_sw_industry': second_sw_industry_name,
|
|
282
|
-
"third_sw_industry": 0
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
sw_third_industry['first_industry_code'] = first_sw_industry['_id']
|
|
286
|
-
sw_third_industry['second_industry_code'] = second_sw_industry['_id']
|
|
287
|
-
return sw_third_industry
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
def fix_industry_data(industry_id, company_info):
|
|
291
|
-
sw_industry = find_sw_third_industry(industry_id)
|
|
292
|
-
company_info['first_sw_industry'] = sw_industry.first_sw_industry
|
|
293
|
-
company_info['first_industry_code'] = sw_industry.industry_code
|
|
294
|
-
company_info['second_sw_industry'] = sw_industry.second_sw_industry
|
|
295
|
-
company_info['second_industry_code'] = sw_industry.second_industry_code
|
|
296
|
-
company_info['third_sw_industry'] = sw_industry.third_sw_industry
|
|
297
|
-
company_info['third_industry_code'] = sw_industry.industry_code
|
|
298
|
-
return company_info
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
def fix_symbol_industry(company_info, symbol):
|
|
302
|
-
fix_symbol_df = get_fix_symbol_industry()
|
|
303
|
-
fix_symbol_df_one = fix_symbol_df.loc[fix_symbol_df['symbol'] == symbol]
|
|
304
|
-
if data_frame_util.is_not_empty(fix_symbol_df_one):
|
|
305
|
-
new_industry_code = list(fix_symbol_df_one['new_industry_code'])[0]
|
|
306
|
-
company_info = fix_industry_data(new_industry_code, company_info)
|
|
307
|
-
|
|
308
|
-
return company_info
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
def fix_one_symbol():
|
|
312
|
-
symbol = '300483'
|
|
313
|
-
company_info = mongodb_util.find_query_data('company_info', query={'_id': symbol})
|
|
314
|
-
company_info = fix_symbol_industry(company_info, symbol)
|
|
315
|
-
company_info['industry'] = company_info['second_sw_industry']
|
|
316
|
-
mongodb_util.save_mongo(company_info, 'company_info')
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if __name__ == '__main__':
|
|
320
|
-
fix_one_symbol()
|
|
321
|
-
industry_df = get_industry_final_fix_df()
|
|
322
|
-
print(industry_df)
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') + 17
|
|
6
|
-
project_path = file_path[0:end]
|
|
7
|
-
sys.path.append(project_path)
|
|
8
|
-
from loguru import logger
|
|
9
|
-
|
|
10
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
11
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
12
|
-
import pandas as pd
|
|
13
|
-
from datetime import datetime
|
|
14
|
-
import akshare as ak
|
|
15
|
-
import mns_scheduler.concept.ths.common.ths_concept_sync_common_api as ths_concept_sync_common_api
|
|
16
|
-
import mns_common.api.ths.ths_stock_api as ths_stock_api
|
|
17
|
-
import mns_scheduler.concept.clean.ths_concept_clean_api as ths_concept_clean_api
|
|
18
|
-
|
|
19
|
-
mongodb_util = MongodbUtil('27017')
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# 与概念接口对比 找出缺失数据和名称不一样的数据
|
|
23
|
-
|
|
24
|
-
def sync_new_ths_concept_by_ak_api():
|
|
25
|
-
stock_board_concept_name_ths_df = ak.stock_board_concept_name_ths()
|
|
26
|
-
stock_board_concept_name_ths_df = stock_board_concept_name_ths_df.rename(columns={"日期": "str_day",
|
|
27
|
-
"概念名称": "concept_name",
|
|
28
|
-
"成分股数量": "numbers",
|
|
29
|
-
"网址": "url",
|
|
30
|
-
"代码": "concept_code",
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
stock_board_concept_name_ths_df['str_day'].fillna(datetime(1970, 1, 1), inplace=True)
|
|
34
|
-
stock_board_concept_name_ths_df.concept_name = stock_board_concept_name_ths_df.concept_name.str.replace('(', '(')
|
|
35
|
-
stock_board_concept_name_ths_df.concept_name = stock_board_concept_name_ths_df.concept_name.str.replace(')', ')')
|
|
36
|
-
|
|
37
|
-
stock_board_concept_name_ths_df['str_day'] = stock_board_concept_name_ths_df['str_day'].apply(
|
|
38
|
-
lambda x: datetime.strftime(x, '%Y-%m-%d'))
|
|
39
|
-
|
|
40
|
-
# 同花顺概念列表
|
|
41
|
-
ths_concept_list_exist = mongodb_util.find_all_data('ths_concept_list')
|
|
42
|
-
|
|
43
|
-
for concept_one in stock_board_concept_name_ths_df.itertuples():
|
|
44
|
-
try:
|
|
45
|
-
exist_concept_df_one = ths_concept_list_exist.loc[
|
|
46
|
-
(ths_concept_list_exist['name'] == concept_one.concept_name)
|
|
47
|
-
| (ths_concept_list_exist['web_concept_code'] == concept_one.concept_code)]
|
|
48
|
-
now_date = datetime.now()
|
|
49
|
-
str_now_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
50
|
-
str_day = concept_one.str_day
|
|
51
|
-
if data_frame_util.is_empty(exist_concept_df_one):
|
|
52
|
-
concept_code = concept_one.concept_code
|
|
53
|
-
|
|
54
|
-
diff_one = {
|
|
55
|
-
'_id': int(concept_code),
|
|
56
|
-
'symbol': int(concept_code),
|
|
57
|
-
'name': concept_one.concept_name,
|
|
58
|
-
'url': concept_one.url,
|
|
59
|
-
'str_day': str_day,
|
|
60
|
-
'success': True,
|
|
61
|
-
'str_now_time': str_now_time,
|
|
62
|
-
'web_concept_code': int(concept_one.concept_code),
|
|
63
|
-
'web_concept_url': concept_one.url,
|
|
64
|
-
'valid': True
|
|
65
|
-
}
|
|
66
|
-
diff_one_df = pd.DataFrame(diff_one, index=[1])
|
|
67
|
-
mongodb_util.save_mongo(diff_one_df, 'ths_concept_list')
|
|
68
|
-
url = 'http://q.10jqka.com.cn/gn/detail/code/' + str(concept_one.concept_code)
|
|
69
|
-
# 新增概念信息处理
|
|
70
|
-
handle_new_concept_msg(concept_code, concept_one.concept_name, url)
|
|
71
|
-
new_concept_symbol_df = get_concept_detail_info_web(concept_code)
|
|
72
|
-
if new_concept_symbol_df is None or new_concept_symbol_df.shape[0] == 0:
|
|
73
|
-
return None
|
|
74
|
-
new_concept_symbol_df.loc[:, 'way'] = 'index_sync'
|
|
75
|
-
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_df, concept_one.concept_name,
|
|
76
|
-
str_day,
|
|
77
|
-
str_now_time, concept_code)
|
|
78
|
-
logger.info("新增同花顺新概念:{}", concept_one.concept_name)
|
|
79
|
-
except BaseException as e:
|
|
80
|
-
logger.error("同步概念:{},信息异常:{}", concept_one.concept_name, e)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def handle_new_concept_msg(concept_code, concept_name, url):
|
|
84
|
-
# 推送新概念信息到微信
|
|
85
|
-
ths_concept_sync_common_api.push_msg_to_we_chat_web(concept_code, concept_name,
|
|
86
|
-
url)
|
|
87
|
-
# 更新ths概念信息
|
|
88
|
-
ths_concept_clean_api.update_ths_concept_info()
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
# 获取web端 新增概念详情
|
|
92
|
-
def get_concept_detail_info_web(concept_code):
|
|
93
|
-
new_concept_symbol_list = ths_stock_api.ths_stock_concept(concept_code)
|
|
94
|
-
if new_concept_symbol_list is None or new_concept_symbol_list.shape[0] == 0:
|
|
95
|
-
return None
|
|
96
|
-
new_concept_symbol_list = new_concept_symbol_list[ths_concept_sync_common_api.order_fields]
|
|
97
|
-
new_concept_symbol_list['_id'] = str(concept_code) + '-' + new_concept_symbol_list['symbol']
|
|
98
|
-
return new_concept_symbol_list
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if __name__ == '__main__':
|
|
102
|
-
# get_concept_detail_info_web(886068)
|
|
103
|
-
sync_new_ths_concept_by_ak_api()
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') + 17
|
|
6
|
-
project_path = file_path[0:end]
|
|
7
|
-
sys.path.append(project_path)
|
|
8
|
-
import mns_common.api.ths.ths_stock_api as ths_stock_api
|
|
9
|
-
|
|
10
|
-
import datetime
|
|
11
|
-
import time
|
|
12
|
-
import mns_common.api.msg.push_msg_api as push_msg_api
|
|
13
|
-
from loguru import logger
|
|
14
|
-
import mns_scheduler.concept.ths.common.ths_concept_sync_common_api as ths_concept_sync_common_api
|
|
15
|
-
import mns_scheduler.concept.clean.ths_concept_clean_api as ths_concept_clean_api
|
|
16
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
17
|
-
|
|
18
|
-
mongodb_util = MongodbUtil('27017')
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# 获取web端 新增概念详情
|
|
22
|
-
def get_concept_detail_info_web(concept_code):
|
|
23
|
-
new_concept_symbol_list = ths_stock_api.ths_stock_concept(concept_code)
|
|
24
|
-
if new_concept_symbol_list is None or new_concept_symbol_list.shape[0] == 0:
|
|
25
|
-
return None
|
|
26
|
-
new_concept_symbol_list = new_concept_symbol_list[ths_concept_sync_common_api.order_fields]
|
|
27
|
-
new_concept_symbol_list['_id'] = str(concept_code) + '-' + new_concept_symbol_list['symbol']
|
|
28
|
-
return new_concept_symbol_list
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# web端获取新概念消息推送
|
|
32
|
-
def push_msg_to_we_chat_web(concept_code, concept_name):
|
|
33
|
-
url = 'http://q.10jqka.com.cn/thshy/detail/code/' + str(concept_code)
|
|
34
|
-
msg = "概念代码:" + str(concept_code) + "," + "概念名称:" + concept_name + "," + "url: " + url
|
|
35
|
-
title = "新增同花顺概念:" + str(concept_code) + "-" + concept_name
|
|
36
|
-
push_msg_api.push_msg_to_wechat(title, msg)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# # 同步同花顺新增概念指数通过web端接口爬取
|
|
40
|
-
def sync_new_concept_data_by_web():
|
|
41
|
-
concept_code = ths_concept_sync_common_api.get_max_concept_code()
|
|
42
|
-
concept_code = concept_code + 1
|
|
43
|
-
|
|
44
|
-
while concept_code < ths_concept_sync_common_api.max_concept_code:
|
|
45
|
-
try:
|
|
46
|
-
now_date = datetime.datetime.now()
|
|
47
|
-
str_day = now_date.strftime('%Y-%m-%d')
|
|
48
|
-
str_now_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
49
|
-
new_concept_symbol_df = get_concept_detail_info_web(concept_code)
|
|
50
|
-
if new_concept_symbol_df is None or new_concept_symbol_df.shape[0] == 0:
|
|
51
|
-
concept_code = concept_code + 1
|
|
52
|
-
time.sleep(1)
|
|
53
|
-
continue
|
|
54
|
-
time.sleep(2)
|
|
55
|
-
concept_name = ths_stock_api.get_concept_name(concept_code)
|
|
56
|
-
concept_name = concept_name.replace('(', '(')
|
|
57
|
-
concept_name = concept_name.replace(')', ')')
|
|
58
|
-
|
|
59
|
-
url = 'http://q.10jqka.com.cn/thshy/detail/code/' + str(concept_code)
|
|
60
|
-
# 推送新概念信息到微信
|
|
61
|
-
handle_new_concept_msg(concept_code, concept_name, url)
|
|
62
|
-
# 保存新概念信息到概念列表
|
|
63
|
-
ths_concept_sync_common_api.save_ths_concept_list(concept_code, concept_name, str_day, str_now_time)
|
|
64
|
-
# 保存新概念详细信息到数据库
|
|
65
|
-
new_concept_symbol_df.loc[:, 'way'] = 'index_sync'
|
|
66
|
-
ths_concept_sync_common_api.save_ths_concept_detail(new_concept_symbol_df, concept_name, str_day,
|
|
67
|
-
str_now_time, concept_code)
|
|
68
|
-
|
|
69
|
-
concept_code = concept_code + 1
|
|
70
|
-
except BaseException as e:
|
|
71
|
-
logger.error("同步新概念异常:{},concept_code:{}", e, concept_code)
|
|
72
|
-
concept_code = concept_code + 1
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def handle_new_concept_msg(concept_code, concept_name, url):
|
|
76
|
-
# 推送新概念信息到微信
|
|
77
|
-
ths_concept_sync_common_api.push_msg_to_we_chat_web(concept_code, concept_name,
|
|
78
|
-
url)
|
|
79
|
-
# 更新ths概念信息
|
|
80
|
-
ths_concept_clean_api.update_ths_concept_info()
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if __name__ == '__main__':
|
|
84
|
-
# code = 886025
|
|
85
|
-
# name = ths_stock_api.get_concept_name(code)
|
|
86
|
-
# push_msg_to_we_chat_web(code, name)
|
|
87
|
-
# get_concept_detail_info_web(886026)
|
|
88
|
-
# get_concept_detail_info_web(886035)
|
|
89
|
-
sync_new_concept_data_by_web()
|