hikyuu 2.6.8.4__py3-none-manylinux2014_x86_64.whl → 2.6.9__py3-none-manylinux2014_x86_64.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.
- hikyuu/__init__.py +5 -12
- hikyuu/__init__.pyi +612 -587
- hikyuu/analysis/__init__.pyi +589 -563
- hikyuu/analysis/analysis.pyi +590 -564
- hikyuu/core.py +2 -0
- hikyuu/core.pyi +591 -565
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/core310.pyi +446 -13
- hikyuu/cpp/core310.so +0 -0
- hikyuu/cpp/core311.pyi +440 -13
- hikyuu/cpp/core311.so +0 -0
- hikyuu/cpp/core312.pyi +440 -13
- hikyuu/cpp/core312.so +0 -0
- hikyuu/cpp/core313.pyi +446 -13
- hikyuu/cpp/core313.so +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/libboost_charconv-mt.so +0 -0
- hikyuu/cpp/libboost_charconv-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_chrono-mt.so +0 -0
- hikyuu/cpp/libboost_chrono-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_date_time-mt.so +0 -0
- hikyuu/cpp/libboost_date_time-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_serialization-mt.so +0 -0
- hikyuu/cpp/libboost_serialization-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_system-mt.so +0 -0
- hikyuu/cpp/libboost_system-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_thread-mt.so +0 -0
- hikyuu/cpp/libboost_thread-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_wserialization-mt.so +0 -0
- hikyuu/cpp/libboost_wserialization-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libhikyuu.so +0 -0
- hikyuu/cpp/libsqlite3.so +0 -0
- hikyuu/data/clickhouse_upgrade/createdb.sql +105 -105
- hikyuu/data/common.py +3 -3
- hikyuu/data/common_clickhouse.py +1 -1
- hikyuu/data/download_block.py +318 -0
- hikyuu/data/em_block_to_clickhouse.py +26 -74
- hikyuu/data/em_block_to_mysql.py +25 -75
- hikyuu/data/em_block_to_sqlite.py +26 -78
- hikyuu/data/hku_config_template.py +3 -3
- hikyuu/data/pytdx_to_clickhouse.py +15 -11
- hikyuu/data/pytdx_to_h5.py +6 -2
- hikyuu/data/pytdx_to_mysql.py +5 -1
- hikyuu/data/pytdx_weight_to_clickhouse.py +1 -1
- hikyuu/data/pytdx_weight_to_mysql.py +1 -1
- hikyuu/data/pytdx_weight_to_sqlite.py +1 -1
- hikyuu/data/zh_bond10_to_clickhouse.py +1 -1
- hikyuu/draw/drawplot/__init__.pyi +8 -8
- hikyuu/draw/drawplot/bokeh_draw.pyi +603 -578
- hikyuu/draw/drawplot/common.pyi +1 -1
- hikyuu/draw/drawplot/echarts_draw.pyi +605 -580
- hikyuu/draw/drawplot/matplotlib_draw.py +4 -74
- hikyuu/draw/drawplot/matplotlib_draw.pyi +615 -590
- hikyuu/draw/elder.pyi +11 -11
- hikyuu/draw/kaufman.pyi +18 -18
- hikyuu/draw/volume.pyi +10 -10
- hikyuu/examples/notebook/Demo/Demo1.ipynb +48 -33
- hikyuu/extend.pyi +599 -573
- hikyuu/fetcher/stock/zh_block_em.py +50 -18
- hikyuu/gui/HikyuuTDX.py +81 -30
- hikyuu/gui/data/CollectSpotThread.py +1 -1
- hikyuu/gui/data/EscapetimeThread.py +8 -14
- hikyuu/gui/data/ImportBlockInfoTask.py +3 -10
- hikyuu/gui/data/MainWindow.py +1168 -715
- hikyuu/gui/data/SchedImportThread.py +2 -2
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +3 -3
- hikyuu/gui/data/UseQmtImportToH5Thread.py +2 -2
- hikyuu/gui/data/UseTdxImportToH5Thread.py +3 -3
- hikyuu/gui/data/tool.py +32 -25
- hikyuu/gui/dataserver.py +5 -3
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/DataType.h +4 -16
- hikyuu/include/hikyuu/KData.h +6 -3
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +1 -1
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +1 -1
- hikyuu/include/hikyuu/KQuery.h +2 -2
- hikyuu/include/hikyuu/Stock.h +3 -0
- hikyuu/include/hikyuu/StockManager.h +13 -3
- hikyuu/include/hikyuu/config.h +3 -0
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +8 -0
- hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +26 -1
- hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +1 -1
- hikyuu/include/hikyuu/hikyuu.h +1 -1
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +4 -4
- hikyuu/include/hikyuu/indicator/crt/HSL.h +2 -2
- hikyuu/include/hikyuu/indicator/crt/QUANTILE_TRUNC.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +2 -2
- hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +25 -0
- hikyuu/include/hikyuu/misc.h +38 -0
- hikyuu/include/hikyuu/plugin/dataserver.h +2 -1
- hikyuu/include/hikyuu/plugin/extind.h +37 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +0 -18
- hikyuu/include/hikyuu/plugin/hkuviews.h +36 -0
- hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -2
- hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +12 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +0 -14
- hikyuu/include/hikyuu/plugin/interface/HkuViewsPluginInterface.h +34 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +8 -1
- hikyuu/include/hikyuu/python/pybind_utils.h +6 -1
- hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +3 -0
- hikyuu/include/hikyuu/trade_manage/Performance.h +4 -4
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +0 -4
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +36 -3
- hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +125 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +125 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +3 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/buildin_norm.h +36 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/buildin_scfilter.h +51 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/GroupSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreLessOrEqualValueSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreNanSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/MinAmountPercentSCFilter.h +25 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/PriceSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/TopNSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormMinMax.h +23 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantile.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantileUniform.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormZScore.h +25 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/quantile_trunc.h +16 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +49 -0
- hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +40 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +0 -3
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +49 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +0 -4
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +1 -1
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +4 -4
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/system/System.h +14 -1
- hikyuu/include/hikyuu/utilities/SpendTimer.h +17 -7
- hikyuu/include/hikyuu/utilities/arithmetic.h +55 -0
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +1 -1
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +4 -1
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/plugin/libbacktest.so +0 -0
- hikyuu/plugin/libclickhousedriver.so +0 -0
- hikyuu/plugin/libdataserver.so +0 -0
- hikyuu/plugin/libdevice.so +0 -0
- hikyuu/plugin/libextind.so +0 -0
- hikyuu/plugin/libhkuextra.so +0 -0
- hikyuu/plugin/libhkuviews.so +0 -0
- hikyuu/plugin/libimport2hdf5.so +0 -0
- hikyuu/plugin/libtmreport.so +0 -0
- hikyuu/trade_manage/__init__.pyi +603 -578
- hikyuu/trade_manage/broker.pyi +3 -3
- hikyuu/trade_manage/broker_easytrader.pyi +1 -1
- hikyuu/trade_manage/trade.pyi +603 -578
- hikyuu/util/__init__.pyi +2 -2
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/METADATA +13 -13
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/RECORD +185 -156
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/top_level.txt +2 -1
- hikyuu/cpp/core39.pyi +0 -14385
- hikyuu/cpp/core39.so +0 -0
- hikyuu/data_driver/__init__.py +0 -49
- hikyuu/data_driver/jqdata_data_driver.py +0 -277
- hikyuu/data_driver/pytdx_data_driver.py +0 -292
- hikyuu/fetcher/stock/zh_stock_a_huatai.py +0 -51
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +0 -129
- hikyuu/gui/data/CollectToMemThread.py +0 -123
- hikyuu/gui/data/CollectToMySQLThread.py +0 -178
- hikyuu/gui/start_huatai_insight.py +0 -510
- hikyuu/tools/update_block_info.py +0 -168
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/entry_points.txt +0 -0
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
try:
|
|
5
|
-
from insight_sdk.com.interface.mdc_gateway_base_define import ESubscribeActionType, ESecurityIDSource, ESecurityType, \
|
|
6
|
-
EMarketDataType, MDPlaybackExrightsType
|
|
7
|
-
from insight_sdk.com.insight import common, query, playback, subscribe
|
|
8
|
-
from insight_sdk.com.insight.market_service import market_service
|
|
9
|
-
except Exception as e:
|
|
10
|
-
print(e)
|
|
11
|
-
print('You must "pip install insgith_sdk"!')
|
|
12
|
-
exit(-1)
|
|
13
|
-
|
|
14
|
-
from hikyuu.fetcher.stock.zh_stock_a_huatai import parse_one_result_huatai
|
|
15
|
-
from hikyuu.gui.spot_server import release_nng_senders, start_send_spot, end_send_spot, send_spot
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# ************************************用户登录************************************
|
|
19
|
-
# 登陆
|
|
20
|
-
# user 用户名
|
|
21
|
-
# password 密码
|
|
22
|
-
def login(user, password):
|
|
23
|
-
markets = insightmarketservice()
|
|
24
|
-
# 登陆前 初始化
|
|
25
|
-
# result格式为string格式
|
|
26
|
-
result = common.login(markets, user, password)
|
|
27
|
-
print("login result: ", result)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class insightmarketservice(market_service):
|
|
31
|
-
def __init__(self):
|
|
32
|
-
pass
|
|
33
|
-
|
|
34
|
-
# ************************************处理数据订阅************************************
|
|
35
|
-
# 处理订阅的股票Tick数据,mdStock格式为json格式
|
|
36
|
-
# 订阅的证券类型为ESecurityType.StockType
|
|
37
|
-
def onSubscribe_StockType_MD_TICK(self, mdStock):
|
|
38
|
-
# print(mdStock)
|
|
39
|
-
result = parse_one_result_huatai(mdStock)
|
|
40
|
-
# print("{}{}".format(result['market'], result['code']))
|
|
41
|
-
start_send_spot()
|
|
42
|
-
send_spot([result])
|
|
43
|
-
end_send_spot()
|
|
44
|
-
# pass
|
|
45
|
-
|
|
46
|
-
# 处理订阅的指数Tick数据,mdIndex格式为json格式
|
|
47
|
-
# 订阅的证券类型为ESecurityType.IndexType
|
|
48
|
-
def onSubscribe_IndexType_MD_TICK(self, mdIndex):
|
|
49
|
-
print(mdIndex)
|
|
50
|
-
pass
|
|
51
|
-
|
|
52
|
-
# 处理订阅的债券Tick数据,mdBond格式为json格式
|
|
53
|
-
# 订阅的证券类型为ESecurityType.BondType
|
|
54
|
-
def onSubscribe_BondType_MD_TICK(self, mdBond):
|
|
55
|
-
pass
|
|
56
|
-
# print(mdBond)
|
|
57
|
-
|
|
58
|
-
# 处理订阅的基金Tick数据,mdFund格式为json格式
|
|
59
|
-
# 订阅的证券类型为ESecurityType.FundType
|
|
60
|
-
def onSubscribe_FundType_MD_TICK(self, mdFund):
|
|
61
|
-
# print(mdFund)
|
|
62
|
-
pass
|
|
63
|
-
|
|
64
|
-
# 处理订阅的逐笔成交,marketdatajson格式为json格式
|
|
65
|
-
# 订阅的证券类型为ESecurityType.MD_TRANSACTION
|
|
66
|
-
# 处理订阅的逐笔委托,格式为json格式
|
|
67
|
-
# 订阅的证券类型为ESecurityType.MD_ORDER
|
|
68
|
-
def onSubscribe_MD_TRANSACTION_and_MD_ORDER(self, marketdatajson):
|
|
69
|
-
if marketdatajson["marketDataType"] == EMarketDataType.MD_TRANSACTION: # 逐笔成交
|
|
70
|
-
mdtransaction = marketdatajson["mdTransaction"]
|
|
71
|
-
pass
|
|
72
|
-
# print(mdtransaction)
|
|
73
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_ORDER: # 逐笔委托
|
|
74
|
-
mdorder = marketdatajson["mdOrder"]
|
|
75
|
-
pass
|
|
76
|
-
# print(mdorder)
|
|
77
|
-
# print(marketdatajsons)
|
|
78
|
-
|
|
79
|
-
# 处理订阅的K线指标模型,marketdatajson格式为json格式
|
|
80
|
-
# 订阅的数据类型为EMarketDataType.MD_KLINE_15S 返回#15秒钟K线
|
|
81
|
-
# 订阅的数据类型为EMarketDataType.MD_KLINE_1MIN 返回#1分钟K线
|
|
82
|
-
# 订阅的数据类型为EMarketDataType.MD_KLINE_5MIN 返回#5分钟K线
|
|
83
|
-
# 订阅的数据类型为EMarketDataType.MD_KLINE_15MIN 返回#15分钟K线
|
|
84
|
-
# 订阅的数据类型为EMarketDataType.MD_KLINE_30MIN 返回#30分钟K线
|
|
85
|
-
# 订阅的数据类型为EMarketDataType.MD_KLINE_60MIN 返回#60分钟K线
|
|
86
|
-
# 订阅的数据类型为EMarketDataType.MD_KLINE_1D 返回#日K线
|
|
87
|
-
def onSubscribe_MD_KLINE(self, marketdatajson):
|
|
88
|
-
if marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_15S: # 15秒钟K线
|
|
89
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
90
|
-
pass
|
|
91
|
-
# print(mdKLine)
|
|
92
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_1MIN: # 1分钟K线
|
|
93
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
94
|
-
pass
|
|
95
|
-
# print(mdKLine)
|
|
96
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_5MIN: # 5分钟K线
|
|
97
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
98
|
-
pass
|
|
99
|
-
# print(mdKLine)
|
|
100
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_15MIN: # 15分钟K线
|
|
101
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
102
|
-
pass
|
|
103
|
-
# print(mdKLine)
|
|
104
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_30MIN: # 30分钟K线
|
|
105
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
106
|
-
pass
|
|
107
|
-
# print(mdKLine)
|
|
108
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_60MIN: # 60分钟K线
|
|
109
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
110
|
-
pass
|
|
111
|
-
# print(mdKLine)
|
|
112
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_1D: # 日K线
|
|
113
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
114
|
-
pass
|
|
115
|
-
# print(mdKLine)
|
|
116
|
-
|
|
117
|
-
# print(marketdatajson)
|
|
118
|
-
|
|
119
|
-
# 处理订阅的资金流向数据,mdFundFlowAnalysis格式为json格式
|
|
120
|
-
# 订阅的证券类型为ESecurityType.AD_FUND_FLOW_ANALYSIS
|
|
121
|
-
def onSubscribe_AD_FUND_FLOW_ANALYSIS(self, mdFundFlowAnalysis):
|
|
122
|
-
pass
|
|
123
|
-
# print(mdFundFlowAnalysis)
|
|
124
|
-
|
|
125
|
-
# 处理订阅的融券通数据,mdSecurityLending格式为json格式
|
|
126
|
-
# 订阅的证券类型为ESecurityType.MD_SECURITY_LENDING
|
|
127
|
-
def onSubscribe_MD_SECURITY_LENDING(self, mdSecurityLending):
|
|
128
|
-
pass
|
|
129
|
-
# print(mdSecurityLending)
|
|
130
|
-
|
|
131
|
-
# ************************************处理回放数据************************************
|
|
132
|
-
# 处理回放的股票Tick数据,mdStock格式为json格式
|
|
133
|
-
# 回放的证券类型为ESecurityType.StockType
|
|
134
|
-
def onPlayback_StockType_MD_TICK(self, mdStock):
|
|
135
|
-
pass
|
|
136
|
-
# print(mdStock)
|
|
137
|
-
|
|
138
|
-
# 处理回放的指数Tick数据,mdIndex格式为json格式
|
|
139
|
-
# 回放的证券类型为ESecurityType.IndexType
|
|
140
|
-
def onPlayback_IndexType_MD_TICK(self, mdIndex):
|
|
141
|
-
pass
|
|
142
|
-
# print(mdIndex)
|
|
143
|
-
|
|
144
|
-
# 处理回放的债券Tick数据,mdBond格式为json格式
|
|
145
|
-
# 回放的证券类型为ESecurityType.BondType
|
|
146
|
-
def onPlayback_BondType_MD_TICK(self, mdBond):
|
|
147
|
-
pass
|
|
148
|
-
# print(mdBond)
|
|
149
|
-
|
|
150
|
-
# 处理回放的基金Tick数据,mdFund格式为json格式
|
|
151
|
-
# 回放的证券类型为ESecurityType.FundType
|
|
152
|
-
def onPlayback_FundType_MD_TICK(self, mdFund):
|
|
153
|
-
pass
|
|
154
|
-
# print(mdFund)
|
|
155
|
-
|
|
156
|
-
# 处理回放的期权Tick数据,mdOption格式为json格式
|
|
157
|
-
# 回放的证券类型为ESecurityType.OptionType
|
|
158
|
-
def onPlayback_OptionType_MD_TICK(self, mdOption):
|
|
159
|
-
pass
|
|
160
|
-
# print(mdOption)
|
|
161
|
-
|
|
162
|
-
# 处理回放的期货Tick数据,mdFuture格式为json格式
|
|
163
|
-
# 回放的证券类型为ESecurityType.OptionType
|
|
164
|
-
def onPlayback_FuturesType_MD_TICK(self, mdFuture):
|
|
165
|
-
pass
|
|
166
|
-
# print(mdFuture)
|
|
167
|
-
|
|
168
|
-
# 处理回放的逐笔成交,marketdatajson格式为json格式
|
|
169
|
-
# 回放的证券类型为ESecurityType.MD_TRANSACTION
|
|
170
|
-
# 处理回放的逐笔委托,格式为json格式
|
|
171
|
-
# 回放的证券类型为ESecurityType.MD_ORDER
|
|
172
|
-
def onPlayback_MD_TRANSACTION_and_MD_ORDER(self, marketdatajson):
|
|
173
|
-
if marketdatajson["marketDataType"] == EMarketDataType.MD_TRANSACTION: # 逐笔成交
|
|
174
|
-
mdtransaction = marketdatajson["mdTransaction"]
|
|
175
|
-
pass
|
|
176
|
-
# print(mdtransaction)
|
|
177
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_ORDER: # 逐笔委托
|
|
178
|
-
mdorder = marketdatajson["mdOrder"]
|
|
179
|
-
pass
|
|
180
|
-
# print(mdorder)
|
|
181
|
-
# print(marketdatajsons)
|
|
182
|
-
|
|
183
|
-
# 处理回放的K线指标模型,marketdatajson格式为json格式
|
|
184
|
-
# 回放的数据类型为EMarketDataType.MD_KLINE_15S 返回#15秒钟K线
|
|
185
|
-
# 回放的数据类型为EMarketDataType.MD_KLINE_1MIN 返回#1分钟K线
|
|
186
|
-
# 回放的数据类型为EMarketDataType.MD_KLINE_5MIN 返回#5分钟K线
|
|
187
|
-
# 回放的数据类型为EMarketDataType.MD_KLINE_15MIN 返回#15分钟K线
|
|
188
|
-
# 回放的数据类型为EMarketDataType.MD_KLINE_30MIN 返回#30分钟K线
|
|
189
|
-
# 回放的数据类型为EMarketDataType.MD_KLINE_60MIN 返回#60分钟K线
|
|
190
|
-
# 回放的数据类型为EMarketDataType.MD_KLINE_1D 返回#日K线
|
|
191
|
-
def onPlayback_MD_KLINE(self, marketdatajson):
|
|
192
|
-
if marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_15S: # 15秒钟K线
|
|
193
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
194
|
-
pass
|
|
195
|
-
# print(mdKLine)
|
|
196
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_1MIN: # 1分钟K线
|
|
197
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
198
|
-
pass
|
|
199
|
-
# print(mdKLine)
|
|
200
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_5MIN: # 5分钟K线
|
|
201
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
202
|
-
pass
|
|
203
|
-
# print(mdKLine)
|
|
204
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_15MIN: # 15分钟K线
|
|
205
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
206
|
-
pass
|
|
207
|
-
# print(mdKLine)
|
|
208
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_30MIN: # 30分钟K线
|
|
209
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
210
|
-
pass
|
|
211
|
-
# print(mdKLine)
|
|
212
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_60MIN: # 60分钟K线
|
|
213
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
214
|
-
pass
|
|
215
|
-
# print(mdKLine)
|
|
216
|
-
elif marketdatajson["marketDataType"] == EMarketDataType.MD_KLINE_1D: # 日K线
|
|
217
|
-
mdKLine = marketdatajson["mdKLine"]
|
|
218
|
-
pass
|
|
219
|
-
# print(mdKLine)
|
|
220
|
-
|
|
221
|
-
# print(marketdatajson)
|
|
222
|
-
|
|
223
|
-
# 处理回放的资金流向数据,mdFundFlowAnalysis格式为json格式
|
|
224
|
-
# 回放的证券类型为ESecurityType.AD_FUND_FLOW_ANALYSIS
|
|
225
|
-
def onPlayback_AD_FUND_FLOW_ANALYSIS(self, mdFundFlowAnalysis):
|
|
226
|
-
pass
|
|
227
|
-
# print(mdFundFlowAnalysis)
|
|
228
|
-
|
|
229
|
-
# 处理回放的融券通数据,mdSecurityLending格式为json格式
|
|
230
|
-
# 回放的证券类型为ESecurityType.MD_SECURITY_LENDING
|
|
231
|
-
def onPlayback_MD_SECURITY_LENDING(self, mdSecurityLending):
|
|
232
|
-
pass
|
|
233
|
-
# print(mdSecurityLending)
|
|
234
|
-
|
|
235
|
-
# 处理回放的状态,status格式为string格式
|
|
236
|
-
def onPlaybackStatus(self, status):
|
|
237
|
-
pass
|
|
238
|
-
# print(status)
|
|
239
|
-
|
|
240
|
-
# 处理回放请求返回结果,response格式为string格式
|
|
241
|
-
def onPlaybackResponse(self, response):
|
|
242
|
-
pass
|
|
243
|
-
# print(response)
|
|
244
|
-
|
|
245
|
-
# 处理回放控制请求返回结果,response格式为string格式
|
|
246
|
-
def onPlaybackControlResponse(self, response):
|
|
247
|
-
pass
|
|
248
|
-
# print(response)
|
|
249
|
-
|
|
250
|
-
# ************************************处理查询请求返回结果************************************
|
|
251
|
-
# 处理查询历史上所有的指定证券的基础信息 query_mdcontant_by_type()的返回结果,queryresponse格式为list[json]
|
|
252
|
-
# 处理查询今日最新的指定证券的基础信息 query_last_mdcontant_by_type()的返回结果,queryresponse格式为list[json]
|
|
253
|
-
# 处理查询历史上所有的指定证券的基础信息 query_mdcontant_by_id()的返回结果,queryresponse格式为list[json]
|
|
254
|
-
# 处理查询今日最新的指定证券的基础信息 query_last_mdcontant_by_id()的返回结果,queryresponse格式为list[json]
|
|
255
|
-
# 处理查询指定证券的ETF的基础信息 query_ETFinfo()的返回结果,queryresponse格式为list[json]
|
|
256
|
-
# 处理查询指定证券的最新一条Tick数据 query_last_mdtick()的返回结果,queryresponse格式为list[json]
|
|
257
|
-
def onQueryResponse(self, queryresponse):
|
|
258
|
-
pass
|
|
259
|
-
for resonse in iter(queryresponse):
|
|
260
|
-
# response格式为json格式
|
|
261
|
-
print(resonse)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
# 配置日志打开
|
|
265
|
-
# open_trace trace日志开关 True为打开日志False关闭日志
|
|
266
|
-
# open_file_log 本地file日志开关 True为打开日志False关闭日志
|
|
267
|
-
# open_cout_log 控制台日志开关 True为打开日志False关闭日志
|
|
268
|
-
def config(open_trace=True, open_file_log=True, open_cout_log=True):
|
|
269
|
-
common.config(open_trace, open_file_log, open_cout_log)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
# ************************************数据订阅************************************
|
|
273
|
-
# 根据证券数据来源订阅行情数据,由三部分确定行情数据
|
|
274
|
-
# 行情源(SecurityIdSource):XSHG(沪市)|XSHE(深市)|...
|
|
275
|
-
# 证券类型(SecurityType):BondType(债)|StockType(股)|FundType(基)|IndexType(指)|OptionType(期权)|...
|
|
276
|
-
# 数据类型(MarketDataTypes):MD_TICK(快照)|MD_TRANSACTION(逐笔成交)|MD_ORDER(逐笔委托)|...
|
|
277
|
-
# 异步接口,返回函数在functional_test.py
|
|
278
|
-
# 结果返回 onSubscribe_StockType_MD_TICK 处理订阅的股票Tick数据
|
|
279
|
-
# 结果返回 onSubscribe_IndexType_MD_TICK 处理订阅的指数Tick数据
|
|
280
|
-
# 结果返回 onSubscribe_BondType_MD_TICK 处理订阅的债券Tick数据
|
|
281
|
-
# 结果返回 onSubscribe_FundType_MD_TICK 处理订阅的基金Tick数据
|
|
282
|
-
# 结果返回 onSubscribe_OptionType_MD_TICK 处理订阅的期权Tick数据
|
|
283
|
-
# 结果返回 onSubscribe_FuturesType_MD_TICK 处理订阅的期货Tick数据
|
|
284
|
-
# 结果返回 onSubscribe_MD_TRANSACTION_and_MD_ORDER 处理订阅的逐笔成交和逐笔委托的数据
|
|
285
|
-
# 结果返回 onSubscribe_MD_KLINE 处理订阅的K线指标模型数据
|
|
286
|
-
# 结果返回 onSubscribe_AD_FUND_FLOW_ANALYSIS 处理订阅的资金流向数据
|
|
287
|
-
# 结果返回 onSubscribe_MD_SECURITY_LENDING 处理订阅的融券通数据
|
|
288
|
-
def subscribe_by_type():
|
|
289
|
-
# element
|
|
290
|
-
# params1: ESecurityIDSource枚举值 --行情源
|
|
291
|
-
# params2: ESecurityType的枚举值 --证券类型
|
|
292
|
-
# params3: EMarketDataType的枚举值集合 --数据类型
|
|
293
|
-
datatype = ESubscribeActionType.COVERAGE
|
|
294
|
-
marketdatatypes = []
|
|
295
|
-
marketdatatype = {
|
|
296
|
-
"ESecurityIDSource": ESecurityIDSource.XSHG,
|
|
297
|
-
"ESecurityType": ESecurityType.StockType,
|
|
298
|
-
"EMarketDataType": EMarketDataType.MD_SECURITY_LENDING
|
|
299
|
-
}
|
|
300
|
-
marketdatatypes.append(marketdatatype)
|
|
301
|
-
marketdatatype1 = {
|
|
302
|
-
"ESecurityIDSource": ESecurityIDSource.XSHE,
|
|
303
|
-
"ESecurityType": ESecurityType.StockType,
|
|
304
|
-
"EMarketDataType": EMarketDataType.MD_TICK
|
|
305
|
-
}
|
|
306
|
-
marketdatatypes.append(marketdatatype1)
|
|
307
|
-
|
|
308
|
-
subscribe.subscribe_by_type(marketdatatypes, datatype)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
# 根据证券ID来源订阅行情数据
|
|
312
|
-
# 异步接口,返回函数在functional_test.py
|
|
313
|
-
# 结果返回 onSubscribe_StockType_MD_TICK 处理订阅的股票Tick数据
|
|
314
|
-
# 结果返回 onSubscribe_IndexType_MD_TICK 处理订阅的指数Tick数据
|
|
315
|
-
# 结果返回 onSubscribe_BondType_MD_TICK 处理订阅的债券Tick数据
|
|
316
|
-
# 结果返回 onSubscribe_FundType_MD_TICK 处理订阅的基金Tick数据
|
|
317
|
-
# 结果返回 onSubscribe_OptionType_MD_TICK 处理订阅的期权Tick数据
|
|
318
|
-
# 结果返回 onSubscribe_FuturesType_MD_TICK 处理订阅的期货Tick数据
|
|
319
|
-
# 结果返回 onSubscribe_MD_TRANSACTION_and_MD_ORDER 处理订阅的逐笔成交和逐笔委托的数据
|
|
320
|
-
# 结果返回 onSubscribe_MD_KLINE 处理订阅的K线指标模型数据
|
|
321
|
-
# 结果返回 onSubscribe_AD_FUND_FLOW_ANALYSIS 处理订阅的资金流向数据
|
|
322
|
-
# 结果返回 onSubscribe_MD_SECURITY_LENDING 处理订阅的融券通数据
|
|
323
|
-
def subscribe_by_id():
|
|
324
|
-
# params1:HTSCSecurityID华泰内部证券标string --证券代码
|
|
325
|
-
# params2: EMarketDataType的枚举值集合 --数据类型
|
|
326
|
-
datatype = ESubscribeActionType.COVERAGE
|
|
327
|
-
HTSCSecurityIDs = []
|
|
328
|
-
HTSCSecurityID = {"HTSCSecurityID": "002371.SZ", "EMarketDataType": EMarketDataType.MD_TICK}
|
|
329
|
-
HTSCSecurityIDs.append(HTSCSecurityID)
|
|
330
|
-
|
|
331
|
-
HTSCSecurityID1 = {"HTSCSecurityID": "002714.SZ", "EMarketDataType": EMarketDataType.MD_TICK}
|
|
332
|
-
HTSCSecurityIDs.append(HTSCSecurityID1)
|
|
333
|
-
subscribe.subscribe_by_id(HTSCSecurityIDs, datatype)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
# ************************************数据查询************************************
|
|
337
|
-
# 查询findata数据,返回结果list[json]
|
|
338
|
-
# 同步接口,返回结果为result,格式为list[json]
|
|
339
|
-
def query_fin_info():
|
|
340
|
-
# params1:Hquery_type int
|
|
341
|
-
# params2:params dict{}
|
|
342
|
-
query_type = 1102010003
|
|
343
|
-
params = {"HTSC_SECURITY_ID": "510050.SH", "START_DATE": "20210101", "END_DATE": "20210107"}
|
|
344
|
-
# query_type = 1002010001
|
|
345
|
-
# params = {"HTSC_SECURITY_ID": "601688.SH", "START_DATE": "20191211", "END_DATE": "20201010"}
|
|
346
|
-
# query_type = 1002070003
|
|
347
|
-
# params = {"HTSC_SECURITY_ID": "600498.SH", "START_TIME": "20200101000000", "END_TIME": "20210107000000", "EXRIGHTS_TYPE": "NoExrights", "EMD_PERIOD_TYPE":"Period1D"}
|
|
348
|
-
result = query.query_fin_info(query_type, params)
|
|
349
|
-
if isinstance(result, list):
|
|
350
|
-
for response in iter(result):
|
|
351
|
-
print(response)
|
|
352
|
-
else:
|
|
353
|
-
print(result)
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
# 查询历史上所有的指定证券的基础信息
|
|
357
|
-
# params:securityIdSource 为市场ESecurityIDSource 枚举值;securityType 为 ESecurityType枚举值
|
|
358
|
-
# 异步接口,返回函数在functional_test.py
|
|
359
|
-
# 结果返回在onQueryResponse函数
|
|
360
|
-
def query_mdcontant_by_type():
|
|
361
|
-
# params:security_idsource 为 ESecurityIDSource枚举值
|
|
362
|
-
# params:security_type 为 ESecurityType枚举值
|
|
363
|
-
# 沪市 股票
|
|
364
|
-
idsource_and_types = []
|
|
365
|
-
security_idsource = ESecurityIDSource.XSHG
|
|
366
|
-
security_type = ESecurityType.StockType
|
|
367
|
-
idsource_and_type = {"ESecurityIDSource": security_idsource, "ESecurityType": security_type}
|
|
368
|
-
idsource_and_types.append(idsource_and_type)
|
|
369
|
-
security_idsource1 = ESecurityIDSource.XSHE
|
|
370
|
-
security_type1 = ESecurityType.IndexType
|
|
371
|
-
idsource_and_type1 = {"ESecurityIDSource": security_idsource1, "ESecurityType": security_type1}
|
|
372
|
-
idsource_and_types.append(idsource_and_type1)
|
|
373
|
-
|
|
374
|
-
query.query_basicInfo_by_type(idsource_and_types, False)
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
# 查询今日最新的指定证券的基础信息
|
|
378
|
-
# params:securityIdSource 为市场ESecurityIDSource 枚举值;securityType 为 ESecurityType枚举值
|
|
379
|
-
# 异步接口,返回函数在functional_test.py
|
|
380
|
-
# 结果返回在onQueryResponse函数
|
|
381
|
-
def query_last_mdcontant_by_type():
|
|
382
|
-
# 按市场查询
|
|
383
|
-
# 沪市 股票
|
|
384
|
-
|
|
385
|
-
idsource_and_types = []
|
|
386
|
-
security_idsource = ESecurityIDSource.XSHG
|
|
387
|
-
security_type = ESecurityType.StockType
|
|
388
|
-
idsource_and_type = {"ESecurityIDSource": security_idsource, "ESecurityType": security_type}
|
|
389
|
-
idsource_and_types.append(idsource_and_type)
|
|
390
|
-
security_idsource1 = ESecurityIDSource.XSHE
|
|
391
|
-
security_type1 = ESecurityType.IndexType
|
|
392
|
-
idsource_and_type1 = {"ESecurityIDSource": security_idsource1, "ESecurityType": security_type1}
|
|
393
|
-
idsource_and_types.append(idsource_and_type1)
|
|
394
|
-
|
|
395
|
-
query.query_basicInfo_by_type(idsource_and_types, True)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
# 查询历史上所有的指定证券的基础信息 -- 结果返回在onQueryResponse
|
|
399
|
-
# param:HTSCSecurityID华泰内部证券标string --证券代码
|
|
400
|
-
# params:list[HTSCSecurityID]
|
|
401
|
-
# 异步接口,返回函数在functional_test.py
|
|
402
|
-
# 结果返回在onQueryResponse函数
|
|
403
|
-
def query_mdcontant_by_id():
|
|
404
|
-
# params:security_idsource 为 ESecurityIDSource枚举值
|
|
405
|
-
# params:security_type 为 ESecurityType枚举值
|
|
406
|
-
# params:security_id_list 为 标的集合
|
|
407
|
-
security_id_list = ["601688.SH", "002714.SZ"] # 置空表示不额外查询某些标的
|
|
408
|
-
query.query_basicInfo_by_id(security_id_list, False)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
# 查询今日最新的指定证券的基础信息 -- 结果返回在onQueryResponse
|
|
412
|
-
# param:HTSCSecurityID华泰内部证券标string --证券代码
|
|
413
|
-
# params:list[HTSCSecurityID]
|
|
414
|
-
# 异步接口,返回函数在functional_test.py
|
|
415
|
-
# 结果返回在onQueryResponse函数
|
|
416
|
-
def query_last_mdcontant_by_id():
|
|
417
|
-
# 按市场查询
|
|
418
|
-
# 沪市 股票
|
|
419
|
-
|
|
420
|
-
# params:security_id_list 为 标的集合
|
|
421
|
-
security_id_list = ["601688.SH"] # 置空表示不额外查询某些标的
|
|
422
|
-
query.query_basicInfo_by_id(security_id_list, True)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
# 查询指定证券的ETF的基础信息 -- 结果返回在onQueryResponse
|
|
426
|
-
# params:securityIdSource 为市场ESecurityIDSource 枚举值;securityType 为 ESecurityType枚举值
|
|
427
|
-
# 异步接口,返回函数在functional_test.py
|
|
428
|
-
# 结果返回在onQueryResponse函数
|
|
429
|
-
def query_ETFinfo():
|
|
430
|
-
# params:securityIDSource 为 ESecurityIDSource枚举值
|
|
431
|
-
# params:securityType 为 ESecurityType枚举值
|
|
432
|
-
query.query_ETFinfo(ESecurityIDSource.XSHG, ESecurityType.FundType)
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
# 查询指定证券的最新一条Tick数据 -- 结果返回在onQueryResponse
|
|
436
|
-
# params:securityIdSource 为市场ESecurityIDSource 枚举值;securityType 为 ESecurityType枚举值
|
|
437
|
-
# 异步接口,返回函数在functional_test.py
|
|
438
|
-
# 结果返回在onQueryResponse函数
|
|
439
|
-
def query_last_mdtick():
|
|
440
|
-
# params:security_idsource 为 ESecurityIDSource枚举值
|
|
441
|
-
# params:security_type 为 ESecurityType枚举值
|
|
442
|
-
# 沪市 股票
|
|
443
|
-
query.query_last_tick_by_type(ESecurityIDSource.XSHG, ESecurityType.StockType)
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
# 获取当前版本号
|
|
447
|
-
def get_version():
|
|
448
|
-
print(common.get_version())
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
# 释放资源
|
|
452
|
-
def fini():
|
|
453
|
-
common.fini()
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
def subscribe_by_hikyuu():
|
|
457
|
-
datatype = ESubscribeActionType.COVERAGE
|
|
458
|
-
marketdatatypes = [
|
|
459
|
-
{
|
|
460
|
-
"ESecurityIDSource": ESecurityIDSource.XSHE,
|
|
461
|
-
"ESecurityType": ESecurityType.StockType,
|
|
462
|
-
"EMarketDataType": EMarketDataType.MD_TICK
|
|
463
|
-
},
|
|
464
|
-
{
|
|
465
|
-
"ESecurityIDSource": ESecurityIDSource.XSHE,
|
|
466
|
-
"ESecurityType": ESecurityType.IndexType,
|
|
467
|
-
"EMarketDataType": EMarketDataType.MD_TICK
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
"ESecurityIDSource": ESecurityIDSource.XSHE,
|
|
471
|
-
"ESecurityType": ESecurityType.FundType,
|
|
472
|
-
"EMarketDataType": EMarketDataType.MD_TICK
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
"ESecurityIDSource": ESecurityIDSource.XSHG,
|
|
476
|
-
"ESecurityType": ESecurityType.StockType,
|
|
477
|
-
"EMarketDataType": EMarketDataType.MD_TICK
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
"ESecurityIDSource": ESecurityIDSource.XSHG,
|
|
481
|
-
"ESecurityType": ESecurityType.IndexType,
|
|
482
|
-
"EMarketDataType": EMarketDataType.MD_TICK
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
"ESecurityIDSource": ESecurityIDSource.XSHG,
|
|
486
|
-
"ESecurityType": ESecurityType.FundType,
|
|
487
|
-
"EMarketDataType": EMarketDataType.MD_TICK
|
|
488
|
-
},
|
|
489
|
-
]
|
|
490
|
-
|
|
491
|
-
subscribe.subscribe_by_type(marketdatatypes, datatype)
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if __name__ == "__main__":
|
|
495
|
-
# 登陆部分调用
|
|
496
|
-
get_version()
|
|
497
|
-
|
|
498
|
-
login(user="", password="")
|
|
499
|
-
|
|
500
|
-
config(False, False, False)
|
|
501
|
-
|
|
502
|
-
try:
|
|
503
|
-
# 订阅部分接口调用
|
|
504
|
-
subscribe_by_type()
|
|
505
|
-
except KeyboardInterrupt:
|
|
506
|
-
pass
|
|
507
|
-
|
|
508
|
-
# 退出释放资源
|
|
509
|
-
release_nng_senders()
|
|
510
|
-
fini()
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
# -*- coding: utf8 -*-
|
|
3
|
-
#
|
|
4
|
-
# Create on: 2023-12-18
|
|
5
|
-
# Author: fasiondog
|
|
6
|
-
|
|
7
|
-
import requests
|
|
8
|
-
import akshare as ak
|
|
9
|
-
from hikyuu.interactive import *
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def get_code_market_dict():
|
|
13
|
-
ret = {}
|
|
14
|
-
for s in sm:
|
|
15
|
-
if s.type in (constant.STOCKTYPE_A, constant.STOCKTYPE_A_BJ, constant.STOCKTYPE_B, constant.STOCKTYPE_GEM, constant.STOCKTYPE_START):
|
|
16
|
-
ret[s.code] = "0" if s.market == 'SH' else "1"
|
|
17
|
-
return ret
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def get_all_hybk_info():
|
|
21
|
-
code_market = get_code_market_dict()
|
|
22
|
-
blk_names = ak.stock_board_industry_name_em()['板块名称']
|
|
23
|
-
ret = {}
|
|
24
|
-
for blk_name in blk_names:
|
|
25
|
-
print(blk_name)
|
|
26
|
-
ret[blk_name] = []
|
|
27
|
-
stk_codes = ak.stock_board_industry_cons_em(blk_name)
|
|
28
|
-
stk_codes = stk_codes['代码'].to_list()
|
|
29
|
-
for stk_code in stk_codes:
|
|
30
|
-
try:
|
|
31
|
-
ret[blk_name].append(f"{code_market[stk_code]},{stk_code}")
|
|
32
|
-
except:
|
|
33
|
-
print(stk_code)
|
|
34
|
-
return ret
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def get_all_gnbk_info():
|
|
38
|
-
code_market = get_code_market_dict()
|
|
39
|
-
blk_names = ak.stock_board_concept_name_em()['板块名称']
|
|
40
|
-
ret = {}
|
|
41
|
-
for blk_name in blk_names:
|
|
42
|
-
print(blk_name)
|
|
43
|
-
ret[blk_name] = []
|
|
44
|
-
stk_codes = ak.stock_board_concept_cons_em(blk_name)
|
|
45
|
-
stk_codes = stk_codes['代码'].to_list()
|
|
46
|
-
for stk_code in stk_codes:
|
|
47
|
-
try:
|
|
48
|
-
ret[blk_name].append(f"{code_market[stk_code]},{stk_code}")
|
|
49
|
-
except:
|
|
50
|
-
print(stk_code)
|
|
51
|
-
return ret
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def get_all_dybk_info():
|
|
55
|
-
url = "http://13.push2.eastmoney.com/api/qt/clist/get"
|
|
56
|
-
params = {
|
|
57
|
-
"pn": "1",
|
|
58
|
-
"pz": "50000",
|
|
59
|
-
"po": "1",
|
|
60
|
-
"np": "1",
|
|
61
|
-
"ut": "bd1d9ddb04089700cf9c27f6f7426281",
|
|
62
|
-
"fltt": "2",
|
|
63
|
-
"invt": "2",
|
|
64
|
-
"fid": "f3",
|
|
65
|
-
"fs": "m:90+t:1+f:!50",
|
|
66
|
-
"fields": "f12,f14",
|
|
67
|
-
# "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,"
|
|
68
|
-
# "f136,f115,f152",
|
|
69
|
-
"_": "1623833739532",
|
|
70
|
-
}
|
|
71
|
-
r = requests.get(url, params=params)
|
|
72
|
-
data_json = r.json()
|
|
73
|
-
data_json = data_json["data"]["diff"]
|
|
74
|
-
|
|
75
|
-
params = {
|
|
76
|
-
"pn": "1",
|
|
77
|
-
"pz": "2000",
|
|
78
|
-
"po": "1",
|
|
79
|
-
"np": "1",
|
|
80
|
-
"ut": "bd1d9ddb04089700cf9c27f6f7426281",
|
|
81
|
-
"fltt": "2",
|
|
82
|
-
"invt": "2",
|
|
83
|
-
"fid": "f3",
|
|
84
|
-
# "fs": f"b:{stock_board_code} f:!50",
|
|
85
|
-
"fields": "f12",
|
|
86
|
-
"_": "1626081702127",
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
ret = {}
|
|
90
|
-
code_market = get_code_market_dict()
|
|
91
|
-
for v in data_json:
|
|
92
|
-
# print(v)
|
|
93
|
-
blk_code = v["f12"]
|
|
94
|
-
blk_name = v["f14"]
|
|
95
|
-
print(blk_name)
|
|
96
|
-
ret[blk_name] = []
|
|
97
|
-
params["fs"] = f"b:{blk_code} f:!50"
|
|
98
|
-
r = requests.get(url, params=params)
|
|
99
|
-
stk_json = r.json()
|
|
100
|
-
stk_json = stk_json["data"]["diff"]
|
|
101
|
-
|
|
102
|
-
for item in stk_json:
|
|
103
|
-
stk_code = item["f12"]
|
|
104
|
-
try:
|
|
105
|
-
ret[blk_name].append(f"{code_market[stk_code]},{stk_code}")
|
|
106
|
-
except:
|
|
107
|
-
print(stk_code)
|
|
108
|
-
return ret
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def get_all_zsbk_info():
|
|
112
|
-
code_market = get_code_market_dict()
|
|
113
|
-
blk_info = ak.index_stock_info()
|
|
114
|
-
blk_codes = blk_info["index_code"]
|
|
115
|
-
blk_names = blk_info["display_name"]
|
|
116
|
-
ret = {}
|
|
117
|
-
total = len(blk_codes)
|
|
118
|
-
# for blk_name in blk_names:
|
|
119
|
-
for i in range(total):
|
|
120
|
-
blk_name = blk_names[i]
|
|
121
|
-
blk_code = blk_codes[i]
|
|
122
|
-
print(i, blk_name)
|
|
123
|
-
# 沪深指数有重复,避免深指覆盖
|
|
124
|
-
if blk_name in ret:
|
|
125
|
-
continue
|
|
126
|
-
try:
|
|
127
|
-
ret[blk_name] = []
|
|
128
|
-
stk_codes = ak.index_stock_cons_csindex(symbol=blk_code)
|
|
129
|
-
stk_codes = stk_codes['成分券代码'].to_list()
|
|
130
|
-
for stk_code in stk_codes:
|
|
131
|
-
try:
|
|
132
|
-
ret[blk_name].append(f"{code_market[stk_code]},{stk_code}")
|
|
133
|
-
except:
|
|
134
|
-
print(stk_code)
|
|
135
|
-
except KeyboardInterrupt:
|
|
136
|
-
exit(-1)
|
|
137
|
-
except:
|
|
138
|
-
print("Failed!", blk_code, blk_name)
|
|
139
|
-
return ret
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def write_blk_file(blk_info, filename):
|
|
143
|
-
with open(filename, 'w', encoding='utf-8') as f:
|
|
144
|
-
for k in blk_info:
|
|
145
|
-
print(k)
|
|
146
|
-
if blk_info[k]:
|
|
147
|
-
f.write(f"[{k}]\n")
|
|
148
|
-
for code in blk_info[k]:
|
|
149
|
-
f.write(f'{code}\n')
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if __name__ == "__main__":
|
|
153
|
-
# # 更新行业板块
|
|
154
|
-
# x = get_all_hybk_info()
|
|
155
|
-
# write_blk_file(x, 'hikyuu/config/block/hybk.ini')
|
|
156
|
-
|
|
157
|
-
# # 更新概念板块
|
|
158
|
-
# x = get_all_gnbk_info()
|
|
159
|
-
# write_blk_file(x, 'hikyuu/config/block/gnbk.ini')
|
|
160
|
-
|
|
161
|
-
# # 更新地域板块
|
|
162
|
-
# x = get_all_dybk_info()
|
|
163
|
-
# write_blk_file(x, 'hikyuu/config/block/dybk.ini')
|
|
164
|
-
|
|
165
|
-
# 更新指数成分
|
|
166
|
-
x = get_all_zsbk_info()
|
|
167
|
-
write_blk_file(x, 'hikyuu/config/block/zsbk.ini')
|
|
168
|
-
# print(x)
|
|
File without changes
|
|
File without changes
|