mns-scheduler 1.2.9.6__py3-none-any.whl → 1.4.2.5__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.
Potentially problematic release.
This version of mns-scheduler might be problematic. Click here for more details.
- mns_scheduler/company_info/announce/__init__.py +1 -1
- mns_scheduler/company_info/announce/company_announce_sync_service.py +11 -6
- mns_scheduler/company_info/base/__init__.py +1 -1
- mns_scheduler/company_info/base/sync_company_base_info_api.py +164 -74
- 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 +2 -2
- mns_scheduler/company_info/constant/__init__.py +1 -1
- mns_scheduler/company_info/constant/company_constant_data.py +4 -0
- 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 +1 -1
- mns_scheduler/company_info/em_stock_info/sync_em_stock_info_sync.py +44 -33
- mns_scheduler/company_info/remark/__init__.py +1 -1
- mns_scheduler/company_info/remark/company_remark_info_sync.py +1 -1
- mns_scheduler/concept/clean/kpl_concept_clean_api.py +1 -1
- mns_scheduler/concept/clean/ths_concept_clean_api.py +3 -6
- 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 +1 -1
- mns_scheduler/db/script/db_move/col_move_one_service.py +1 -1
- mns_scheduler/db/script/sync/__init__.py +1 -1
- mns_scheduler/db/script/sync/remote_data_sync_to_local.py +39 -9
- mns_scheduler/db/script/sync/sync_hui_ce_test_data.py +35 -24
- mns_scheduler/db/script/sync/sync_hui_ce_test_data_01.py +23 -23
- mns_scheduler/db/script/update/__init__.py +1 -1
- mns_scheduler/db/script/update/update_col_field.py +1 -1
- 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} +6 -4
- mns_scheduler/finance/{finance_common_api.py → em/finance_common_api.py} +1 -1
- 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 +2 -1
- mns_scheduler/hk/hk_industry_info_sync_service_api.py +1 -1
- mns_scheduler/industry/__init__.py +1 -1
- mns_scheduler/industry/ths/__init__.py +1 -1
- mns_scheduler/industry/ths/ths_industry_index_service.py +1 -1
- mns_scheduler/industry/ths/ths_industry_sync_service.py +1 -1
- 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 +10 -6
- mns_scheduler/k_line/clean/daily/__init__.py +1 -1
- mns_scheduler/k_line/clean/daily/daily_k_line_clean_common_service.py +1 -1
- mns_scheduler/k_line/clean/daily/daily_k_line_service.py +1 -1
- mns_scheduler/k_line/clean/k_line_info_clean_task.py +7 -2
- 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 +1 -1
- mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py +1 -1
- mns_scheduler/{extraIncome/one_minute → k_line}/common/__init__.py +1 -1
- 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 +12 -32
- mns_scheduler/k_line/month_week_daily/daily_week_month_line_sync.py +6 -13
- 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 +1 -1
- mns_scheduler/k_line/year_quarter/__init__.py +1 -1
- mns_scheduler/k_line/year_quarter/year_quarter_line_sync.py +17 -10
- 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 +1 -1
- mns_scheduler/risk/__init__.py +1 -1
- mns_scheduler/risk/compliance/undisclosed_annual_report_api.py +4 -2
- mns_scheduler/risk/financial/annual_report_audit_check_api.py +1 -1
- mns_scheduler/risk/financial/profit_income_check_api.py +1 -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 +2 -2
- mns_scheduler/risk/transactions/transactions_check_api.py +2 -2
- mns_scheduler/self_choose/__init__.py +1 -1
- mns_scheduler/self_choose/ths_self_choose_service.py +37 -28
- mns_scheduler/trade/auto_login/trader_auto_service.py +6 -4
- mns_scheduler/trade/auto_sell_service_api.py +2 -2
- mns_scheduler/trade/balance/__init__.py +1 -1
- mns_scheduler/trade/balance/ths_account_balance_service.py +1 -1
- mns_scheduler/trade/sync_position_api.py +1 -1
- mns_scheduler/trade/task/trader_task_service.py +26 -9
- mns_scheduler/trade/tfp/__init__.py +1 -1
- mns_scheduler/trade/tfp/stock_tfp_info_sync.py +5 -2
- mns_scheduler/zt/script/__init__.py +1 -1
- mns_scheduler/zt/script/fix_error_deal_day.py +1 -1
- 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 +5 -4
- mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py +44 -17
- mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py +33 -80
- mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py +18 -5
- 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 +64 -60
- {mns_scheduler-1.2.9.6.dist-info → mns_scheduler-1.4.2.5.dist-info}/METADATA +1 -1
- mns_scheduler-1.4.2.5.dist-info/RECORD +169 -0
- mns_scheduler/big_deal/__init__.py +0 -7
- mns_scheduler/big_deal/ths_big_deal_sync.py +0 -98
- mns_scheduler/debt/kzz_bond_info_sync.py +0 -33
- mns_scheduler/extraIncome/one_minute/common/db_create_index.py +0 -9
- mns_scheduler/extraIncome/one_minute/common/symbol_handle_util.py +0 -41
- mns_scheduler/extraIncome/one_minute/etf/__init__.py +0 -7
- mns_scheduler/extraIncome/one_minute/etf/etf_one_minute_sync_task.py +0 -87
- mns_scheduler/extraIncome/one_minute/index/__init__.py +0 -7
- mns_scheduler/extraIncome/one_minute/index/main_index_sync_task.py +0 -74
- mns_scheduler/extraIncome/one_minute/kzz/__init__.py +0 -7
- mns_scheduler/extraIncome/one_minute/kzz/kzz_one_minute_sync_task.py +0 -87
- mns_scheduler/extraIncome/one_minute/one_minute_sync_task.py +0 -34
- mns_scheduler/extraIncome/one_minute/stock/__init__.py +0 -7
- mns_scheduler/extraIncome/one_minute/stock/stock_one_minute_sync_task.py +0 -89
- mns_scheduler/extraIncome/temp/__init__.py +0 -7
- mns_scheduler/extraIncome/temp/tu_share_data_etf_sync.py +0 -103
- mns_scheduler/extraIncome/temp/tu_share_data_kzz_sync.py +0 -113
- mns_scheduler/extraIncome/temp/tu_share_data_stock_sync.py +0 -137
- mns_scheduler/extraIncome/temp/tu_share_zhi_shu_sync_api.py +0 -107
- mns_scheduler/us/__init__.py +0 -7
- mns_scheduler/us/baidu_yun_pan_handle_service.py +0 -131
- mns_scheduler/us/k_line.py +0 -91
- mns_scheduler/us/us_company_info_sync_service_api.py +0 -39
- mns_scheduler-1.2.9.6.dist-info/RECORD +0 -183
- /mns_scheduler/{debt → finance/em}/__init__.py +0 -0
- /mns_scheduler/{extraIncome → finance/xue_qiu}/__init__.py +0 -0
- /mns_scheduler/{extraIncome/one_minute → k_line/sync_status}/__init__.py +0 -0
- {mns_scheduler-1.2.9.6.dist-info → mns_scheduler-1.4.2.5.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.2.9.6.dist-info → mns_scheduler-1.4.2.5.dist-info}/top_level.txt +0 -0
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')
|
|
201
|
+
sync_miss_report(sync_time_test)
|
|
149
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
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
file_path = os.path.abspath(__file__)
|
|
5
|
+
end = file_path.index('mns') + 16
|
|
6
|
+
project_path = file_path[0:end]
|
|
7
|
+
sys.path.append(project_path)
|
|
8
|
+
|
|
9
|
+
from mns_common.db.MongodbUtil import MongodbUtil
|
|
10
|
+
import mns_common.constant.extra_income_db_name as extra_income_db_name
|
|
11
|
+
import mns_scheduler.finance.xue_qiu.down_load_xueqiu_report_api as down_load_xueqiu_report_api
|
|
12
|
+
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
13
|
+
import pandas as pd
|
|
14
|
+
from loguru import logger
|
|
15
|
+
import time
|
|
16
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
17
|
+
import mns_common.component.cookie.cookie_info_service as cookie_info_service
|
|
18
|
+
from datetime import datetime
|
|
19
|
+
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
20
|
+
|
|
21
|
+
mongodb_util_27017 = MongodbUtil('27017')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# report_type income 利润表
|
|
25
|
+
# cash_flow 现金流量
|
|
26
|
+
# balance 资产负债
|
|
27
|
+
# 同步所有股票 报表
|
|
28
|
+
def sync_all_stocks_report():
|
|
29
|
+
em_a_stock_info_df = em_stock_info_api.get_a_stock_info()
|
|
30
|
+
em_a_stock_info_df = common_service_fun_api.add_pre_prefix(em_a_stock_info_df)
|
|
31
|
+
# 或等效写法 df['A'].str[0:6]
|
|
32
|
+
|
|
33
|
+
fail_list = []
|
|
34
|
+
|
|
35
|
+
xue_qiu_cookie = cookie_info_service.get_xue_qiu_cookie()
|
|
36
|
+
report_type_list = ['income', 'balance', 'cash_flow']
|
|
37
|
+
for stock_one in em_a_stock_info_df.itertuples():
|
|
38
|
+
fail_list = save_one_symbol_data(stock_one, report_type_list, xue_qiu_cookie, True, fail_list, '', False)
|
|
39
|
+
|
|
40
|
+
handle_number = 0
|
|
41
|
+
# 处理失败的
|
|
42
|
+
while len(fail_list) > 0:
|
|
43
|
+
fail_df = em_a_stock_info_df.loc[em_a_stock_info_df['symbol'].isin(fail_list)]
|
|
44
|
+
for fail_one in fail_df.itertuples():
|
|
45
|
+
fail_list = save_one_symbol_data(fail_one, report_type_list, xue_qiu_cookie, True, fail_list, '', False)
|
|
46
|
+
handle_number = handle_number + 1
|
|
47
|
+
if handle_number > 10:
|
|
48
|
+
break
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def save_one_symbol_data(stock_one, report_type_list, xue_qiu_cookie, save_tag, fail_list, report_name, check_exist):
|
|
52
|
+
try:
|
|
53
|
+
symbol_prefix = stock_one.symbol_prefix
|
|
54
|
+
name = stock_one.name
|
|
55
|
+
symbol = stock_one.symbol
|
|
56
|
+
for report_type in report_type_list:
|
|
57
|
+
if report_type == 'income':
|
|
58
|
+
col_name = extra_income_db_name.XUE_QIU_LRB_INCOME
|
|
59
|
+
elif report_type == 'balance':
|
|
60
|
+
col_name = extra_income_db_name.XUE_QIU_ASSET_DEBT
|
|
61
|
+
elif report_type == 'cash_flow':
|
|
62
|
+
col_name = extra_income_db_name.XUE_QIU_CASH_FLOW
|
|
63
|
+
if check_exist:
|
|
64
|
+
query_exist = {'symbol': symbol, 'report_name': report_name}
|
|
65
|
+
# 存在数据 不在同步
|
|
66
|
+
if mongodb_util_27017.exist_data_query(col_name, query_exist):
|
|
67
|
+
continue
|
|
68
|
+
|
|
69
|
+
index_create = [('symbol', 1), ('report_date', 1)]
|
|
70
|
+
mongodb_util_27017.create_index(col_name, index_create)
|
|
71
|
+
|
|
72
|
+
index_create_01 = [('symbol', 1), ('sync_time', 1)]
|
|
73
|
+
mongodb_util_27017.create_index(col_name, index_create_01)
|
|
74
|
+
|
|
75
|
+
if check_exist:
|
|
76
|
+
# 季度同步只同步一条数据
|
|
77
|
+
result_df = down_load_xueqiu_report_api.get_xue_qiu_report(symbol_prefix, report_type, xue_qiu_cookie,
|
|
78
|
+
1,
|
|
79
|
+
'all')
|
|
80
|
+
else:
|
|
81
|
+
result_df = down_load_xueqiu_report_api.get_xue_qiu_report(symbol_prefix, report_type, xue_qiu_cookie,
|
|
82
|
+
200,
|
|
83
|
+
'all')
|
|
84
|
+
|
|
85
|
+
now_date = datetime.now()
|
|
86
|
+
sync_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
87
|
+
|
|
88
|
+
if data_frame_util.is_empty(result_df):
|
|
89
|
+
logger.error("财务信息为空,代码:{}:{}", symbol, name)
|
|
90
|
+
continue
|
|
91
|
+
else:
|
|
92
|
+
# 季度同步check
|
|
93
|
+
if check_exist:
|
|
94
|
+
result_df = result_df.loc[result_df['report_name'] == report_name]
|
|
95
|
+
if data_frame_util.is_empty(result_df):
|
|
96
|
+
continue
|
|
97
|
+
|
|
98
|
+
result_df['sync_time'] = sync_time
|
|
99
|
+
time.sleep(0.5)
|
|
100
|
+
# 1. 将毫秒时间戳转为 datetime
|
|
101
|
+
result_df['report_date'] = pd.to_datetime(result_df['report_date'], unit='ms')
|
|
102
|
+
|
|
103
|
+
# 2. 格式化为 '%Y-%m-%d' 字符串
|
|
104
|
+
result_df['report_date'] = result_df['report_date'].dt.strftime('%Y-%m-%d')
|
|
105
|
+
|
|
106
|
+
result_df['_id'] = symbol + '_' + result_df['report_date']
|
|
107
|
+
result_df['symbol'] = symbol
|
|
108
|
+
|
|
109
|
+
# 1. 将毫秒时间戳转为 datetime
|
|
110
|
+
result_df['ctime'] = pd.to_datetime(result_df['ctime'], unit='ms')
|
|
111
|
+
|
|
112
|
+
# 2. 格式化为 '%Y-%m-%d' 字符串
|
|
113
|
+
result_df['ctime'] = result_df['ctime'].dt.strftime('%Y-%m-%d')
|
|
114
|
+
result_df.loc[result_df['report_name'].str.contains('年报'), 'period'] = 4
|
|
115
|
+
result_df.loc[result_df['report_name'].str.contains('一季报'), 'period'] = 1
|
|
116
|
+
result_df.loc[result_df['report_name'].str.contains('中报'), 'period'] = 2
|
|
117
|
+
result_df.loc[result_df['report_name'].str.contains('三季报'), 'period'] = 3
|
|
118
|
+
result_df['year'] = result_df['report_name'].str[:4]
|
|
119
|
+
if save_tag:
|
|
120
|
+
mongodb_util_27017.save_mongo(result_df, col_name)
|
|
121
|
+
else:
|
|
122
|
+
mongodb_util_27017.insert_mongo(result_df, col_name)
|
|
123
|
+
|
|
124
|
+
if symbol in fail_list:
|
|
125
|
+
fail_list.remove(symbol)
|
|
126
|
+
logger.info("同步财务数据完成:{}:{}", symbol, name, report_name)
|
|
127
|
+
except BaseException as e:
|
|
128
|
+
logger.error("同步错误:{},异常信息:{}", symbol, e)
|
|
129
|
+
fail_list.append(symbol)
|
|
130
|
+
return fail_list
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def sync_xue_qiu_very_period_report(report_name, symbol):
|
|
134
|
+
em_a_stock_info_df = em_stock_info_api.get_a_stock_info()
|
|
135
|
+
if symbol is not None:
|
|
136
|
+
em_a_stock_info_df = em_a_stock_info_df.loc[em_a_stock_info_df['symbol'] == symbol]
|
|
137
|
+
em_a_stock_info_df = common_service_fun_api.add_pre_prefix(em_a_stock_info_df)
|
|
138
|
+
# 或等效写法 df['A'].str[0:6]
|
|
139
|
+
|
|
140
|
+
fail_list = []
|
|
141
|
+
|
|
142
|
+
xue_qiu_cookie = cookie_info_service.get_xue_qiu_cookie()
|
|
143
|
+
report_type_list = ['income', 'balance', 'cash_flow']
|
|
144
|
+
for stock_one in em_a_stock_info_df.itertuples():
|
|
145
|
+
fail_list = save_one_symbol_data(stock_one, report_type_list, xue_qiu_cookie, False, fail_list, report_name,
|
|
146
|
+
True)
|
|
147
|
+
|
|
148
|
+
handle_number = 0
|
|
149
|
+
# 处理失败的
|
|
150
|
+
while len(fail_list) > 0:
|
|
151
|
+
fail_df = em_a_stock_info_df.loc[em_a_stock_info_df['symbol'].isin(fail_list)]
|
|
152
|
+
for fail_one in fail_df.itertuples():
|
|
153
|
+
fail_list = save_one_symbol_data(fail_one, report_type_list, xue_qiu_cookie, False, fail_list, report_name,
|
|
154
|
+
True)
|
|
155
|
+
handle_number = handle_number + 1
|
|
156
|
+
if handle_number > 10:
|
|
157
|
+
break
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if __name__ == '__main__':
|
|
161
|
+
sync_all_stocks_report()
|
mns_scheduler/hk/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@ 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 mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
@@ -99,4 +99,5 @@ def sync_hk_company_info():
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
if __name__ == '__main__':
|
|
102
|
+
get_hk_ggt_component()
|
|
102
103
|
sync_hk_company_info()
|
|
@@ -2,7 +2,7 @@ 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 mns_common.api.ths.concept.app.ths_concept_index_app as ths_concept_index_app
|
|
@@ -2,7 +2,7 @@ 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 mns_scheduler.industry.ths.ths_industry_index_service as ths_industry_index_service
|
mns_scheduler/irm/__init__.py
CHANGED
|
@@ -2,7 +2,7 @@ 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
|
|
@@ -119,10 +119,10 @@ def save_sh_stock_uid():
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
# 同步所有互动问题
|
|
122
|
-
def
|
|
122
|
+
def sync_symbols_interactive_questions(symbol_list):
|
|
123
123
|
# 同步互动易映射
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
if len(symbol_list) == 0:
|
|
125
|
+
save_sh_stock_uid()
|
|
126
126
|
real_time_quotes_all_stocks = em_stock_info_api.get_a_stock_info()
|
|
127
127
|
de_list_company_symbols = company_common_service_api.get_de_list_company()
|
|
128
128
|
real_time_quotes_all_stocks = real_time_quotes_all_stocks.loc[
|
|
@@ -130,7 +130,7 @@ def sync_all_interactive_questions(symbol_list):
|
|
|
130
130
|
real_time_quotes_all_stocks = common_service_fun_api.classify_symbol(real_time_quotes_all_stocks)
|
|
131
131
|
real_time_quotes_all_stocks = real_time_quotes_all_stocks.sort_values(by=['chg'], ascending=False)
|
|
132
132
|
fail_symbol_list = []
|
|
133
|
-
if symbol_list
|
|
133
|
+
if len(symbol_list) != 0:
|
|
134
134
|
real_time_quotes_all_stocks = real_time_quotes_all_stocks.loc[
|
|
135
135
|
real_time_quotes_all_stocks['symbol'].isin(symbol_list)]
|
|
136
136
|
for stock_one in real_time_quotes_all_stocks.itertuples():
|
|
@@ -149,6 +149,8 @@ def sync_all_interactive_questions(symbol_list):
|
|
|
149
149
|
|
|
150
150
|
else:
|
|
151
151
|
continue
|
|
152
|
+
if data_frame_util.is_empty(stock_irm_cninfo_df):
|
|
153
|
+
continue
|
|
152
154
|
stock_irm_cninfo_df['sync_time'] = str_now_date
|
|
153
155
|
stock_irm_cninfo_df['str_day'] = str_day
|
|
154
156
|
stock_irm_cninfo_df.drop_duplicates('_id', keep='last', inplace=True)
|
|
@@ -191,6 +193,8 @@ def save_new_data(stock_irm_cninfo_df):
|
|
|
191
193
|
|
|
192
194
|
|
|
193
195
|
if __name__ == '__main__':
|
|
196
|
+
sync_symbols_interactive_questions([])
|
|
197
|
+
get_stock_irm_cninfo_sh_api('688778')
|
|
194
198
|
fail_symbol_list_01 = ['000638', '002886', '688778', '688766', '688733', '688778', '688793', '688787']
|
|
195
199
|
# get_stock_irm_cninfo_sh_api('603633')
|
|
196
|
-
|
|
200
|
+
# sync_symbols_interactive_questions(None)
|
|
@@ -113,8 +113,9 @@ def multi_threaded_k_line_sync(str_day):
|
|
|
113
113
|
real_time_quotes_now = real_time_quotes_now.loc[
|
|
114
114
|
~(real_time_quotes_now['symbol'].isin(de_list_company_df['symbol']))]
|
|
115
115
|
|
|
116
|
-
# 将list_date列中的所有NaN值设置为
|
|
117
|
-
real_time_quotes_now['list_date'].fillna(
|
|
116
|
+
# 将list_date列中的所有NaN值设置为19890604
|
|
117
|
+
real_time_quotes_now['list_date'].fillna(19890604, inplace=True)
|
|
118
|
+
real_time_quotes_now['list_date'] = real_time_quotes_now['list_date'].replace(99990909, 19890604)
|
|
118
119
|
|
|
119
120
|
# 将日期数值转换为日期时间格式
|
|
120
121
|
real_time_quotes_now['list_date_01'] = pd.to_datetime(real_time_quotes_now['list_date'], format='%Y%m%d')
|
|
@@ -198,3 +199,7 @@ def create_k_line_index():
|
|
|
198
199
|
mongodb_util.create_index('k_line_info', [("symbol", 1)])
|
|
199
200
|
mongodb_util.create_index('k_line_info', [("str_day", 1)])
|
|
200
201
|
mongodb_util.create_index('k_line_info', [("str_day", 1), ("symbol", 1)])
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
if __name__ == '__main__':
|
|
205
|
+
sync_k_line_info_task('2025-11-13')
|