mns-scheduler 1.1.8.4__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/base/__init__.py +1 -1
- mns_scheduler/company_info/base/sync_company_base_info_api.py +171 -79
- mns_scheduler/company_info/base/sync_company_hold_info_api.py +3 -6
- mns_scheduler/company_info/base/sync_company_product_area_industry.py +161 -0
- mns_scheduler/company_info/clean/__init__.py +1 -1
- mns_scheduler/company_info/clean/company_info_clean_api.py +29 -9
- mns_scheduler/company_info/constant/__init__.py +1 -1
- mns_scheduler/company_info/constant/company_constant_data.py +285 -184
- mns_scheduler/company_info/de_list_stock/__init__.py +1 -1
- mns_scheduler/company_info/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 +1 -1
- mns_scheduler/company_info/remark/company_remark_info_sync.py +3 -3
- mns_scheduler/concept/clean/kpl_concept_clean_api.py +1 -1
- mns_scheduler/concept/clean/ths_concept_clean_api.py +20 -4
- mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py +21 -16
- mns_scheduler/concept/ths/common/ths_concept_update_common_api.py +4 -1
- mns_scheduler/concept/ths/detaill/ths_concept_detail_api.py +7 -7
- mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py +9 -4
- mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py +3 -3
- mns_scheduler/db/col_move_service.py +3 -3
- mns_scheduler/db/script/__init__.py +1 -1
- mns_scheduler/db/script/col_move_script.py +1 -1
- 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 +1 -1
- mns_scheduler/db/script/sync/remote_data_sync_to_local.py +57 -4
- 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} +2 -2
- mns_scheduler/finance/{em_financial_profit_sync_service_api.py → em/em_financial_profit_sync_service_api.py} +27 -26
- mns_scheduler/finance/{finance_common_api.py → em/finance_common_api.py} +3 -3
- mns_scheduler/finance/{sync_financial_report_service_api.py → sync_financial_report_service_task.py} +80 -27
- 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 +4 -4
- mns_scheduler/hk/hk_industry_info_sync_service_api.py +3 -5
- 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 +12 -8
- mns_scheduler/k_line/clean/daily/__init__.py +1 -1
- mns_scheduler/k_line/clean/daily/daily_k_line_clean_common_service.py +52 -6
- mns_scheduler/k_line/clean/daily/daily_k_line_service.py +7 -2
- 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 -15
- 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 +124 -26
- mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py +2 -2
- 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/{sync → month_week_daily}/bfq_k_line_sync.py +14 -29
- mns_scheduler/k_line/{sync → month_week_daily}/daily_week_month_line_sync.py +11 -12
- 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 +1 -1
- mns_scheduler/k_line/test/k_line_info_clean_his_data.py +14 -3
- 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 +1 -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 +5 -0
- 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 +2 -3
- mns_scheduler/risk/__init__.py +1 -1
- mns_scheduler/risk/compliance/undisclosed_annual_report_api.py +8 -2
- mns_scheduler/risk/financial/annual_report_audit_check_api.py +13 -3
- mns_scheduler/risk/financial/net_assets_check_api.py +21 -18
- mns_scheduler/risk/financial/profit_income_check_api.py +7 -2
- mns_scheduler/risk/financial_report_risk_check_api.py +1 -1
- mns_scheduler/risk/major_violations/register_and_investigate_stock_sync_api.py +1 -1
- mns_scheduler/risk/self/wei_pan_stock_api.py +1 -1
- mns_scheduler/risk/test/__init__.py +1 -1
- mns_scheduler/risk/test/fix_blask_list.py +4 -6
- mns_scheduler/risk/transactions/transactions_check_api.py +22 -4
- mns_scheduler/self_choose/__init__.py +1 -1
- mns_scheduler/self_choose/ths_self_choose_service.py +60 -32
- mns_scheduler/trade/auto_login/trader_auto_service.py +6 -4
- mns_scheduler/trade/auto_sell_service_api.py +4 -4
- 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 +39 -6
- mns_scheduler/trade/task/trader_task_service.py +26 -9
- 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 -16
- mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py +2 -2
- mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py +1 -1
- 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 -2
- mns_scheduler/zt/script/sync_high_chg_pool_his_data.py +2 -2
- mns_scheduler/zt/script/sync_now_higt_chg_zt.py +8 -7
- mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py +256 -55
- mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py +33 -90
- mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py +24 -13
- 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 +177 -91
- {mns_scheduler-1.1.8.4.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.1.8.4.dist-info → mns_scheduler-1.4.3.2.dist-info}/WHEEL +1 -1
- mns_scheduler/2014-2015-test/2014_2015_chg_statistics.py +0 -87
- mns_scheduler/big_deal/ths_big_deal_sync.py +0 -98
- mns_scheduler/db/real_time_task_check.py +0 -84
- mns_scheduler/debt/kzz_bond_info_sync.py +0 -33
- mns_scheduler-1.1.8.4.dist-info/RECORD +0 -142
- /mns_scheduler/{big_deal → company_info/announce}/__init__.py +0 -0
- /mns_scheduler/{2014-2015-test → finance/em}/__init__.py +0 -0
- /mns_scheduler/{debt → finance/xue_qiu}/__init__.py +0 -0
- /mns_scheduler/k_line/{sync → month_week_daily}/__init__.py +0 -0
- {mns_scheduler-1.1.8.4.dist-info → mns_scheduler-1.4.3.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
|
|
9
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
10
|
+
from mns_scheduler.db.script.sync.remote_mongo_util import RemoteMongodbUtil
|
|
11
|
+
from mns_scheduler.db.script.sync.local_mongo_util import LocalMongodbUtil
|
|
12
|
+
from loguru import logger
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
15
|
+
remote_mongodb_util = RemoteMongodbUtil('27017')
|
|
16
|
+
local_mongodb_util = LocalMongodbUtil('27017')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def sync_real_time_data(str_day, min_number, max_number):
|
|
20
|
+
db_name = 'realtime_quotes_now_' + str_day
|
|
21
|
+
while min_number <= max_number:
|
|
22
|
+
query = {'number': min_number}
|
|
23
|
+
data_df = remote_mongodb_util.find_query_data(db_name, query)
|
|
24
|
+
local_mongodb_util.insert_mongo(data_df, db_name)
|
|
25
|
+
min_number = min_number + 1
|
|
26
|
+
logger.info(min_number)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def sync_k_line(str_day):
|
|
30
|
+
query = {"str_day": str_day}
|
|
31
|
+
db_name = 'k_line_info'
|
|
32
|
+
data_df = remote_mongodb_util.find_query_data(db_name, query)
|
|
33
|
+
try:
|
|
34
|
+
local_mongodb_util.save_mongo(data_df, db_name)
|
|
35
|
+
except BaseException as e:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if __name__ == '__main__':
|
|
40
|
+
sync_k_line('2025-08-27')
|
|
41
|
+
# sync_k_line('2025-07-24')
|
|
42
|
+
# sync_k_line('2025-07-25')
|
|
43
|
+
# sync_k_line(str_day_01)
|
|
44
|
+
# sync_k_line('2024-11-13')
|
|
45
|
+
# sync_k_line('2024-11-12')
|
|
46
|
+
# sync_k_line('2024-11-15') 232
|
|
47
|
+
# sync_real_time_data(str_day_01, 1, 2000)
|
|
48
|
+
# sync_real_time_data('2024-11-15', 10, 1010)
|
|
49
|
+
#
|
|
50
|
+
# sync_k_line('2024-12-20')
|
|
51
|
+
# sync_k_line('2024-12-19')
|
|
52
|
+
# sync_k_line('2024-12-18')
|
|
53
|
+
# sync_k_line('2024-12-17')
|
|
54
|
+
# sync_k_line('2024-12-16')
|
|
55
|
+
#
|
|
56
|
+
# sync_k_line('2024-12-13')
|
|
57
|
+
# sync_k_line('2024-12-12')
|
|
58
|
+
# sync_k_line('2024-12-11')
|
|
59
|
+
# sync_k_line('2024-12-10')
|
|
60
|
+
# sync_k_line('2024-12-09')
|
|
61
|
+
#
|
|
62
|
+
# sync_k_line('2024-12-06')
|
|
63
|
+
# sync_k_line('2024-12-05')
|
|
64
|
+
# sync_k_line('2024-12-04')
|
|
65
|
+
# sync_k_line('2024-12-03')
|
|
66
|
+
# sync_k_line('2024-12-02')
|
|
67
|
+
|
|
68
|
+
# sync_real_time_data('2024-12-20', 1000, 2000)
|
|
69
|
+
# sync_real_time_data('2024-11-13', 10, 1010)
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
from loguru import logger
|
|
10
|
+
|
|
11
|
+
mongodb_util_27017 = MongodbUtil('27017')
|
|
12
|
+
mongodb_util_27019 = MongodbUtil('27019')
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def update_col_data():
|
|
16
|
+
query = {"$and": [{'trade_date': {'$lte': '2024-05-23'}},
|
|
17
|
+
{'trade_date': {'$gte': '2022-07-02'}}]}
|
|
18
|
+
trade_date_list_df = mongodb_util_27017.find_query_data('trade_date_list', query)
|
|
19
|
+
trade_date_list_df = trade_date_list_df.sort_values(by=['trade_date'], ascending=True)
|
|
20
|
+
for trade_one in trade_date_list_df.itertuples():
|
|
21
|
+
col_name = 'realtime_quotes_now_' + trade_one.trade_date
|
|
22
|
+
new_values = {'$unset': {
|
|
23
|
+
'classification': '',
|
|
24
|
+
'medium_order_net_inflow': '',
|
|
25
|
+
'small_order_net_inflow': '',
|
|
26
|
+
'str_day': '',
|
|
27
|
+
'list_date': '',
|
|
28
|
+
'amount_level': '',
|
|
29
|
+
'name': '', 'industry': '', 'concept': ''}}
|
|
30
|
+
|
|
31
|
+
mongodb_util_27019.update_many({}, new_values, col_name)
|
|
32
|
+
logger.info("完成集合数据更新:{}", col_name)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
if __name__ == '__main__':
|
|
36
|
+
update_col_data()
|
|
@@ -2,12 +2,12 @@ import sys
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') +
|
|
5
|
+
end = file_path.index('mns') + 17
|
|
6
6
|
project_path = file_path[0:end]
|
|
7
7
|
sys.path.append(project_path)
|
|
8
8
|
import akshare as ak
|
|
9
9
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
10
|
-
import mns_scheduler.finance.finance_common_api as finance_common_api
|
|
10
|
+
import mns_scheduler.finance.em.finance_common_api as finance_common_api
|
|
11
11
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
12
12
|
|
|
13
13
|
mongodb_util = MongodbUtil('27017')
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
4
6
|
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') +
|
|
7
|
+
end = file_path.index('mns') + 17
|
|
6
8
|
project_path = file_path[0:end]
|
|
7
9
|
sys.path.append(project_path)
|
|
8
10
|
|
|
@@ -12,7 +14,7 @@ import mns_common.utils.data_frame_util as data_frame_util
|
|
|
12
14
|
|
|
13
15
|
mongodb_util = MongodbUtil('27017')
|
|
14
16
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
15
|
-
import mns_scheduler.finance.finance_common_api as finance_common_api
|
|
17
|
+
import mns_scheduler.finance.em.finance_common_api as finance_common_api
|
|
16
18
|
from loguru import logger
|
|
17
19
|
|
|
18
20
|
|
|
@@ -228,7 +230,7 @@ def get_em_profit_api(symbol):
|
|
|
228
230
|
stock_profit_sheet_by_report_em = ak.stock_profit_sheet_by_report_em(sec_code)
|
|
229
231
|
except Exception as e:
|
|
230
232
|
logger.error("同步利润表异常:{},{}", symbol, e)
|
|
231
|
-
if data_frame_util.is_empty(stock_profit_sheet_by_report_em):
|
|
233
|
+
if data_frame_util.is_empty(stock_profit_sheet_by_report_em.copy()):
|
|
232
234
|
return None
|
|
233
235
|
stock_profit_sheet_by_report_em = check_columns(stock_profit_sheet_by_report_em)
|
|
234
236
|
stock_profit_sheet_by_report_em = stock_profit_sheet_by_report_em[[
|
|
@@ -293,57 +295,56 @@ def get_em_profit_api(symbol):
|
|
|
293
295
|
else:
|
|
294
296
|
new_profit_df = stock_profit_sheet_by_report_em
|
|
295
297
|
if data_frame_util.is_empty(new_profit_df):
|
|
296
|
-
return
|
|
297
|
-
new_profit_df.fillna(0
|
|
298
|
+
return pd.DataFrame()
|
|
299
|
+
new_profit_df = new_profit_df.fillna(0)
|
|
298
300
|
return new_profit_df
|
|
299
301
|
|
|
300
302
|
|
|
301
303
|
def check_columns(profit_df):
|
|
302
304
|
if 'TOTAL_OPERATE_INCOME' not in profit_df.columns:
|
|
303
|
-
profit_df
|
|
305
|
+
profit_df = profit_df.assign(TOTAL_OPERATE_INCOME=0)
|
|
304
306
|
|
|
305
307
|
if 'FAIRVALUE_CHANGE_INCOME' not in profit_df.columns:
|
|
306
|
-
profit_df
|
|
308
|
+
profit_df = profit_df.assign(FAIRVALUE_CHANGE_INCOME=0)
|
|
307
309
|
|
|
308
310
|
if 'INTEREST_INCOME' not in profit_df.columns:
|
|
309
|
-
profit_df
|
|
311
|
+
profit_df = profit_df.assign(INTEREST_INCOME=0)
|
|
310
312
|
if 'TOTAL_OPERATE_COST' not in profit_df.columns:
|
|
311
|
-
profit_df
|
|
313
|
+
profit_df = profit_df.assign(TOTAL_OPERATE_COST=0)
|
|
312
314
|
if 'OPERATE_COST' not in profit_df.columns:
|
|
313
|
-
profit_df
|
|
315
|
+
profit_df = profit_df.assign(OPERATE_COST=0)
|
|
314
316
|
if 'INTEREST_EXPENSE' not in profit_df.columns:
|
|
315
|
-
profit_df
|
|
317
|
+
profit_df = profit_df.assign(INTEREST_EXPENSE=0)
|
|
316
318
|
if 'FEE_COMMISSION_EXPENSE' not in profit_df.columns:
|
|
317
|
-
profit_df
|
|
319
|
+
profit_df = profit_df.assign(FEE_COMMISSION_EXPENSE=0)
|
|
318
320
|
if 'RESEARCH_EXPENSE' not in profit_df.columns:
|
|
319
|
-
profit_df
|
|
321
|
+
profit_df = profit_df.assign(RESEARCH_EXPENSE=0)
|
|
320
322
|
if 'SALE_EXPENSE' not in profit_df.columns:
|
|
321
|
-
profit_df
|
|
323
|
+
profit_df = profit_df.assign(SALE_EXPENSE=0)
|
|
322
324
|
if 'MANAGE_EXPENSE' not in profit_df.columns:
|
|
323
|
-
profit_df
|
|
325
|
+
profit_df = profit_df.assign(MANAGE_EXPENSE=0)
|
|
324
326
|
if 'FINANCE_EXPENSE' not in profit_df.columns:
|
|
325
|
-
profit_df
|
|
327
|
+
profit_df = profit_df.assign(FINANCE_EXPENSE=0)
|
|
326
328
|
if 'FE_INTEREST_EXPENSE' not in profit_df.columns:
|
|
327
|
-
profit_df
|
|
329
|
+
profit_df = profit_df.assign(FE_INTEREST_EXPENSE=0)
|
|
328
330
|
if 'FE_INTEREST_INCOME' not in profit_df.columns:
|
|
329
|
-
profit_df
|
|
331
|
+
profit_df = profit_df.assign(FE_INTEREST_INCOME=0)
|
|
330
332
|
if 'CREDIT_IMPAIRMENT_INCOME' not in profit_df.columns:
|
|
331
|
-
profit_df
|
|
333
|
+
profit_df = profit_df.assign(CREDIT_IMPAIRMENT_INCOME=0)
|
|
332
334
|
if 'ACCOUNTS_RECE' not in profit_df.columns:
|
|
333
|
-
profit_df
|
|
334
|
-
|
|
335
|
+
profit_df = profit_df.assign(ACCOUNTS_RECE=0)
|
|
335
336
|
if 'LOAN_ADVANCE' not in profit_df.columns:
|
|
336
|
-
profit_df
|
|
337
|
+
profit_df = profit_df.assign(LOAN_ADVANCE=0)
|
|
337
338
|
if 'MONETARYFUNDS' not in profit_df.columns:
|
|
338
|
-
profit_df
|
|
339
|
+
profit_df = profit_df.assign(MONETARYFUNDS=0)
|
|
339
340
|
return profit_df
|
|
340
341
|
|
|
341
342
|
|
|
342
|
-
import mns_common.
|
|
343
|
+
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
343
344
|
|
|
344
345
|
if __name__ == '__main__':
|
|
345
|
-
get_em_profit_api('
|
|
346
|
-
em_df =
|
|
346
|
+
get_em_profit_api('688302')
|
|
347
|
+
em_df = em_stock_info_api.get_a_stock_info()
|
|
347
348
|
for em_one in em_df.itertuples():
|
|
348
349
|
try:
|
|
349
350
|
get_em_profit_api(em_one.symbol)
|
|
@@ -2,14 +2,14 @@ import sys
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') +
|
|
5
|
+
end = file_path.index('mns') + 17
|
|
6
6
|
project_path = file_path[0:end]
|
|
7
7
|
sys.path.append(project_path)
|
|
8
8
|
|
|
9
9
|
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
10
10
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
11
11
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
12
|
-
import mns_common.
|
|
12
|
+
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
13
13
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
14
14
|
|
|
15
15
|
mongodb_util = MongodbUtil('27017')
|
|
@@ -39,7 +39,7 @@ def find_asset_liability_report(period_time):
|
|
|
39
39
|
|
|
40
40
|
# 查出未报告的股票
|
|
41
41
|
def find_un_report_symbol(period_time, report_name):
|
|
42
|
-
real_time_quotes_df =
|
|
42
|
+
real_time_quotes_df = em_stock_info_api.get_a_stock_info()
|
|
43
43
|
real_time_quotes_df = real_time_quotes_df.loc[~(real_time_quotes_df['name'].str.contains('退'))]
|
|
44
44
|
real_time_quotes_df.dropna(subset=['list_date'], axis=0, inplace=True)
|
|
45
45
|
|
mns_scheduler/finance/{sync_financial_report_service_api.py → sync_financial_report_service_task.py}
RENAMED
|
@@ -2,21 +2,22 @@ import sys
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') +
|
|
5
|
+
end = file_path.index('mns') + 17
|
|
6
6
|
project_path = file_path[0:end]
|
|
7
7
|
sys.path.append(project_path)
|
|
8
8
|
from datetime import datetime
|
|
9
9
|
|
|
10
10
|
import mns_common.constant.db_name_constant as db_name_constant
|
|
11
|
-
import mns_scheduler.finance.em_financial_profit_sync_service_api as em_financial_profit_sync_service_api
|
|
11
|
+
import mns_scheduler.finance.em.em_financial_profit_sync_service_api as em_financial_profit_sync_service_api
|
|
12
12
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
13
13
|
from loguru import logger
|
|
14
14
|
import \
|
|
15
|
-
mns_scheduler.finance.em_financial_asset_liability_sync_service_api as em_financial_asset_liability_sync_service_api
|
|
15
|
+
mns_scheduler.finance.em.em_financial_asset_liability_sync_service_api as em_financial_asset_liability_sync_service_api
|
|
16
16
|
import mns_scheduler.risk.financial_report_risk_check_api as financial_report_risk_check_api
|
|
17
17
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
18
|
-
import mns_scheduler.finance.finance_common_api as finance_common_api
|
|
18
|
+
import mns_scheduler.finance.em.finance_common_api as finance_common_api
|
|
19
19
|
import mns_scheduler.risk.compliance.undisclosed_annual_report_api as undisclosed_annual_report_api
|
|
20
|
+
import mns_scheduler.finance.xue_qiu.sync_xue_qiu_fiance_data as sync_xue_qiu_fiance_data
|
|
20
21
|
|
|
21
22
|
mongodb_util = MongodbUtil('27017')
|
|
22
23
|
|
|
@@ -26,39 +27,90 @@ mongodb_util = MongodbUtil('27017')
|
|
|
26
27
|
# 3、上市公司季报披露时间:
|
|
27
28
|
# 1季报:每年4月1日-- -4月30日。
|
|
28
29
|
# 2季报(中报) :每年7月1日--8月30日。
|
|
29
|
-
# 3季报:每年10月1日--10月31日
|
|
30
|
+
# 3季报:每年10月1日--10月31日
|
|
31
|
+
# 4季报(年报) :每年1月1日--4月30日
|
|
30
32
|
|
|
31
33
|
def sync_financial_report():
|
|
32
34
|
now_date = datetime.now()
|
|
33
35
|
now_year = now_date.year
|
|
34
36
|
now_month = now_date.month
|
|
35
37
|
sync_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
36
|
-
|
|
37
|
-
if 1
|
|
38
|
+
|
|
39
|
+
if now_month in [1, 2, 3, 4]:
|
|
40
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year - 1) + '年报', None)
|
|
41
|
+
|
|
42
|
+
# 年报
|
|
38
43
|
period = 4
|
|
39
44
|
period_time = str(now_year - 1) + "-12-31 00:00:00"
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
sync_em_profit_report(period_time, sync_time, period)
|
|
46
|
+
sync_em_asset_liability_report(period_time, sync_time, period)
|
|
47
|
+
|
|
48
|
+
# 一季报
|
|
49
|
+
if now_month == 4:
|
|
50
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '一季报', None)
|
|
51
|
+
|
|
52
|
+
period = 1
|
|
53
|
+
period_time = str(now_year) + "-03-31 00:00:00"
|
|
54
|
+
sync_em_profit_report(period_time, sync_time, period)
|
|
55
|
+
sync_em_asset_liability_report(period_time, sync_time, period)
|
|
56
|
+
|
|
42
57
|
|
|
43
|
-
# 一季报
|
|
44
|
-
elif now_month == 5:
|
|
45
|
-
period = 1
|
|
46
|
-
period_time = str(now_year) + "-03-31 00:00:00"
|
|
47
|
-
sync_profit_report(period_time, sync_time, period)
|
|
48
|
-
sync_asset_liability_report(period_time, sync_time, period)
|
|
49
58
|
|
|
50
59
|
# 二季报
|
|
51
|
-
elif
|
|
60
|
+
elif now_month in [7, 8]:
|
|
61
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '中报', None)
|
|
62
|
+
|
|
52
63
|
period = 2
|
|
53
64
|
period_time = str(now_year) + "-06-30 00:00:00"
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
sync_em_profit_report(period_time, sync_time, period)
|
|
66
|
+
sync_em_asset_liability_report(period_time, sync_time, period)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
56
70
|
# 三季报
|
|
57
71
|
elif now_month == 10:
|
|
72
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '三季报', None)
|
|
73
|
+
|
|
58
74
|
period = 3
|
|
59
75
|
period_time = str(now_year) + "-09-30 00:00:00"
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
sync_em_profit_report(period_time, sync_time, period)
|
|
77
|
+
sync_em_asset_liability_report(period_time, sync_time, period)
|
|
78
|
+
|
|
79
|
+
elif now_month == 5:
|
|
80
|
+
|
|
81
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year - 1) + '年报', None)
|
|
82
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '一季报', None)
|
|
83
|
+
|
|
84
|
+
# 补偿年报和一季度,出不了报告的
|
|
85
|
+
miss_period_04 = 4
|
|
86
|
+
miss_period_time_04 = str(now_year - 1) + "-12-31 00:00:00"
|
|
87
|
+
|
|
88
|
+
sync_em_profit_report(miss_period_time_04, sync_time, miss_period_04)
|
|
89
|
+
sync_em_asset_liability_report(miss_period_time_04, sync_time, miss_period_04)
|
|
90
|
+
|
|
91
|
+
period_01 = 1
|
|
92
|
+
period_time_01 = str(now_year) + "-03-31 00:00:00"
|
|
93
|
+
sync_em_profit_report(period_time_01, sync_time, period_01)
|
|
94
|
+
sync_em_asset_liability_report(period_time_01, sync_time, period_01)
|
|
95
|
+
|
|
96
|
+
elif now_month == 9:
|
|
97
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '中报', None)
|
|
98
|
+
|
|
99
|
+
# 补偿二季度
|
|
100
|
+
period_02 = 2
|
|
101
|
+
period_time_02 = str(now_year) + "-06-30 00:00:00"
|
|
102
|
+
sync_em_profit_report(period_time_02, sync_time, period_02)
|
|
103
|
+
sync_em_asset_liability_report(period_time_02, sync_time, period_02)
|
|
104
|
+
|
|
105
|
+
elif now_month in [11, 12]:
|
|
106
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '三季报', None)
|
|
107
|
+
|
|
108
|
+
# 补偿三季度
|
|
109
|
+
period_03 = 3
|
|
110
|
+
period_time_03 = str(now_year) + "-09-30 00:00:00"
|
|
111
|
+
sync_em_profit_report(period_time_03, sync_time, period_03)
|
|
112
|
+
sync_em_asset_liability_report(period_time_03, sync_time, period_03)
|
|
113
|
+
|
|
62
114
|
# 未出报告check
|
|
63
115
|
undisclosed_annual_report_api.un_disclosed_report_check(sync_time, now_year, period, period_time)
|
|
64
116
|
# 新股或者未出报告的
|
|
@@ -66,7 +118,7 @@ def sync_financial_report():
|
|
|
66
118
|
|
|
67
119
|
|
|
68
120
|
# 同步资产表
|
|
69
|
-
def
|
|
121
|
+
def sync_em_asset_liability_report(period_time, sync_time, period):
|
|
70
122
|
un_report_asset_df = finance_common_api.find_un_report_symbol(period_time,
|
|
71
123
|
db_name_constant.EM_STOCK_ASSET_LIABILITY)
|
|
72
124
|
for un_report_asset_one in un_report_asset_df.itertuples():
|
|
@@ -91,8 +143,8 @@ def sync_asset_liability_report(period_time, sync_time, period):
|
|
|
91
143
|
logger.error("同步资产表异常:{},{},{}", symbol, period_time, e)
|
|
92
144
|
|
|
93
145
|
|
|
94
|
-
#
|
|
95
|
-
def
|
|
146
|
+
# 同步em利润表
|
|
147
|
+
def sync_em_profit_report(period_time, sync_time, period):
|
|
96
148
|
un_report_profit_df = finance_common_api.find_un_report_symbol(period_time, db_name_constant.EM_STOCK_PROFIT)
|
|
97
149
|
for un_report_profit_one in un_report_profit_df.itertuples():
|
|
98
150
|
try:
|
|
@@ -142,8 +194,9 @@ def sync_miss_report(sync_time):
|
|
|
142
194
|
|
|
143
195
|
|
|
144
196
|
if __name__ == '__main__':
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
sync_time_test =
|
|
197
|
+
now_date_test = datetime.now()
|
|
198
|
+
now_year_test = now_date_test.year
|
|
199
|
+
now_month_test = now_date_test.month
|
|
200
|
+
sync_time_test = now_date_test.strftime('%Y-%m-%d %H:%M:%S')
|
|
149
201
|
sync_miss_report(sync_time_test)
|
|
202
|
+
sync_financial_report()
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
import requests
|
|
9
|
+
import pandas as pd
|
|
10
|
+
from loguru import logger
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# report_type income 利润表
|
|
14
|
+
# cash_flow 现金流量
|
|
15
|
+
# balance 资产负债
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_xue_qiu_report(symbol, report_type, cookie, count, period_type):
|
|
19
|
+
# 请求 URL
|
|
20
|
+
url = (f"https://stock.xueqiu.com/v5/stock/finance/cn/{report_type}.json?symbol={symbol}&type={period_type}"
|
|
21
|
+
f"&is_detail=true&count={count}")
|
|
22
|
+
|
|
23
|
+
# 请求头(关键是 cookies)
|
|
24
|
+
headers = {
|
|
25
|
+
"accept": "application/json, text/plain, */*",
|
|
26
|
+
"accept-language": "zh-CN,zh;q=0.9",
|
|
27
|
+
"origin": "https://xueqiu.com",
|
|
28
|
+
"referer": f"https://xueqiu.com/snowman/S/{symbol}/detail",
|
|
29
|
+
"sec-fetch-mode": "cors",
|
|
30
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
|
|
31
|
+
# ⚠ 替换为你浏览器访问雪球后的 Cookie(需含 xq_a_token)
|
|
32
|
+
"cookie": cookie,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# 发送请求
|
|
36
|
+
response = requests.get(url, headers=headers)
|
|
37
|
+
|
|
38
|
+
# 检查结果
|
|
39
|
+
if response.status_code == 200:
|
|
40
|
+
data = response.json()
|
|
41
|
+
|
|
42
|
+
# 提取财报数据列表
|
|
43
|
+
raw_list = data['data']['list']
|
|
44
|
+
processed_list = []
|
|
45
|
+
|
|
46
|
+
for entry in raw_list:
|
|
47
|
+
flat_entry = {}
|
|
48
|
+
for key, value in entry.items():
|
|
49
|
+
if isinstance(value, list) and len(value) == 2:
|
|
50
|
+
# 处理列表字段:提取两个值,空则填 0
|
|
51
|
+
v0 = value[0] if value[0] is not None else 0
|
|
52
|
+
v1 = value[1] if value[1] is not None else 0
|
|
53
|
+
flat_entry[key] = v0
|
|
54
|
+
flat_entry[key + "_chg"] = round(v1 * 100, 2)
|
|
55
|
+
elif value is None:
|
|
56
|
+
# 整个字段为空,设置为 0 和 0(变化量)
|
|
57
|
+
flat_entry[key] = 0
|
|
58
|
+
else:
|
|
59
|
+
flat_entry[key] = value
|
|
60
|
+
processed_list.append(flat_entry)
|
|
61
|
+
|
|
62
|
+
# 转换为 DataFrame
|
|
63
|
+
df = pd.DataFrame(processed_list)
|
|
64
|
+
return df
|
|
65
|
+
|
|
66
|
+
else:
|
|
67
|
+
logger.error("请求失败,状态码:{}", response.status_code)
|
|
68
|
+
return pd.DataFrame()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
import mns_common.component.cookie.cookie_info_service as cookie_info_service
|
|
72
|
+
|
|
73
|
+
if __name__ == '__main__':
|
|
74
|
+
cash_flow_df = get_xue_qiu_report('SZ301662', 'cash_flow', cookie_info_service.get_xue_qiu_cookie(), 1, 'all')
|
|
75
|
+
income_df = get_xue_qiu_report('SZ301662', 'income', cookie_info_service.get_xue_qiu_cookie(), 1, 'all')
|
|
76
|
+
balance_df = get_xue_qiu_report('SZ301662', 'balance', cookie_info_service.get_xue_qiu_cookie(), 1, 'all')
|
|
77
|
+
pass
|