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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
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.component.em.em_stock_info_api as em_stock_info_api
|
|
9
|
+
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
10
|
+
import mns_common.api.ths.company.company_product_area_industry_index_query as company_product_area_industry_index_query
|
|
11
|
+
from loguru import logger
|
|
12
|
+
from mns_common.db.MongodbUtil import MongodbUtil
|
|
13
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
14
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
15
|
+
import pandas as pd
|
|
16
|
+
from datetime import datetime
|
|
17
|
+
|
|
18
|
+
mongodb_util = MongodbUtil('27017')
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def sync_company_product_area_industry_task(symbol):
|
|
22
|
+
now_date = datetime.now()
|
|
23
|
+
now_year = now_date.year
|
|
24
|
+
now_month = now_date.month
|
|
25
|
+
|
|
26
|
+
if now_month in [1, 2, 3, 4]:
|
|
27
|
+
period_time_year = str(now_year - 1) + "-12-31"
|
|
28
|
+
sync_company_product_area_industry(symbol, period_time_year)
|
|
29
|
+
|
|
30
|
+
if now_month in [4, 5, 6]:
|
|
31
|
+
period_time_one = str(now_year) + "-03-31"
|
|
32
|
+
sync_company_product_area_industry(symbol, period_time_one)
|
|
33
|
+
|
|
34
|
+
elif now_month in [7, 8, 9]:
|
|
35
|
+
period_time_two = str(now_year) + "-06-30"
|
|
36
|
+
sync_company_product_area_industry(symbol, period_time_two)
|
|
37
|
+
|
|
38
|
+
elif now_month in [10, 11, 12]:
|
|
39
|
+
period_time_three = str(now_year) + "-09-30"
|
|
40
|
+
sync_company_product_area_industry(symbol, period_time_three)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def sync_company_product_area_industry(symbol, date):
|
|
44
|
+
real_time_quotes_all_stocks = em_stock_info_api.get_a_stock_info()
|
|
45
|
+
real_time_quotes_all_stocks = common_service_fun_api.classify_symbol(real_time_quotes_all_stocks)
|
|
46
|
+
if symbol is not None:
|
|
47
|
+
real_time_quotes_all_stocks = real_time_quotes_all_stocks.loc[real_time_quotes_all_stocks['symbol'] == symbol]
|
|
48
|
+
for stock_one in real_time_quotes_all_stocks.itertuples():
|
|
49
|
+
try:
|
|
50
|
+
symbol = stock_one.symbol
|
|
51
|
+
|
|
52
|
+
classification = stock_one.classification
|
|
53
|
+
if classification in ['H', 'K']:
|
|
54
|
+
market = '17'
|
|
55
|
+
elif classification in ['S', 'C']:
|
|
56
|
+
market = '33'
|
|
57
|
+
elif classification in ['X']:
|
|
58
|
+
market = '151'
|
|
59
|
+
|
|
60
|
+
company_product_area_industry_list = company_product_area_industry_index_query.company_product_area_industry(
|
|
61
|
+
symbol, market, date)
|
|
62
|
+
for company_one in company_product_area_industry_list:
|
|
63
|
+
try:
|
|
64
|
+
analysis_type = company_one['analysis_type']
|
|
65
|
+
time_operate_index_item_list = company_one['time_operate_index_item_list']
|
|
66
|
+
time_operate_index_item_df = pd.DataFrame(time_operate_index_item_list)
|
|
67
|
+
if data_frame_util.is_empty(time_operate_index_item_df):
|
|
68
|
+
continue
|
|
69
|
+
time_operate_index_item_df['symbol'] = symbol
|
|
70
|
+
time_operate_index_item_df['analysis_type'] = analysis_type
|
|
71
|
+
|
|
72
|
+
time_operate_index_item_df['_id'] = symbol + '_' + time_operate_index_item_df[
|
|
73
|
+
'time'] + '_' + analysis_type
|
|
74
|
+
handle_industry_area_product(time_operate_index_item_df, symbol)
|
|
75
|
+
except BaseException as e:
|
|
76
|
+
logger.error("同步经营数据异常:{},{}", symbol, e)
|
|
77
|
+
|
|
78
|
+
logger.info("同步经营数据完成:{}", stock_one.symbol)
|
|
79
|
+
except BaseException as e:
|
|
80
|
+
logger.error("同步经营数据:{},{}", stock_one.symbol, e)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def handle_industry_area_product(time_operate_index_item_df, symbol):
|
|
84
|
+
if data_frame_util.is_empty(time_operate_index_item_df):
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
for business_one in time_operate_index_item_df.itertuples():
|
|
88
|
+
time = business_one.time
|
|
89
|
+
analysis_type = business_one.analysis_type
|
|
90
|
+
|
|
91
|
+
product_index_item_list = business_one.product_index_item_list
|
|
92
|
+
for product_one in product_index_item_list:
|
|
93
|
+
try:
|
|
94
|
+
# 初始化数据
|
|
95
|
+
income_amount = 0
|
|
96
|
+
income_percent = 0
|
|
97
|
+
cost_amount = 0
|
|
98
|
+
cost_percent = 0
|
|
99
|
+
gross_profit_amount = 0
|
|
100
|
+
gross_profit_percent = 0
|
|
101
|
+
gross_profit_rate_amount = 0
|
|
102
|
+
gross_profit_rate_percent = 0
|
|
103
|
+
|
|
104
|
+
product_name = product_one['product_name']
|
|
105
|
+
index_analysis_list = product_one['index_analysis_list']
|
|
106
|
+
for index_one in index_analysis_list:
|
|
107
|
+
try:
|
|
108
|
+
index_id = index_one['index_id']
|
|
109
|
+
if index_id == 'income':
|
|
110
|
+
income_amount = index_one['index_value']
|
|
111
|
+
income_percent = index_one['account']
|
|
112
|
+
elif index_id == 'cost':
|
|
113
|
+
cost_amount = index_one['index_value']
|
|
114
|
+
cost_percent = index_one['account']
|
|
115
|
+
elif index_id == 'gross_profit':
|
|
116
|
+
gross_profit_amount = index_one['index_value']
|
|
117
|
+
gross_profit_percent = index_one['account']
|
|
118
|
+
|
|
119
|
+
elif index_id == 'gross_profit_rate':
|
|
120
|
+
gross_profit_rate_amount = index_one['index_value']
|
|
121
|
+
gross_profit_rate_percent = index_one['account']
|
|
122
|
+
except BaseException as e:
|
|
123
|
+
logger.error("同步经营数据异常:{},{}", symbol, e)
|
|
124
|
+
|
|
125
|
+
id_key = symbol + '_' + time + '_' + analysis_type + '_' + product_name
|
|
126
|
+
result_dict = {
|
|
127
|
+
'_id': id_key,
|
|
128
|
+
'symbol': symbol,
|
|
129
|
+
'time': time,
|
|
130
|
+
'analysis_type': analysis_type,
|
|
131
|
+
'product_name': product_name,
|
|
132
|
+
|
|
133
|
+
'income_amount': income_amount,
|
|
134
|
+
'income_percent': income_percent,
|
|
135
|
+
|
|
136
|
+
'cost_amount': cost_amount,
|
|
137
|
+
'cost_percent': cost_percent,
|
|
138
|
+
|
|
139
|
+
'gross_profit_amount': gross_profit_amount,
|
|
140
|
+
'gross_profit_percent': gross_profit_percent,
|
|
141
|
+
|
|
142
|
+
'gross_profit_rate_amount': gross_profit_rate_amount,
|
|
143
|
+
'gross_profit_rate_percent': gross_profit_rate_percent,
|
|
144
|
+
}
|
|
145
|
+
result_dict_df = pd.DataFrame(result_dict, index=[1])
|
|
146
|
+
mongodb_util.save_mongo(result_dict_df, db_name_constant.COMPANY_BUSINESS_INFO)
|
|
147
|
+
except BaseException as e:
|
|
148
|
+
logger.error("同步经营数据异常:{},{}", symbol, e)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
if __name__ == '__main__':
|
|
152
|
+
sync_company_product_area_industry('300211', '2025-09-30')
|
|
153
|
+
# sync_company_product_area_industry('002323')
|
|
154
|
+
# sync_company_product_area_industry('300901')
|
|
155
|
+
# sync_company_product_area_industry('603225')
|
|
156
|
+
# sync_company_product_area_industry('688039')
|
|
157
|
+
# sync_company_product_area_industry('600849')
|
|
158
|
+
# sync_company_product_area_industry('000508')
|
|
159
|
+
# sync_company_product_area_industry('810011')
|
|
160
|
+
|
|
161
|
+
sync_company_product_area_industry(None, None)
|
|
@@ -0,0 +1,133 @@
|
|
|
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 mns_common.db.MongodbUtil import MongodbUtil
|
|
9
|
+
import pandas as pd
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
from loguru import logger
|
|
12
|
+
import mns_scheduler.company_info.constant.company_constant_data as company_constant_data
|
|
13
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
14
|
+
import mns_scheduler.concept.ths.detaill.ths_concept_detail_api as ths_concept_detail_api
|
|
15
|
+
import mns_scheduler.company_info.base.sync_company_base_info_api as company_info_sync_api
|
|
16
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
17
|
+
|
|
18
|
+
mongodb_util = MongodbUtil('27017')
|
|
19
|
+
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
20
|
+
import mns_common.component.company.company_common_service_api as company_common_service_api
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# 修改行业信息
|
|
24
|
+
def clean_company_info(symbol):
|
|
25
|
+
if symbol is not None:
|
|
26
|
+
query = {"symbol": symbol}
|
|
27
|
+
company_info = mongodb_util.find_query_data('company_info_base', query)
|
|
28
|
+
else:
|
|
29
|
+
company_info = mongodb_util.find_all_data('company_info_base')
|
|
30
|
+
|
|
31
|
+
company_info = company_constant_data.fix_second_industry(company_info)
|
|
32
|
+
|
|
33
|
+
company_info = company_info.set_index(['second_sw_industry'], drop=False)
|
|
34
|
+
|
|
35
|
+
# 修改行业名称
|
|
36
|
+
del company_info['industry']
|
|
37
|
+
# fix industry name
|
|
38
|
+
industry_final_fix_df = company_constant_data.get_fix_industry_name_df()
|
|
39
|
+
industry_final_fix_df = industry_final_fix_df.set_index(['second_sw_industry'], drop=True)
|
|
40
|
+
company_info = pd.merge(company_info, industry_final_fix_df, how='outer',
|
|
41
|
+
left_index=True, right_index=True)
|
|
42
|
+
|
|
43
|
+
# 将申万第三行业做为行业 拆分过大的二级行业 主要有通用设备 和专业设备
|
|
44
|
+
company_info = company_constant_data.fix_industry_use_sw_third(company_info.copy())
|
|
45
|
+
company_info['industry'] = company_info['industry'].fillna('综合')
|
|
46
|
+
company_info = company_constant_data.filed_sort(company_info)
|
|
47
|
+
company_info['company_type'] = company_info['business_nature']
|
|
48
|
+
|
|
49
|
+
# 将list_date列中的所有NaN值设置为99990909
|
|
50
|
+
company_info.fillna({'list_date': 19890604}, inplace=True)
|
|
51
|
+
|
|
52
|
+
# 将日期数值转换为日期时间格式
|
|
53
|
+
company_info['list_date_01'] = pd.to_datetime(company_info['list_date'], format='%Y%m%d')
|
|
54
|
+
|
|
55
|
+
company_info['list_date'] = company_info['list_date'].apply(
|
|
56
|
+
lambda x: pd.to_numeric(x, errors="coerce"))
|
|
57
|
+
|
|
58
|
+
now_date = datetime.now()
|
|
59
|
+
|
|
60
|
+
# 计算日期差值 距离现在上市时间
|
|
61
|
+
company_info['diff_days'] = company_info.apply(
|
|
62
|
+
lambda row: (now_date - row['list_date_01']).days, axis=1)
|
|
63
|
+
|
|
64
|
+
str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
65
|
+
company_info['sync_date'] = str_now_date
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
# 次新股
|
|
69
|
+
sub_stock = ths_concept_detail_api.get_ths_concept_detail('885598', None)
|
|
70
|
+
sub_stock_symbol_list = list(sub_stock['symbol'])
|
|
71
|
+
except BaseException as e:
|
|
72
|
+
logger.error("出现异常:{},{}", symbol, e)
|
|
73
|
+
query = {'concept_code': 885598}
|
|
74
|
+
ths_stock_concept_detail = mongodb_util.find_query_data(db_name_constant.THS_STOCK_CONCEPT_DETAIL, query)
|
|
75
|
+
sub_stock_symbol_list = list(ths_stock_concept_detail['symbol'])
|
|
76
|
+
company_info.loc[:, 'sub_stock'] = False
|
|
77
|
+
company_info.loc[company_info['symbol'].isin(sub_stock_symbol_list), 'sub_stock'] = True
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
company_info.dropna(subset=['symbol'], axis=0, inplace=True)
|
|
81
|
+
company_info.dropna(subset=['_id'], axis=0, inplace=True)
|
|
82
|
+
ths_stock_industry_detail_df = mongodb_util.find_all_data(db_name_constant.THS_STOCK_INDUSTRY_DETAIL)
|
|
83
|
+
if data_frame_util.is_not_empty(ths_stock_industry_detail_df):
|
|
84
|
+
ths_stock_industry_detail_df = ths_stock_industry_detail_df[
|
|
85
|
+
['symbol', 'ths_industry_name', 'ths_industry_code']]
|
|
86
|
+
ths_stock_industry_detail_df = ths_stock_industry_detail_df.set_index(['symbol'], drop=True)
|
|
87
|
+
company_info = company_info.set_index(['_id'], drop=False)
|
|
88
|
+
company_info = pd.merge(company_info, ths_stock_industry_detail_df, how='outer',
|
|
89
|
+
left_index=True, right_index=True)
|
|
90
|
+
company_info['ths_industry_code'] = company_info['ths_industry_code'].fillna('0')
|
|
91
|
+
company_info['ths_industry_name'] = company_info['ths_industry_name'].fillna('异常')
|
|
92
|
+
|
|
93
|
+
else:
|
|
94
|
+
company_info['ths_industry_code'] = '0'
|
|
95
|
+
company_info['ths_industry_name'] = '异常'
|
|
96
|
+
mongodb_util.save_mongo(company_info, db_name_constant.COMPANY_INFO)
|
|
97
|
+
# 保存历史数据
|
|
98
|
+
save_company_info_his(company_info)
|
|
99
|
+
except BaseException as e:
|
|
100
|
+
logger.error("出现异常:{},{}", symbol, e)
|
|
101
|
+
|
|
102
|
+
return company_info
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def save_company_info_his(company_info_df):
|
|
106
|
+
now_date = datetime.now()
|
|
107
|
+
str_day = now_date.strftime('%Y-%m-%d')
|
|
108
|
+
company_info_df['symbol'] = company_info_df['_id']
|
|
109
|
+
company_info_df['str_day'] = str_day
|
|
110
|
+
company_info_df['_id'] = company_info_df['_id'] + "_" + str_day
|
|
111
|
+
remove_query = {'str_day': str_day}
|
|
112
|
+
tag = mongodb_util.remove_data(remove_query, db_name_constant.COMPANY_INFO_HIS)
|
|
113
|
+
success = tag.acknowledged
|
|
114
|
+
if success:
|
|
115
|
+
mongodb_util.save_mongo(company_info_df, db_name_constant.COMPANY_INFO_HIS)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# 更新新上市公司信息
|
|
119
|
+
def new_company_info_update():
|
|
120
|
+
east_money_stock_info = company_info_sync_api.get_east_money_stock_info()
|
|
121
|
+
new_stock = common_service_fun_api.get_new_stock(east_money_stock_info.copy())
|
|
122
|
+
for company_one in new_stock.itertuples():
|
|
123
|
+
try:
|
|
124
|
+
company_info_sync_api.sync_company_base_info([company_one.symbol])
|
|
125
|
+
clean_company_info(company_one.symbol)
|
|
126
|
+
|
|
127
|
+
except BaseException as e:
|
|
128
|
+
logger.error("出现异常:{}", e)
|
|
129
|
+
company_common_service_api.company_info_industry_cache_clear
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
if __name__ == '__main__':
|
|
133
|
+
clean_company_info(None)
|