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
hikyuu/cpp/core39.so
DELETED
|
Binary file
|
hikyuu/data_driver/__init__.py
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
# -*- coding: utf8 -*-
|
|
3
|
-
# cp936
|
|
4
|
-
#
|
|
5
|
-
# The MIT License (MIT)
|
|
6
|
-
#
|
|
7
|
-
# Copyright (c) 2010-2017 fasiondog
|
|
8
|
-
#
|
|
9
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
# in the Software without restriction, including without limitation the rights
|
|
12
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
# furnished to do so, subject to the following conditions:
|
|
15
|
-
#
|
|
16
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
# copies or substantial portions of the Software.
|
|
18
|
-
#
|
|
19
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
# SOFTWARE.
|
|
26
|
-
|
|
27
|
-
__copyright__ = """
|
|
28
|
-
MIT License
|
|
29
|
-
|
|
30
|
-
Copyright (c) 2010-2017 fasiondog
|
|
31
|
-
|
|
32
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
-
in the Software without restriction, including without limitation the rights
|
|
35
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
-
furnished to do so, subject to the following conditions:
|
|
38
|
-
|
|
39
|
-
The above copyright notice and this permission notice shall be included in all
|
|
40
|
-
copies or substantial portions of the Software.
|
|
41
|
-
|
|
42
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
-
SOFTWARE.
|
|
49
|
-
"""
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
# -*- coding: utf8 -*-
|
|
3
|
-
# cp936
|
|
4
|
-
#
|
|
5
|
-
# The MIT License (MIT)
|
|
6
|
-
#
|
|
7
|
-
# Copyright (c) 2010-2019 weituo2002
|
|
8
|
-
#
|
|
9
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
# in the Software without restriction, including without limitation the rights
|
|
12
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
# furnished to do so, subject to the following conditions:
|
|
15
|
-
#
|
|
16
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
# copies or substantial portions of the Software.
|
|
18
|
-
#
|
|
19
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
# SOFTWARE.
|
|
26
|
-
|
|
27
|
-
####################################################################
|
|
28
|
-
#
|
|
29
|
-
# 使用 jqdata 作为K线数据驱动,可自行实现自己的K线数据驱动
|
|
30
|
-
#
|
|
31
|
-
# 感谢网友哥本哈斯根贡献
|
|
32
|
-
#
|
|
33
|
-
#####################################################################
|
|
34
|
-
|
|
35
|
-
from ..cpp.core import KDataDriver, DataDriverFactory
|
|
36
|
-
from hikyuu import KRecord, Query, Datetime, Parameter, KRecordList
|
|
37
|
-
|
|
38
|
-
from jqdatasdk import *
|
|
39
|
-
from datetime import *
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class jqdataKDataDriver(KDataDriver):
|
|
43
|
-
def __init__(self):
|
|
44
|
-
super(jqdataKDataDriver, self).__init__('jqdata')
|
|
45
|
-
|
|
46
|
-
def clone(self):
|
|
47
|
-
return jqdataKDataDriver()
|
|
48
|
-
|
|
49
|
-
def _init(self):
|
|
50
|
-
"""【重载接口】(可选)初始化子类私有变量"""
|
|
51
|
-
self._max = {
|
|
52
|
-
Query.DAY: 10,
|
|
53
|
-
Query.WEEK: 2,
|
|
54
|
-
Query.MONTH: 1,
|
|
55
|
-
Query.QUARTER: 1,
|
|
56
|
-
#Query.HALFYEAR:1,
|
|
57
|
-
Query.YEAR: 1,
|
|
58
|
-
Query.MIN: 25,
|
|
59
|
-
Query.MIN5: 25,
|
|
60
|
-
Query.MIN15: 25,
|
|
61
|
-
Query.MIN30: 25,
|
|
62
|
-
Query.MIN60: 25
|
|
63
|
-
}
|
|
64
|
-
return True
|
|
65
|
-
|
|
66
|
-
def isIndexFirst(self):
|
|
67
|
-
return False
|
|
68
|
-
|
|
69
|
-
def canParallelLoad(self):
|
|
70
|
-
return False
|
|
71
|
-
|
|
72
|
-
def getKRecordList(self, market, code, query): # ktype, start_ix, end_ix, out_buffer):
|
|
73
|
-
"""
|
|
74
|
-
【重载接口】(必须)按指定的位置[start_ix, end_ix)读取K线数据至out_buffer
|
|
75
|
-
|
|
76
|
-
:param str market: 市场标识
|
|
77
|
-
:param str code: 证券代码
|
|
78
|
-
:param Query.KType ktype: K线类型
|
|
79
|
-
:param int start_ix: 起始位置
|
|
80
|
-
:param int end_ix: 结束位置
|
|
81
|
-
:param KRecordListPtr out_buffer: 传入的数据缓存,读取数据后使用
|
|
82
|
-
out_buffer.append(krecord) 加入数据
|
|
83
|
-
"""
|
|
84
|
-
if query.query_type == Query.DATE:
|
|
85
|
-
print("未实现按日期查询")
|
|
86
|
-
return KRecordList()
|
|
87
|
-
start_ix = query.start
|
|
88
|
-
end_ix = query.end
|
|
89
|
-
if start_ix >= end_ix or start_ix < 0 or end_ix < 0:
|
|
90
|
-
return KRecordList()
|
|
91
|
-
|
|
92
|
-
data = self._get_bars(market, code, query.ktype)
|
|
93
|
-
|
|
94
|
-
if len(data) < start_ix:
|
|
95
|
-
return KRecordList()
|
|
96
|
-
|
|
97
|
-
result = KRecordList()
|
|
98
|
-
total = end_ix if end_ix < len(data) else len(data)
|
|
99
|
-
for i in range(start_ix, total):
|
|
100
|
-
record = KRecord()
|
|
101
|
-
record.datetime = Datetime(data.index[i])
|
|
102
|
-
record.open = data['open'][i]
|
|
103
|
-
record.high = data['high'][i]
|
|
104
|
-
record.low = data['low'][i]
|
|
105
|
-
record.close = data['close'][i]
|
|
106
|
-
record.amount = data['money'][i]
|
|
107
|
-
record.volume = data['volume'][i]
|
|
108
|
-
result.append(record)
|
|
109
|
-
return result
|
|
110
|
-
|
|
111
|
-
def getCount(self, market, code, ktype):
|
|
112
|
-
"""
|
|
113
|
-
【重载接口】(必须)获取K线数量
|
|
114
|
-
|
|
115
|
-
:param str market: 市场标识
|
|
116
|
-
:param str code: 证券代码
|
|
117
|
-
:param Query.KType ktype: K线类型
|
|
118
|
-
"""
|
|
119
|
-
data = self._get_bars(market, code, ktype)
|
|
120
|
-
return len(data)
|
|
121
|
-
|
|
122
|
-
def _getIndexRangeByDate(self, market, code, query):
|
|
123
|
-
"""
|
|
124
|
-
【重载接口】(必须)按日期获取指定的K线数据
|
|
125
|
-
|
|
126
|
-
:param str market: 市场标识
|
|
127
|
-
:param str code: 证券代码
|
|
128
|
-
:param Query query: 日期查询条件(QueryByDate)
|
|
129
|
-
"""
|
|
130
|
-
print("getIndexRangeByDate")
|
|
131
|
-
|
|
132
|
-
if query.query_type != Query.DATE:
|
|
133
|
-
return (0, 0)
|
|
134
|
-
|
|
135
|
-
start_datetime = query.startDatetime
|
|
136
|
-
end_datetime = query.endDatetime
|
|
137
|
-
if start_datetime >= end_datetime or start_datetime > Datetime.max():
|
|
138
|
-
return (0, 0)
|
|
139
|
-
|
|
140
|
-
data = self._get_bars(market, code, query.kType)
|
|
141
|
-
total = len(data)
|
|
142
|
-
if total == 0:
|
|
143
|
-
return (0, 0)
|
|
144
|
-
|
|
145
|
-
mid, low = 0, 0
|
|
146
|
-
high = total - 1
|
|
147
|
-
while low <= high:
|
|
148
|
-
tmp_datetime = Datetime(data.index[high])
|
|
149
|
-
if start_datetime > tmp_datetime:
|
|
150
|
-
mid = high + 1
|
|
151
|
-
break
|
|
152
|
-
|
|
153
|
-
tmp_datetime = Datetime(data.index[low])
|
|
154
|
-
if tmp_datetime >= start_datetime:
|
|
155
|
-
mid = low
|
|
156
|
-
break
|
|
157
|
-
|
|
158
|
-
mid = (low + high) // 2
|
|
159
|
-
tmp_datetime = Datetime(data.index[mid])
|
|
160
|
-
if start_datetime > tmp_datetime:
|
|
161
|
-
low = mid + 1
|
|
162
|
-
else:
|
|
163
|
-
high = mid - 1
|
|
164
|
-
|
|
165
|
-
if mid >= total:
|
|
166
|
-
return (0, 0)
|
|
167
|
-
|
|
168
|
-
start_pos = mid
|
|
169
|
-
low = mid
|
|
170
|
-
high = total - 1
|
|
171
|
-
while low <= high:
|
|
172
|
-
tmp_datetime = Datetime(data.index[high])
|
|
173
|
-
if end_datetime > tmp_datetime:
|
|
174
|
-
mid = high + 1
|
|
175
|
-
break
|
|
176
|
-
|
|
177
|
-
tmp_datetime = Datetime(data.index[low])
|
|
178
|
-
if tmp_datetime >= end_datetime:
|
|
179
|
-
mid = low
|
|
180
|
-
break
|
|
181
|
-
|
|
182
|
-
mid = (low + high) // 2
|
|
183
|
-
tmp_datetime = Datetime(data.index[mid])
|
|
184
|
-
if end_datetime > tmp_datetime:
|
|
185
|
-
low = mid + 1
|
|
186
|
-
else:
|
|
187
|
-
high = mid - 1
|
|
188
|
-
|
|
189
|
-
end_pos = total if mid >= total else mid
|
|
190
|
-
if start_pos >= end_pos:
|
|
191
|
-
return (0, 0)
|
|
192
|
-
|
|
193
|
-
return (start_pos, end_pos)
|
|
194
|
-
|
|
195
|
-
def getKRecord(self, market, code, pos, ktype):
|
|
196
|
-
"""
|
|
197
|
-
【重载接口】(必须)获取指定位置的K线记录
|
|
198
|
-
|
|
199
|
-
:param str market: 市场标识
|
|
200
|
-
:param str code: 证券代码
|
|
201
|
-
:param int pos: 指定位置(大于等于0)
|
|
202
|
-
:param Query.KType ktype: K线类型
|
|
203
|
-
"""
|
|
204
|
-
record = KRecord()
|
|
205
|
-
if pos < 0:
|
|
206
|
-
return record
|
|
207
|
-
|
|
208
|
-
data = self._get_bars(market, code, ktype)
|
|
209
|
-
if data is None:
|
|
210
|
-
return record
|
|
211
|
-
|
|
212
|
-
if pos < len(data):
|
|
213
|
-
record.datetime = Datetime(data.index[pos])
|
|
214
|
-
record.open = data['open'][pos]
|
|
215
|
-
record.high = data['high'][pos]
|
|
216
|
-
record.low = data['low'][pos]
|
|
217
|
-
record.close = data['close'][pos]
|
|
218
|
-
record.amount = data['money'][pos]
|
|
219
|
-
record.volume = data['volume'][pos]
|
|
220
|
-
|
|
221
|
-
return record
|
|
222
|
-
|
|
223
|
-
def _trans_ktype(self, ktype): #此处的周月季年数据只是近似的,目前jqdata未提供聚宽网络平台上的get_bar函数,不能直接取,需要自行用日线数据拼装
|
|
224
|
-
ktype_map = {
|
|
225
|
-
Query.MIN: '1m',
|
|
226
|
-
Query.MIN5: '5m',
|
|
227
|
-
Query.MIN15: '15m',
|
|
228
|
-
Query.MIN30: '30m',
|
|
229
|
-
Query.MIN60: '60m',
|
|
230
|
-
Query.DAY: '1d',
|
|
231
|
-
Query.WEEK: '7d',
|
|
232
|
-
Query.MONTH: '30d',
|
|
233
|
-
Query.QUARTER: '90d',
|
|
234
|
-
Query.YEAR: '365d'
|
|
235
|
-
}
|
|
236
|
-
return ktype_map.get(ktype)
|
|
237
|
-
|
|
238
|
-
def _get_bars(self, market, code, ktype):
|
|
239
|
-
data = []
|
|
240
|
-
username = self.getParam('username')
|
|
241
|
-
password = self.getParam('password')
|
|
242
|
-
auth(username, password)
|
|
243
|
-
|
|
244
|
-
jqdataCode = normalize_code(code)
|
|
245
|
-
jqdata_ktype = self._trans_ktype(ktype)
|
|
246
|
-
|
|
247
|
-
if jqdata_ktype is None:
|
|
248
|
-
print("jqdata_ktype == None")
|
|
249
|
-
return data
|
|
250
|
-
|
|
251
|
-
print(jqdataCode)
|
|
252
|
-
security_info = get_security_info(jqdataCode)
|
|
253
|
-
|
|
254
|
-
if security_info is None: #有可能取不到任何信息
|
|
255
|
-
return data
|
|
256
|
-
#print(security_info)
|
|
257
|
-
|
|
258
|
-
data = get_price(jqdataCode, security_info.start_date, datetime.now(), jqdata_ktype)
|
|
259
|
-
|
|
260
|
-
return data
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
#DataDriverFactory.regKDataDriver(jqdataKDataDriver())
|
|
264
|
-
|
|
265
|
-
#jqdata_param = Parameter()
|
|
266
|
-
#jqdata_param.set('type', 'jqdata')
|
|
267
|
-
#jqdata_param.set('username', '用户名')
|
|
268
|
-
#jqdata_param.set('password', '密码')
|
|
269
|
-
|
|
270
|
-
#base_param = sm.getBaseInfoDriverParameter()
|
|
271
|
-
#block_param = sm.getBlockDriverParameter()
|
|
272
|
-
#kdata_param = sm.getKDataDriverParameter()
|
|
273
|
-
#preload_param = sm.getPreloadParameter()
|
|
274
|
-
#hku_param = sm.getHikyuuParameter()
|
|
275
|
-
|
|
276
|
-
#切换K线数据驱动,重新初始化
|
|
277
|
-
#sm.init(base_param, block_param, jqdata_param, preload_param, hku_param)
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
# -*- coding: utf8 -*-
|
|
3
|
-
# cp936
|
|
4
|
-
#
|
|
5
|
-
# The MIT License (MIT)
|
|
6
|
-
#
|
|
7
|
-
# Copyright (c) 2010-2017 fasiondog
|
|
8
|
-
#
|
|
9
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
11
|
-
# in the Software without restriction, including without limitation the rights
|
|
12
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
# furnished to do so, subject to the following conditions:
|
|
15
|
-
#
|
|
16
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
17
|
-
# copies or substantial portions of the Software.
|
|
18
|
-
#
|
|
19
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
-
# SOFTWARE.
|
|
26
|
-
|
|
27
|
-
####################################################################
|
|
28
|
-
#
|
|
29
|
-
# 使用 pytdx 作为K线数据驱动示例,可自行实现自己的K线数据驱动
|
|
30
|
-
#
|
|
31
|
-
# 注意:此处仅为示例,因 pytdx 使用的数据索引位置是倒序(即最近一天的
|
|
32
|
-
# 位置为0,和 KDataDriver 使用第一个交易日位置为0 刚好相反。
|
|
33
|
-
# 在读取时效率较低,需多次访问网络,不建设实际使用。仅作为示例!
|
|
34
|
-
#
|
|
35
|
-
#####################################################################
|
|
36
|
-
|
|
37
|
-
from ..cpp.core import KDataDriver, DataDriverFactory
|
|
38
|
-
from hikyuu import KRecord, Query, Datetime, Parameter, KRecordList
|
|
39
|
-
|
|
40
|
-
from pytdx.hq import TdxHq_API
|
|
41
|
-
from pytdx.params import TDXParams
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class PytdxKDataDriver(KDataDriver):
|
|
45
|
-
def __init__(self):
|
|
46
|
-
super(PytdxKDataDriver, self).__init__('pytdx')
|
|
47
|
-
|
|
48
|
-
def _clone(self):
|
|
49
|
-
return PytdxKDataDriver()
|
|
50
|
-
|
|
51
|
-
def _init(self):
|
|
52
|
-
"""【重载接口】(可选)初始化子类私有变量"""
|
|
53
|
-
self._max = {
|
|
54
|
-
Query.DAY: 10,
|
|
55
|
-
Query.WEEK: 2,
|
|
56
|
-
Query.MONTH: 1,
|
|
57
|
-
Query.QUARTER: 1,
|
|
58
|
-
#Query.HALFYEAR:1,
|
|
59
|
-
Query.YEAR: 1,
|
|
60
|
-
Query.MIN: 25,
|
|
61
|
-
Query.MIN5: 25,
|
|
62
|
-
Query.MIN15: 25,
|
|
63
|
-
Query.MIN30: 25,
|
|
64
|
-
Query.MIN60: 25
|
|
65
|
-
}
|
|
66
|
-
return True
|
|
67
|
-
|
|
68
|
-
def isIndexFirst(self):
|
|
69
|
-
return True
|
|
70
|
-
|
|
71
|
-
def canParallelLoad(self):
|
|
72
|
-
return False
|
|
73
|
-
|
|
74
|
-
def getKRecordList(self, market, code, query):
|
|
75
|
-
"""
|
|
76
|
-
【重载接口】(必须)按指定的位置[start_ix, end_ix)读取K线数据至out_buffer
|
|
77
|
-
|
|
78
|
-
:param str market: 市场标识
|
|
79
|
-
:param str code: 证券代码
|
|
80
|
-
:param Query query: 查询条件
|
|
81
|
-
:rtype: KRecordList
|
|
82
|
-
"""
|
|
83
|
-
if query.query_type == Query.DATE:
|
|
84
|
-
print("未实现按日期查询")
|
|
85
|
-
return KRecordList()
|
|
86
|
-
start_ix = query.start
|
|
87
|
-
end_ix = query.end
|
|
88
|
-
if start_ix >= end_ix or start_ix < 0 or end_ix < 0:
|
|
89
|
-
return KRecordList()
|
|
90
|
-
|
|
91
|
-
data = self._get_bars(market, code, query.ktype)
|
|
92
|
-
|
|
93
|
-
if len(data) < start_ix:
|
|
94
|
-
return KRecordList()
|
|
95
|
-
|
|
96
|
-
total = end_ix if end_ix < len(data) else len(data)
|
|
97
|
-
result = KRecordList()
|
|
98
|
-
for i in range(start_ix, total):
|
|
99
|
-
record = KRecord()
|
|
100
|
-
record.datetime = Datetime(data[i].get('datetime'))
|
|
101
|
-
record.open = data[i].get('open')
|
|
102
|
-
record.high = data[i].get('high')
|
|
103
|
-
record.low = data[i].get('low')
|
|
104
|
-
record.close = data[i].get('close')
|
|
105
|
-
record.amount = data[i].get('amount')
|
|
106
|
-
record.volume = data[i].get('vol')
|
|
107
|
-
result.append(record)
|
|
108
|
-
return result
|
|
109
|
-
|
|
110
|
-
def getCount(self, market, code, ktype):
|
|
111
|
-
"""
|
|
112
|
-
【重载接口】(必须)获取K线数量
|
|
113
|
-
|
|
114
|
-
:param str market: 市场标识
|
|
115
|
-
:param str code: 证券代码
|
|
116
|
-
:param Query.KType ktype: K线类型
|
|
117
|
-
"""
|
|
118
|
-
data = self._get_bars(market, code, ktype)
|
|
119
|
-
return len(data) if data else 0
|
|
120
|
-
|
|
121
|
-
def _getIndexRangeByDate(self, market, code, query):
|
|
122
|
-
"""
|
|
123
|
-
【重载接口】(必须)按日期获取指定的K线数据
|
|
124
|
-
|
|
125
|
-
:param str market: 市场标识
|
|
126
|
-
:param str code: 证券代码
|
|
127
|
-
:param Query query: 日期查询条件(QueryByDate)
|
|
128
|
-
"""
|
|
129
|
-
print("getIndexRangeByDate")
|
|
130
|
-
|
|
131
|
-
if query.query_type != Query.DATE:
|
|
132
|
-
return (0, 0)
|
|
133
|
-
|
|
134
|
-
start_datetime = query.startDatetime
|
|
135
|
-
end_datetime = query.endDatetime
|
|
136
|
-
if start_datetime >= end_datetime or start_datetime > Datetime.max():
|
|
137
|
-
return (0, 0)
|
|
138
|
-
|
|
139
|
-
data = self._get_bars(market, code, query.kType)
|
|
140
|
-
total = len(data)
|
|
141
|
-
if total == 0:
|
|
142
|
-
return (0, 0)
|
|
143
|
-
|
|
144
|
-
mid, low = 0, 0
|
|
145
|
-
high = total - 1
|
|
146
|
-
while low <= high:
|
|
147
|
-
tmp_datetime = Datetime(data[high].get('datetime'))
|
|
148
|
-
if start_datetime > tmp_datetime:
|
|
149
|
-
mid = high + 1
|
|
150
|
-
break
|
|
151
|
-
|
|
152
|
-
tmp_datetime = Datetime(data[low].get('datetime'))
|
|
153
|
-
if tmp_datetime >= start_datetime:
|
|
154
|
-
mid = low
|
|
155
|
-
break
|
|
156
|
-
|
|
157
|
-
mid = (low + high) // 2
|
|
158
|
-
tmp_datetime = Datetime(data[mid].get('datetime'))
|
|
159
|
-
if start_datetime > tmp_datetime:
|
|
160
|
-
low = mid + 1
|
|
161
|
-
else:
|
|
162
|
-
high = mid - 1
|
|
163
|
-
|
|
164
|
-
if mid >= total:
|
|
165
|
-
return (0, 0)
|
|
166
|
-
|
|
167
|
-
start_pos = mid
|
|
168
|
-
low = mid
|
|
169
|
-
high = total - 1
|
|
170
|
-
while low <= high:
|
|
171
|
-
tmp_datetime = Datetime(data[high].get('datetime'))
|
|
172
|
-
if end_datetime > tmp_datetime:
|
|
173
|
-
mid = high + 1
|
|
174
|
-
break
|
|
175
|
-
|
|
176
|
-
tmp_datetime = Datetime(data[low].get('datetime'))
|
|
177
|
-
if tmp_datetime >= end_datetime:
|
|
178
|
-
mid = low
|
|
179
|
-
break
|
|
180
|
-
|
|
181
|
-
mid = (low + high) // 2
|
|
182
|
-
tmp_datetime = Datetime(data[mid].get('datetime'))
|
|
183
|
-
if end_datetime > tmp_datetime:
|
|
184
|
-
low = mid + 1
|
|
185
|
-
else:
|
|
186
|
-
high = mid - 1
|
|
187
|
-
|
|
188
|
-
end_pos = total if mid >= total else mid
|
|
189
|
-
if start_pos >= end_pos:
|
|
190
|
-
return (0, 0)
|
|
191
|
-
|
|
192
|
-
return (start_pos, end_pos)
|
|
193
|
-
|
|
194
|
-
def getKRecord(self, market, code, pos, ktype):
|
|
195
|
-
"""
|
|
196
|
-
【重载接口】(必须)获取指定位置的K线记录
|
|
197
|
-
|
|
198
|
-
:param str market: 市场标识
|
|
199
|
-
:param str code: 证券代码
|
|
200
|
-
:param int pos: 指定位置(大于等于0)
|
|
201
|
-
:param Query.KType ktype: K线类型
|
|
202
|
-
"""
|
|
203
|
-
record = KRecord()
|
|
204
|
-
if pos < 0:
|
|
205
|
-
return record
|
|
206
|
-
|
|
207
|
-
data = self._get_bars(market, code, ktype)
|
|
208
|
-
if data is None:
|
|
209
|
-
return record
|
|
210
|
-
|
|
211
|
-
if pos < len(data):
|
|
212
|
-
record.datetime = Datetime(data[pos].get('datetime'))
|
|
213
|
-
record.open = data[pos].get('open')
|
|
214
|
-
record.high = data[pos].get('high')
|
|
215
|
-
record.low = data[pos].get('low')
|
|
216
|
-
record.close = data[pos].get('close')
|
|
217
|
-
record.amount = data[pos].get('amount')
|
|
218
|
-
record.volume = data[pos].get('vol')
|
|
219
|
-
|
|
220
|
-
return record
|
|
221
|
-
|
|
222
|
-
def _trans_market(self, market):
|
|
223
|
-
market_map = {'SH': TDXParams.MARKET_SH, 'SZ': TDXParams.MARKET_SZ}
|
|
224
|
-
return market_map.get(market)
|
|
225
|
-
|
|
226
|
-
def _trans_ktype(self, ktype):
|
|
227
|
-
ktype_map = {
|
|
228
|
-
Query.MIN: TDXParams.KLINE_TYPE_1MIN,
|
|
229
|
-
Query.MIN5: TDXParams.KLINE_TYPE_5MIN,
|
|
230
|
-
Query.MIN15: TDXParams.KLINE_TYPE_15MIN,
|
|
231
|
-
Query.MIN30: TDXParams.KLINE_TYPE_30MIN,
|
|
232
|
-
Query.MIN60: TDXParams.KLINE_TYPE_1HOUR,
|
|
233
|
-
Query.DAY: TDXParams.KLINE_TYPE_RI_K,
|
|
234
|
-
Query.WEEK: TDXParams.KLINE_TYPE_WEEKLY,
|
|
235
|
-
Query.MONTH: TDXParams.KLINE_TYPE_MONTHLY,
|
|
236
|
-
Query.QUARTER: TDXParams.KLINE_TYPE_3MONTH,
|
|
237
|
-
Query.YEAR: TDXParams.KLINE_TYPE_YEARLY
|
|
238
|
-
}
|
|
239
|
-
return ktype_map.get(ktype)
|
|
240
|
-
|
|
241
|
-
def _get_bars(self, market, code, ktype):
|
|
242
|
-
data = []
|
|
243
|
-
tdx_market = self._trans_market(market)
|
|
244
|
-
if tdx_market is None:
|
|
245
|
-
print("tdx_market == None")
|
|
246
|
-
return data
|
|
247
|
-
|
|
248
|
-
tdx_ktype = self._trans_ktype(ktype)
|
|
249
|
-
if tdx_ktype is None:
|
|
250
|
-
print("tdx_ktype == None")
|
|
251
|
-
return data
|
|
252
|
-
|
|
253
|
-
try:
|
|
254
|
-
ip = self.getParam('ip')
|
|
255
|
-
port = self.getParam('port')
|
|
256
|
-
except:
|
|
257
|
-
ip = '119.147.212.81'
|
|
258
|
-
port = 7709
|
|
259
|
-
|
|
260
|
-
api = TdxHq_API(raise_exception=True)
|
|
261
|
-
|
|
262
|
-
with api.connect(ip, port):
|
|
263
|
-
if (market == 'SH' and code[:3] == '000') \
|
|
264
|
-
or (market == 'SZ' and code[:2] == '39'):
|
|
265
|
-
for i in range(self._max[ktype]):
|
|
266
|
-
data += api.get_index_bars(
|
|
267
|
-
tdx_ktype, tdx_market, code, (self._max[ktype] - 1 - i) * 800, 800
|
|
268
|
-
)
|
|
269
|
-
else:
|
|
270
|
-
for i in range(self._max[ktype]):
|
|
271
|
-
data += api.get_security_bars(
|
|
272
|
-
tdx_ktype, tdx_market, code, (self._max[ktype] - 1 - i) * 800, 800
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
return data
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
#DataDriverFactory.regKDataDriver(PytdxKDataDriver())
|
|
279
|
-
|
|
280
|
-
#tdx_param = Parameter()
|
|
281
|
-
#tdx_param['type'] = 'pytdx'
|
|
282
|
-
#tdx_param['ip'] = '119.147.212.81'
|
|
283
|
-
#tdx_param['port'] = 7709
|
|
284
|
-
|
|
285
|
-
#base_param = sm.get_base_info_parameter()
|
|
286
|
-
#block_param = sm.get_block_parameter()
|
|
287
|
-
#kdata_param = sm.get_kdata_parameter()
|
|
288
|
-
#preload_param = sm.get_preload_parameter()
|
|
289
|
-
#hku_param = sm.get_hikyuu_parameter()
|
|
290
|
-
|
|
291
|
-
#切换K线数据驱动,重新初始化
|
|
292
|
-
#sm.init(base_param, block_param, tdx_param, preload_param, hku_param)
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
# -*- coding: utf8 -*-
|
|
3
|
-
#
|
|
4
|
-
# Create on: 2022-08-22
|
|
5
|
-
# Author: fasiondog
|
|
6
|
-
|
|
7
|
-
import datetime
|
|
8
|
-
from hikyuu.util import *
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@hku_catch(trace=True, callback=lambda stk: hku_warn("Failed parse stk: {}", stk))
|
|
12
|
-
def parse_one_result_huatai(stk):
|
|
13
|
-
result = {}
|
|
14
|
-
if 'OpenPx' not in stk:
|
|
15
|
-
return result
|
|
16
|
-
|
|
17
|
-
bids = [x / 10000.0 for x in stk['BuyPriceQueue']]
|
|
18
|
-
bids_amount = [x / 100.0 for x in stk['BuyOrderQtyQueue']]
|
|
19
|
-
asks = [x / 10000.0 for x in stk['SellPriceQueue']]
|
|
20
|
-
asks_amount = [x / 100.0 for x in stk['SellOrderQtyQueue']]
|
|
21
|
-
|
|
22
|
-
result['market'] = stk['HTSCSecurityID'][7:]
|
|
23
|
-
result['code'] = stk['HTSCSecurityID'][:6]
|
|
24
|
-
result['name'] = ''
|
|
25
|
-
result['open'] = stk['OpenPx'] / 10000.0 # 今日开盘价
|
|
26
|
-
|
|
27
|
-
result['yesterday_close'] = stk['PreClosePx'] / 10000.0 # 昨日收盘价
|
|
28
|
-
result['close'] = stk['ClosePx'] / 10000.0 # 当前价格
|
|
29
|
-
result['high'] = stk['HighPx'] / 10000.0 # 今日最高价
|
|
30
|
-
result['low'] = stk['LowPx'] / 10000.0 # 今日最低价
|
|
31
|
-
result['bid'] = bids[0] # 竞买价,即“买一”报价
|
|
32
|
-
result['ask'] = asks[0] # 竞卖价,即“卖一”报价
|
|
33
|
-
result['volume'] = stk['TotalVolumeTrade'] / 100.0 # 成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百
|
|
34
|
-
result['amount'] = stk['TotalValueTrade'] # 成交金额,单位为“元”
|
|
35
|
-
|
|
36
|
-
# 买入委托
|
|
37
|
-
for i in range(len(bids)):
|
|
38
|
-
result[f'bid{i}'] = bids[i]
|
|
39
|
-
for i in range(len(bids_amount)):
|
|
40
|
-
result[f'bid{i}_amount'] = bids_amount[i]
|
|
41
|
-
|
|
42
|
-
# 卖出委托
|
|
43
|
-
for i in range(len(asks)):
|
|
44
|
-
result[f'ask{i}'] = asks[i]
|
|
45
|
-
for i in range(len(asks_amount)):
|
|
46
|
-
result[f'ask{i}_amount'] = asks_amount[i]
|
|
47
|
-
|
|
48
|
-
d = str(stk['MDDate'])
|
|
49
|
-
t = str(stk['MDTime'])
|
|
50
|
-
result['datetime'] = datetime.datetime(int(d[:4]), int(d[4:6]), int(d[6:8]), int(t[:2]), int(t[2:4]), int(t[4:6]))
|
|
51
|
-
return result
|