mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-02 03:48:19 +08:00
优化板块数据下载
This commit is contained in:
parent
2f92c91a16
commit
462c243daa
@ -4,6 +4,7 @@
|
||||
# Create on: 20240102
|
||||
# Author: fasiondog
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from hikyuu.data.common import MARKET, get_stk_code_name_list
|
||||
from hikyuu.util import *
|
||||
from hikyuu.fetcher.stock.zh_block_em import *
|
||||
@ -12,34 +13,47 @@ from hikyuu.fetcher.stock.zh_block_em import *
|
||||
def em_import_block_to_mysql(connect, code_market_dict, categorys=('行业板块', '概念板块', '地域板块', '指数板块')):
|
||||
all_block_info = {}
|
||||
|
||||
with ThreadPoolExecutor(4) as executor:
|
||||
if '行业板块' in categorys:
|
||||
t1 = executor.submit(get_all_hybk_info, code_market_dict)
|
||||
|
||||
if '概念板块' in categorys:
|
||||
t2 = executor.submit(get_all_gnbk_info, code_market_dict)
|
||||
|
||||
if '地域板块' in categorys:
|
||||
t3 = executor.submit(get_all_dybk_info, code_market_dict)
|
||||
|
||||
if '指数板块' in categorys:
|
||||
t4 = executor.submit(get_all_zsbk_info, code_market_dict)
|
||||
|
||||
success_fetch_hy = False
|
||||
if '行业板块' in categorys:
|
||||
hku_info("获取行业板块信息")
|
||||
x = get_all_hybk_info(code_market_dict)
|
||||
x = t1.result()
|
||||
hku_info("获取行业板块信息完毕")
|
||||
if x:
|
||||
all_block_info["行业板块"] = x
|
||||
success_fetch_hy = True
|
||||
|
||||
success_fetch_gn = False
|
||||
if '概念板块' in categorys:
|
||||
hku_info("获取概念板块信息")
|
||||
x = get_all_gnbk_info(code_market_dict)
|
||||
x = t2.result()
|
||||
hku_info("获取概念板块信息完毕")
|
||||
if x:
|
||||
all_block_info["概念板块"] = x
|
||||
success_fetch_gn = True
|
||||
|
||||
success_fetch_dy = False
|
||||
if '地域板块' in categorys:
|
||||
hku_info("获取地域板块信息")
|
||||
x = get_all_dybk_info(code_market_dict)
|
||||
x = t3.result()
|
||||
hku_info("获取地域板块信息完毕")
|
||||
if x:
|
||||
all_block_info["地域板块"] = x
|
||||
success_fetch_dy = True
|
||||
|
||||
success_fetch_zs = False
|
||||
if '指数板块' in categorys:
|
||||
hku_info("获取指数板块信息")
|
||||
x = get_all_zsbk_info(code_market_dict)
|
||||
x = t4.result()
|
||||
hku_info("获取指数板块信息完毕")
|
||||
if x:
|
||||
all_block_info["指数板块"] = x
|
||||
success_fetch_zs = True
|
||||
|
@ -4,42 +4,57 @@
|
||||
# Create on: 20240102
|
||||
# Author: fasiondog
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from hikyuu.data.common import MARKET, get_stk_code_name_list
|
||||
from hikyuu.util import *
|
||||
from hikyuu.fetcher.stock.zh_block_em import *
|
||||
|
||||
|
||||
@spend_time
|
||||
def em_import_block_to_sqlite(connect, code_market_dict, categorys=('行业板块', '概念板块', '地域板块', '指数板块')):
|
||||
all_block_info = {}
|
||||
|
||||
with ThreadPoolExecutor(4) as executor:
|
||||
if '行业板块' in categorys:
|
||||
t1 = executor.submit(get_all_hybk_info, code_market_dict)
|
||||
|
||||
if '概念板块' in categorys:
|
||||
t2 = executor.submit(get_all_gnbk_info, code_market_dict)
|
||||
|
||||
if '地域板块' in categorys:
|
||||
t3 = executor.submit(get_all_dybk_info, code_market_dict)
|
||||
|
||||
if '指数板块' in categorys:
|
||||
t4 = executor.submit(get_all_zsbk_info, code_market_dict)
|
||||
|
||||
success_fetch_hy = False
|
||||
if '行业板块' in categorys:
|
||||
hku_info("获取行业板块信息")
|
||||
x = get_all_hybk_info(code_market_dict)
|
||||
x = t1.result()
|
||||
hku_info("获取行业板块信息完毕")
|
||||
if x:
|
||||
all_block_info["行业板块"] = x
|
||||
success_fetch_hy = True
|
||||
|
||||
success_fetch_gn = False
|
||||
if '概念板块' in categorys:
|
||||
hku_info("获取概念板块信息")
|
||||
x = get_all_gnbk_info(code_market_dict)
|
||||
x = t2.result()
|
||||
hku_info("获取概念板块信息完毕")
|
||||
if x:
|
||||
all_block_info["概念板块"] = x
|
||||
success_fetch_gn = True
|
||||
|
||||
success_fetch_dy = False
|
||||
if '地域板块' in categorys:
|
||||
hku_info("获取地域板块信息")
|
||||
x = get_all_dybk_info(code_market_dict)
|
||||
x = t3.result()
|
||||
hku_info("获取地域板块信息完毕")
|
||||
if x:
|
||||
all_block_info["地域板块"] = x
|
||||
success_fetch_dy = True
|
||||
|
||||
success_fetch_zs = False
|
||||
if '指数板块' in categorys:
|
||||
hku_info("获取指数板块信息")
|
||||
x = get_all_zsbk_info(code_market_dict)
|
||||
x = t4.result()
|
||||
hku_info("获取指数板块信息完毕")
|
||||
if x:
|
||||
all_block_info["指数板块"] = x
|
||||
success_fetch_zs = True
|
||||
@ -85,8 +100,8 @@ if __name__ == "__main__":
|
||||
import sqlite3
|
||||
from hikyuu.data.common_sqlite3 import create_database
|
||||
|
||||
dest_dir = "/home/fasiondog/stock"
|
||||
# dest_dir = "d:\\stock"
|
||||
# dest_dir = "/home/fasiondog/stock"
|
||||
dest_dir = "d:\\stock"
|
||||
|
||||
connect = sqlite3.connect(dest_dir + "/stock.db")
|
||||
create_database(connect)
|
||||
|
Loading…
Reference in New Issue
Block a user