hikyuu 2.6.6__py3-none-win_amd64.whl → 2.6.8__py3-none-win_amd64.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 +16 -2
- hikyuu/__init__.pyi +658 -627
- hikyuu/analysis/__init__.pyi +563 -519
- hikyuu/analysis/analysis.pyi +583 -541
- hikyuu/core.pyi +565 -521
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/concrt140.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +1424 -865
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +1424 -865
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +1424 -865
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +1424 -863
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +1424 -865
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/hku_hdf5.dll +0 -0
- hikyuu/cpp/hku_hdf5_cpp.dll +0 -0
- hikyuu/cpp/hku_hdf5_hl.dll +0 -0
- hikyuu/cpp/hku_hdf5_hl_cpp.dll +0 -0
- hikyuu/cpp/i18n/zh_CN/__init__.py +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/msvcp140.dll +0 -0
- hikyuu/cpp/msvcp140_1.dll +0 -0
- hikyuu/cpp/msvcp140_2.dll +0 -0
- hikyuu/cpp/msvcp140_atomic_wait.dll +0 -0
- hikyuu/cpp/msvcp140_codecvt_ids.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/cpp/vcruntime140.dll +0 -0
- hikyuu/cpp/vcruntime140_1.dll +0 -0
- hikyuu/data/common_clickhouse.py +0 -47
- hikyuu/data/tdx_to_h5.py +1 -1
- hikyuu/draw/drawplot/__init__.pyi +32 -37
- hikyuu/draw/drawplot/bokeh_draw.pyi +651 -632
- hikyuu/draw/drawplot/common.pyi +3 -4
- hikyuu/draw/drawplot/echarts_draw.py +9 -8
- hikyuu/draw/drawplot/echarts_draw.pyi +598 -567
- hikyuu/draw/drawplot/matplotlib_draw.py +3 -3
- hikyuu/draw/drawplot/matplotlib_draw.pyi +872 -874
- hikyuu/draw/elder.pyi +19 -20
- hikyuu/draw/kaufman.py +1 -1
- hikyuu/draw/kaufman.pyi +18 -18
- hikyuu/draw/volume.pyi +10 -10
- hikyuu/examples/notebook/000-Index.ipynb +1 -1
- hikyuu/examples/notebook/001-overview.ipynb +78 -63
- hikyuu/examples/notebook/002-HowToGetStock.ipynb +259 -40
- hikyuu/examples/notebook/003-HowToGetKDataAndDraw.ipynb +49 -41
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +29 -29
- hikyuu/examples/notebook/005-Drawplot.ipynb +66 -37
- hikyuu/examples/notebook/006-TradeManager.ipynb +808 -61
- hikyuu/examples/notebook/007-SystemDetails.ipynb +23 -23
- hikyuu/examples/notebook/009-RealData.ipynb +3 -3
- hikyuu/examples/notebook/010-Portfolio.ipynb +761 -122
- hikyuu/extend.py +32 -98
- hikyuu/extend.pyi +597 -593
- hikyuu/gui/HikyuuTDX.py +2 -4
- hikyuu/gui/data/MainWindow.py +185 -174
- hikyuu/hub.pyi +69 -67
- hikyuu/include/hikyuu/DataType.h +3 -12
- hikyuu/include/hikyuu/KData.h +83 -25
- hikyuu/include/hikyuu/KDataImp.h +31 -46
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
- hikyuu/include/hikyuu/KQuery.h +38 -32
- hikyuu/include/hikyuu/KRecord.h +4 -1
- hikyuu/include/hikyuu/MarketInfo.h +1 -1
- hikyuu/include/hikyuu/Stock.h +24 -6
- hikyuu/include/hikyuu/StockManager.h +15 -6
- hikyuu/include/hikyuu/StockTypeInfo.h +6 -0
- hikyuu/include/hikyuu/TransRecord.h +2 -8
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
- hikyuu/include/hikyuu/doc.h +4 -0
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
- hikyuu/include/hikyuu/indicator/Indicator.h +48 -0
- hikyuu/include/hikyuu/indicator/Indicator2InImp.h +9 -0
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +83 -15
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/AMA.h +2 -1
- hikyuu/include/hikyuu/indicator/crt/ATR.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +3 -0
- hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/IC.h +14 -6
- hikyuu/include/hikyuu/indicator/crt/ICIR.h +8 -4
- hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
- hikyuu/include/hikyuu/indicator/crt/SLICE.h +4 -4
- hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
- hikyuu/include/hikyuu/indicator/imp/IContext.h +5 -0
- hikyuu/include/hikyuu/indicator/imp/ICval.h +6 -0
- hikyuu/include/hikyuu/indicator/imp/IDropna.h +9 -0
- hikyuu/include/hikyuu/indicator/imp/IIc.h +2 -1
- hikyuu/include/hikyuu/indicator/imp/IPriceList.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
- hikyuu/include/hikyuu/lang.h +27 -0
- hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +6 -1
- hikyuu/include/hikyuu/plugin/backtest.h +2 -0
- hikyuu/include/hikyuu/plugin/extind.h +45 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +77 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +54 -0
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +10 -1
- hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +2 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +28 -11
- hikyuu/include/hikyuu/trade_manage/Performance.h +0 -1
- hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -0
- hikyuu/include/hikyuu/trade_manage/TradeManager.h +4 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +6 -3
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +4 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +5 -2
- hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -1
- hikyuu/include/hikyuu/trade_sys/system/System.h +5 -0
- hikyuu/include/hikyuu/utilities/config.h +0 -2
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +2 -2
- hikyuu/include/hikyuu/utilities/os.h +7 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +2 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/include/hikyuu/views/arrow_common.h +38 -0
- hikyuu/include/hikyuu/views/arrow_views.h +117 -0
- hikyuu/indicator/__init__.py +0 -1
- hikyuu/indicator/indicator.py +17 -57
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/clickhousedriver.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/plugin/extind.dll +0 -0
- hikyuu/plugin/hkuextra.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/strategy/strategy_demo1.py +1 -1
- hikyuu/test/test_init.py +73 -14
- hikyuu/test/test_real_tdx_import.py +336 -0
- hikyuu/test/test_tdx_import.py +315 -0
- hikyuu/test/test_tdx_real_data_import.py +281 -0
- hikyuu/trade_manage/__init__.pyi +583 -553
- hikyuu/trade_manage/broker.pyi +19 -18
- hikyuu/trade_manage/broker_easytrader.pyi +6 -4
- hikyuu/trade_manage/broker_mail.pyi +22 -24
- hikyuu/trade_manage/trade.py +10 -65
- hikyuu/trade_manage/trade.pyi +583 -565
- hikyuu/trade_sys/__init__.py +15 -0
- hikyuu/util/__init__.pyi +0 -1
- hikyuu/util/check.pyi +17 -15
- hikyuu/util/mylog.pyi +8 -7
- hikyuu/util/notebook.pyi +9 -11
- hikyuu/util/singleton.pyi +8 -6
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/METADATA +8 -4
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/RECORD +172 -160
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/top_level.txt +2 -1
- hikyuu/cpp/i18n/zh_CN.mo +0 -0
- hikyuu/include/hikyuu/utilities/mo/mo.h +0 -64
- hikyuu/indicator/talib_wrap.py +0 -1273
- /hikyuu/include/hikyuu/utilities/{mo/moFileReader.h → moFileReader.h} +0 -0
- /hikyuu/include/hikyuu/{utilities/mo → views}/__init__.py +0 -0
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/LICENSE +0 -0
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-08-28
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "KDataImp.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
class HKU_API KDataSharedBufferImp : public KDataImp {
|
|
15
|
+
public:
|
|
16
|
+
KDataSharedBufferImp() = default;
|
|
17
|
+
KDataSharedBufferImp(const Stock& stock, const KQuery& query);
|
|
18
|
+
virtual ~KDataSharedBufferImp();
|
|
19
|
+
|
|
20
|
+
virtual bool empty() const override {
|
|
21
|
+
return m_size == 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
virtual size_t size() const override {
|
|
25
|
+
return m_size;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
virtual size_t startPos() const override {
|
|
29
|
+
return m_start;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
virtual size_t endPos() const override {
|
|
33
|
+
return m_end;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
virtual size_t lastPos() const override {
|
|
37
|
+
return m_end == 0 ? 0 : m_end - 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
virtual size_t getPos(const Datetime& datetime) const override;
|
|
41
|
+
|
|
42
|
+
virtual const KRecord& getKRecord(size_t pos) const override;
|
|
43
|
+
|
|
44
|
+
virtual const KRecord& front() const override {
|
|
45
|
+
return m_data[0];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
virtual const KRecord& back() const override {
|
|
49
|
+
return m_data[m_size - 1];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
virtual const KRecord* data() const override {
|
|
53
|
+
return m_data;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
virtual KRecord* data() override {
|
|
57
|
+
return m_data;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
virtual DatetimeList getDatetimeList() const override;
|
|
61
|
+
|
|
62
|
+
private:
|
|
63
|
+
size_t m_start{0};
|
|
64
|
+
size_t m_end{0};
|
|
65
|
+
size_t m_size{0};
|
|
66
|
+
KRecord* m_data{nullptr};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} /* namespace hku */
|
hikyuu/include/hikyuu/KQuery.h
CHANGED
|
@@ -26,56 +26,54 @@ public:
|
|
|
26
26
|
INVALID = 2
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/// 查询K线类型:日线/周线等
|
|
30
|
-
/*enum KType {
|
|
31
|
-
//notes: 如添加新类型,请注意按大小顺序添加,否则可能出错
|
|
32
|
-
MIN = 0, ///<1分钟线
|
|
33
|
-
MIN5 = 1, ///<5分钟线
|
|
34
|
-
MIN15 = 2, ///<15分钟线
|
|
35
|
-
MIN30 = 3, ///<30分钟线
|
|
36
|
-
MIN60 = 4, ///<60分钟线
|
|
37
|
-
DAY = 5, ///<日线
|
|
38
|
-
WEEK = 6, ///<周线
|
|
39
|
-
MONTH = 7, ///<月线
|
|
40
|
-
QUARTER = 8, ///<季线
|
|
41
|
-
HALFYEAR = 9, ///<半年线
|
|
42
|
-
YEAR = 10, ///<年线
|
|
43
|
-
|
|
44
|
-
//BTC扩展
|
|
45
|
-
MIN3 = 11, ///<3分钟线
|
|
46
|
-
HOUR2 = 12, ///<2小时线
|
|
47
|
-
HOUR4 = 13, ///<4小时线
|
|
48
|
-
HOUR6 = 14, ///<6小时线
|
|
49
|
-
HOUR12 = 15, ///<12小时线
|
|
50
|
-
INVALID_KTYPE = 16
|
|
51
|
-
};*/
|
|
52
29
|
typedef string KType;
|
|
53
30
|
|
|
31
|
+
// 基础K线类型
|
|
54
32
|
static const string MIN;
|
|
55
33
|
static const string MIN5;
|
|
56
34
|
static const string MIN15;
|
|
57
35
|
static const string MIN30;
|
|
58
36
|
static const string MIN60;
|
|
37
|
+
static const string HOUR2;
|
|
59
38
|
static const string DAY;
|
|
60
39
|
static const string WEEK;
|
|
61
40
|
static const string MONTH;
|
|
62
41
|
static const string QUARTER;
|
|
63
42
|
static const string HALFYEAR;
|
|
64
43
|
static const string YEAR;
|
|
44
|
+
|
|
45
|
+
// 扩展K线类型
|
|
46
|
+
static const string DAY3;
|
|
47
|
+
static const string DAY5;
|
|
48
|
+
static const string DAY7;
|
|
65
49
|
static const string MIN3;
|
|
66
|
-
static const string
|
|
67
|
-
static const string
|
|
68
|
-
static const string
|
|
69
|
-
static const string HOUR12;
|
|
70
|
-
// static const string INVALID_KTYPE;
|
|
50
|
+
static const string HOUR4; // 默认不支持
|
|
51
|
+
static const string HOUR6; // 默认不支持
|
|
52
|
+
static const string HOUR12; // 默认不支持
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
static const
|
|
54
|
+
static const string TIMELINE; // 分时
|
|
55
|
+
static const string TRANS; // 分笔
|
|
74
56
|
|
|
75
|
-
|
|
57
|
+
/** 判断指定的K线类型是否有效 */
|
|
58
|
+
static bool isValidKType(const string& ktype);
|
|
76
59
|
|
|
77
60
|
/** 判断是否为有效 ktype */
|
|
78
|
-
static bool
|
|
61
|
+
static bool isBaseKType(const string& ktype);
|
|
62
|
+
|
|
63
|
+
/** 判断是否为扩展 ktype */
|
|
64
|
+
static bool isExtraKType(const string& ktype);
|
|
65
|
+
|
|
66
|
+
/** 获取所有的 KType */
|
|
67
|
+
static vector<KType> getBaseKTypeList();
|
|
68
|
+
|
|
69
|
+
/** 获取所有扩展 KType */
|
|
70
|
+
static vector<KType> getExtraKTypeList();
|
|
71
|
+
|
|
72
|
+
static int32_t getKTypeInMin(const KType& ktype);
|
|
73
|
+
|
|
74
|
+
static int32_t getBaseKTypeInMin(const KType& ktype);
|
|
75
|
+
|
|
76
|
+
static int64_t getKTypeInSeconds(const KType& ktype);
|
|
79
77
|
|
|
80
78
|
/**
|
|
81
79
|
* 复权类型
|
|
@@ -181,6 +179,14 @@ public:
|
|
|
181
179
|
*/
|
|
182
180
|
uint64_t hash() const;
|
|
183
181
|
|
|
182
|
+
/** 判断是否为右开区间,即未指定结束时间 */
|
|
183
|
+
bool isRightOpening() const {
|
|
184
|
+
if (m_queryType == DATE) {
|
|
185
|
+
return endDatetime().isNull();
|
|
186
|
+
}
|
|
187
|
+
return m_end == Null<int64_t>();
|
|
188
|
+
}
|
|
189
|
+
|
|
184
190
|
/** 获取queryType名称,用于显示输出 */
|
|
185
191
|
static string getQueryTypeName(QueryType);
|
|
186
192
|
|
hikyuu/include/hikyuu/KRecord.h
CHANGED
|
@@ -17,7 +17,7 @@ namespace hku {
|
|
|
17
17
|
* K线数据记录
|
|
18
18
|
* @ingroup StockManage
|
|
19
19
|
*/
|
|
20
|
-
class KRecord {
|
|
20
|
+
class HKU_API KRecord {
|
|
21
21
|
public:
|
|
22
22
|
Datetime datetime; ///< 日期,格式:YYYYMMDDHHMM 如:200901010930
|
|
23
23
|
price_t openPrice; ///< 开盘价
|
|
@@ -58,6 +58,9 @@ public:
|
|
|
58
58
|
bool isValid() const {
|
|
59
59
|
return datetime == Null<Datetime>() ? false : true;
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
static const KRecord NullKRecord;
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
/** @ingroup StockManage */
|
hikyuu/include/hikyuu/Stock.h
CHANGED
|
@@ -29,6 +29,7 @@ typedef shared_ptr<KDataDriverConnectPool> KDataDriverConnectPoolPtr;
|
|
|
29
29
|
class HKU_API KData;
|
|
30
30
|
class HKU_API Parameter;
|
|
31
31
|
class HKU_API Block;
|
|
32
|
+
class HKU_API KDataSharedBufferImp;
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Stock基类,Application中一般使用StockPtr进行操作
|
|
@@ -36,6 +37,7 @@ class HKU_API Block;
|
|
|
36
37
|
*/
|
|
37
38
|
class HKU_API Stock {
|
|
38
39
|
friend class StockManager;
|
|
40
|
+
friend class KDataSharedBufferImp;
|
|
39
41
|
|
|
40
42
|
private:
|
|
41
43
|
static const string default_market;
|
|
@@ -162,7 +164,7 @@ public:
|
|
|
162
164
|
*/
|
|
163
165
|
bool getIndexRange(const KQuery& query, size_t& out_start, size_t& out_end) const;
|
|
164
166
|
|
|
165
|
-
/** 获取指定索引的K线数据记录,pos 无效时返回
|
|
167
|
+
/** 获取指定索引的K线数据记录,pos 无效时返回 KRecord::NullRecord */
|
|
166
168
|
KRecord getKRecord(size_t pos, const KQuery::KType& dataType = KQuery::DAY) const;
|
|
167
169
|
|
|
168
170
|
/** 根据数据类型(日线/周线等),获取指定日期的KRecord */
|
|
@@ -230,10 +232,10 @@ public:
|
|
|
230
232
|
* 将K线数据做自身缓存
|
|
231
233
|
* @note 一般不主动调用,谨慎
|
|
232
234
|
*/
|
|
233
|
-
void loadKDataToBuffer(KQuery::KType);
|
|
235
|
+
void loadKDataToBuffer(KQuery::KType) const;
|
|
234
236
|
|
|
235
237
|
/** 释放对应的K线缓存 */
|
|
236
|
-
void releaseKDataBuffer(KQuery::KType);
|
|
238
|
+
void releaseKDataBuffer(KQuery::KType) const;
|
|
237
239
|
|
|
238
240
|
/** 指定类型的K线数据是否被缓存 */
|
|
239
241
|
bool isBuffer(KQuery::KType) const;
|
|
@@ -242,7 +244,10 @@ public:
|
|
|
242
244
|
bool isNull() const;
|
|
243
245
|
|
|
244
246
|
/** (临时函数)只用于更新缓存中的K线数据 **/
|
|
245
|
-
void realtimeUpdate(KRecord, KQuery::KType ktype = KQuery::DAY);
|
|
247
|
+
void realtimeUpdate(KRecord, const KQuery::KType& ktype = KQuery::DAY);
|
|
248
|
+
|
|
249
|
+
/** 获取指定K线数据类型最后更新时间 */
|
|
250
|
+
Datetime getLastUpdateTime(const KQuery::KType& ktype) const;
|
|
246
251
|
|
|
247
252
|
/**
|
|
248
253
|
* 部分临时创建的 Stock, 直接设置KRecordList
|
|
@@ -258,12 +263,19 @@ private:
|
|
|
258
263
|
bool _getIndexRangeByIndex(const KQuery&, size_t& out_start, size_t& out_end) const;
|
|
259
264
|
|
|
260
265
|
// 以下函数属于基础操作添加了读锁
|
|
261
|
-
size_t _getCountFromBuffer(KQuery::KType ktype) const;
|
|
262
|
-
KRecord _getKRecordFromBuffer(size_t pos, const KQuery::KType& ktype) const;
|
|
266
|
+
size_t _getCountFromBuffer(const KQuery::KType& ktype) const;
|
|
267
|
+
const KRecord& _getKRecordFromBuffer(size_t pos, const KQuery::KType& ktype) const;
|
|
263
268
|
KRecordList _getKRecordListFromBuffer(size_t start_ix, size_t end_ix,
|
|
264
269
|
KQuery::KType ktype) const;
|
|
265
270
|
bool _getIndexRangeByDateFromBuffer(const KQuery&, size_t&, size_t&) const;
|
|
266
271
|
|
|
272
|
+
KRecordList _getKRecordList(const KQuery& query) const;
|
|
273
|
+
|
|
274
|
+
// 仅供 StockManager 初始化时调用
|
|
275
|
+
void setPreload(const vector<KQuery::KType>& preload_ktypes);
|
|
276
|
+
|
|
277
|
+
bool isPreload(KQuery::KType ktype) const;
|
|
278
|
+
|
|
267
279
|
private:
|
|
268
280
|
struct HKU_API Data;
|
|
269
281
|
shared_ptr<Data> m_data;
|
|
@@ -295,8 +307,10 @@ struct HKU_API Stock::Data {
|
|
|
295
307
|
double m_minTradeNumber;
|
|
296
308
|
double m_maxTradeNumber;
|
|
297
309
|
|
|
310
|
+
std::unordered_set<string> m_ktype_preload; // 记录当前证券的K线数据是否需要预加载
|
|
298
311
|
unordered_map<string, KRecordList*> pKData;
|
|
299
312
|
unordered_map<string, std::shared_mutex*> pMutex;
|
|
313
|
+
unordered_map<string, Datetime> m_lastUpdate; // 记录各类型K线数据最后更新时间
|
|
300
314
|
|
|
301
315
|
Data();
|
|
302
316
|
Data(const string& market, const string& code, const string& name, uint32_t type, bool valid,
|
|
@@ -338,6 +352,10 @@ inline bool Stock::operator!=(const Stock& stock) const {
|
|
|
338
352
|
return !(*this == stock);
|
|
339
353
|
}
|
|
340
354
|
|
|
355
|
+
inline bool Stock::isNull() const {
|
|
356
|
+
return !m_data || !m_kdataDriver;
|
|
357
|
+
}
|
|
358
|
+
|
|
341
359
|
} // namespace hku
|
|
342
360
|
|
|
343
361
|
namespace std {
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
|
|
23
23
|
namespace hku {
|
|
24
24
|
|
|
25
|
-
typedef vector<string> MarketList;
|
|
26
|
-
|
|
27
25
|
/**
|
|
28
26
|
* 证券信息统一管理类
|
|
29
27
|
* @ingroup StockManage
|
|
@@ -111,7 +109,7 @@ public:
|
|
|
111
109
|
* @param market 指定的市场标识
|
|
112
110
|
* @return 相应的市场信息,如果相应的市场信息不存在,则返回Null<MarketInfo>()
|
|
113
111
|
*/
|
|
114
|
-
MarketInfo getMarketInfo(const string& market) const;
|
|
112
|
+
MarketInfo getMarketInfo(const string& market) const noexcept;
|
|
115
113
|
|
|
116
114
|
/**
|
|
117
115
|
* 获取指定市场代表指数证券
|
|
@@ -126,8 +124,11 @@ public:
|
|
|
126
124
|
*/
|
|
127
125
|
StockTypeInfo getStockTypeInfo(uint32_t type) const;
|
|
128
126
|
|
|
127
|
+
/** 获取所有证券类型信息 */
|
|
128
|
+
vector<StockTypeInfo> getStockTypeInfoList() const;
|
|
129
|
+
|
|
129
130
|
/** 获取市场简称列表 */
|
|
130
|
-
|
|
131
|
+
StringList getAllMarket() const;
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
134
|
* 获取预定义的板块
|
|
@@ -182,11 +183,19 @@ public:
|
|
|
182
183
|
const ZhBond10List& getZhBond10() const;
|
|
183
184
|
|
|
184
185
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @
|
|
186
|
+
* 判断指定时间对应的日期是否为节假日(包含周六、周日)
|
|
187
|
+
* @note 仅支持中国大陆市场, Null<Datetime>() 将抛出异常
|
|
188
|
+
* @param d 指定时间
|
|
187
189
|
*/
|
|
188
190
|
bool isHoliday(const Datetime& d) const;
|
|
189
191
|
|
|
192
|
+
/**
|
|
193
|
+
* 粗略判断指定时间是否为交易时间
|
|
194
|
+
* @param d 指定时间,Null<Datetime>() 将抛出异常
|
|
195
|
+
* @param market 指定市场
|
|
196
|
+
*/
|
|
197
|
+
bool isTradingHours(const Datetime& d, const string& market = "SH") const;
|
|
198
|
+
|
|
190
199
|
const string& getHistoryFinanceFieldName(size_t ix) const;
|
|
191
200
|
size_t getHistoryFinanceFieldIndex(const string& name) const;
|
|
192
201
|
vector<std::pair<size_t, string>> getHistoryFinanceAllFields() const;
|
|
@@ -38,6 +38,12 @@ public:
|
|
|
38
38
|
StockTypeInfo();
|
|
39
39
|
StockTypeInfo(uint32_t, const string&, price_t, price_t, int, double, double);
|
|
40
40
|
|
|
41
|
+
StockTypeInfo(const StockTypeInfo&) = default;
|
|
42
|
+
StockTypeInfo& operator=(const StockTypeInfo&) = default;
|
|
43
|
+
|
|
44
|
+
StockTypeInfo(StockTypeInfo&&);
|
|
45
|
+
StockTypeInfo& operator=(StockTypeInfo&&) noexcept;
|
|
46
|
+
|
|
41
47
|
/** 获取证券类型 */
|
|
42
48
|
uint32_t type() const {
|
|
43
49
|
return m_type;
|
|
@@ -19,19 +19,13 @@ namespace hku {
|
|
|
19
19
|
*/
|
|
20
20
|
class HKU_API TransRecord {
|
|
21
21
|
public:
|
|
22
|
-
enum DIRECT {
|
|
23
|
-
BUY = 0, /**< 买盘 */
|
|
24
|
-
SELL = 1, /**< 卖盘 */
|
|
25
|
-
AUCTION = 2 /**< 集合竞价 */
|
|
26
|
-
};
|
|
27
|
-
|
|
28
22
|
Datetime datetime; // 时间
|
|
29
23
|
price_t price; // 成交均价
|
|
30
24
|
price_t vol; // 成交量
|
|
31
|
-
|
|
25
|
+
int32_t direct; // 买卖盘性质:1--sell 0--buy 2--集合竞价 其他未知
|
|
32
26
|
|
|
33
27
|
TransRecord();
|
|
34
|
-
TransRecord(const Datetime& datetime, price_t price, price_t vol,
|
|
28
|
+
TransRecord(const Datetime& datetime, price_t price, price_t vol, int32_t direct);
|
|
35
29
|
|
|
36
30
|
bool isValid() const;
|
|
37
31
|
};
|
hikyuu/include/hikyuu/doc.h
CHANGED
|
@@ -30,4 +30,12 @@ HKU_API SpotAgent* getGlobalSpotAgent();
|
|
|
30
30
|
|
|
31
31
|
void HKU_API releaseGlobalSpotAgent();
|
|
32
32
|
|
|
33
|
+
inline bool spotAgentIsRunning() {
|
|
34
|
+
return getGlobalSpotAgent()->isRunning();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
inline bool spotAgentIsConnected() {
|
|
38
|
+
return getGlobalSpotAgent()->isConnected();
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
} // namespace hku
|
|
@@ -68,6 +68,10 @@ public:
|
|
|
68
68
|
return m_server_addr;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
bool isConnected() const {
|
|
72
|
+
return m_connected;
|
|
73
|
+
}
|
|
74
|
+
|
|
71
75
|
/**
|
|
72
76
|
* 增加收到 Spot 数据时的处理函数
|
|
73
77
|
* @note 仅能在停止状态时执行此操作,否则将抛出异常
|
|
@@ -99,9 +103,9 @@ public:
|
|
|
99
103
|
static void setQuotationServer(const string& server);
|
|
100
104
|
|
|
101
105
|
private:
|
|
102
|
-
static string ms_pubUrl;
|
|
103
|
-
static const char* ms_startTag;
|
|
104
|
-
static const char* ms_endTag;
|
|
106
|
+
static string ms_pubUrl; // 数据发送服务地址
|
|
107
|
+
static const char* ms_startTag; // 批次数据接收起始标记,用于判断启动了新的批次数据接收
|
|
108
|
+
static const char* ms_endTag; // 批次数据接收接收标记,用于判断该批次数据更新结束
|
|
105
109
|
static const char* ms_spotTopic; // 向数据发送服务订阅的主题
|
|
106
110
|
static const size_t ms_startTagLength; // 批次数据接收起始标记长度
|
|
107
111
|
static const size_t ms_endTagLength; // 批次数据接收结束标记长度
|
|
@@ -121,9 +125,10 @@ private:
|
|
|
121
125
|
void work_thread();
|
|
122
126
|
|
|
123
127
|
private:
|
|
124
|
-
enum STATUS { WAITING, RECEIVING };
|
|
125
|
-
enum STATUS m_status = WAITING;
|
|
126
|
-
std::atomic_bool m_stop = true;
|
|
128
|
+
enum STATUS { WAITING, RECEIVING }; // 等待新的批次数据,正在接收批次数据中
|
|
129
|
+
enum STATUS m_status = WAITING; // 当前内部状态
|
|
130
|
+
std::atomic_bool m_stop = true; // 结束代理工作标识
|
|
131
|
+
std::atomic_bool m_connected = false; // 是否已连接数据服务
|
|
127
132
|
|
|
128
133
|
int m_revTimeout = 100; // 连接数据服务超时时长(毫秒)
|
|
129
134
|
std::thread m_receiveThread; // 数据接收线程
|
|
@@ -137,7 +142,7 @@ private:
|
|
|
137
142
|
// 下面属性被修改时需要加锁,以便可以使用多线程方式运行 strategy
|
|
138
143
|
std::mutex m_mutex;
|
|
139
144
|
list<std::function<void(const SpotRecord&)>> m_processList; // 已注册的 spot 处理函数列表
|
|
140
|
-
list<std::function<void(Datetime)>> m_postProcessList;
|
|
145
|
+
list<std::function<void(Datetime)>> m_postProcessList; // 已注册的批次后处理函数列表
|
|
141
146
|
};
|
|
142
147
|
|
|
143
148
|
} // namespace hku
|
|
@@ -110,6 +110,9 @@ public:
|
|
|
110
110
|
*/
|
|
111
111
|
value_t get(size_t pos, size_t num = 0) const;
|
|
112
112
|
|
|
113
|
+
value_t front(size_t num = 0) const;
|
|
114
|
+
value_t back(size_t num = 0) const;
|
|
115
|
+
|
|
113
116
|
/**
|
|
114
117
|
* 获取指定位置的日期
|
|
115
118
|
* @param pos 结果集中的位置
|
|
@@ -205,6 +208,43 @@ public:
|
|
|
205
208
|
|
|
206
209
|
string str() const;
|
|
207
210
|
|
|
211
|
+
public:
|
|
212
|
+
class Iterator {
|
|
213
|
+
private:
|
|
214
|
+
const Indicator& container;
|
|
215
|
+
size_t index;
|
|
216
|
+
|
|
217
|
+
public:
|
|
218
|
+
Iterator(const Indicator& cont, size_t idx) : container(cont), index(idx) {}
|
|
219
|
+
|
|
220
|
+
Iterator& operator++() {
|
|
221
|
+
index++;
|
|
222
|
+
return *this;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
value_t operator*() const {
|
|
226
|
+
return container.get(index);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
bool operator!=(const Iterator& other) const {
|
|
230
|
+
return index != other.index;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
bool operator==(const Iterator& other) const {
|
|
234
|
+
return index == other.index;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
Iterator begin() const {
|
|
239
|
+
return Iterator(*this, 0);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
Iterator end() const {
|
|
243
|
+
return Iterator(*this, size());
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
typedef Iterator iterator;
|
|
247
|
+
|
|
208
248
|
protected:
|
|
209
249
|
IndicatorImpPtr m_imp;
|
|
210
250
|
|
|
@@ -285,6 +325,14 @@ inline Indicator::value_t Indicator::get(size_t pos, size_t num) const {
|
|
|
285
325
|
return m_imp->get(pos, num);
|
|
286
326
|
}
|
|
287
327
|
|
|
328
|
+
inline Indicator::value_t Indicator::front(size_t num) const {
|
|
329
|
+
return m_imp->front(num);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
inline Indicator::value_t Indicator::back(size_t num) const {
|
|
333
|
+
return m_imp->back(num);
|
|
334
|
+
}
|
|
335
|
+
|
|
288
336
|
inline Datetime Indicator::getDatetime(size_t pos) const {
|
|
289
337
|
return m_imp ? m_imp->getDatetime(pos) : Null<Datetime>();
|
|
290
338
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
namespace hku {
|
|
13
13
|
|
|
14
|
+
/* note: 双输入但同一上下文*/
|
|
14
15
|
class Indicator2InImp : public IndicatorImp {
|
|
15
16
|
public:
|
|
16
17
|
Indicator2InImp();
|
|
@@ -21,6 +22,14 @@ public:
|
|
|
21
22
|
|
|
22
23
|
virtual IndicatorImpPtr _clone() override;
|
|
23
24
|
|
|
25
|
+
virtual bool needSelfAlikeCompare() const noexcept override {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
virtual bool selfAlike(const IndicatorImp& other) const noexcept override;
|
|
30
|
+
|
|
31
|
+
virtual void getSelfInnerNodesWithInputConext(vector<IndicatorImpPtr>& nodes) const override;
|
|
32
|
+
|
|
24
33
|
protected:
|
|
25
34
|
Indicator prepare(const Indicator& ind);
|
|
26
35
|
|