mns-scheduler 1.3.1.6__py3-none-any.whl → 1.3.1.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/company_info/em_stock_info/sync_em_stock_info_sync.py +5 -4
- mns_scheduler/trade/auto_login/trader_auto_service.py +1 -1
- mns_scheduler/trade/sync_position_api.py +2 -2
- mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py +9 -7
- mns_scheduler/zz_task/data_sync_task.py +2 -43
- {mns_scheduler-1.3.1.6.dist-info → mns_scheduler-1.3.1.8.dist-info}/METADATA +1 -1
- {mns_scheduler-1.3.1.6.dist-info → mns_scheduler-1.3.1.8.dist-info}/RECORD +9 -55
- mns_scheduler/baidu/__init__.py +0 -7
- mns_scheduler/baidu/baidu_yun_pan_handle_service.py +0 -122
- mns_scheduler/extraIncome/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/common/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/common/db_create_index.py +0 -9
- mns_scheduler/extraIncome/a_stock/one_minute/common/symbol_handle_util.py +0 -41
- mns_scheduler/extraIncome/a_stock/one_minute/etf/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/etf/etf_one_minute_sync_task.py +0 -87
- mns_scheduler/extraIncome/a_stock/one_minute/index/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/index/main_index_sync_task.py +0 -74
- mns_scheduler/extraIncome/a_stock/one_minute/kzz/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/kzz/kzz_one_minute_sync_task.py +0 -87
- mns_scheduler/extraIncome/a_stock/one_minute/one_minute_sync_task.py +0 -34
- mns_scheduler/extraIncome/a_stock/one_minute/stock/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/stock/stock_one_minute_sync_task.py +0 -89
- mns_scheduler/extraIncome/a_stock/one_minute/upload/__init__.py +0 -7
- mns_scheduler/extraIncome/a_stock/one_minute/upload/etf_upload_to_baidu_task.py +0 -95
- mns_scheduler/extraIncome/a_stock/one_minute/upload/index_upload_to_baidu_task.py +0 -87
- mns_scheduler/extraIncome/a_stock/one_minute/upload/kzz_upload_to_baidu_task.py +0 -95
- mns_scheduler/extraIncome/a_stock/one_minute/upload/stock_upload_to_baidu_task.py +0 -85
- mns_scheduler/extraIncome/hk/__init__.py +0 -7
- mns_scheduler/extraIncome/hk/hk_stock_qfq_daily_k_line.py +0 -102
- mns_scheduler/extraIncome/us/__init__.py +0 -7
- mns_scheduler/extraIncome/us/daily/__init__.py +0 -7
- mns_scheduler/extraIncome/us/daily/us_stock_qfq_daily_k_line.py +0 -103
- mns_scheduler/extraIncome/us/one_minute/__init__.py +0 -7
- mns_scheduler/extraIncome/us/one_minute/api/__init__.py +0 -0
- mns_scheduler/extraIncome/us/one_minute/api/alpha_vantage_api.py +0 -34
- mns_scheduler/extraIncome/us/one_minute/api/em_us_one_minute_api.py +0 -139
- mns_scheduler/extraIncome/us/one_minute/api/stock_etf_info_api.py +0 -68
- mns_scheduler/extraIncome/us/one_minute/api/y_finance_api.py +0 -63
- mns_scheduler/extraIncome/us/one_minute/etf/__init__.py +0 -7
- mns_scheduler/extraIncome/us/one_minute/stock/__init__.py +0 -7
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/__init__.py +0 -7
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/etf/__init__.py +0 -11
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/etf/down_load_ETF_his_2024.py +0 -152
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/etf/handle_down_load_fail_ETF.py +0 -67
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/stock/__init__.py +0 -7
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/stock/down_load_stock_his_01.py +0 -203
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/stock/down_load_stock_his_02.py +0 -202
- mns_scheduler/extraIncome/us/one_minute/stock/down_load/stock/down_load_stock_his_2025.py +0 -144
- mns_scheduler/extraIncome/us/one_minute/stock/now/__init__.py +0 -7
- mns_scheduler/extraIncome/us/one_minute/stock/now/us_etf_one_minute_sync.py +0 -52
- mns_scheduler/extraIncome/us/one_minute/stock/now/us_stock_one_minute_sync.py +0 -141
- {mns_scheduler-1.3.1.6.dist-info → mns_scheduler-1.3.1.8.dist-info}/WHEEL +0 -0
- {mns_scheduler-1.3.1.6.dist-info → mns_scheduler-1.3.1.8.dist-info}/top_level.txt +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
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 loguru import logger
|
|
10
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
11
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
12
|
-
from mns_common.db.v2.MongodbUtilV2 import MongodbUtilV2
|
|
13
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.common.db_create_index as db_create_index
|
|
14
|
-
import mns_common.constant.extra_income_db_name as extra_income_db_name
|
|
15
|
-
from datetime import datetime
|
|
16
|
-
import mns_common.api.k_line.stock_minute_data_api as stock_minute_data_api
|
|
17
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.common.symbol_handle_util as symbol_handle_util
|
|
18
|
-
|
|
19
|
-
mongodb_util_27017 = MongodbUtil('27017')
|
|
20
|
-
mongodbUtilV2_27019 = MongodbUtilV2('27019', extra_income_db_name.EXTRA_INCOME)
|
|
21
|
-
|
|
22
|
-
main_index_list = [
|
|
23
|
-
"000001.SH",
|
|
24
|
-
"000016.SH",
|
|
25
|
-
"000010.SH",
|
|
26
|
-
"000009.SH",
|
|
27
|
-
"000015.SH",
|
|
28
|
-
"399001.SZ",
|
|
29
|
-
"399004.SZ",
|
|
30
|
-
"399005.SZ",
|
|
31
|
-
"399006.SZ",
|
|
32
|
-
"000300.SH",
|
|
33
|
-
"000905.SH",
|
|
34
|
-
"000688.SH",
|
|
35
|
-
"000903.SH",
|
|
36
|
-
"000906.SH",
|
|
37
|
-
"000852.SH",
|
|
38
|
-
"000932.SH",
|
|
39
|
-
"000933.SH",
|
|
40
|
-
"980017.SZ",
|
|
41
|
-
"399808.SZ",
|
|
42
|
-
"399997.SZ",
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def sync_main_index_one_minute(data_tag):
|
|
47
|
-
now_date = datetime.now()
|
|
48
|
-
now_day = now_date.strftime('%Y-%m-%d')
|
|
49
|
-
year = now_date.strftime('%Y')
|
|
50
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_MAIN_INDEX + '_' + str(year)
|
|
51
|
-
# 创建索引
|
|
52
|
-
db_create_index.create_index(mongodbUtilV2_27019, col_name)
|
|
53
|
-
for symbol in main_index_list:
|
|
54
|
-
try:
|
|
55
|
-
symbol_prefix = symbol_handle_util.symbol_add_prefix(symbol)
|
|
56
|
-
one_min_df = stock_minute_data_api.get_minute_data(symbol_prefix, now_day, now_day, '1', '')
|
|
57
|
-
one_min_df['symbol'] = symbol
|
|
58
|
-
one_min_df['_id'] = one_min_df['symbol'] + '_' + one_min_df['time']
|
|
59
|
-
if data_frame_util.is_empty(one_min_df) or one_min_df.shape[0] < 241:
|
|
60
|
-
logger.error("当前沪深指数分钟数据同步异常:{}", symbol)
|
|
61
|
-
continue
|
|
62
|
-
else:
|
|
63
|
-
del one_min_df['ava_price']
|
|
64
|
-
if data_tag:
|
|
65
|
-
mongodbUtilV2_27019.insert_mongo(one_min_df, col_name)
|
|
66
|
-
else:
|
|
67
|
-
mongodbUtilV2_27019.save_mongo(one_min_df, col_name)
|
|
68
|
-
except BaseException as e:
|
|
69
|
-
logger.error("沪深指数分钟数据同步异常:{},{}", symbol, e)
|
|
70
|
-
logger.info("沪深指数分钟数据同步完成:{}", symbol)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if __name__ == '__main__':
|
|
74
|
-
sync_main_index_one_minute(False)
|
|
@@ -1,87 +0,0 @@
|
|
|
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.component.em.em_stock_info_api as em_stock_info_api
|
|
10
|
-
from loguru import logger
|
|
11
|
-
import time
|
|
12
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
13
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
14
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.common.symbol_handle_util as symbol_handle_util
|
|
15
|
-
from mns_common.db.v2.MongodbUtilV2 import MongodbUtilV2
|
|
16
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.common.db_create_index as db_create_index
|
|
17
|
-
import mns_common.constant.extra_income_db_name as extra_income_db_name
|
|
18
|
-
import mns_common.api.k_line.stock_minute_data_api as stock_minute_data_api
|
|
19
|
-
from datetime import datetime
|
|
20
|
-
|
|
21
|
-
mongodb_util_27017 = MongodbUtil('27017')
|
|
22
|
-
mongodbUtilV2_27019 = MongodbUtilV2('27019', extra_income_db_name.EXTRA_INCOME)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def sync_kzz_one_minute(data_tag):
|
|
26
|
-
debt_real_time_quotes = em_stock_info_api.get_kzz_info()
|
|
27
|
-
debt_real_time_quotes = classify_symbol(debt_real_time_quotes)
|
|
28
|
-
debt_real_time_quotes['symbol'] = debt_real_time_quotes.apply(
|
|
29
|
-
lambda row: row['symbol'] + '.SZ' if row['classification'] in ['S', 'C']
|
|
30
|
-
else row['symbol'] + '.BJ' if row['classification'] in ['X']
|
|
31
|
-
else row['symbol'] + '.SH',
|
|
32
|
-
axis=1
|
|
33
|
-
)
|
|
34
|
-
# 假设数字格式为 YYYYMMDD
|
|
35
|
-
# debt_real_time_quotes['list_date'] = pd.to_datetime(debt_real_time_quotes['list_date'],
|
|
36
|
-
# format='%Y%m%d').dt.strftime('%Y-%m-%d')
|
|
37
|
-
|
|
38
|
-
debt_real_time_quotes = debt_real_time_quotes.loc[debt_real_time_quotes['amount'] != 0]
|
|
39
|
-
|
|
40
|
-
now_date = datetime.now()
|
|
41
|
-
now_day = now_date.strftime('%Y-%m-%d')
|
|
42
|
-
year = now_date.strftime('%Y')
|
|
43
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_KZZ + '_' + str(year)
|
|
44
|
-
# 创建索引
|
|
45
|
-
db_create_index.create_index(mongodbUtilV2_27019, col_name)
|
|
46
|
-
|
|
47
|
-
for stock_one in debt_real_time_quotes.itertuples():
|
|
48
|
-
|
|
49
|
-
symbol = stock_one.symbol
|
|
50
|
-
symbol_prefix = symbol_handle_util.symbol_add_prefix(symbol)
|
|
51
|
-
try:
|
|
52
|
-
one_min_df = stock_minute_data_api.get_minute_data(symbol_prefix, now_day, now_day, '1', '')
|
|
53
|
-
one_min_df['symbol'] = symbol
|
|
54
|
-
one_min_df['_id'] = one_min_df['symbol'] + '_' + one_min_df['time']
|
|
55
|
-
if data_frame_util.is_empty(one_min_df) or one_min_df.shape[0] < 241:
|
|
56
|
-
symbol_handle_util.save_fail_data(now_day, symbol_prefix, col_name)
|
|
57
|
-
logger.error("当前可转债分钟数据同步异常:{}", symbol)
|
|
58
|
-
continue
|
|
59
|
-
else:
|
|
60
|
-
del one_min_df['ava_price']
|
|
61
|
-
if data_tag:
|
|
62
|
-
mongodbUtilV2_27019.insert_mongo(one_min_df, col_name)
|
|
63
|
-
else:
|
|
64
|
-
mongodbUtilV2_27019.save_mongo(one_min_df, col_name)
|
|
65
|
-
except BaseException as e:
|
|
66
|
-
time.sleep(2)
|
|
67
|
-
symbol_handle_util.save_fail_data(now_day, symbol_prefix, col_name)
|
|
68
|
-
logger.error("同步可转债分钟数据出现异常:,{},{},{}", e, symbol, now_day)
|
|
69
|
-
logger.info("同步完可转债分钟数据:{},{}", stock_one.symbol, stock_one.name)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def classify_symbol(debt_real_time_quotes_df):
|
|
73
|
-
debt_real_time_quotes_df['classification'] = debt_real_time_quotes_df['market'].apply(
|
|
74
|
-
lambda market: classify_symbol_one(market))
|
|
75
|
-
return debt_real_time_quotes_df
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# 单个股票分类
|
|
79
|
-
def classify_symbol_one(market):
|
|
80
|
-
if market == 0:
|
|
81
|
-
return 'S'
|
|
82
|
-
else:
|
|
83
|
-
return 'H'
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if __name__ == '__main__':
|
|
87
|
-
3()
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.index.main_index_sync_task as main_index_sync_task
|
|
9
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.etf.etf_one_minute_sync_task as etf_one_minute_sync_task
|
|
10
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.kzz.kzz_one_minute_sync_task as kzz_one_minute_sync_task
|
|
11
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.stock.stock_one_minute_sync_task as stock_one_minute_sync_task
|
|
12
|
-
from datetime import datetime
|
|
13
|
-
import mns_common.component.trade_date.trade_date_common_service_api as trade_date_common_service_api
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def sync_one_minute_data():
|
|
17
|
-
now_date = datetime.now()
|
|
18
|
-
hour = now_date.hour
|
|
19
|
-
now_day = now_date.strftime('%Y-%m-%d')
|
|
20
|
-
if trade_date_common_service_api.is_trade_day(now_day):
|
|
21
|
-
if 15 < hour < 20:
|
|
22
|
-
main_index_sync_task.sync_main_index_one_minute(True)
|
|
23
|
-
etf_one_minute_sync_task.sync_etf_one_minute(True)
|
|
24
|
-
kzz_one_minute_sync_task.sync_kzz_one_minute(True)
|
|
25
|
-
stock_one_minute_sync_task.sync_stock_one_minute(True)
|
|
26
|
-
elif hour < 9 or hour >= 20:
|
|
27
|
-
main_index_sync_task.sync_main_index_one_minute(False)
|
|
28
|
-
etf_one_minute_sync_task.sync_etf_one_minute(False)
|
|
29
|
-
kzz_one_minute_sync_task.sync_kzz_one_minute(False)
|
|
30
|
-
stock_one_minute_sync_task.sync_stock_one_minute(False)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if __name__ == '__main__':
|
|
34
|
-
sync_one_minute_data()
|
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
9
|
-
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
10
|
-
from loguru import logger
|
|
11
|
-
import time
|
|
12
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
13
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
14
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.common.symbol_handle_util as symbol_handle_util
|
|
15
|
-
from mns_common.db.v2.MongodbUtilV2 import MongodbUtilV2
|
|
16
|
-
import mns_scheduler.extraIncome.a_stock.one_minute.common.db_create_index as db_create_index
|
|
17
|
-
import mns_common.constant.extra_income_db_name as extra_income_db_name
|
|
18
|
-
import mns_common.api.k_line.stock_minute_data_api as stock_minute_data_api
|
|
19
|
-
from datetime import datetime
|
|
20
|
-
|
|
21
|
-
mongodb_util_27017 = MongodbUtil('27017')
|
|
22
|
-
mongodbUtilV2_27019 = MongodbUtilV2('27019', extra_income_db_name.EXTRA_INCOME)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def sync_stock_one_minute(data_tag):
|
|
26
|
-
real_time_quotes_all_stocks = em_stock_info_api.get_a_stock_info()
|
|
27
|
-
real_time_quotes_all_stocks = common_service_fun_api.classify_symbol(real_time_quotes_all_stocks)
|
|
28
|
-
real_time_quotes_all_stocks['symbol'] = real_time_quotes_all_stocks.apply(
|
|
29
|
-
lambda row: row['symbol'] + '.SZ' if row['classification'] in ['S', 'C']
|
|
30
|
-
else row['symbol'] + '.BJ' if row['classification'] in ['X']
|
|
31
|
-
else row['symbol'] + '.SH',
|
|
32
|
-
axis=1)
|
|
33
|
-
# 假设数字格式为 YYYYMMDD
|
|
34
|
-
# debt_real_time_quotes['list_date'] = pd.to_datetime(debt_real_time_quotes['list_date'],
|
|
35
|
-
# format='%Y%m%d').dt.strftime('%Y-%m-%d')
|
|
36
|
-
|
|
37
|
-
real_time_quotes_all_stocks = real_time_quotes_all_stocks.loc[real_time_quotes_all_stocks['amount'] != 0]
|
|
38
|
-
|
|
39
|
-
now_date = datetime.now()
|
|
40
|
-
now_day = now_date.strftime('%Y-%m-%d')
|
|
41
|
-
year = now_date.strftime('%Y')
|
|
42
|
-
|
|
43
|
-
# 创建索引
|
|
44
|
-
db_create_index.create_index(mongodbUtilV2_27019, extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_C + '_' + str(year))
|
|
45
|
-
db_create_index.create_index(mongodbUtilV2_27019, extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_BJ + '_' + str(year))
|
|
46
|
-
db_create_index.create_index(mongodbUtilV2_27019, extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_H + '_' + str(year))
|
|
47
|
-
db_create_index.create_index(mongodbUtilV2_27019, extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_K + '_' + str(year))
|
|
48
|
-
db_create_index.create_index(mongodbUtilV2_27019, extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_S + '_' + str(year))
|
|
49
|
-
|
|
50
|
-
for stock_one in real_time_quotes_all_stocks.itertuples():
|
|
51
|
-
classification = stock_one.classification
|
|
52
|
-
|
|
53
|
-
if classification == 'X':
|
|
54
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_BJ
|
|
55
|
-
elif classification == 'S':
|
|
56
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_S
|
|
57
|
-
elif classification == 'H':
|
|
58
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_H
|
|
59
|
-
elif classification == 'K':
|
|
60
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_K
|
|
61
|
-
elif classification == 'C':
|
|
62
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_C
|
|
63
|
-
col_name = col_name + '_' + str(year)
|
|
64
|
-
|
|
65
|
-
symbol = stock_one.symbol
|
|
66
|
-
symbol_prefix = symbol_handle_util.symbol_add_prefix(symbol)
|
|
67
|
-
try:
|
|
68
|
-
one_min_df = stock_minute_data_api.get_minute_data(symbol_prefix, now_day, now_day, '1', '')
|
|
69
|
-
one_min_df['symbol'] = symbol
|
|
70
|
-
one_min_df['_id'] = one_min_df['symbol'] + '_' + one_min_df['time']
|
|
71
|
-
if data_frame_util.is_empty(one_min_df) or one_min_df.shape[0] < 241:
|
|
72
|
-
symbol_handle_util.save_fail_data(now_day, symbol_prefix, col_name)
|
|
73
|
-
logger.error("当前股票分钟数据同步异常:{}", symbol)
|
|
74
|
-
continue
|
|
75
|
-
else:
|
|
76
|
-
del one_min_df['ava_price']
|
|
77
|
-
if data_tag:
|
|
78
|
-
mongodbUtilV2_27019.insert_mongo(one_min_df, col_name)
|
|
79
|
-
else:
|
|
80
|
-
mongodbUtilV2_27019.save_mongo(one_min_df, col_name)
|
|
81
|
-
except BaseException as e:
|
|
82
|
-
time.sleep(2)
|
|
83
|
-
symbol_handle_util.save_fail_data(now_day, symbol_prefix, col_name)
|
|
84
|
-
logger.error("同步股票分钟数据出现异常:,{},{},{}", e, symbol, now_day)
|
|
85
|
-
logger.info("同步股票分钟票数据完整:{},{}", stock_one.symbol, stock_one.name)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if __name__ == '__main__':
|
|
89
|
-
sync_stock_one_minute()
|
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
import sys
|
|
9
|
-
import os
|
|
10
|
-
|
|
11
|
-
file_path = os.path.abspath(__file__)
|
|
12
|
-
end = file_path.index('mns') + 17
|
|
13
|
-
project_path = file_path[0:end]
|
|
14
|
-
sys.path.append(project_path)
|
|
15
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
16
|
-
from loguru import logger
|
|
17
|
-
import mns_scheduler.baidu.baidu_yun_pan_handle_service as baidu_yun_pan_handle_service
|
|
18
|
-
from mns_common.db.v2.MongodbUtilV2 import MongodbUtilV2
|
|
19
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
20
|
-
from datetime import datetime
|
|
21
|
-
import mns_common.constant.extra_income_db_name as extra_income_db_name
|
|
22
|
-
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
23
|
-
|
|
24
|
-
mongodb_util = MongodbUtil('27017')
|
|
25
|
-
mongodbUtilV2_27019 = MongodbUtilV2('27019', extra_income_db_name.EXTRA_INCOME)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def upload_etf_to_baidu():
|
|
29
|
-
a_stock_path = '/A股/ETF/'
|
|
30
|
-
|
|
31
|
-
now_date_time = datetime.now()
|
|
32
|
-
now_year = now_date_time.year
|
|
33
|
-
month = now_date_time.month
|
|
34
|
-
a_stock_path = a_stock_path + str(now_year) + '/' + str(month)
|
|
35
|
-
# 创建路径
|
|
36
|
-
baidu_yun_pan_handle_service.mkdir_baidu_new_folder(a_stock_path)
|
|
37
|
-
em_a_etf_info_df = em_stock_info_api.get_etf_info()
|
|
38
|
-
|
|
39
|
-
em_a_etf_info_df = classify_symbol(em_a_etf_info_df)
|
|
40
|
-
|
|
41
|
-
em_a_etf_info_df['symbol'] = em_a_etf_info_df.apply(
|
|
42
|
-
lambda row: row['symbol'] + '.SZ' if row['classification'] in ['S', 'C']
|
|
43
|
-
else row['symbol'] + '.BJ' if row['classification'] in ['X']
|
|
44
|
-
else row['symbol'] + '.SH',
|
|
45
|
-
axis=1
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
file_folder_df = baidu_yun_pan_handle_service.get_file_folder(a_stock_path)
|
|
49
|
-
if data_frame_util.is_not_empty(file_folder_df):
|
|
50
|
-
# 去除文件名中的 .csv 后缀
|
|
51
|
-
file_folder_df['name'] = file_folder_df['name'].str.replace(r'\.csv$', '', regex=True)
|
|
52
|
-
em_a_etf_info_df = em_a_etf_info_df.loc[~(em_a_etf_info_df['symbol'].isin(file_folder_df['name']))]
|
|
53
|
-
fail_list = []
|
|
54
|
-
for stock_one in em_a_etf_info_df.itertuples():
|
|
55
|
-
symbol = stock_one.symbol
|
|
56
|
-
name = stock_one.name
|
|
57
|
-
try:
|
|
58
|
-
|
|
59
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_ETF + '_' + str(now_year)
|
|
60
|
-
|
|
61
|
-
if month < 10:
|
|
62
|
-
month_str = '0' + str(month)
|
|
63
|
-
else:
|
|
64
|
-
month_str = str(month)
|
|
65
|
-
begin_time = str(now_year) + '-' + month_str + '-01 09:00:00'
|
|
66
|
-
query = {'symbol': symbol, 'time': {"$gte": begin_time}}
|
|
67
|
-
one_minute_k_line_bfq_df = mongodbUtilV2_27019.find_query_data(col_name, query)
|
|
68
|
-
if data_frame_util.is_not_empty(one_minute_k_line_bfq_df):
|
|
69
|
-
one_minute_k_line_bfq_df = one_minute_k_line_bfq_df.sort_values(by=['time'], ascending=True)
|
|
70
|
-
del one_minute_k_line_bfq_df['_id']
|
|
71
|
-
del one_minute_k_line_bfq_df['symbol']
|
|
72
|
-
result = baidu_yun_pan_handle_service.upload_to_baidu(symbol, a_stock_path, one_minute_k_line_bfq_df)
|
|
73
|
-
if result != 0:
|
|
74
|
-
fail_list.append(symbol)
|
|
75
|
-
except BaseException as e:
|
|
76
|
-
fail_list.append(symbol)
|
|
77
|
-
logger.error("上传数据异常:{}", e)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def classify_symbol(etf_real_time_quotes):
|
|
81
|
-
etf_real_time_quotes['classification'] = etf_real_time_quotes['market'].apply(
|
|
82
|
-
lambda market: classify_symbol_one(market))
|
|
83
|
-
return etf_real_time_quotes
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# 单个股票分类
|
|
87
|
-
def classify_symbol_one(market):
|
|
88
|
-
if market == 0:
|
|
89
|
-
return 'S'
|
|
90
|
-
else:
|
|
91
|
-
return 'H'
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if __name__ == '__main__':
|
|
95
|
-
upload_etf_to_baidu()
|
|
@@ -1,87 +0,0 @@
|
|
|
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_common.db.MongodbUtil import MongodbUtil
|
|
10
|
-
from loguru import logger
|
|
11
|
-
import mns_scheduler.baidu.baidu_yun_pan_handle_service as baidu_yun_pan_handle_service
|
|
12
|
-
from mns_common.db.v2.MongodbUtilV2 import MongodbUtilV2
|
|
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
|
-
main_index_list = [
|
|
21
|
-
"000001.SH",
|
|
22
|
-
"000016.SH",
|
|
23
|
-
"000010.SH",
|
|
24
|
-
"000009.SH",
|
|
25
|
-
"000015.SH",
|
|
26
|
-
"399001.SZ",
|
|
27
|
-
"399004.SZ",
|
|
28
|
-
"399005.SZ",
|
|
29
|
-
"399006.SZ",
|
|
30
|
-
"000300.SH",
|
|
31
|
-
"000905.SH",
|
|
32
|
-
"000688.SH",
|
|
33
|
-
"000903.SH",
|
|
34
|
-
"000906.SH",
|
|
35
|
-
"000852.SH",
|
|
36
|
-
"000932.SH",
|
|
37
|
-
"000933.SH",
|
|
38
|
-
"980017.SZ",
|
|
39
|
-
"399808.SZ",
|
|
40
|
-
"399997.SZ",
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def upload_index_to_baidu():
|
|
45
|
-
a_stock_path = '/A股/主要指数/'
|
|
46
|
-
|
|
47
|
-
now_date_time = datetime.now()
|
|
48
|
-
now_year = now_date_time.year
|
|
49
|
-
month = now_date_time.month
|
|
50
|
-
a_stock_path = a_stock_path + str(now_year) + '/' + str(month)
|
|
51
|
-
# 创建路径
|
|
52
|
-
baidu_yun_pan_handle_service.mkdir_baidu_new_folder(a_stock_path)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
fail_list = []
|
|
59
|
-
for symbol in main_index_list:
|
|
60
|
-
|
|
61
|
-
try:
|
|
62
|
-
|
|
63
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_MAIN_INDEX + '_' + str(now_year)
|
|
64
|
-
|
|
65
|
-
if month < 10:
|
|
66
|
-
month_str = '0' + str(month)
|
|
67
|
-
else:
|
|
68
|
-
month_str = str(month)
|
|
69
|
-
begin_time = str(now_year) + '-' + month_str + '-01 09:00:00'
|
|
70
|
-
query = {'symbol': symbol, 'time': {"$gte": begin_time}}
|
|
71
|
-
one_minute_k_line_bfq_df = mongodbUtilV2_27019.find_query_data(col_name, query)
|
|
72
|
-
if data_frame_util.is_not_empty(one_minute_k_line_bfq_df):
|
|
73
|
-
one_minute_k_line_bfq_df = one_minute_k_line_bfq_df.sort_values(by=['time'], ascending=True)
|
|
74
|
-
del one_minute_k_line_bfq_df['_id']
|
|
75
|
-
del one_minute_k_line_bfq_df['symbol']
|
|
76
|
-
result = baidu_yun_pan_handle_service.upload_to_baidu(symbol, a_stock_path, one_minute_k_line_bfq_df)
|
|
77
|
-
if result != 0:
|
|
78
|
-
fail_list.append(symbol)
|
|
79
|
-
except BaseException as e:
|
|
80
|
-
fail_list.append(symbol)
|
|
81
|
-
logger.error("上传数据异常:{}", e)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if __name__ == '__main__':
|
|
87
|
-
upload_index_to_baidu()
|
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
import sys
|
|
9
|
-
import os
|
|
10
|
-
|
|
11
|
-
file_path = os.path.abspath(__file__)
|
|
12
|
-
end = file_path.index('mns') + 17
|
|
13
|
-
project_path = file_path[0:end]
|
|
14
|
-
sys.path.append(project_path)
|
|
15
|
-
from mns_common.db.MongodbUtil import MongodbUtil
|
|
16
|
-
from loguru import logger
|
|
17
|
-
import mns_scheduler.baidu.baidu_yun_pan_handle_service as baidu_yun_pan_handle_service
|
|
18
|
-
from mns_common.db.v2.MongodbUtilV2 import MongodbUtilV2
|
|
19
|
-
import mns_common.utils.data_frame_util as data_frame_util
|
|
20
|
-
from datetime import datetime
|
|
21
|
-
import mns_common.constant.extra_income_db_name as extra_income_db_name
|
|
22
|
-
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
23
|
-
|
|
24
|
-
mongodb_util = MongodbUtil('27017')
|
|
25
|
-
mongodbUtilV2_27019 = MongodbUtilV2('27019', extra_income_db_name.EXTRA_INCOME)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def upload_kzz_to_baidu():
|
|
29
|
-
a_stock_path = '/A股/可转债/1分钟'
|
|
30
|
-
|
|
31
|
-
now_date_time = datetime.now()
|
|
32
|
-
now_year = now_date_time.year
|
|
33
|
-
month = now_date_time.month
|
|
34
|
-
a_stock_path = a_stock_path + str(now_year) + '/' + str(month)
|
|
35
|
-
# 创建路径
|
|
36
|
-
baidu_yun_pan_handle_service.mkdir_baidu_new_folder(a_stock_path)
|
|
37
|
-
em_a_kzz_info_df = em_stock_info_api.get_kzz_info()
|
|
38
|
-
|
|
39
|
-
em_a_kzz_info_df = classify_symbol(em_a_kzz_info_df)
|
|
40
|
-
|
|
41
|
-
em_a_kzz_info_df['symbol'] = em_a_kzz_info_df.apply(
|
|
42
|
-
lambda row: row['symbol'] + '.SZ' if row['classification'] in ['S', 'C']
|
|
43
|
-
else row['symbol'] + '.BJ' if row['classification'] in ['X']
|
|
44
|
-
else row['symbol'] + '.SH',
|
|
45
|
-
axis=1
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
file_folder_df = baidu_yun_pan_handle_service.get_file_folder(a_stock_path)
|
|
49
|
-
if data_frame_util.is_not_empty(file_folder_df):
|
|
50
|
-
# 去除文件名中的 .csv 后缀
|
|
51
|
-
file_folder_df['name'] = file_folder_df['name'].str.replace(r'\.csv$', '', regex=True)
|
|
52
|
-
em_a_kzz_info_df = em_a_kzz_info_df.loc[~(em_a_kzz_info_df['symbol'].isin(file_folder_df['name']))]
|
|
53
|
-
fail_list = []
|
|
54
|
-
for stock_one in em_a_kzz_info_df.itertuples():
|
|
55
|
-
symbol = stock_one.symbol
|
|
56
|
-
name = stock_one.name
|
|
57
|
-
try:
|
|
58
|
-
|
|
59
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_KZZ + '_' + str(now_year)
|
|
60
|
-
|
|
61
|
-
if month < 10:
|
|
62
|
-
month_str = '0' + str(month)
|
|
63
|
-
else:
|
|
64
|
-
month_str = str(month)
|
|
65
|
-
begin_time = str(now_year) + '-' + month_str + '-01 09:00:00'
|
|
66
|
-
query = {'symbol': symbol, 'time': {"$gte": begin_time}}
|
|
67
|
-
one_minute_k_line_bfq_df = mongodbUtilV2_27019.find_query_data(col_name, query)
|
|
68
|
-
if data_frame_util.is_not_empty(one_minute_k_line_bfq_df):
|
|
69
|
-
one_minute_k_line_bfq_df = one_minute_k_line_bfq_df.sort_values(by=['time'], ascending=True)
|
|
70
|
-
del one_minute_k_line_bfq_df['_id']
|
|
71
|
-
del one_minute_k_line_bfq_df['symbol']
|
|
72
|
-
result = baidu_yun_pan_handle_service.upload_to_baidu(symbol, a_stock_path, one_minute_k_line_bfq_df)
|
|
73
|
-
if result != 0:
|
|
74
|
-
fail_list.append(symbol)
|
|
75
|
-
except BaseException as e:
|
|
76
|
-
fail_list.append(symbol)
|
|
77
|
-
logger.error("上传数据异常:{}", e)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def classify_symbol(kzz_real_time_quotes):
|
|
81
|
-
kzz_real_time_quotes['classification'] = kzz_real_time_quotes['market'].apply(
|
|
82
|
-
lambda market: classify_symbol_one(market))
|
|
83
|
-
return kzz_real_time_quotes
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# 单个股票分类
|
|
87
|
-
def classify_symbol_one(market):
|
|
88
|
-
if market == 0:
|
|
89
|
-
return 'S'
|
|
90
|
-
else:
|
|
91
|
-
return 'H'
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if __name__ == '__main__':
|
|
95
|
-
upload_kzz_to_baidu()
|
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
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
|
-
symbol = stock_one.symbol
|
|
49
|
-
name = stock_one.name
|
|
50
|
-
try:
|
|
51
|
-
classification = stock_one.classification
|
|
52
|
-
if classification == 'X':
|
|
53
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_BJ
|
|
54
|
-
elif classification == 'S':
|
|
55
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_S
|
|
56
|
-
|
|
57
|
-
elif classification == 'H':
|
|
58
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_H
|
|
59
|
-
elif classification == 'K':
|
|
60
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_K
|
|
61
|
-
elif classification == 'C':
|
|
62
|
-
col_name = extra_income_db_name.ONE_MINUTE_K_LINE_BFQ_C
|
|
63
|
-
col_name = col_name + '_' + str(now_year)
|
|
64
|
-
|
|
65
|
-
if month < 10:
|
|
66
|
-
month_str = '0' + str(month)
|
|
67
|
-
else:
|
|
68
|
-
month_str = str(month)
|
|
69
|
-
begin_time = str(now_year) + '-' + month_str + '-01 09:00:00'
|
|
70
|
-
query = {'symbol': symbol, 'time': {"$gte": begin_time}}
|
|
71
|
-
one_minute_k_line_bfq_df = mongodbUtilV2_27019.find_query_data(col_name, query)
|
|
72
|
-
if data_frame_util.is_not_empty(one_minute_k_line_bfq_df):
|
|
73
|
-
one_minute_k_line_bfq_df = one_minute_k_line_bfq_df.sort_values(by=['time'], ascending=True)
|
|
74
|
-
del one_minute_k_line_bfq_df['_id']
|
|
75
|
-
del one_minute_k_line_bfq_df['symbol']
|
|
76
|
-
result = baidu_yun_pan_handle_service.upload_to_baidu(symbol, a_stock_path, one_minute_k_line_bfq_df)
|
|
77
|
-
if result != 0:
|
|
78
|
-
fail_list.append(symbol)
|
|
79
|
-
except BaseException as e:
|
|
80
|
-
fail_list.append(symbol)
|
|
81
|
-
logger.error("上传数据异常:{}", e)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if __name__ == '__main__':
|
|
85
|
-
upload_stock_to_baidu()
|