hikyuu 2.6.2__py3-none-win_amd64.whl → 2.6.5__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 +1 -1
- hikyuu/__init__.pyi +28 -13
- hikyuu/analysis/__init__.pyi +20 -0
- hikyuu/analysis/analysis.pyi +21 -1
- hikyuu/core.pyi +22 -2
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +499 -50
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +499 -50
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +499 -50
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +499 -50
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +499 -50
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/data/common.py +1 -1
- hikyuu/data/common_mysql.py +19 -0
- hikyuu/data/common_pytdx.py +2 -0
- hikyuu/data/common_sqlite3.py +1 -0
- hikyuu/data/hku_config_template.py +14 -0
- hikyuu/data/mysql_upgrade/0028.sql +95 -0
- hikyuu/data/pytdx_to_h5.py +53 -13
- hikyuu/data/pytdx_to_mysql.py +42 -9
- hikyuu/data/pytdx_to_taos.py +736 -0
- hikyuu/data/sqlite_upgrade/0028.sql +97 -0
- hikyuu/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/__init__.pyi +1 -1
- hikyuu/draw/drawplot/bokeh_draw.pyi +24 -9
- hikyuu/draw/drawplot/echarts_draw.pyi +24 -9
- hikyuu/draw/drawplot/matplotlib_draw.py +26 -4
- hikyuu/draw/drawplot/matplotlib_draw.pyi +24 -9
- hikyuu/draw/kaufman.py +2 -2
- hikyuu/draw/kaufman.pyi +2 -2
- hikyuu/examples/notebook/001-overview.ipynb +65 -100
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +34 -32
- hikyuu/examples/notebook/007-SystemDetails.ipynb +64 -50
- hikyuu/examples/notebook/010-Portfolio.ipynb +120 -124
- hikyuu/extend.py +1 -1
- hikyuu/extend.pyi +24 -9
- hikyuu/fetcher/stock/zh_block_em.py +349 -5
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +2 -1
- hikyuu/gui/HikyuuTDX.py +47 -24
- hikyuu/gui/data/ImportBlockInfoTask.py +1 -1
- hikyuu/gui/data/ImportHistoryFinanceTask.py +48 -44
- hikyuu/gui/data/ImportPytdxTimeToH5Task.py +3 -1
- hikyuu/gui/data/ImportPytdxToH5Task.py +4 -2
- hikyuu/gui/data/ImportPytdxTransToH5Task.py +3 -1
- hikyuu/gui/data/ImportWeightToSqliteTask.py +2 -1
- hikyuu/gui/data/ImportZhBond10Task.py +1 -1
- hikyuu/gui/data/MainWindow.py +123 -106
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +7 -3
- hikyuu/gui/data/UseQmtImportToH5Thread.py +1 -0
- hikyuu/gui/data/UseTdxImportToH5Thread.py +2 -1
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/Block.h +20 -0
- hikyuu/include/hikyuu/KQuery.h +8 -0
- hikyuu/include/hikyuu/MarketInfo.h +6 -0
- hikyuu/include/hikyuu/Stock.h +1 -1
- hikyuu/include/hikyuu/StockManager.h +6 -0
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +35 -0
- hikyuu/include/hikyuu/indicator/Indicator.h +5 -0
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +8 -3
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/BARSLASTCOUNT.h +33 -0
- hikyuu/include/hikyuu/indicator/crt/INSUM.h +5 -10
- hikyuu/include/hikyuu/indicator/crt/RSI.h +2 -18
- hikyuu/include/hikyuu/indicator/imp/IBarsLastCount.h +27 -0
- hikyuu/include/hikyuu/plugin/backtest.h +3 -2
- hikyuu/include/hikyuu/plugin/device.h +6 -3
- hikyuu/include/hikyuu/plugin/extind.h +150 -0
- hikyuu/include/hikyuu/plugin/interface/BackTestPluginInterface.h +2 -1
- hikyuu/include/hikyuu/plugin/interface/DevicePluginInterface.h +1 -0
- hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +26 -0
- hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +80 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +4 -0
- hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +7 -5
- hikyuu/include/hikyuu/strategy/Strategy.h +22 -9
- hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +11 -4
- hikyuu/include/hikyuu/trade_manage/Performance.h +17 -9
- hikyuu/include/hikyuu/trade_manage/PositionExtInfo.h +92 -0
- hikyuu/include/hikyuu/trade_manage/PositionRecord.h +7 -1
- hikyuu/include/hikyuu/trade_manage/TradeManager.h +8 -5
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +66 -5
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +9 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +8 -5
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_EqualWeight.h +4 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICIRWeight.h +4 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICWeight.h +4 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_Weight.h +4 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +2 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +2 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +2 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Optimal.h +8 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalEvaluateSelector.h +28 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalSelectorBase.h +1 -0
- hikyuu/include/hikyuu/trade_sys/system/TradeRequest.h +7 -4
- hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardTradeManager.h +17 -13
- hikyuu/include/hikyuu/utilities/DllLoader.h +226 -0
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +20 -0
- hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +6 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +10 -10
- hikyuu/include/hikyuu/utilities/thread/{MQStealThreadPool.h → GlobalMQStealThreadPool.h} +12 -12
- hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +271 -0
- hikyuu/include/hikyuu/utilities/thread/{StealThreadPool.h → GlobalStealThreadPool.h} +11 -10
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +224 -0
- hikyuu/include/hikyuu/utilities/thread/InterruptFlag.h +16 -0
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +40 -77
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +31 -59
- hikyuu/include/hikyuu/utilities/thread/ThreadSafeQueue.h +4 -0
- hikyuu/include/hikyuu/utilities/thread/algorithm.h +9 -9
- hikyuu/include/hikyuu/utilities/thread/thread.h +4 -0
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/plugin/extind.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/trade_manage/__init__.pyi +23 -8
- hikyuu/trade_manage/broker.py +8 -8
- hikyuu/trade_manage/broker.pyi +4 -4
- hikyuu/trade_manage/broker_easytrader.py +3 -3
- hikyuu/trade_manage/broker_easytrader.pyi +2 -2
- hikyuu/trade_manage/broker_mail.py +2 -2
- hikyuu/trade_manage/broker_mail.pyi +2 -2
- hikyuu/trade_manage/trade.pyi +23 -8
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.6.2.dist-info → hikyuu-2.6.5.dist-info}/METADATA +4 -3
- {hikyuu-2.6.2.dist-info → hikyuu-2.6.5.dist-info}/RECORD +136 -121
- {hikyuu-2.6.2.dist-info → hikyuu-2.6.5.dist-info}/LICENSE +0 -0
- {hikyuu-2.6.2.dist-info → hikyuu-2.6.5.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.2.dist-info → hikyuu-2.6.5.dist-info}/entry_points.txt +0 -0
- {hikyuu-2.6.2.dist-info → hikyuu-2.6.5.dist-info}/top_level.txt +0 -0
hikyuu/include/hikyuu/Block.h
CHANGED
|
@@ -43,6 +43,14 @@ public:
|
|
|
43
43
|
return iter;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
bool isNull() const {
|
|
47
|
+
return !m_data;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
uint64_t id() const {
|
|
51
|
+
return m_data ? (uint64_t)m_data.get() : 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
46
54
|
bool operator==(const Block& blk) const {
|
|
47
55
|
return m_data == blk.m_data;
|
|
48
56
|
}
|
|
@@ -145,6 +153,8 @@ public:
|
|
|
145
153
|
/** 设置对应的指数 */
|
|
146
154
|
void setIndexStock(const Stock& stk);
|
|
147
155
|
|
|
156
|
+
uint64_t strongHash() const;
|
|
157
|
+
|
|
148
158
|
private:
|
|
149
159
|
struct HKU_API Data {
|
|
150
160
|
string m_category;
|
|
@@ -170,4 +180,14 @@ HKU_API Block getBlock(const string& category, const string& name);
|
|
|
170
180
|
|
|
171
181
|
} /* namespace hku */
|
|
172
182
|
|
|
183
|
+
namespace std {
|
|
184
|
+
template <>
|
|
185
|
+
class hash<hku::Block> {
|
|
186
|
+
public:
|
|
187
|
+
size_t operator()(hku::Block const& blk) const noexcept {
|
|
188
|
+
return blk.id();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
} // namespace std
|
|
192
|
+
|
|
173
193
|
#endif /* BLOCK_H_ */
|
hikyuu/include/hikyuu/KQuery.h
CHANGED
|
@@ -173,6 +173,14 @@ public:
|
|
|
173
173
|
m_recoverType = recoverType;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* @brief 哈希值(谨慎)
|
|
178
|
+
* @note 由于 end 为 null 时,获取
|
|
179
|
+
* K线数据行为不一致,所以除非知道自己的使用场景,否则勿使用此方法
|
|
180
|
+
* @return size_t
|
|
181
|
+
*/
|
|
182
|
+
uint64_t hash() const;
|
|
183
|
+
|
|
176
184
|
/** 获取queryType名称,用于显示输出 */
|
|
177
185
|
static string getQueryTypeName(QueryType);
|
|
178
186
|
|
|
@@ -37,6 +37,12 @@ public:
|
|
|
37
37
|
const string& code, const Datetime& lastDate, TimeDelta openTime1,
|
|
38
38
|
TimeDelta closeTime1, TimeDelta openTime2, TimeDelta closeTime2);
|
|
39
39
|
|
|
40
|
+
MarketInfo(const MarketInfo&) = default;
|
|
41
|
+
MarketInfo& operator=(const MarketInfo&) = default;
|
|
42
|
+
|
|
43
|
+
MarketInfo(MarketInfo&&);
|
|
44
|
+
MarketInfo& operator=(MarketInfo&&);
|
|
45
|
+
|
|
40
46
|
/** 获取市场简称 */
|
|
41
47
|
const string& market() const {
|
|
42
48
|
return m_market;
|
hikyuu/include/hikyuu/Stock.h
CHANGED
|
@@ -113,6 +113,12 @@ public:
|
|
|
113
113
|
*/
|
|
114
114
|
MarketInfo getMarketInfo(const string& market) const;
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* 获取指定市场代表指数证券
|
|
118
|
+
* @param market 指定的市场标识
|
|
119
|
+
*/
|
|
120
|
+
Stock getMarketStock(const string& market) const;
|
|
121
|
+
|
|
116
122
|
/**
|
|
117
123
|
* 获取相应的证券类型详细信息
|
|
118
124
|
* @param type 证券类型
|
|
@@ -32,6 +32,41 @@ struct StockInfo {
|
|
|
32
32
|
minTradeNumber(0.0),
|
|
33
33
|
maxTradeNumber(0.0) {}
|
|
34
34
|
|
|
35
|
+
StockInfo(const StockInfo&) = default;
|
|
36
|
+
StockInfo& operator=(const StockInfo&) = default;
|
|
37
|
+
|
|
38
|
+
StockInfo(StockInfo&& rhs)
|
|
39
|
+
: market(std::move(rhs.market)),
|
|
40
|
+
code(std::move(rhs.code)),
|
|
41
|
+
name(std::move(rhs.name)),
|
|
42
|
+
type(rhs.type),
|
|
43
|
+
valid(rhs.valid),
|
|
44
|
+
startDate(rhs.startDate),
|
|
45
|
+
endDate(rhs.endDate),
|
|
46
|
+
precision(rhs.precision),
|
|
47
|
+
tick(rhs.tick),
|
|
48
|
+
tickValue(rhs.tickValue),
|
|
49
|
+
minTradeNumber(rhs.minTradeNumber),
|
|
50
|
+
maxTradeNumber(rhs.maxTradeNumber) {}
|
|
51
|
+
|
|
52
|
+
StockInfo& operator=(StockInfo&& rhs) {
|
|
53
|
+
if (this != &rhs) {
|
|
54
|
+
market = std::move(rhs.market);
|
|
55
|
+
code = std::move(rhs.code);
|
|
56
|
+
name = std::move(rhs.name);
|
|
57
|
+
type = rhs.type;
|
|
58
|
+
valid = rhs.valid;
|
|
59
|
+
startDate = rhs.startDate;
|
|
60
|
+
endDate = rhs.endDate;
|
|
61
|
+
precision = rhs.precision;
|
|
62
|
+
tick = rhs.tick;
|
|
63
|
+
tickValue = rhs.tickValue;
|
|
64
|
+
minTradeNumber = rhs.minTradeNumber;
|
|
65
|
+
maxTradeNumber = rhs.maxTradeNumber;
|
|
66
|
+
}
|
|
67
|
+
return *this;
|
|
68
|
+
}
|
|
69
|
+
|
|
35
70
|
static const char* getSelectSQL() {
|
|
36
71
|
return "select c.market, a.code, a.name, a.type, a.valid, a.startDate, a.endDate, b.tick, "
|
|
37
72
|
"b.tickValue, b.precision, b.minTradeNumber, b.maxTradeNumber from stock a, "
|
|
@@ -198,6 +198,11 @@ public:
|
|
|
198
198
|
return !m_imp && m_imp == other.m_imp;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/** 判断指标公式中是否包含指定名称的指标(特殊用途) */
|
|
202
|
+
bool contains(const string& name) const {
|
|
203
|
+
return m_imp ? m_imp->contains(name) : false;
|
|
204
|
+
}
|
|
205
|
+
|
|
201
206
|
string str() const;
|
|
202
207
|
|
|
203
208
|
protected:
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
#include "../config.h"
|
|
13
13
|
#include "../KData.h"
|
|
14
14
|
#include "../utilities/Parameter.h"
|
|
15
|
-
#include "../utilities/thread/
|
|
15
|
+
#include "../utilities/thread/thread.h"
|
|
16
16
|
|
|
17
17
|
namespace hku {
|
|
18
18
|
|
|
@@ -95,6 +95,9 @@ public:
|
|
|
95
95
|
/** 判断是否和另一个指标等效,即计算效果相同 */
|
|
96
96
|
bool alike(const IndicatorImp& other) const;
|
|
97
97
|
|
|
98
|
+
/** 判断指标公式中是否包含指定名称的指标(特殊用途) */
|
|
99
|
+
bool contains(const string& name) const;
|
|
100
|
+
|
|
98
101
|
/**
|
|
99
102
|
* 使用IndicatorImp(const Indicator&...)构造函数后,计算结果使用该函数,
|
|
100
103
|
* 未做越界保护
|
|
@@ -195,9 +198,11 @@ private:
|
|
|
195
198
|
void execute_weave();
|
|
196
199
|
void execute_if();
|
|
197
200
|
|
|
198
|
-
std::vector<IndicatorImpPtr> getAllSubNodes();
|
|
201
|
+
std::vector<IndicatorImpPtr> getAllSubNodes() const;
|
|
199
202
|
void repeatALikeNodes();
|
|
200
203
|
|
|
204
|
+
void _clearBuffer();
|
|
205
|
+
|
|
201
206
|
protected:
|
|
202
207
|
static size_t _get_step_start(size_t pos, size_t step, size_t discard);
|
|
203
208
|
|
|
@@ -224,7 +229,7 @@ public:
|
|
|
224
229
|
static void releaseDynEngine();
|
|
225
230
|
|
|
226
231
|
protected:
|
|
227
|
-
static
|
|
232
|
+
static ThreadPool* ms_tg;
|
|
228
233
|
|
|
229
234
|
#if HKU_SUPPORT_SERIALIZATION
|
|
230
235
|
private:
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-06-01
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef INDICATOR_CRT_BARSLASTCOUNT_H_
|
|
10
|
+
#define INDICATOR_CRT_BARSLASTCOUNT_H_
|
|
11
|
+
|
|
12
|
+
#include "CVAL.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 统计连续满足条件的周期数
|
|
18
|
+
* @details
|
|
19
|
+
* <pre>
|
|
20
|
+
* 用法:BARSLASTCOUNT(X),其中X为条件表达式。
|
|
21
|
+
* 例如:BARSLASTCOUNT(CLOSE>OPEN)表示统计连续收阳的周期数
|
|
22
|
+
* </pre>
|
|
23
|
+
* @ingroup Indicator
|
|
24
|
+
*/
|
|
25
|
+
Indicator HKU_API BARSLASTCOUNT();
|
|
26
|
+
|
|
27
|
+
inline Indicator BARSLASTCOUNT(const Indicator& ind) {
|
|
28
|
+
return BARSLASTCOUNT()(ind);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
} // namespace hku
|
|
32
|
+
|
|
33
|
+
#endif /* INDICATOR_CRT_BARSLASTCOUNT_H_ */
|
|
@@ -12,25 +12,20 @@
|
|
|
12
12
|
namespace hku {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* 返回板块各成分该指标相应输出按计算类型得到的计算值.
|
|
16
|
+
* @note 注意: INSUM使用模式4/5时相当于RANK功能, 但不适合在MF中使用, 在 MF 中使用时计算量为 N x N
|
|
17
|
+
* 级别, 计算缓慢。如果希望在 MF 中使用,建议直接使用 RANK[VIP] 指标。
|
|
16
18
|
* @param block 指定板块
|
|
17
19
|
* @param query 指定范围
|
|
18
20
|
* @param ind 指定指标
|
|
19
|
-
* @param mode 计算类型:0-累加,1-平均数,2-最大值,3
|
|
21
|
+
* @param mode 计算类型:0-累加,1-平均数,2-最大值,3-最小值,4-降序排名(指标值最高的排名值为1)
|
|
22
|
+
* 5-升序排名(指标值最低的排名值为1),
|
|
20
23
|
* @param fill_null 日期对齐时缺失数据填充 nan 值。
|
|
21
24
|
* @return Indicator
|
|
22
25
|
*/
|
|
23
26
|
Indicator HKU_API INSUM(const Block& block, const KQuery& query, const Indicator& ind, int mode,
|
|
24
27
|
bool fill_null = true);
|
|
25
28
|
|
|
26
|
-
/**
|
|
27
|
-
* 返回板块各成分该指标相应输出按计算类型得到的计算值.计算类型:0-累加,1-平均数,2-最大值,3-最小值.
|
|
28
|
-
* @param block 指定板块
|
|
29
|
-
* @param ind 指定指标
|
|
30
|
-
* @param mode 计算类型:0-累加,1-平均数,2-最大值,3-最小值.
|
|
31
|
-
* @param fill_null 日期对齐时缺失数据填充 nan 值。
|
|
32
|
-
* @return Indicator
|
|
33
|
-
*/
|
|
34
29
|
Indicator HKU_API INSUM(const Block& block, const Indicator& ind, int mode, bool fill_null = true);
|
|
35
30
|
|
|
36
31
|
} // namespace hku
|
|
@@ -19,24 +19,8 @@ namespace hku {
|
|
|
19
19
|
* 相对强弱指数
|
|
20
20
|
* @ingroup Indicator
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Indicator u = IF(diff > 0, diff, 0);
|
|
25
|
-
Indicator d = IF(diff < 0, (-1) * diff, 0);
|
|
26
|
-
Indicator ema_u = EMA(u, n);
|
|
27
|
-
Indicator ema_d = EMA(d, n);
|
|
28
|
-
ema_d = IF(ema_d == 0.0, 1, ema_d);
|
|
29
|
-
Indicator rs = ema_u / ema_d;
|
|
30
|
-
Indicator _1 = CVAL(1);
|
|
31
|
-
Indicator rsi = (_1 - _1 / (_1 + rs)) * CVAL(100);
|
|
32
|
-
rsi.name("RSI");
|
|
33
|
-
rsi.setParam<int>("n", n);
|
|
34
|
-
return rsi;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
inline Indicator RSI(const Indicator& data, int n) {
|
|
38
|
-
return RSI(n)(data);
|
|
39
|
-
}
|
|
22
|
+
Indicator HKU_API RSI(int n = 14);
|
|
23
|
+
Indicator HKU_API RSI(const Indicator& data, int n = 14);
|
|
40
24
|
|
|
41
25
|
} // namespace hku
|
|
42
26
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-06-01
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef INDICATOR_IMP_IBARSLASTCOUNT_H_
|
|
10
|
+
#define INDICATOR_IMP_IBARSLASTCOUNT_H_
|
|
11
|
+
|
|
12
|
+
#include "../Indicator.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
/* 统计连续满足条件的周期数 */
|
|
17
|
+
class IBarsLastCount : public IndicatorImp {
|
|
18
|
+
INDICATOR_IMP(IBarsLastCount)
|
|
19
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
20
|
+
|
|
21
|
+
public:
|
|
22
|
+
IBarsLastCount();
|
|
23
|
+
virtual ~IBarsLastCount();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} /* namespace hku */
|
|
27
|
+
#endif /* INDICATOR_IMP_IBARSLASTCOUNT_H_ */
|
|
@@ -21,17 +21,18 @@ namespace hku {
|
|
|
21
21
|
* @param ktype K线类型
|
|
22
22
|
* @param ref_market 所属市场
|
|
23
23
|
* @param mode 模式 0: 当前bar收盘价执行买卖操作;1: 下一bar开盘价执行买卖操作;
|
|
24
|
+
* @param support_short 是否支持做空
|
|
24
25
|
*/
|
|
25
26
|
void HKU_API backtest(const StrategyContext& context, const std::function<void(Strategy*)>& on_bar,
|
|
26
27
|
const TradeManagerPtr& tm, const Datetime& start_date,
|
|
27
28
|
const Datetime& end_date = Null<Datetime>(),
|
|
28
29
|
const KQuery::KType& ktype = KQuery::DAY, const string& ref_market = "SH",
|
|
29
|
-
int mode = 0);
|
|
30
|
+
int mode = 0, bool support_short = false, SlippagePtr slip = SlippagePtr());
|
|
30
31
|
|
|
31
32
|
// 仅在 sm.init 之后使用
|
|
32
33
|
void HKU_API backtest(const std::function<void(Strategy*)>& on_bar, const TradeManagerPtr& tm,
|
|
33
34
|
const Datetime& start_date, const Datetime& end_date = Null<Datetime>(),
|
|
34
35
|
const KQuery::KType& ktype = KQuery::DAY, const string& ref_market = "SH",
|
|
35
|
-
int mode = 0);
|
|
36
|
+
int mode = 0, bool support_short = false, SlippagePtr slip = SlippagePtr());
|
|
36
37
|
|
|
37
38
|
} // namespace hku
|
|
@@ -17,13 +17,16 @@ namespace hku {
|
|
|
17
17
|
*/
|
|
18
18
|
void HKU_API activeDevice(const std::string& active_code);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/** 查看授权信息 */
|
|
21
21
|
std::string HKU_API viewLicense();
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/** 移除授权 */
|
|
24
24
|
void HKU_API removeLicense();
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/** 获取 trial 授权 */
|
|
27
27
|
std::string HKU_API fetchTrialLicense(const std::string& email);
|
|
28
28
|
|
|
29
|
+
/** 检查授权是否有效 */
|
|
30
|
+
bool HKU_API isValidLicense();
|
|
31
|
+
|
|
29
32
|
} // namespace hku
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-05-19
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "hikyuu/indicator/Indicator.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @brief 将指标数据转换到指定周期
|
|
16
|
+
* @param ktype 指定周期
|
|
17
|
+
* @param fill_null 扩展时填充null数据,否则为使用最近值填充
|
|
18
|
+
* @return Indicator
|
|
19
|
+
*/
|
|
20
|
+
Indicator HKU_API WITHKTYPE(const KQuery::KType& ktype, bool fill_null = false);
|
|
21
|
+
|
|
22
|
+
Indicator HKU_API WITHKTYPE(const Indicator& ind, const KQuery::KType& ktype,
|
|
23
|
+
bool fill_null = false);
|
|
24
|
+
|
|
25
|
+
inline Indicator WITHDAY(bool fill_null = false) {
|
|
26
|
+
return WITHKTYPE(KQuery::DAY, fill_null);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
inline Indicator WITHDAY(const Indicator& ind, bool fill_null = false) {
|
|
30
|
+
return WITHKTYPE(ind, KQuery::DAY, fill_null);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
inline Indicator WITHWEEK(bool fill_null = false) {
|
|
34
|
+
return WITHKTYPE(KQuery::WEEK, fill_null);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
inline Indicator WITHWEEK(const Indicator& ind, bool fill_null = false) {
|
|
38
|
+
return WITHKTYPE(ind, KQuery::WEEK, fill_null);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
inline Indicator WITHMONTH(bool fill_null = false) {
|
|
42
|
+
return WITHKTYPE(KQuery::MONTH, fill_null);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
inline Indicator WITHMONTH(const Indicator& ind, bool fill_null = false) {
|
|
46
|
+
return WITHKTYPE(ind, KQuery::MONTH, fill_null);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
inline Indicator WITHQUARTER(bool fill_null = false) {
|
|
50
|
+
return WITHKTYPE(KQuery::QUARTER, fill_null);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
inline Indicator WITHQUARTER(const Indicator& ind, bool fill_null = false) {
|
|
54
|
+
return WITHKTYPE(ind, KQuery::QUARTER, fill_null);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
inline Indicator WITHHALFYEAR(bool fill_null = false) {
|
|
58
|
+
return WITHKTYPE(KQuery::HALFYEAR, fill_null);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
inline Indicator WITHHALFYEAR(const Indicator& ind, bool fill_null = false) {
|
|
62
|
+
return WITHKTYPE(ind, KQuery::HALFYEAR, fill_null);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
inline Indicator WITHYEAR(bool fill_null = false) {
|
|
66
|
+
return WITHKTYPE(KQuery::YEAR, fill_null);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
inline Indicator WITHYEAR(const Indicator& ind, bool fill_null = false) {
|
|
70
|
+
return WITHKTYPE(ind, KQuery::YEAR, fill_null);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
inline Indicator WITHMIN(bool fill_null = false) {
|
|
74
|
+
return WITHKTYPE(KQuery::MIN, fill_null);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
inline Indicator WITHMIN(const Indicator& ind, bool fill_null = false) {
|
|
78
|
+
return WITHKTYPE(ind, KQuery::MIN, fill_null);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
inline Indicator WITHMIN5(bool fill_null = false) {
|
|
82
|
+
return WITHKTYPE(KQuery::MIN5, fill_null);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
inline Indicator WITHMIN5(const Indicator& ind, bool fill_null = false) {
|
|
86
|
+
return WITHKTYPE(ind, KQuery::MIN5, fill_null);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
inline Indicator WITHMIN15(bool fill_null = false) {
|
|
90
|
+
return WITHKTYPE(KQuery::MIN15, fill_null);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
inline Indicator WITHMIN15(const Indicator& ind, bool fill_null = false) {
|
|
94
|
+
return WITHKTYPE(ind, KQuery::MIN15, fill_null);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
inline Indicator WITHMIN30(bool fill_null = false) {
|
|
98
|
+
return WITHKTYPE(KQuery::MIN30, fill_null);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
inline Indicator WITHMIN30(const Indicator& ind, bool fill_null = false) {
|
|
102
|
+
return WITHKTYPE(ind, KQuery::MIN30, fill_null);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
inline Indicator WITHMIN60(bool fill_null = false) {
|
|
106
|
+
return WITHKTYPE(KQuery::MIN60, fill_null);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
inline Indicator WITHMIN60(const Indicator& ind, bool fill_null = false) {
|
|
110
|
+
return WITHKTYPE(ind, KQuery::MIN60, fill_null);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
inline Indicator WITHHOUR(bool fill_null = false) {
|
|
114
|
+
return WITHKTYPE(KQuery::MIN60, fill_null);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
inline Indicator WITHHOUR(const Indicator& ind, bool fill_null = false) {
|
|
118
|
+
return WITHKTYPE(ind, KQuery::MIN60, fill_null);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
inline Indicator WITHHOUR2(bool fill_null = false) {
|
|
122
|
+
return WITHKTYPE(KQuery::HOUR2, fill_null);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
inline Indicator WITHHOUR2(const Indicator& ind, bool fill_null = false) {
|
|
126
|
+
return WITHKTYPE(ind, KQuery::HOUR2, fill_null);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
inline Indicator WITHHOUR4(bool fill_null = false) {
|
|
130
|
+
return WITHKTYPE(KQuery::HOUR4, fill_null);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
inline Indicator WITHHOUR4(const Indicator& ind, bool fill_null = false) {
|
|
134
|
+
return WITHKTYPE(ind, KQuery::HOUR4, fill_null);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @brief 计算指标值在指定板块中的排名
|
|
139
|
+
* @param block 指定板块
|
|
140
|
+
* @param ref_ind 指标
|
|
141
|
+
* @param mode 排名模式,0-降序排名(指标值最高值排名为1), 1-升序排名(指标值越大排名值越大),
|
|
142
|
+
* 2-降序排名百分比, 3-升序排名百分比
|
|
143
|
+
* @param fill_null 是否填充null数据
|
|
144
|
+
* @param market 指定市场(对齐日期)
|
|
145
|
+
* @return Indicator
|
|
146
|
+
*/
|
|
147
|
+
Indicator HKU_API RANK(const Block& block, const Indicator& ref_ind, int mode = 0,
|
|
148
|
+
bool fill_null = true, const string& market = "SH");
|
|
149
|
+
|
|
150
|
+
} // namespace hku
|
|
@@ -20,7 +20,8 @@ public:
|
|
|
20
20
|
virtual void backtest(const StrategyContext& context,
|
|
21
21
|
const std::function<void(Strategy*)>& on_bar, const TradeManagerPtr& tm,
|
|
22
22
|
const Datetime& start_date, const Datetime& end_date,
|
|
23
|
-
const KQuery::KType& ktype, const string& ref_market, int mode
|
|
23
|
+
const KQuery::KType& ktype, const string& ref_market, int mode,
|
|
24
|
+
bool support_short, SlippagePtr slip) = 0;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
} // namespace hku
|
|
@@ -20,6 +20,7 @@ public:
|
|
|
20
20
|
virtual std::string viewLicense() noexcept = 0;
|
|
21
21
|
virtual void removeLicense() noexcept = 0;
|
|
22
22
|
virtual std::string fetchTrialLicense(const std::string& email) noexcept = 0;
|
|
23
|
+
virtual bool isValidLicsense() noexcept = 0;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
} // namespace hku
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-05-19
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "hikyuu/indicator/Indicator.h"
|
|
11
|
+
#include "hikyuu/utilities/plugin/PluginBase.h"
|
|
12
|
+
|
|
13
|
+
namespace hku {
|
|
14
|
+
|
|
15
|
+
class ExtendIndicatorsPluginInterface : public PluginBase {
|
|
16
|
+
public:
|
|
17
|
+
ExtendIndicatorsPluginInterface() = default;
|
|
18
|
+
virtual ~ExtendIndicatorsPluginInterface() = default;
|
|
19
|
+
|
|
20
|
+
virtual Indicator getIndicator(const std::string& name, const Parameter& params) const = 0;
|
|
21
|
+
|
|
22
|
+
virtual Indicator getIndicator(const std::string& name, const Indicator& ref_ind,
|
|
23
|
+
const Parameter& params) const = 0;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
} // namespace hku
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-05-27
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <vector>
|
|
11
|
+
#include "hikyuu/KQuery.h"
|
|
12
|
+
#include "hikyuu/trade_manage/TradeManagerBase.h"
|
|
13
|
+
#include "hikyuu/trade_manage/Performance.h"
|
|
14
|
+
#include "hikyuu/trade_manage/PositionExtInfo.h"
|
|
15
|
+
#include "hikyuu/utilities/plugin/PluginBase.h"
|
|
16
|
+
|
|
17
|
+
namespace hku {
|
|
18
|
+
|
|
19
|
+
class TMReportPluginInterface : public PluginBase {
|
|
20
|
+
public:
|
|
21
|
+
TMReportPluginInterface() = default;
|
|
22
|
+
virtual ~TMReportPluginInterface() = default;
|
|
23
|
+
|
|
24
|
+
// 获取账户截止至指定时刻的最大回撤百分比(包含该时刻)(仅根据收盘价计算)
|
|
25
|
+
virtual price_t getMaxPullBack(const TMPtr& tm, const Datetime& date,
|
|
26
|
+
const KQuery::KType& ktype) = 0;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @brief 获取账户历史持仓扩展详情
|
|
30
|
+
* @param tm 指定账户
|
|
31
|
+
* @param ktype k线类型
|
|
32
|
+
* @param trade_mode 交易模式,影响部分统计项: 0-收盘时交易, 1-下一开盘时交易
|
|
33
|
+
* @return std::vector<PositionExtInfo>
|
|
34
|
+
*/
|
|
35
|
+
virtual std::vector<PositionExtInfo> getHistoryPositionExtInfoList(const TMPtr& tm,
|
|
36
|
+
const KQuery::KType& ktype,
|
|
37
|
+
int trade_mode) = 0;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @brief 获取账户最后交易时刻后持仓详情
|
|
41
|
+
* @param tm 指定账户
|
|
42
|
+
* @param current_time 当前时刻(需大于等于最后交易时刻)
|
|
43
|
+
* @param ktype k线类型
|
|
44
|
+
* @param trade_mode 交易模式,影响部分统计项: 0-收盘时交易, 1-下一开盘时交易
|
|
45
|
+
* @return std::vector<PositionExtInfo>
|
|
46
|
+
*/
|
|
47
|
+
virtual std::vector<PositionExtInfo> getPositionExtInfoList(const TMPtr& tm,
|
|
48
|
+
const Datetime& current_time,
|
|
49
|
+
const KQuery::KType& ktype,
|
|
50
|
+
int trade_mode) = 0;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 统计截至某一时刻的系统绩效, datetime必须大于等于lastDatetime,
|
|
54
|
+
* 以便用于计算当前市值
|
|
55
|
+
* @param tm 指定的交易管理实例
|
|
56
|
+
* @param datetime 统计截止时刻
|
|
57
|
+
*/
|
|
58
|
+
virtual Performance getExtPerformance(const TMPtr& tm, const Datetime& datetime,
|
|
59
|
+
const KQuery::KType& ktype) = 0;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @brief 获取指定截止时间前各月的收益百分比
|
|
63
|
+
* @param tm
|
|
64
|
+
* @param datetime
|
|
65
|
+
* @return std::vector<std::pair<Datetime, double>>
|
|
66
|
+
*/
|
|
67
|
+
virtual std::vector<std::pair<Datetime, double>> getProfitPercentMonthly(
|
|
68
|
+
const TMPtr& tm, const Datetime& datetime) = 0;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @brief 获取指定截止时间前各年的收益百分比
|
|
72
|
+
* @param tm
|
|
73
|
+
* @param datetime
|
|
74
|
+
* @return std::vector<std::pair<Datetime, double>>
|
|
75
|
+
*/
|
|
76
|
+
virtual std::vector<std::pair<Datetime, double>> getProfitPercentYearly(
|
|
77
|
+
const TMPtr& tm, const Datetime& datetime) = 0;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace hku
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
#include "DevicePluginInterface.h"
|
|
12
12
|
#include "DataServerPluginInterface.h"
|
|
13
13
|
#include "ImportKDataToHdf5PluginInterface.h"
|
|
14
|
+
#include "ExtendIndicatorsPluginInterface.h"
|
|
15
|
+
#include "TMReportPluginInterface.h"
|
|
14
16
|
|
|
15
17
|
namespace hku {
|
|
16
18
|
|
|
@@ -18,5 +20,7 @@ namespace hku {
|
|
|
18
20
|
#define HKU_PLUGIN_DEVICE "device"
|
|
19
21
|
#define HKU_PLUGIN_DATASERVER "dataserver"
|
|
20
22
|
#define HKU_PLUGIN_IMPORTKDATATOHDF5 "import2hdf5"
|
|
23
|
+
#define HKU_PLUGIN_EXTEND_INDICATOR "extind"
|
|
24
|
+
#define HKU_PLUGIN_TMREPORT "tmreport"
|
|
21
25
|
|
|
22
26
|
}
|