hikyuu 2.6.7__py3-none-win_amd64.whl → 2.6.8.2__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 +6 -2
- hikyuu/__init__.pyi +37 -10
- hikyuu/analysis/__init__.pyi +24 -0
- hikyuu/analysis/analysis.pyi +25 -1
- hikyuu/core.pyi +26 -2
- hikyuu/cpp/concrt140.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +419 -31
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +419 -31
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +419 -31
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +419 -31
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +419 -31
- 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/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/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/bokeh_draw.pyi +33 -8
- hikyuu/draw/drawplot/echarts_draw.pyi +33 -8
- hikyuu/draw/drawplot/matplotlib_draw.pyi +33 -8
- hikyuu/extend.py +19 -0
- hikyuu/extend.pyi +27 -3
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/DataType.h +2 -2
- hikyuu/include/hikyuu/KData.h +91 -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 +16 -4
- hikyuu/include/hikyuu/KRecord.h +4 -1
- hikyuu/include/hikyuu/Stock.h +10 -4
- hikyuu/include/hikyuu/StockManager.h +11 -3
- hikyuu/include/hikyuu/TransRecord.h +2 -2
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
- hikyuu/include/hikyuu/doc.h +2 -2
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
- hikyuu/include/hikyuu/indicator/Indicator.h +11 -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/plugin/backtest.h +2 -0
- hikyuu/include/hikyuu/plugin/extind.h +45 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +21 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +16 -0
- hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +27 -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_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/datetime/Datetime.h +2 -2
- hikyuu/include/hikyuu/utilities/os.h +4 -0
- 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/indicator.py +4 -5
- 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 +19 -19
- hikyuu/trade_manage/__init__.pyi +32 -7
- hikyuu/trade_manage/trade.py +6 -0
- hikyuu/trade_manage/trade.pyi +32 -7
- hikyuu/trade_sys/__init__.py +4 -0
- hikyuu/util/__init__.pyi +1 -1
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/METADATA +15 -3
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/RECORD +128 -125
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/WHEEL +1 -1
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/top_level.txt +1 -1
- hikyuu/include/hikyuu/view/MarketView.h +0 -59
- hikyuu/setup.py +0 -104
- hikyuu-2.6.7.dist-info/LICENSE +0 -201
- /hikyuu/include/hikyuu/{view → views}/__init__.py +0 -0
- {hikyuu-2.6.7.dist-info → hikyuu-2.6.8.2.dist-info}/entry_points.txt +0 -0
hikyuu/include/hikyuu/KData.h
CHANGED
|
@@ -57,6 +57,9 @@ public:
|
|
|
57
57
|
return getKRecord(datetime);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
const KRecord& front() const;
|
|
61
|
+
const KRecord& back() const;
|
|
62
|
+
|
|
60
63
|
/**
|
|
61
64
|
* 通过当前 KData 获取一个保持数据类型、复权类型不变的新的 KData
|
|
62
65
|
* @note 新的 KData 并不一定是原 KData 的子集
|
|
@@ -65,6 +68,21 @@ public:
|
|
|
65
68
|
*/
|
|
66
69
|
KData getKData(const Datetime& start, const Datetime& end) const;
|
|
67
70
|
|
|
71
|
+
/**
|
|
72
|
+
* 获取相同时间范围内的其他类型K线数据,如日线下对应的分钟线数据
|
|
73
|
+
* @param ktype
|
|
74
|
+
* @return KData
|
|
75
|
+
*/
|
|
76
|
+
KData getKData(const KQuery::KType& ktype) const;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 通过索引获取其子集 [star, end)
|
|
80
|
+
* @param start 起始索引
|
|
81
|
+
* @param end 结束索引
|
|
82
|
+
* @return KData
|
|
83
|
+
*/
|
|
84
|
+
KData getKData(int64_t start, int64_t end = Null<int64_t>()) const;
|
|
85
|
+
|
|
68
86
|
/** 按日期查询对应的索引位置,注:是 KData 中的位置,不是在 Stock 中原始K记录的位置 */
|
|
69
87
|
size_t getPos(const Datetime& datetime) const;
|
|
70
88
|
|
|
@@ -110,17 +128,70 @@ public:
|
|
|
110
128
|
Indicator amo() const;
|
|
111
129
|
|
|
112
130
|
public:
|
|
113
|
-
typedef KRecordList::iterator iterator;
|
|
114
|
-
typedef KRecordList::const_iterator const_iterator;
|
|
115
|
-
iterator begin();
|
|
116
|
-
iterator end();
|
|
117
|
-
const_iterator cbegin() const;
|
|
118
|
-
const_iterator cend() const;
|
|
119
131
|
const KRecord* data() const;
|
|
120
132
|
KRecord* data(); // 谨慎使用(用于强制调整数据)
|
|
121
133
|
|
|
134
|
+
// 常量迭代器定义
|
|
135
|
+
class const_iterator {
|
|
136
|
+
public:
|
|
137
|
+
using iterator_category = std::forward_iterator_tag;
|
|
138
|
+
using value_type = const KRecord;
|
|
139
|
+
using difference_type = std::ptrdiff_t;
|
|
140
|
+
using pointer = const KRecord*;
|
|
141
|
+
using reference = const KRecord&;
|
|
142
|
+
|
|
143
|
+
const_iterator(const KData& container, size_t index)
|
|
144
|
+
: container_(container), index_(index) {}
|
|
145
|
+
|
|
146
|
+
reference operator*() const {
|
|
147
|
+
return container_[index_];
|
|
148
|
+
}
|
|
149
|
+
pointer operator->() const {
|
|
150
|
+
return &(container_[index_]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const_iterator& operator++() {
|
|
154
|
+
++index_;
|
|
155
|
+
return *this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const_iterator operator++(int) {
|
|
159
|
+
const_iterator temp = *this;
|
|
160
|
+
++index_;
|
|
161
|
+
return temp;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
bool operator==(const const_iterator& other) const {
|
|
165
|
+
return &container_ == &other.container_ && index_ == other.index_;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
bool operator!=(const const_iterator& other) const {
|
|
169
|
+
return !(*this == other);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private:
|
|
173
|
+
const KData& container_; // 常量引用容器
|
|
174
|
+
size_t index_; // 当前索引
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
using iterator = const_iterator;
|
|
178
|
+
|
|
179
|
+
const_iterator begin() const {
|
|
180
|
+
return const_iterator(*this, 0);
|
|
181
|
+
}
|
|
182
|
+
const_iterator end() const {
|
|
183
|
+
return const_iterator(*this, size());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const_iterator cbegin() const {
|
|
187
|
+
return const_iterator(*this, 0);
|
|
188
|
+
}
|
|
189
|
+
const_iterator cend() const {
|
|
190
|
+
return const_iterator(*this, size());
|
|
191
|
+
}
|
|
192
|
+
|
|
122
193
|
private:
|
|
123
|
-
static
|
|
194
|
+
static shared_ptr<KDataImp> ms_null_kdata_imp;
|
|
124
195
|
|
|
125
196
|
private:
|
|
126
197
|
KDataImpPtr m_imp;
|
|
@@ -177,7 +248,9 @@ KData HKU_API getKData(const string& market_code, int64_t start = 0, int64_t end
|
|
|
177
248
|
|
|
178
249
|
inline KData::KData(const KData& x) : m_imp(x.m_imp) {}
|
|
179
250
|
|
|
180
|
-
inline KData::KData(KData&& x) : m_imp(std::move(x.m_imp)) {
|
|
251
|
+
inline KData::KData(KData&& x) : m_imp(std::move(x.m_imp)) {
|
|
252
|
+
x.m_imp = ms_null_kdata_imp;
|
|
253
|
+
}
|
|
181
254
|
|
|
182
255
|
inline KData& KData::operator=(const KData& x) {
|
|
183
256
|
if (this == &x)
|
|
@@ -190,6 +263,7 @@ inline KData& KData::operator=(KData&& x) {
|
|
|
190
263
|
if (this == &x)
|
|
191
264
|
return *this;
|
|
192
265
|
m_imp = std::move(x.m_imp);
|
|
266
|
+
x.m_imp = ms_null_kdata_imp;
|
|
193
267
|
return *this;
|
|
194
268
|
}
|
|
195
269
|
|
|
@@ -203,7 +277,7 @@ inline const KRecord& KData::getKRecord(size_t pos) const {
|
|
|
203
277
|
|
|
204
278
|
inline const KRecord& KData::getKRecord(Datetime datetime) const {
|
|
205
279
|
size_t pos = getPos(datetime);
|
|
206
|
-
return pos != Null<size_t>() ? getKRecord(pos) :
|
|
280
|
+
return pos != Null<size_t>() ? getKRecord(pos) : KRecord::NullKRecord;
|
|
207
281
|
}
|
|
208
282
|
|
|
209
283
|
inline size_t KData::getPos(const Datetime& datetime) const {
|
|
@@ -226,6 +300,14 @@ inline const Stock& KData::getStock() const {
|
|
|
226
300
|
return m_imp->getStock();
|
|
227
301
|
}
|
|
228
302
|
|
|
303
|
+
inline const KRecord& KData::front() const {
|
|
304
|
+
return m_imp->front();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
inline const KRecord& KData::back() const {
|
|
308
|
+
return m_imp->back();
|
|
309
|
+
}
|
|
310
|
+
|
|
229
311
|
inline size_t KData::startPos() const {
|
|
230
312
|
return m_imp->startPos();
|
|
231
313
|
}
|
|
@@ -242,22 +324,6 @@ inline bool KData::operator!=(const KData& other) const {
|
|
|
242
324
|
return !(*this == other);
|
|
243
325
|
}
|
|
244
326
|
|
|
245
|
-
inline KData::iterator KData::begin() {
|
|
246
|
-
return m_imp->begin();
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
inline KData::iterator KData::end() {
|
|
250
|
-
return m_imp->end();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
inline KData::const_iterator KData::cbegin() const {
|
|
254
|
-
return m_imp->cbegin();
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
inline KData::const_iterator KData::cend() const {
|
|
258
|
-
return m_imp->cend();
|
|
259
|
-
}
|
|
260
|
-
|
|
261
327
|
inline const KRecord* KData::data() const {
|
|
262
328
|
return m_imp->data();
|
|
263
329
|
}
|
hikyuu/include/hikyuu/KDataImp.h
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
3
|
*
|
|
4
|
-
* Created on:
|
|
4
|
+
* Created on: 2025-08-28
|
|
5
5
|
* Author: fasiondog
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
|
-
#ifndef KDATAIMP_H_
|
|
10
|
-
#define KDATAIMP_H_
|
|
11
9
|
|
|
12
10
|
#include "Stock.h"
|
|
13
11
|
|
|
@@ -15,7 +13,7 @@ namespace hku {
|
|
|
15
13
|
|
|
16
14
|
class HKU_API KDataImp {
|
|
17
15
|
public:
|
|
18
|
-
KDataImp();
|
|
16
|
+
KDataImp() = default;
|
|
19
17
|
KDataImp(const Stock& stock, const KQuery& query);
|
|
20
18
|
virtual ~KDataImp();
|
|
21
19
|
|
|
@@ -27,72 +25,59 @@ public:
|
|
|
27
25
|
return m_stock;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
return
|
|
28
|
+
virtual bool empty() const {
|
|
29
|
+
return true;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
return
|
|
32
|
+
virtual size_t size() const {
|
|
33
|
+
return 0;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
size_t
|
|
39
|
-
return
|
|
36
|
+
virtual size_t startPos() const {
|
|
37
|
+
return 0;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
size_t
|
|
43
|
-
|
|
44
|
-
size_t lastPos();
|
|
45
|
-
|
|
46
|
-
size_t getPos(const Datetime& datetime);
|
|
47
|
-
|
|
48
|
-
const KRecord* data() const {
|
|
49
|
-
return m_buffer.data();
|
|
40
|
+
virtual size_t endPos() const {
|
|
41
|
+
return 0;
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
return
|
|
44
|
+
virtual size_t lastPos() const {
|
|
45
|
+
return 0;
|
|
54
46
|
}
|
|
55
47
|
|
|
56
|
-
|
|
48
|
+
virtual size_t getPos(const Datetime& datetime) const {
|
|
49
|
+
return Null<size_t>();
|
|
50
|
+
}
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
virtual const KRecord& getKRecord(size_t pos) const {
|
|
53
|
+
return KRecord::NullKRecord;
|
|
54
|
+
}
|
|
61
55
|
|
|
62
|
-
|
|
63
|
-
return
|
|
56
|
+
virtual const KRecord& front() const {
|
|
57
|
+
return KRecord::NullKRecord;
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
return
|
|
60
|
+
virtual const KRecord& back() const {
|
|
61
|
+
return KRecord::NullKRecord;
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
return
|
|
64
|
+
virtual const KRecord* data() const {
|
|
65
|
+
return nullptr;
|
|
72
66
|
}
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
return
|
|
68
|
+
virtual KRecord* data() {
|
|
69
|
+
return nullptr;
|
|
76
70
|
}
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
void _recoverBackward();
|
|
82
|
-
void _recoverEqualForward();
|
|
83
|
-
void _recoverEqualBackward();
|
|
84
|
-
void _recoverForUpDay();
|
|
72
|
+
virtual DatetimeList getDatetimeList() const {
|
|
73
|
+
return DatetimeList();
|
|
74
|
+
}
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
KRecordList m_buffer;
|
|
76
|
+
protected:
|
|
88
77
|
KQuery m_query;
|
|
89
78
|
Stock m_stock;
|
|
90
|
-
size_t m_start;
|
|
91
|
-
size_t m_end;
|
|
92
|
-
bool m_have_pos_in_stock;
|
|
93
79
|
};
|
|
94
80
|
|
|
95
81
|
typedef shared_ptr<KDataImp> KDataImpPtr;
|
|
96
82
|
|
|
97
83
|
} /* namespace hku */
|
|
98
|
-
#endif /* KDATAIMP_H_ */
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* KDataPrivatedBufferImp.h
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2013-2-4
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "KDataImp.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
class HKU_API KDataPrivatedBufferImp : public KDataImp {
|
|
15
|
+
public:
|
|
16
|
+
KDataPrivatedBufferImp();
|
|
17
|
+
KDataPrivatedBufferImp(const Stock& stock, const KQuery& query);
|
|
18
|
+
virtual ~KDataPrivatedBufferImp();
|
|
19
|
+
|
|
20
|
+
virtual bool empty() const override {
|
|
21
|
+
return m_buffer.empty();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
virtual size_t size() const override {
|
|
25
|
+
return m_buffer.size();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
virtual size_t startPos() const override;
|
|
29
|
+
virtual size_t endPos() const override;
|
|
30
|
+
virtual size_t lastPos() const override;
|
|
31
|
+
|
|
32
|
+
virtual size_t getPos(const Datetime& datetime) const override;
|
|
33
|
+
|
|
34
|
+
virtual const KRecord& getKRecord(size_t pos) const override {
|
|
35
|
+
return m_buffer[pos];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
virtual const KRecord& front() const override {
|
|
39
|
+
return m_buffer.front();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
virtual const KRecord& back() const override {
|
|
43
|
+
return m_buffer.back();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
virtual const KRecord* data() const override {
|
|
47
|
+
return m_buffer.data();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
virtual KRecord* data() override {
|
|
51
|
+
return m_buffer.data();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
virtual DatetimeList getDatetimeList() const override;
|
|
55
|
+
|
|
56
|
+
private:
|
|
57
|
+
void _getPosInStock() const;
|
|
58
|
+
void _recoverForward();
|
|
59
|
+
void _recoverBackward();
|
|
60
|
+
void _recoverEqualForward();
|
|
61
|
+
void _recoverEqualBackward();
|
|
62
|
+
void _recoverForUpDay();
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
KRecordList m_buffer;
|
|
66
|
+
mutable size_t m_start{0};
|
|
67
|
+
mutable size_t m_end{0};
|
|
68
|
+
mutable bool m_have_pos_in_stock{false};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
typedef shared_ptr<KDataPrivatedBufferImp> KDataPrivatedBufferImpPtr;
|
|
72
|
+
|
|
73
|
+
} /* namespace hku */
|
|
@@ -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
|
@@ -47,10 +47,12 @@ public:
|
|
|
47
47
|
static const string DAY5;
|
|
48
48
|
static const string DAY7;
|
|
49
49
|
static const string MIN3;
|
|
50
|
-
static const string HOUR4;
|
|
51
|
-
static const string HOUR6;
|
|
52
|
-
static const string HOUR12;
|
|
53
|
-
|
|
50
|
+
static const string HOUR4; // 默认不支持
|
|
51
|
+
static const string HOUR6; // 默认不支持
|
|
52
|
+
static const string HOUR12; // 默认不支持
|
|
53
|
+
|
|
54
|
+
static const string TIMELINE; // 分时
|
|
55
|
+
static const string TRANS; // 分笔
|
|
54
56
|
|
|
55
57
|
/** 判断指定的K线类型是否有效 */
|
|
56
58
|
static bool isValidKType(const string& ktype);
|
|
@@ -71,6 +73,8 @@ public:
|
|
|
71
73
|
|
|
72
74
|
static int32_t getBaseKTypeInMin(const KType& ktype);
|
|
73
75
|
|
|
76
|
+
static int64_t getKTypeInSeconds(const KType& ktype);
|
|
77
|
+
|
|
74
78
|
/**
|
|
75
79
|
* 复权类型
|
|
76
80
|
* @note 日线以上,如周线/月线不支持复权
|
|
@@ -175,6 +179,14 @@ public:
|
|
|
175
179
|
*/
|
|
176
180
|
uint64_t hash() const;
|
|
177
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
|
+
|
|
178
190
|
/** 获取queryType名称,用于显示输出 */
|
|
179
191
|
static string getQueryTypeName(QueryType);
|
|
180
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 */
|
|
@@ -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
|
|
@@ -259,7 +264,7 @@ private:
|
|
|
259
264
|
|
|
260
265
|
// 以下函数属于基础操作添加了读锁
|
|
261
266
|
size_t _getCountFromBuffer(const KQuery::KType& ktype) const;
|
|
262
|
-
KRecord _getKRecordFromBuffer(size_t pos, 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;
|
|
@@ -267,7 +272,7 @@ private:
|
|
|
267
272
|
KRecordList _getKRecordList(const KQuery& query) const;
|
|
268
273
|
|
|
269
274
|
// 仅供 StockManager 初始化时调用
|
|
270
|
-
void setPreload(vector<KQuery::KType>& preload_ktypes);
|
|
275
|
+
void setPreload(const vector<KQuery::KType>& preload_ktypes);
|
|
271
276
|
|
|
272
277
|
bool isPreload(KQuery::KType ktype) const;
|
|
273
278
|
|
|
@@ -305,6 +310,7 @@ struct HKU_API Stock::Data {
|
|
|
305
310
|
std::unordered_set<string> m_ktype_preload; // 记录当前证券的K线数据是否需要预加载
|
|
306
311
|
unordered_map<string, KRecordList*> pKData;
|
|
307
312
|
unordered_map<string, std::shared_mutex*> pMutex;
|
|
313
|
+
unordered_map<string, Datetime> m_lastUpdate; // 记录各类型K线数据最后更新时间
|
|
308
314
|
|
|
309
315
|
Data();
|
|
310
316
|
Data(const string& market, const string& code, const string& name, uint32_t type, bool valid,
|
|
@@ -109,7 +109,7 @@ public:
|
|
|
109
109
|
* @param market 指定的市场标识
|
|
110
110
|
* @return 相应的市场信息,如果相应的市场信息不存在,则返回Null<MarketInfo>()
|
|
111
111
|
*/
|
|
112
|
-
MarketInfo getMarketInfo(const string& market) const;
|
|
112
|
+
MarketInfo getMarketInfo(const string& market) const noexcept;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* 获取指定市场代表指数证券
|
|
@@ -183,11 +183,19 @@ public:
|
|
|
183
183
|
const ZhBond10List& getZhBond10() const;
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
*
|
|
187
|
-
* @
|
|
186
|
+
* 判断指定时间对应的日期是否为节假日(包含周六、周日)
|
|
187
|
+
* @note 仅支持中国大陆市场, Null<Datetime>() 将抛出异常
|
|
188
|
+
* @param d 指定时间
|
|
188
189
|
*/
|
|
189
190
|
bool isHoliday(const Datetime& d) const;
|
|
190
191
|
|
|
192
|
+
/**
|
|
193
|
+
* 粗略判断指定时间是否为交易时间
|
|
194
|
+
* @param d 指定时间,Null<Datetime>() 将抛出异常
|
|
195
|
+
* @param market 指定市场
|
|
196
|
+
*/
|
|
197
|
+
bool isTradingHours(const Datetime& d, const string& market = "SH") const;
|
|
198
|
+
|
|
191
199
|
const string& getHistoryFinanceFieldName(size_t ix) const;
|
|
192
200
|
size_t getHistoryFinanceFieldIndex(const string& name) const;
|
|
193
201
|
vector<std::pair<size_t, string>> getHistoryFinanceAllFields() const;
|
|
@@ -22,10 +22,10 @@ public:
|
|
|
22
22
|
Datetime datetime; // 时间
|
|
23
23
|
price_t price; // 成交均价
|
|
24
24
|
price_t vol; // 成交量
|
|
25
|
-
|
|
25
|
+
int32_t direct; // 买卖盘性质:1--sell 0--buy 2--集合竞价 其他未知
|
|
26
26
|
|
|
27
27
|
TransRecord();
|
|
28
|
-
TransRecord(const Datetime& datetime, price_t price, price_t vol,
|
|
28
|
+
TransRecord(const Datetime& datetime, price_t price, price_t vol, int32_t direct);
|
|
29
29
|
|
|
30
30
|
bool isValid() const;
|
|
31
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
|