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,80 @@
|
|
|
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
|
+
from mns_scheduler.db.script.sync.remote_mongo_util import RemoteMongodbUtil
|
|
10
|
+
from mns_scheduler.db.script.sync.local_mongo_util import LocalMongodbUtil
|
|
11
|
+
from loguru import logger
|
|
12
|
+
|
|
13
|
+
remote_mongodb_util = RemoteMongodbUtil('27017')
|
|
14
|
+
local_mongodb_util = LocalMongodbUtil('27017')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def create_index(db_name):
|
|
18
|
+
local_mongodb_util.create_index(db_name, [("symbol", 1)])
|
|
19
|
+
|
|
20
|
+
local_mongodb_util.create_index(db_name, [("str_now_date", 1)])
|
|
21
|
+
|
|
22
|
+
local_mongodb_util.create_index(db_name, [("symbol", 1), ("number", 1)])
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def sync_real_time_data(str_day, min_number, max_number):
|
|
26
|
+
db_name = 'realtime_quotes_now_' + str_day
|
|
27
|
+
# 创建索引
|
|
28
|
+
create_index(db_name)
|
|
29
|
+
while min_number <= max_number:
|
|
30
|
+
query = {'number': min_number}
|
|
31
|
+
data_df = remote_mongodb_util.find_query_data(db_name, query)
|
|
32
|
+
local_mongodb_util.insert_mongo(data_df, db_name)
|
|
33
|
+
min_number = min_number + 1
|
|
34
|
+
logger.info(min_number)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def sync_k_line(str_day):
|
|
38
|
+
query = {"str_day": str_day}
|
|
39
|
+
db_name = 'k_line_info'
|
|
40
|
+
data_df = remote_mongodb_util.find_query_data(db_name, query)
|
|
41
|
+
try:
|
|
42
|
+
local_mongodb_util.insert_mongo(data_df, db_name)
|
|
43
|
+
except BaseException as e:
|
|
44
|
+
logger.error("出现异常:{}", e)
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == '__main__':
|
|
49
|
+
str_day_01 = '2025-09-10'
|
|
50
|
+
sync_k_line(str_day_01)
|
|
51
|
+
|
|
52
|
+
# sync_real_time_data(str_day_01, 1, 2500)
|
|
53
|
+
|
|
54
|
+
# sync_k_line(str_day_01)
|
|
55
|
+
# sync_k_line('2024-11-13')
|
|
56
|
+
# sync_k_line('2024-11-12')
|
|
57
|
+
# sync_k_line('2024-11-15') 232
|
|
58
|
+
|
|
59
|
+
# sync_real_time_data('2024-11-15', 10, 1010)
|
|
60
|
+
|
|
61
|
+
# sync_k_line('2024-12-20')
|
|
62
|
+
# sync_k_line('2024-12-19')
|
|
63
|
+
# sync_k_line('2024-12-18')
|
|
64
|
+
# sync_k_line('2024-12-17')
|
|
65
|
+
# sync_k_line('2024-12-16')
|
|
66
|
+
#
|
|
67
|
+
# sync_k_line('2024-12-13')
|
|
68
|
+
# sync_k_line('2024-12-12')
|
|
69
|
+
# sync_k_line('2024-12-11')
|
|
70
|
+
# sync_k_line('2024-12-10')
|
|
71
|
+
# sync_k_line('2024-12-09')
|
|
72
|
+
#
|
|
73
|
+
# sync_k_line('2024-12-06')
|
|
74
|
+
# sync_k_line('2024-12-05')
|
|
75
|
+
# sync_k_line('2024-12-04')
|
|
76
|
+
# sync_k_line('2024-12-03')
|
|
77
|
+
# sync_k_line('2024-12-02')
|
|
78
|
+
|
|
79
|
+
# sync_real_time_data('2024-12-20', 1000, 2000)
|
|
80
|
+
# sync_real_time_data('2024-11-13', 10, 1010)
|
|
@@ -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')
|
|
@@ -422,7 +422,7 @@ def get_em_asset_liability_api(symbol):
|
|
|
422
422
|
exist_asset_em_df = mongodb_util.find_query_data(db_name_constant.EM_STOCK_ASSET_LIABILITY, query)
|
|
423
423
|
if data_frame_util.is_not_empty(exist_asset_em_df):
|
|
424
424
|
new_asset_df = stock_balance_sheet_by_report_em_df.loc[
|
|
425
|
-
~(stock_balance_sheet_by_report_em_df['
|
|
425
|
+
~(stock_balance_sheet_by_report_em_df['_id'].isin(list(exist_asset_em_df['_id'])))]
|
|
426
426
|
else:
|
|
427
427
|
new_asset_df = stock_balance_sheet_by_report_em_df
|
|
428
428
|
if data_frame_util.is_empty(new_asset_df):
|
|
@@ -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[[
|
|
@@ -289,57 +291,60 @@ def get_em_profit_api(symbol):
|
|
|
289
291
|
exist_profit_em_df = mongodb_util.find_query_data(db_name_constant.EM_STOCK_PROFIT, query)
|
|
290
292
|
if data_frame_util.is_not_empty(exist_profit_em_df):
|
|
291
293
|
new_profit_df = stock_profit_sheet_by_report_em.loc[
|
|
292
|
-
~(stock_profit_sheet_by_report_em['
|
|
294
|
+
~(stock_profit_sheet_by_report_em['_id'].isin(list(exist_profit_em_df['_id'])))]
|
|
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)
|
|
306
|
+
|
|
307
|
+
if 'FAIRVALUE_CHANGE_INCOME' not in profit_df.columns:
|
|
308
|
+
profit_df = profit_df.assign(FAIRVALUE_CHANGE_INCOME=0)
|
|
304
309
|
|
|
305
310
|
if 'INTEREST_INCOME' not in profit_df.columns:
|
|
306
|
-
profit_df
|
|
311
|
+
profit_df = profit_df.assign(INTEREST_INCOME=0)
|
|
307
312
|
if 'TOTAL_OPERATE_COST' not in profit_df.columns:
|
|
308
|
-
profit_df
|
|
313
|
+
profit_df = profit_df.assign(TOTAL_OPERATE_COST=0)
|
|
309
314
|
if 'OPERATE_COST' not in profit_df.columns:
|
|
310
|
-
profit_df
|
|
315
|
+
profit_df = profit_df.assign(OPERATE_COST=0)
|
|
311
316
|
if 'INTEREST_EXPENSE' not in profit_df.columns:
|
|
312
|
-
profit_df
|
|
317
|
+
profit_df = profit_df.assign(INTEREST_EXPENSE=0)
|
|
313
318
|
if 'FEE_COMMISSION_EXPENSE' not in profit_df.columns:
|
|
314
|
-
profit_df
|
|
319
|
+
profit_df = profit_df.assign(FEE_COMMISSION_EXPENSE=0)
|
|
315
320
|
if 'RESEARCH_EXPENSE' not in profit_df.columns:
|
|
316
|
-
profit_df
|
|
321
|
+
profit_df = profit_df.assign(RESEARCH_EXPENSE=0)
|
|
317
322
|
if 'SALE_EXPENSE' not in profit_df.columns:
|
|
318
|
-
profit_df
|
|
323
|
+
profit_df = profit_df.assign(SALE_EXPENSE=0)
|
|
319
324
|
if 'MANAGE_EXPENSE' not in profit_df.columns:
|
|
320
|
-
profit_df
|
|
325
|
+
profit_df = profit_df.assign(MANAGE_EXPENSE=0)
|
|
321
326
|
if 'FINANCE_EXPENSE' not in profit_df.columns:
|
|
322
|
-
profit_df
|
|
327
|
+
profit_df = profit_df.assign(FINANCE_EXPENSE=0)
|
|
323
328
|
if 'FE_INTEREST_EXPENSE' not in profit_df.columns:
|
|
324
|
-
profit_df
|
|
329
|
+
profit_df = profit_df.assign(FE_INTEREST_EXPENSE=0)
|
|
325
330
|
if 'FE_INTEREST_INCOME' not in profit_df.columns:
|
|
326
|
-
profit_df
|
|
331
|
+
profit_df = profit_df.assign(FE_INTEREST_INCOME=0)
|
|
327
332
|
if 'CREDIT_IMPAIRMENT_INCOME' not in profit_df.columns:
|
|
328
|
-
profit_df
|
|
333
|
+
profit_df = profit_df.assign(CREDIT_IMPAIRMENT_INCOME=0)
|
|
329
334
|
if 'ACCOUNTS_RECE' not in profit_df.columns:
|
|
330
|
-
profit_df
|
|
331
|
-
|
|
335
|
+
profit_df = profit_df.assign(ACCOUNTS_RECE=0)
|
|
332
336
|
if 'LOAN_ADVANCE' not in profit_df.columns:
|
|
333
|
-
profit_df
|
|
337
|
+
profit_df = profit_df.assign(LOAN_ADVANCE=0)
|
|
334
338
|
if 'MONETARYFUNDS' not in profit_df.columns:
|
|
335
|
-
profit_df
|
|
339
|
+
profit_df = profit_df.assign(MONETARYFUNDS=0)
|
|
336
340
|
return profit_df
|
|
337
341
|
|
|
338
342
|
|
|
339
|
-
import mns_common.
|
|
343
|
+
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
340
344
|
|
|
341
345
|
if __name__ == '__main__':
|
|
342
|
-
|
|
346
|
+
get_em_profit_api('688302')
|
|
347
|
+
em_df = em_stock_info_api.get_a_stock_info()
|
|
343
348
|
for em_one in em_df.itertuples():
|
|
344
349
|
try:
|
|
345
350
|
get_em_profit_api(em_one.symbol)
|
|
@@ -2,15 +2,16 @@ 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
|
mongodb_util = MongodbUtil('27017')
|
|
15
16
|
|
|
16
17
|
|
|
@@ -36,10 +37,9 @@ def find_asset_liability_report(period_time):
|
|
|
36
37
|
return mongodb_util.find_query_data(db_name_constant.EM_STOCK_ASSET_LIABILITY, query)
|
|
37
38
|
|
|
38
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
|
|
|
@@ -0,0 +1,202 @@
|
|
|
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 datetime import datetime
|
|
9
|
+
|
|
10
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
11
|
+
import mns_scheduler.finance.em.em_financial_profit_sync_service_api as em_financial_profit_sync_service_api
|
|
12
|
+
from mns_common.db.MongodbUtil import MongodbUtil
|
|
13
|
+
from loguru import logger
|
|
14
|
+
import \
|
|
15
|
+
mns_scheduler.finance.em.em_financial_asset_liability_sync_service_api as em_financial_asset_liability_sync_service_api
|
|
16
|
+
import mns_scheduler.risk.financial_report_risk_check_api as financial_report_risk_check_api
|
|
17
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
18
|
+
import mns_scheduler.finance.em.finance_common_api as finance_common_api
|
|
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
|
|
21
|
+
|
|
22
|
+
mongodb_util = MongodbUtil('27017')
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# 上市公司年报披露时间:每年1月1日一- 4月30日。
|
|
26
|
+
# 2、上市公司中年报披露时间:每年7月1日--8月30日。
|
|
27
|
+
# 3、上市公司季报披露时间:
|
|
28
|
+
# 1季报:每年4月1日-- -4月30日。
|
|
29
|
+
# 2季报(中报) :每年7月1日--8月30日。
|
|
30
|
+
# 3季报:每年10月1日--10月31日
|
|
31
|
+
# 4季报(年报) :每年1月1日--4月30日
|
|
32
|
+
|
|
33
|
+
def sync_financial_report():
|
|
34
|
+
now_date = datetime.now()
|
|
35
|
+
now_year = now_date.year
|
|
36
|
+
now_month = now_date.month
|
|
37
|
+
sync_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
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
|
+
# 年报
|
|
43
|
+
period = 4
|
|
44
|
+
period_time = str(now_year - 1) + "-12-31 00:00:00"
|
|
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
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# 二季报
|
|
60
|
+
elif now_month in [7, 8]:
|
|
61
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '中报', None)
|
|
62
|
+
|
|
63
|
+
period = 2
|
|
64
|
+
period_time = str(now_year) + "-06-30 00:00:00"
|
|
65
|
+
sync_em_profit_report(period_time, sync_time, period)
|
|
66
|
+
sync_em_asset_liability_report(period_time, sync_time, period)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# 三季报
|
|
71
|
+
elif now_month == 10:
|
|
72
|
+
sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '三季报', None)
|
|
73
|
+
|
|
74
|
+
period = 3
|
|
75
|
+
period_time = str(now_year) + "-09-30 00:00:00"
|
|
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
|
+
|
|
114
|
+
# 未出报告check
|
|
115
|
+
undisclosed_annual_report_api.un_disclosed_report_check(sync_time, now_year, period, period_time)
|
|
116
|
+
# 新股或者未出报告的
|
|
117
|
+
sync_miss_report(sync_time)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# 同步资产表
|
|
121
|
+
def sync_em_asset_liability_report(period_time, sync_time, period):
|
|
122
|
+
un_report_asset_df = finance_common_api.find_un_report_symbol(period_time,
|
|
123
|
+
db_name_constant.EM_STOCK_ASSET_LIABILITY)
|
|
124
|
+
for un_report_asset_one in un_report_asset_df.itertuples():
|
|
125
|
+
try:
|
|
126
|
+
symbol = un_report_asset_one.symbol
|
|
127
|
+
new_asset_df = em_financial_asset_liability_sync_service_api.get_em_asset_liability_api(symbol)
|
|
128
|
+
# 负债比
|
|
129
|
+
new_asset_df['liability_ratio'] = round(
|
|
130
|
+
new_asset_df['TOTAL_LIABILITIES'] * 100 / new_asset_df['TOTAL_ASSETS'],
|
|
131
|
+
2)
|
|
132
|
+
new_asset_df['sync_time'] = sync_time
|
|
133
|
+
if data_frame_util.is_empty(new_asset_df):
|
|
134
|
+
continue
|
|
135
|
+
new_asset_df['symbol'] = symbol
|
|
136
|
+
mongodb_util.insert_mongo(new_asset_df, db_name_constant.EM_STOCK_ASSET_LIABILITY)
|
|
137
|
+
|
|
138
|
+
# 年报审核
|
|
139
|
+
financial_report_risk_check_api.financial_report_check(new_asset_df, period_time, period,
|
|
140
|
+
db_name_constant.EM_STOCK_ASSET_LIABILITY)
|
|
141
|
+
|
|
142
|
+
except Exception as e:
|
|
143
|
+
logger.error("同步资产表异常:{},{},{}", symbol, period_time, e)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# 同步em利润表
|
|
147
|
+
def sync_em_profit_report(period_time, sync_time, period):
|
|
148
|
+
un_report_profit_df = finance_common_api.find_un_report_symbol(period_time, db_name_constant.EM_STOCK_PROFIT)
|
|
149
|
+
for un_report_profit_one in un_report_profit_df.itertuples():
|
|
150
|
+
try:
|
|
151
|
+
symbol = un_report_profit_one.symbol
|
|
152
|
+
new_profit_df = em_financial_profit_sync_service_api.get_em_profit_api(symbol)
|
|
153
|
+
if data_frame_util.is_empty(new_profit_df):
|
|
154
|
+
continue
|
|
155
|
+
new_profit_df['sync_time'] = sync_time
|
|
156
|
+
|
|
157
|
+
new_profit_df['symbol'] = symbol
|
|
158
|
+
mongodb_util.insert_mongo(new_profit_df, db_name_constant.EM_STOCK_PROFIT)
|
|
159
|
+
|
|
160
|
+
# 年报审核
|
|
161
|
+
financial_report_risk_check_api.financial_report_check(new_profit_df, period_time,
|
|
162
|
+
period, db_name_constant.EM_STOCK_PROFIT)
|
|
163
|
+
except Exception as e:
|
|
164
|
+
logger.error("同步利润表异常:{},{},{}", symbol, period_time, e)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def sync_miss_report(sync_time):
|
|
168
|
+
query = {"total_operate_income": 0}
|
|
169
|
+
un_report_company_info = mongodb_util.find_query_data(db_name_constant.COMPANY_INFO, query)
|
|
170
|
+
for un_report_one in un_report_company_info.itertuples():
|
|
171
|
+
try:
|
|
172
|
+
symbol = un_report_one.symbol
|
|
173
|
+
new_profit_df = em_financial_profit_sync_service_api.get_em_profit_api(symbol)
|
|
174
|
+
if data_frame_util.is_empty(new_profit_df):
|
|
175
|
+
continue
|
|
176
|
+
new_profit_df['sync_time'] = sync_time
|
|
177
|
+
|
|
178
|
+
new_profit_df['symbol'] = symbol
|
|
179
|
+
mongodb_util.insert_mongo(new_profit_df, db_name_constant.EM_STOCK_PROFIT)
|
|
180
|
+
|
|
181
|
+
new_asset_df = em_financial_asset_liability_sync_service_api.get_em_asset_liability_api(symbol)
|
|
182
|
+
# 负债比
|
|
183
|
+
new_asset_df['liability_ratio'] = round(
|
|
184
|
+
new_asset_df['TOTAL_LIABILITIES'] * 100 / new_asset_df['TOTAL_ASSETS'],
|
|
185
|
+
2)
|
|
186
|
+
new_asset_df['sync_time'] = sync_time
|
|
187
|
+
if data_frame_util.is_empty(new_asset_df):
|
|
188
|
+
continue
|
|
189
|
+
new_asset_df['symbol'] = symbol
|
|
190
|
+
mongodb_util.insert_mongo(new_asset_df, db_name_constant.EM_STOCK_ASSET_LIABILITY)
|
|
191
|
+
|
|
192
|
+
except Exception as e:
|
|
193
|
+
logger.error("同步财报补偿任务异常:{},{},{}", symbol, e)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if __name__ == '__main__':
|
|
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')
|
|
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
|