mns-scheduler 1.2.9.6__py3-none-any.whl → 1.2.9.8__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/baidu/__init__.py +7 -0
- mns_scheduler/baidu/baidu_yun_pan_handle_service.py +122 -0
- mns_scheduler/company_info/base/sync_company_base_info_api.py +2 -0
- mns_scheduler/company_info/constant/company_constant_data.py +1 -0
- mns_scheduler/extraIncome/one_minute/upload/__init__.py +7 -0
- mns_scheduler/extraIncome/one_minute/upload/upload_to_baidu_task.py +83 -0
- mns_scheduler/risk/financial/profit_income_check_api.py +0 -1
- mns_scheduler/risk/test/fix_blask_list.py +1 -1
- mns_scheduler/us/baidu_yun_pan_handle_service.py +91 -131
- {mns_scheduler-1.2.9.6.dist-info → mns_scheduler-1.2.9.8.dist-info}/METADATA +1 -1
- {mns_scheduler-1.2.9.6.dist-info → mns_scheduler-1.2.9.8.dist-info}/RECORD +13 -9
- {mns_scheduler-1.2.9.6.dist-info → mns_scheduler-1.2.9.8.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.2.9.6.dist-info → mns_scheduler-1.2.9.8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
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 sys
|
|
9
|
+
import os
|
|
10
|
+
import json
|
|
11
|
+
import pandas as pd
|
|
12
|
+
|
|
13
|
+
file_path = os.path.abspath(__file__)
|
|
14
|
+
end = file_path.index('mns') + 16
|
|
15
|
+
project_path = file_path[0:end]
|
|
16
|
+
sys.path.append(project_path)
|
|
17
|
+
from bypy import ByPy
|
|
18
|
+
from loguru import logger
|
|
19
|
+
import subprocess
|
|
20
|
+
import re
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def upload_to_baidu(file_name, folder_name, data_df):
|
|
24
|
+
upload_path_temp = fr'D:\upload_temp\{file_name}.csv'
|
|
25
|
+
bp = ByPy()
|
|
26
|
+
|
|
27
|
+
data_df.to_csv(upload_path_temp, index=False, encoding='gbk')
|
|
28
|
+
|
|
29
|
+
# 上传临时文件到百度云
|
|
30
|
+
remote_path = f'/{folder_name}/{file_name}.csv'
|
|
31
|
+
result = bp.upload(upload_path_temp, remote_path)
|
|
32
|
+
if result == 0:
|
|
33
|
+
logger.info("上传成功:{}", file_name)
|
|
34
|
+
else:
|
|
35
|
+
logger.error("上传失败:{}", file_name)
|
|
36
|
+
del_local_file(upload_path_temp)
|
|
37
|
+
return result
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def del_local_file(local_file_path):
|
|
41
|
+
try:
|
|
42
|
+
os.remove(local_file_path)
|
|
43
|
+
except Exception as e:
|
|
44
|
+
print(f"删除文件时出错: {e}")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def mkdir_baidu_new_folder(remote_path):
|
|
48
|
+
bp = ByPy()
|
|
49
|
+
try:
|
|
50
|
+
# 调用 mkdir 方法创建文件夹
|
|
51
|
+
result = bp.mkdir(remote_path)
|
|
52
|
+
|
|
53
|
+
if result == 0:
|
|
54
|
+
logger.info("成功创建文件夹:{}", remote_path)
|
|
55
|
+
else:
|
|
56
|
+
logger.error("创建文件夹失败:{}", result)
|
|
57
|
+
|
|
58
|
+
except Exception as e:
|
|
59
|
+
logger.error("创建文件夹失败:{}", e)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def del_baidu_old_folder(remote_path):
|
|
63
|
+
bp = ByPy()
|
|
64
|
+
try:
|
|
65
|
+
# 调用 mkdir 方法创建文件夹
|
|
66
|
+
result = bp.delete(remote_path)
|
|
67
|
+
|
|
68
|
+
if result == 0:
|
|
69
|
+
logger.info("成功删除文件夹:{}", remote_path)
|
|
70
|
+
else:
|
|
71
|
+
logger.error("删除文件夹失败:{}", result)
|
|
72
|
+
|
|
73
|
+
except Exception as e:
|
|
74
|
+
logger.error("删除文件夹失败:{}", e)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def get_file_folder(path):
|
|
78
|
+
result = subprocess.run(
|
|
79
|
+
['bypy', 'list', path],
|
|
80
|
+
capture_output=True,
|
|
81
|
+
text=True,
|
|
82
|
+
check=True,
|
|
83
|
+
encoding='utf-8'
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# 假设 result 是 subprocess.run 的返回结果
|
|
87
|
+
stdout = result.stdout
|
|
88
|
+
|
|
89
|
+
# 正则表达式匹配文件行
|
|
90
|
+
pattern = re.compile(
|
|
91
|
+
r'^[FD]\s+(\S+)\s+(\d+)\s+(\d{4}-\d{2}-\d{2},\s\d{2}:\d{2}:\d{2})\s+([a-zA-Z0-9]{32})$',
|
|
92
|
+
re.IGNORECASE
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
data = []
|
|
96
|
+
for line in stdout.split('\n'):
|
|
97
|
+
line = line.strip()
|
|
98
|
+
if not line:
|
|
99
|
+
continue
|
|
100
|
+
match = pattern.match(line)
|
|
101
|
+
if match:
|
|
102
|
+
filename, size, mod_time, hash_val = match.groups()
|
|
103
|
+
# 处理时间格式:替换逗号为空格
|
|
104
|
+
mod_time = mod_time.replace(', ', ' ')
|
|
105
|
+
data.append({
|
|
106
|
+
'name': filename,
|
|
107
|
+
'size': int(size),
|
|
108
|
+
'update_time': mod_time,
|
|
109
|
+
'hash_value': hash_val
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
# 创建 DataFrame 并转换时间类型
|
|
113
|
+
df = pd.DataFrame(data)
|
|
114
|
+
if not df.empty:
|
|
115
|
+
df['update_time'] = pd.to_datetime(df['update_time'], format='%Y-%m-%d %H:%M:%S')
|
|
116
|
+
|
|
117
|
+
return df
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == '__main__':
|
|
121
|
+
folder_name1 = '/A股/1分钟/2025/4'
|
|
122
|
+
get_file_folder(folder_name1)
|
|
@@ -408,6 +408,7 @@ def get_recent_year_income(symbol, company_info_type, exist_company_df):
|
|
|
408
408
|
em_stock_profit = mongodb_util.descend_query(query, db_name_constant.EM_STOCK_PROFIT, 'REPORT_DATE', 1)
|
|
409
409
|
if data_frame_util.is_not_empty(em_stock_profit):
|
|
410
410
|
company_info_type['operate_profit'] = list(em_stock_profit['OPERATE_PROFIT'])[0]
|
|
411
|
+
company_info_type['operate_date_name'] = list(em_stock_profit['REPORT_DATE_NAME'])[0]
|
|
411
412
|
total_operate_income = list(em_stock_profit['TOTAL_OPERATE_INCOME'])[0]
|
|
412
413
|
# 金融机构大多收入计入在这个字段中
|
|
413
414
|
if total_operate_income == 0:
|
|
@@ -417,6 +418,7 @@ def get_recent_year_income(symbol, company_info_type, exist_company_df):
|
|
|
417
418
|
else:
|
|
418
419
|
company_info_type['operate_profit'] = 0
|
|
419
420
|
company_info_type['total_operate_income'] = 0
|
|
421
|
+
company_info_type['operate_date_name'] = ''
|
|
420
422
|
company_info_type['operate_profit'] = round(
|
|
421
423
|
company_info_type['operate_profit'] / common_service_fun_api.HUNDRED_MILLION, 2)
|
|
422
424
|
company_info_type['total_operate_income'] = round(
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
from mns_common.db.MongodbUtil import MongodbUtil
|
|
9
|
+
from loguru import logger
|
|
10
|
+
import mns_scheduler.baidu.baidu_yun_pan_handle_service as baidu_yun_pan_handle_service
|
|
11
|
+
from mns_common.db.v2.MongodbUtilV2 import MongodbUtilV2
|
|
12
|
+
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
13
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
14
|
+
from datetime import datetime
|
|
15
|
+
import mns_common.constant.extra_income_db_name as extra_income_db_name
|
|
16
|
+
|
|
17
|
+
mongodb_util = MongodbUtil('27017')
|
|
18
|
+
mongodbUtilV2_27019 = MongodbUtilV2('27019', extra_income_db_name.EXTRA_INCOME)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def upload_stock_to_baidu():
|
|
22
|
+
a_stock_path = '/A股/1分钟/'
|
|
23
|
+
|
|
24
|
+
now_date_time = datetime.now()
|
|
25
|
+
now_year = now_date_time.year
|
|
26
|
+
month = now_date_time.month
|
|
27
|
+
a_stock_path = a_stock_path + str(now_year) + '/' + str(month)
|
|
28
|
+
# 创建路径
|
|
29
|
+
baidu_yun_pan_handle_service.mkdir_baidu_new_folder(a_stock_path)
|
|
30
|
+
em_a_stock_info_df = mongodb_util.find_all_data('em_a_stock_info')
|
|
31
|
+
|
|
32
|
+
em_a_stock_info_df = common_service_fun_api.classify_symbol(em_a_stock_info_df)
|
|
33
|
+
|
|
34
|
+
em_a_stock_info_df['symbol'] = em_a_stock_info_df.apply(
|
|
35
|
+
lambda row: row['symbol'] + '.SZ' if row['classification'] in ['S', 'C']
|
|
36
|
+
else row['symbol'] + '.BJ' if row['classification'] in ['X']
|
|
37
|
+
else row['symbol'] + '.SH',
|
|
38
|
+
axis=1
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
file_folder_df = baidu_yun_pan_handle_service.get_file_folder(a_stock_path)
|
|
42
|
+
if data_frame_util.is_not_empty(file_folder_df):
|
|
43
|
+
# 去除文件名中的 .csv 后缀
|
|
44
|
+
file_folder_df['name'] = file_folder_df['name'].str.replace(r'\.csv$', '', regex=True)
|
|
45
|
+
em_a_stock_info_df = em_a_stock_info_df.loc[~(em_a_stock_info_df['symbol'].isin(file_folder_df['name']))]
|
|
46
|
+
fail_list = []
|
|
47
|
+
for stock_one in em_a_stock_info_df.itertuples():
|
|
48
|
+
try:
|
|
49
|
+
classification = stock_one.classification
|
|
50
|
+
if classification == 'X':
|
|
51
|
+
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_BJ
|
|
52
|
+
elif classification == 'S':
|
|
53
|
+
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_S
|
|
54
|
+
|
|
55
|
+
elif classification == 'H':
|
|
56
|
+
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_H
|
|
57
|
+
elif classification == 'K':
|
|
58
|
+
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_K
|
|
59
|
+
elif classification == 'C':
|
|
60
|
+
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_C
|
|
61
|
+
col_name = col_name + '_' + str(now_year)
|
|
62
|
+
symbol = stock_one.symbol
|
|
63
|
+
if month < 10:
|
|
64
|
+
month_str = '0' + str(month)
|
|
65
|
+
else:
|
|
66
|
+
month_str = str(month)
|
|
67
|
+
begin_time = str(now_year) + '-' + month_str + '-01 09:00:00'
|
|
68
|
+
query = {'symbol': symbol, 'time': {"$gte": begin_time}}
|
|
69
|
+
one_minute_k_line_bfq_df = mongodbUtilV2_27019.find_query_data(col_name, query)
|
|
70
|
+
if data_frame_util.is_not_empty(one_minute_k_line_bfq_df):
|
|
71
|
+
one_minute_k_line_bfq_df = one_minute_k_line_bfq_df.sort_values(by=['time'], ascending=True)
|
|
72
|
+
del one_minute_k_line_bfq_df['_id']
|
|
73
|
+
del one_minute_k_line_bfq_df['symbol']
|
|
74
|
+
result = baidu_yun_pan_handle_service.upload_to_baidu(symbol, a_stock_path, one_minute_k_line_bfq_df)
|
|
75
|
+
if result != 0:
|
|
76
|
+
fail_list.append(symbol)
|
|
77
|
+
except BaseException as e:
|
|
78
|
+
fail_list.append(symbol)
|
|
79
|
+
logger.error("上传数据异常:{}", e)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == '__main__':
|
|
83
|
+
upload_stock_to_baidu()
|
|
@@ -27,7 +27,6 @@ def profit_income_check(new_report_df, period_time, report_type):
|
|
|
27
27
|
name = list(new_report_one_df['SECURITY_NAME_ABBR'])[0]
|
|
28
28
|
now_date = datetime.now()
|
|
29
29
|
str_day = now_date.strftime('%Y-%m-%d')
|
|
30
|
-
str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
|
|
31
30
|
notice_date = list(new_report_one_df['NOTICE_DATE'])[0]
|
|
32
31
|
if report_type == db_name_constant.EM_STOCK_PROFIT:
|
|
33
32
|
# 利润总额 净利润 扣除非经常性损益后的净利润 三者最小为负
|
|
@@ -18,7 +18,7 @@ def fix_profit_black_list():
|
|
|
18
18
|
period = 4
|
|
19
19
|
report_type_list = [db_name_constant.EM_STOCK_ASSET_LIABILITY, db_name_constant.EM_STOCK_PROFIT]
|
|
20
20
|
for report_type in report_type_list:
|
|
21
|
-
query = {'REPORT_DATE': period_time
|
|
21
|
+
query = {'REPORT_DATE': period_time}
|
|
22
22
|
em_stock_profit_df_list = mongodb_util.find_query_data(report_type, query)
|
|
23
23
|
for em_stock_one in em_stock_profit_df_list.itertuples():
|
|
24
24
|
em_stock_one_df = em_stock_profit_df_list.loc[
|
|
@@ -1,131 +1,91 @@
|
|
|
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
|
-
from bypy import ByPy
|
|
9
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
10
|
-
import tempfile
|
|
11
|
-
from loguru import logger
|
|
12
|
-
import akshare as ak
|
|
13
|
-
|
|
14
|
-
mongodb_util = MongodbUtil('27017')
|
|
15
|
-
|
|
16
|
-
import subprocess
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def get_file_list(path):
|
|
20
|
-
"""
|
|
21
|
-
获取百度网盘指定路径下的文件列表
|
|
22
|
-
:param path: 百度网盘中的路径,例如 '/我的资源'
|
|
23
|
-
:return: 文件列表
|
|
24
|
-
"""
|
|
25
|
-
try:
|
|
26
|
-
# 调用 bypy list 命令
|
|
27
|
-
result = subprocess.run(['bypy', 'list', path], capture_output=True, text=True, check=True)
|
|
28
|
-
|
|
29
|
-
# 输出结果
|
|
30
|
-
if result.returncode == 0:
|
|
31
|
-
file_list = result.stdout.splitlines() # 按行分割结果
|
|
32
|
-
return file_list
|
|
33
|
-
else:
|
|
34
|
-
logger.error("获取文件路径异常:{}", result.stderr)
|
|
35
|
-
return []
|
|
36
|
-
except subprocess.CalledProcessError as e:
|
|
37
|
-
logger.error("获取文件路径异常:{}", e)
|
|
38
|
-
return []
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def upload_to_baidu(file_name, folder_name, data_df):
|
|
42
|
-
bp = ByPy()
|
|
43
|
-
file_name = file_name + '.csv'
|
|
44
|
-
with tempfile.NamedTemporaryFile(mode='w', suffix='.csv', delete=False) as temp_file:
|
|
45
|
-
data_df.to_csv(temp_file, index=False)
|
|
46
|
-
temp_file_path = temp_file.name # 获取临时文件的路径
|
|
47
|
-
|
|
48
|
-
# 上传临时文件到百度云
|
|
49
|
-
remote_path = f'/{folder_name}/{file_name}'
|
|
50
|
-
result = bp.upload(temp_file_path, remote_path)
|
|
51
|
-
if result == 0:
|
|
52
|
-
logger.info("上传成功:{}", file_name)
|
|
53
|
-
else:
|
|
54
|
-
logger.error("上传失败:{}", file_name)
|
|
55
|
-
return result
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def mkdir_baidu_new_folder(remote_path):
|
|
59
|
-
bp = ByPy()
|
|
60
|
-
try:
|
|
61
|
-
# 调用 mkdir 方法创建文件夹
|
|
62
|
-
result = bp.mkdir(remote_path)
|
|
63
|
-
|
|
64
|
-
if result == 0:
|
|
65
|
-
logger.info("成功创建文件夹:{}", remote_path)
|
|
66
|
-
else:
|
|
67
|
-
logger.error("创建文件夹失败:{}", result)
|
|
68
|
-
|
|
69
|
-
except Exception as e:
|
|
70
|
-
logger.error("创建文件夹失败:{}", e)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def del_baidu_old_folder(remote_path):
|
|
74
|
-
bp = ByPy()
|
|
75
|
-
try:
|
|
76
|
-
# 调用 mkdir 方法创建文件夹
|
|
77
|
-
result = bp.delete(remote_path)
|
|
78
|
-
|
|
79
|
-
if result == 0:
|
|
80
|
-
logger.info("成功删除文件夹:{}", remote_path)
|
|
81
|
-
else:
|
|
82
|
-
logger.error("删除文件夹失败:{}", result)
|
|
83
|
-
|
|
84
|
-
except Exception as e:
|
|
85
|
-
logger.error("删除文件夹失败:{}", e)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if __name__ == '__main__':
|
|
89
|
-
folder_name1 = '/美股/不复权日线'
|
|
90
|
-
mkdir_baidu_new_folder(folder_name1)
|
|
91
|
-
|
|
92
|
-
stock_us_spot_em_df = ak.stock_us_spot_em()
|
|
93
|
-
stock_us_spot_em_df = stock_us_spot_em_df.rename(columns={
|
|
94
|
-
"序号": "index",
|
|
95
|
-
"代码": "symbol",
|
|
96
|
-
"名称": "name",
|
|
97
|
-
"涨跌额": "change_price",
|
|
98
|
-
"涨跌幅": "chg",
|
|
99
|
-
"开盘价": "open",
|
|
100
|
-
"最高价": "high",
|
|
101
|
-
"最低价": "low",
|
|
102
|
-
"最新价": "now_price",
|
|
103
|
-
"昨收价": "last_price",
|
|
104
|
-
"总市值": "total_mv",
|
|
105
|
-
"市盈率": "pe",
|
|
106
|
-
"成交量": "volume",
|
|
107
|
-
"成交额": "amount",
|
|
108
|
-
"振幅": "pct_chg",
|
|
109
|
-
"换手率": "exchange"
|
|
110
|
-
})
|
|
111
|
-
stock_us_spot_em_df = stock_us_spot_em_df.sort_values(by=['amount'], ascending=False)
|
|
112
|
-
stock_us_spot_em_df = stock_us_spot_em_df.fillna(0)
|
|
113
|
-
stock_us_spot_em_df = stock_us_spot_em_df.loc[stock_us_spot_em_df['total_mv'] != 0]
|
|
114
|
-
for stock_one in stock_us_spot_em_df.itertuples():
|
|
115
|
-
try:
|
|
116
|
-
symbol = stock_one.symbol
|
|
117
|
-
name = stock_one.name
|
|
118
|
-
query = {'symbol': symbol, 'amount': {"$gt": 0}}
|
|
119
|
-
us_stock_bfq_daily_df_one = mongodb_util.find_query_data('us_stock_bfq_daily', query)
|
|
120
|
-
del us_stock_bfq_daily_df_one['_id']
|
|
121
|
-
del us_stock_bfq_daily_df_one['name']
|
|
122
|
-
file_name_one = name + '_' + symbol
|
|
123
|
-
upload_to_baidu(file_name_one, folder_name1, us_stock_bfq_daily_df_one)
|
|
124
|
-
|
|
125
|
-
except BaseException as e:
|
|
126
|
-
logger.error("同步数据发生异常:{}", e)
|
|
127
|
-
|
|
128
|
-
# data_df = mongodb_util.find_query_data('us_stock_bfq_daily', query={'name': file_name1})
|
|
129
|
-
# upload_to_baidu(file_name1, folder_name1, data_df)
|
|
130
|
-
|
|
131
|
-
|
|
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
|
+
from bypy import ByPy
|
|
9
|
+
from mns_common.db.MongodbUtil import MongodbUtil
|
|
10
|
+
import tempfile
|
|
11
|
+
from loguru import logger
|
|
12
|
+
import akshare as ak
|
|
13
|
+
|
|
14
|
+
mongodb_util = MongodbUtil('27017')
|
|
15
|
+
|
|
16
|
+
import subprocess
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_file_list(path):
|
|
20
|
+
"""
|
|
21
|
+
获取百度网盘指定路径下的文件列表
|
|
22
|
+
:param path: 百度网盘中的路径,例如 '/我的资源'
|
|
23
|
+
:return: 文件列表
|
|
24
|
+
"""
|
|
25
|
+
try:
|
|
26
|
+
# 调用 bypy list 命令
|
|
27
|
+
result = subprocess.run(['bypy', 'list', path], capture_output=True, text=True, check=True, encoding='utf-8')
|
|
28
|
+
|
|
29
|
+
# 输出结果
|
|
30
|
+
if result.returncode == 0:
|
|
31
|
+
file_list = result.stdout.splitlines() # 按行分割结果
|
|
32
|
+
return file_list
|
|
33
|
+
else:
|
|
34
|
+
logger.error("获取文件路径异常:{}", result.stderr)
|
|
35
|
+
return []
|
|
36
|
+
except subprocess.CalledProcessError as e:
|
|
37
|
+
logger.error("获取文件路径异常:{}", e)
|
|
38
|
+
return []
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def upload_to_baidu(file_name, folder_name, data_df):
|
|
42
|
+
bp = ByPy()
|
|
43
|
+
file_name = file_name + '.csv'
|
|
44
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.csv', delete=False) as temp_file:
|
|
45
|
+
data_df.to_csv(temp_file, index=False)
|
|
46
|
+
temp_file_path = temp_file.name # 获取临时文件的路径
|
|
47
|
+
|
|
48
|
+
# 上传临时文件到百度云
|
|
49
|
+
remote_path = f'/{folder_name}/{file_name}'
|
|
50
|
+
result = bp.upload(temp_file_path, remote_path)
|
|
51
|
+
if result == 0:
|
|
52
|
+
logger.info("上传成功:{}", file_name)
|
|
53
|
+
else:
|
|
54
|
+
logger.error("上传失败:{}", file_name)
|
|
55
|
+
return result
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def mkdir_baidu_new_folder(remote_path):
|
|
59
|
+
bp = ByPy()
|
|
60
|
+
try:
|
|
61
|
+
# 调用 mkdir 方法创建文件夹
|
|
62
|
+
result = bp.mkdir(remote_path)
|
|
63
|
+
|
|
64
|
+
if result == 0:
|
|
65
|
+
logger.info("成功创建文件夹:{}", remote_path)
|
|
66
|
+
else:
|
|
67
|
+
logger.error("创建文件夹失败:{}", result)
|
|
68
|
+
|
|
69
|
+
except Exception as e:
|
|
70
|
+
logger.error("创建文件夹失败:{}", e)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def del_baidu_old_folder(remote_path):
|
|
74
|
+
bp = ByPy()
|
|
75
|
+
try:
|
|
76
|
+
# 调用 mkdir 方法创建文件夹
|
|
77
|
+
result = bp.delete(remote_path)
|
|
78
|
+
|
|
79
|
+
if result == 0:
|
|
80
|
+
logger.info("成功删除文件夹:{}", remote_path)
|
|
81
|
+
else:
|
|
82
|
+
logger.error("删除文件夹失败:{}", result)
|
|
83
|
+
|
|
84
|
+
except Exception as e:
|
|
85
|
+
logger.error("删除文件夹失败:{}", e)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if __name__ == '__main__':
|
|
89
|
+
folder_name1 = '/美股/不复权日线'
|
|
90
|
+
mkdir_baidu_new_folder(folder_name1)
|
|
91
|
+
list_df = get_file_list('/bypy/美股')
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
mns_scheduler/__init__.py,sha256=_nhtk1b00OsMAiqRATNrb3HD44RmgjSG5jqS-QLNMrQ,130
|
|
2
|
+
mns_scheduler/baidu/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
3
|
+
mns_scheduler/baidu/baidu_yun_pan_handle_service.py,sha256=i46HUgnpLaRIiqAKc9VkOw9gvN02hj1ix_VfD-hro_I,3320
|
|
2
4
|
mns_scheduler/big_deal/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
3
5
|
mns_scheduler/big_deal/ths_big_deal_sync.py,sha256=c3VmLEbEBB3uoQTFZ2HyOtijAiyVRP6wVgNgBS9EuVk,4744
|
|
4
6
|
mns_scheduler/company_info/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
5
7
|
mns_scheduler/company_info/announce/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
6
8
|
mns_scheduler/company_info/announce/company_announce_sync_service.py,sha256=O0x0dqqnCmzzFenw4fShzWPAi_wegtvAZ9EB0ubrvnM,2808
|
|
7
9
|
mns_scheduler/company_info/base/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
8
|
-
mns_scheduler/company_info/base/sync_company_base_info_api.py,sha256=
|
|
10
|
+
mns_scheduler/company_info/base/sync_company_base_info_api.py,sha256=q5sHNqH3Mrirr5eB_AavwgI2uI6yePOyeD2eD56UaRk,20676
|
|
9
11
|
mns_scheduler/company_info/base/sync_company_hold_info_api.py,sha256=W3Nj9st45efx8cy_42PRTcOXijWKnkO1-ZFRyyfR3S0,1587
|
|
10
12
|
mns_scheduler/company_info/clean/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
11
13
|
mns_scheduler/company_info/clean/company_info_clean_api.py,sha256=gykN2aFfjBQoGxux3otM9v_zbD_wbv7z0CqAX_hzG6U,6104
|
|
12
14
|
mns_scheduler/company_info/constant/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
13
|
-
mns_scheduler/company_info/constant/company_constant_data.py,sha256=
|
|
15
|
+
mns_scheduler/company_info/constant/company_constant_data.py,sha256=0qhRXLASsQlYnJe_vy5HCwNQZWz-hmJslbr9VuBnmGY,22486
|
|
14
16
|
mns_scheduler/company_info/de_list_stock/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
15
17
|
mns_scheduler/company_info/de_list_stock/de_list_stock_service.py,sha256=GCp6hlvO-SuH1oIpEsYZwEnGUOa6fXb2D7CqAUYXKQA,1993
|
|
16
18
|
mns_scheduler/company_info/em_stock_info/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
@@ -65,6 +67,8 @@ mns_scheduler/extraIncome/one_minute/kzz/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1
|
|
|
65
67
|
mns_scheduler/extraIncome/one_minute/kzz/kzz_one_minute_sync_task.py,sha256=AR6V7T2-XJp2CHmJI_KEzBT5rIIse1T1-I1foSXkQbo,3691
|
|
66
68
|
mns_scheduler/extraIncome/one_minute/stock/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
67
69
|
mns_scheduler/extraIncome/one_minute/stock/stock_one_minute_sync_task.py,sha256=iB3RWD-Pp9e0an46xoPbn-YkgIlVFxZwQYyQ0Cfad7E,4576
|
|
70
|
+
mns_scheduler/extraIncome/one_minute/upload/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
71
|
+
mns_scheduler/extraIncome/one_minute/upload/upload_to_baidu_task.py,sha256=_AjUYUSqnnq8IST0C0e1cjREBLoI4OWRI-MnPN3avr4,3772
|
|
68
72
|
mns_scheduler/extraIncome/temp/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
69
73
|
mns_scheduler/extraIncome/temp/tu_share_data_etf_sync.py,sha256=XBsLl4o1Ras1zUQBkJ2BAgWtPebqAf9VUu_kLEisGmQ,4464
|
|
70
74
|
mns_scheduler/extraIncome/temp/tu_share_data_kzz_sync.py,sha256=A2Aa4TB2mgTHiDlW9_UpB0mdRCR_1sOTaPZKs-IBbXc,4850
|
|
@@ -126,14 +130,14 @@ mns_scheduler/risk/compliance/undisclosed_annual_report_api.py,sha256=JKc9S8x0-I
|
|
|
126
130
|
mns_scheduler/risk/financial/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
127
131
|
mns_scheduler/risk/financial/annual_report_audit_check_api.py,sha256=EW1PToBJM6yIwbDB4uh1unt20z4nEsduwk-nd2rI_fE,2580
|
|
128
132
|
mns_scheduler/risk/financial/net_assets_check_api.py,sha256=glhBAyixc4mNfFUCRyT22wsAQC20R67jthyg8uvsOS4,4737
|
|
129
|
-
mns_scheduler/risk/financial/profit_income_check_api.py,sha256=
|
|
133
|
+
mns_scheduler/risk/financial/profit_income_check_api.py,sha256=jXQEFV0omojaKfoHrx5mjKs40fZh3cprLB1FA8x8u8M,4568
|
|
130
134
|
mns_scheduler/risk/financial/stock_equity_mortgage_check_api.py,sha256=SQ7dieSCOf1z42Wi1zDEii3poAT5wfyBrV43dXkAaaw,22
|
|
131
135
|
mns_scheduler/risk/major_violations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
132
136
|
mns_scheduler/risk/major_violations/register_and_investigate_stock_sync_api.py,sha256=_xPQxT6OS7J7_PtA7hbfCmMS7VzpZTWoZUOXzwoesUs,5672
|
|
133
137
|
mns_scheduler/risk/self/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
138
|
mns_scheduler/risk/self/wei_pan_stock_api.py,sha256=5ebrjFqK49j_yEMffFBCumMeBzq_rmtsA4--lL5mhZs,1899
|
|
135
139
|
mns_scheduler/risk/test/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
136
|
-
mns_scheduler/risk/test/fix_blask_list.py,sha256
|
|
140
|
+
mns_scheduler/risk/test/fix_blask_list.py,sha256=QKpEOP3-HcUKoCfcu2OeiqUlXGTzLQYCh6Z0erBT_v4,1245
|
|
137
141
|
mns_scheduler/risk/transactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
138
142
|
mns_scheduler/risk/transactions/transactions_check_api.py,sha256=1Tbs8GNoAmdGPqwYOEFiyFjR4ghhvZ5fz4hl5kKjyfk,7379
|
|
139
143
|
mns_scheduler/self_choose/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
@@ -151,7 +155,7 @@ mns_scheduler/trade/task/trader_task_service.py,sha256=xBqByakfCO2ruWXuWWsRPJtZ_
|
|
|
151
155
|
mns_scheduler/trade/tfp/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
152
156
|
mns_scheduler/trade/tfp/stock_tfp_info_sync.py,sha256=KqZlnzKvAGVJXHJfy_aP0KhP91A5wB2C7Sa98QP3_3o,2440
|
|
153
157
|
mns_scheduler/us/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
|
|
154
|
-
mns_scheduler/us/baidu_yun_pan_handle_service.py,sha256=
|
|
158
|
+
mns_scheduler/us/baidu_yun_pan_handle_service.py,sha256=Lc2Pe2uOKEpoO5Sg6ffE4mXgcSKbpb3xpULfbRdC1FA,2730
|
|
155
159
|
mns_scheduler/us/k_line.py,sha256=0F6IR1WCtREGFjLfL6Mcu5gAhNY2yaAshRlXTUE-0Sg,4100
|
|
156
160
|
mns_scheduler/us/us_company_info_sync_service_api.py,sha256=fyCtBb1OX6NdD9OhgMU_Dy80dEepJ3w4BF2g9S5j9yc,1227
|
|
157
161
|
mns_scheduler/zb/__init__.py,sha256=Tyvi_iQlv3jz59EdH67Mycnt9CSixcWPQoJwu55bOq0,165
|
|
@@ -177,7 +181,7 @@ mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py,sha256=u0IvwPuI2hnjTOrwwe8EhBAM
|
|
|
177
181
|
mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py,sha256=1uoiR2Uw46kDfjkvNg2US5rd_4OIkYO3872gIJOufUY,2135
|
|
178
182
|
mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
|
|
179
183
|
mns_scheduler/zz_task/data_sync_task.py,sha256=l7Ol09OhzysGZgza5RzuxwNuJQ-GrNplZlbR0cnZcOs,23411
|
|
180
|
-
mns_scheduler-1.2.9.
|
|
181
|
-
mns_scheduler-1.2.9.
|
|
182
|
-
mns_scheduler-1.2.9.
|
|
183
|
-
mns_scheduler-1.2.9.
|
|
184
|
+
mns_scheduler-1.2.9.8.dist-info/METADATA,sha256=hSoRxdSmHgyfqBeqeUSVhtqHqs_rq32BLXRA9IJTYaU,64
|
|
185
|
+
mns_scheduler-1.2.9.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
186
|
+
mns_scheduler-1.2.9.8.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
|
|
187
|
+
mns_scheduler-1.2.9.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|