mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-29 18:39:10 +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,37 +13,50 @@ from hikyuu.fetcher.stock.zh_block_em import *
|
||||
def em_import_block_to_mysql(connect, code_market_dict, categorys=('行业板块', '概念板块', '地域板块', '指数板块')):
|
||||
all_block_info = {}
|
||||
|
||||
success_fetch_hy = False
|
||||
if '行业板块' in categorys:
|
||||
hku_info("获取行业板块信息")
|
||||
x = get_all_hybk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["行业板块"] = x
|
||||
success_fetch_hy = True
|
||||
with ThreadPoolExecutor(4) as executor:
|
||||
if '行业板块' in categorys:
|
||||
t1 = executor.submit(get_all_hybk_info, code_market_dict)
|
||||
|
||||
success_fetch_gn = False
|
||||
if '概念板块' in categorys:
|
||||
hku_info("获取概念板块信息")
|
||||
x = get_all_gnbk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["概念板块"] = x
|
||||
success_fetch_gn = True
|
||||
if '概念板块' in categorys:
|
||||
t2 = executor.submit(get_all_gnbk_info, code_market_dict)
|
||||
|
||||
success_fetch_dy = False
|
||||
if '地域板块' in categorys:
|
||||
hku_info("获取地域板块信息")
|
||||
x = get_all_dybk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["地域板块"] = x
|
||||
success_fetch_dy = True
|
||||
if '地域板块' in categorys:
|
||||
t3 = executor.submit(get_all_dybk_info, code_market_dict)
|
||||
|
||||
success_fetch_zs = False
|
||||
if '指数板块' in categorys:
|
||||
hku_info("获取指数板块信息")
|
||||
x = get_all_zsbk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["指数板块"] = x
|
||||
success_fetch_zs = True
|
||||
if '指数板块' in categorys:
|
||||
t4 = executor.submit(get_all_zsbk_info, code_market_dict)
|
||||
|
||||
success_fetch_hy = False
|
||||
if '行业板块' in categorys:
|
||||
x = t1.result()
|
||||
hku_info("获取行业板块信息完毕")
|
||||
if x:
|
||||
all_block_info["行业板块"] = x
|
||||
success_fetch_hy = True
|
||||
|
||||
success_fetch_gn = False
|
||||
if '概念板块' in categorys:
|
||||
x = t2.result()
|
||||
hku_info("获取概念板块信息完毕")
|
||||
if x:
|
||||
all_block_info["概念板块"] = x
|
||||
success_fetch_gn = True
|
||||
|
||||
success_fetch_dy = False
|
||||
if '地域板块' in categorys:
|
||||
x = t3.result()
|
||||
hku_info("获取地域板块信息完毕")
|
||||
if x:
|
||||
all_block_info["地域板块"] = x
|
||||
success_fetch_dy = True
|
||||
|
||||
success_fetch_zs = False
|
||||
if '指数板块' in categorys:
|
||||
x = t4.result()
|
||||
hku_info("获取指数板块信息完毕")
|
||||
if x:
|
||||
all_block_info["指数板块"] = x
|
||||
success_fetch_zs = True
|
||||
|
||||
blks = []
|
||||
if success_fetch_hy:
|
||||
|
@ -4,45 +4,60 @@
|
||||
# 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 = {}
|
||||
|
||||
success_fetch_hy = False
|
||||
if '行业板块' in categorys:
|
||||
hku_info("获取行业板块信息")
|
||||
x = get_all_hybk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["行业板块"] = x
|
||||
success_fetch_hy = True
|
||||
with ThreadPoolExecutor(4) as executor:
|
||||
if '行业板块' in categorys:
|
||||
t1 = executor.submit(get_all_hybk_info, code_market_dict)
|
||||
|
||||
success_fetch_gn = False
|
||||
if '概念板块' in categorys:
|
||||
hku_info("获取概念板块信息")
|
||||
x = get_all_gnbk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["概念板块"] = x
|
||||
success_fetch_gn = True
|
||||
if '概念板块' in categorys:
|
||||
t2 = executor.submit(get_all_gnbk_info, code_market_dict)
|
||||
|
||||
success_fetch_dy = False
|
||||
if '地域板块' in categorys:
|
||||
hku_info("获取地域板块信息")
|
||||
x = get_all_dybk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["地域板块"] = x
|
||||
success_fetch_dy = True
|
||||
if '地域板块' in categorys:
|
||||
t3 = executor.submit(get_all_dybk_info, code_market_dict)
|
||||
|
||||
success_fetch_zs = False
|
||||
if '指数板块' in categorys:
|
||||
hku_info("获取指数板块信息")
|
||||
x = get_all_zsbk_info(code_market_dict)
|
||||
if x:
|
||||
all_block_info["指数板块"] = x
|
||||
success_fetch_zs = True
|
||||
if '指数板块' in categorys:
|
||||
t4 = executor.submit(get_all_zsbk_info, code_market_dict)
|
||||
|
||||
success_fetch_hy = False
|
||||
if '行业板块' in categorys:
|
||||
x = t1.result()
|
||||
hku_info("获取行业板块信息完毕")
|
||||
if x:
|
||||
all_block_info["行业板块"] = x
|
||||
success_fetch_hy = True
|
||||
|
||||
success_fetch_gn = False
|
||||
if '概念板块' in categorys:
|
||||
x = t2.result()
|
||||
hku_info("获取概念板块信息完毕")
|
||||
if x:
|
||||
all_block_info["概念板块"] = x
|
||||
success_fetch_gn = True
|
||||
|
||||
success_fetch_dy = False
|
||||
if '地域板块' in categorys:
|
||||
x = t3.result()
|
||||
hku_info("获取地域板块信息完毕")
|
||||
if x:
|
||||
all_block_info["地域板块"] = x
|
||||
success_fetch_dy = True
|
||||
|
||||
success_fetch_zs = False
|
||||
if '指数板块' in categorys:
|
||||
x = t4.result()
|
||||
hku_info("获取指数板块信息完毕")
|
||||
if x:
|
||||
all_block_info["指数板块"] = x
|
||||
success_fetch_zs = True
|
||||
|
||||
blks = []
|
||||
if success_fetch_hy:
|
||||
@ -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