hikyuu 2.1.3__cp310-none-win_amd64.whl → 2.1.5__cp310-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/cpp/core310.pyd +0 -0
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/data/em_block_to_mysql.py +45 -31
- hikyuu/data/em_block_to_sqlite.py +48 -33
- hikyuu/data/mysql_upgrade/0020.sql +4 -0
- hikyuu/data/mysql_upgrade/0021.sql +4 -0
- hikyuu/data/mysql_upgrade/0022.sql +5 -0
- hikyuu/data/pytdx_to_h5.py +21 -15
- hikyuu/data/pytdx_to_mysql.py +20 -2
- hikyuu/data/pytdx_weight_to_mysql.py +1 -1
- hikyuu/data/pytdx_weight_to_sqlite.py +1 -1
- hikyuu/data/sqlite_upgrade/0021.sql +6 -0
- hikyuu/data/sqlite_upgrade/0022.sql +6 -0
- hikyuu/data/sqlite_upgrade/0023.sql +7 -0
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +57 -9
- hikyuu/fetcher/stock/zh_stock_a_qmt.py +3 -3
- hikyuu/fetcher/stock/zh_stock_a_sina_qq.py +15 -5
- hikyuu/gui/HikyuuTDX.py +1 -1
- hikyuu/gui/data/ImportWeightToSqliteTask.py +18 -27
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +17 -6
- hikyuu/gui/data/UseTdxImportToH5Thread.py +30 -6
- hikyuu/gui/spot_server.py +3 -1
- hikyuu/gui/start_qmt.py +99 -13
- hikyuu/include/hikyuu/KQuery.h +5 -2
- hikyuu/include/hikyuu/KRecord.h +1 -1
- hikyuu/include/hikyuu/Stock.h +1 -1
- hikyuu/include/hikyuu/StockManager.h +26 -20
- hikyuu/include/hikyuu/StrategyContext.h +66 -25
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +1 -0
- hikyuu/include/hikyuu/doc.h +1 -1
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +5 -2
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +28 -6
- hikyuu/include/hikyuu/hikyuu.h +13 -0
- hikyuu/include/hikyuu/indicator/crt/AMA.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/CORR.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -7
- hikyuu/include/hikyuu/indicator/crt/ICIR.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/SMA.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +1 -1
- hikyuu/include/hikyuu/indicator/imp/IDma.h +47 -0
- hikyuu/include/hikyuu/strategy/BrokerTradeManager.h +1 -2
- hikyuu/include/hikyuu/strategy/Strategy.h +15 -4
- hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +3 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +1 -2
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +0 -1
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +1 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/FixedSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorSelector.h +11 -2
- hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorValueSelector.h +19 -2
- hikyuu/include/hikyuu/utilities/Parameter.h +1 -1
- hikyuu/include/hikyuu/utilities/TimerManager.h +2 -2
- hikyuu/include/hikyuu/utilities/arithmetic.h +4 -4
- hikyuu/include/hikyuu/utilities/base64.h +1 -2
- hikyuu/include/hikyuu/utilities/mo/moFileReader.h +2 -2
- hikyuu/include/hikyuu/utilities/node/NodeMessage.h +1 -3
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +6 -7
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/interactive.py +55 -135
- {hikyuu-2.1.3.dist-info → hikyuu-2.1.5.dist-info}/METADATA +1 -1
- {hikyuu-2.1.3.dist-info → hikyuu-2.1.5.dist-info}/RECORD +66 -61
- hikyuu/include/hikyuu/global/GlobalTaskGroup.h +0 -44
- hikyuu/puppet.py +0 -297
- {hikyuu-2.1.3.dist-info → hikyuu-2.1.5.dist-info}/LICENSE +0 -0
- {hikyuu-2.1.3.dist-info → hikyuu-2.1.5.dist-info}/WHEEL +0 -0
- {hikyuu-2.1.3.dist-info → hikyuu-2.1.5.dist-info}/entry_points.txt +0 -0
- {hikyuu-2.1.3.dist-info → hikyuu-2.1.5.dist-info}/top_level.txt +0 -0
hikyuu/include/hikyuu/hikyuu.h
CHANGED
|
@@ -35,6 +35,19 @@ namespace hku {
|
|
|
35
35
|
void HKU_API hikyuu_init(const string& config_file_name, bool ignore_preload = false,
|
|
36
36
|
const StrategyContext& context = StrategyContext({"all"}));
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @brief 尝试从 ini 文件获取配置参数
|
|
40
|
+
* @param config_file_name ini 文件名
|
|
41
|
+
* @param baseParam [out]
|
|
42
|
+
* @param blockParam [out]
|
|
43
|
+
* @param kdataParam [out]
|
|
44
|
+
* @param preloadParam [out]
|
|
45
|
+
* @param hkuParam [out]
|
|
46
|
+
*/
|
|
47
|
+
void HKU_API getConfigFromIni(const string& config_file_name, Parameter& baseParam,
|
|
48
|
+
Parameter& blockParam, Parameter& kdataParam, Parameter& preloadParam,
|
|
49
|
+
Parameter& hkuParam);
|
|
50
|
+
|
|
38
51
|
/** @} */
|
|
39
52
|
|
|
40
53
|
} // namespace hku
|
|
@@ -32,7 +32,7 @@ Indicator HKU_API AMA(const IndParam& n, const IndParam& fast_n, const IndParam&
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* 佩里.J 考夫曼(Perry J.Kaufman)自适应移动平均,参见《精明交易者》(2006年 广东经济出版社)
|
|
35
|
-
* @param
|
|
35
|
+
* @param ind 待计算的数据
|
|
36
36
|
* @param n 计算均值的周期窗口,必须为大于2的整数,默认为10天
|
|
37
37
|
* @param fast_n 对应快速周期N,默认为2
|
|
38
38
|
* @param slow_n 对应慢速EMA线的N值,默认为30,不过当超过60左右该指标会收敛不会有太大的影响
|
|
@@ -18,7 +18,7 @@ namespace hku {
|
|
|
18
18
|
* @param n 滚动窗口 (大于2或等于0),等于0时使用输入的ind实际长度。
|
|
19
19
|
* @ingroup Indicator
|
|
20
20
|
*/
|
|
21
|
-
Indicator HKU_API CORR(int n = 10);
|
|
22
21
|
Indicator HKU_API CORR(const Indicator& ind1, const Indicator& ind2, int n = 10);
|
|
22
|
+
Indicator HKU_API CORR(int n = 10);
|
|
23
23
|
|
|
24
24
|
} // namespace hku
|
|
@@ -27,13 +27,7 @@ namespace hku {
|
|
|
27
27
|
* @param a 动态系数
|
|
28
28
|
* @ingroup Indicator
|
|
29
29
|
*/
|
|
30
|
-
Indicator DMA(const Indicator&
|
|
31
|
-
|
|
32
|
-
inline Indicator DMA(const Indicator& ind1, const Indicator& a) {
|
|
33
|
-
Indicator dma = a * ind1 + (1 - a) * REF(ind1, 1);
|
|
34
|
-
dma.name("DMA");
|
|
35
|
-
return dma;
|
|
36
|
-
}
|
|
30
|
+
Indicator HKU_API DMA(const Indicator& x, const Indicator& a);
|
|
37
31
|
|
|
38
32
|
} // namespace hku
|
|
39
33
|
|
|
@@ -34,7 +34,7 @@ Indicator HKU_API SMA(const IndParam& n, const IndParam& m);
|
|
|
34
34
|
* <pre>
|
|
35
35
|
* 用法:若Y=SMA(X,N,M) 则 Y=[M*X+(N-M)*Y')/N,其中Y'表示上一周期Y值
|
|
36
36
|
* </pre>
|
|
37
|
-
* @param
|
|
37
|
+
* @param ind 待计算的数据
|
|
38
38
|
* @param n 计算均值的周期窗口,必须为大于0的整数
|
|
39
39
|
* @param m 系数
|
|
40
40
|
* @ingroup Indicator
|
|
@@ -17,7 +17,7 @@ namespace hku {
|
|
|
17
17
|
* @param n 滚动窗口(大于2 或 等于0),等于0时,代表 n 实际使用 ind 的长度
|
|
18
18
|
* @ingroup Indicator
|
|
19
19
|
*/
|
|
20
|
-
Indicator HKU_API SPEARMAN(int n = 0);
|
|
21
20
|
Indicator HKU_API SPEARMAN(const Indicator& ind1, const Indicator& ind2, int n = 0);
|
|
21
|
+
Indicator HKU_API SPEARMAN(int n = 0);
|
|
22
22
|
|
|
23
23
|
} // namespace hku
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2024-09-09
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../Indicator.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* 动态移动平均
|
|
16
|
+
* 用法:DMA(X,A),求X的动态移动平均。
|
|
17
|
+
* 算法:若Y=DMA(X,A) 则 Y=A*X+(1-A)*Y',其中Y'表示上一周期Y值。
|
|
18
|
+
* 例如:DMA(CLOSE,VOL/CAPITAL)表示求以换手率作平滑因子的平均价
|
|
19
|
+
*/
|
|
20
|
+
class IDma : public IndicatorImp {
|
|
21
|
+
public:
|
|
22
|
+
IDma();
|
|
23
|
+
explicit IDma(const Indicator& ref_a);
|
|
24
|
+
virtual ~IDma();
|
|
25
|
+
|
|
26
|
+
virtual void _checkParam(const string& name) const override;
|
|
27
|
+
virtual void _calculate(const Indicator& data) override;
|
|
28
|
+
virtual IndicatorImpPtr _clone() override;
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
Indicator m_ref_a;
|
|
32
|
+
|
|
33
|
+
//============================================
|
|
34
|
+
// 序列化支持
|
|
35
|
+
//============================================
|
|
36
|
+
#if HKU_SUPPORT_SERIALIZATION
|
|
37
|
+
private:
|
|
38
|
+
friend class boost::serialization::access;
|
|
39
|
+
template <class Archive>
|
|
40
|
+
void serialize(Archive& ar, const unsigned int version) {
|
|
41
|
+
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(IndicatorImp);
|
|
42
|
+
ar& BOOST_SERIALIZATION_NVP(m_ref_a);
|
|
43
|
+
}
|
|
44
|
+
#endif
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
}
|
|
@@ -181,10 +181,9 @@ public:
|
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
183
|
* 获取指定证券的空头持仓记录
|
|
184
|
-
* @param date 指定日期
|
|
185
184
|
* @param stock 指定的证券
|
|
186
185
|
*/
|
|
187
|
-
virtual PositionRecord getShortPosition(const Stock&) const {
|
|
186
|
+
virtual PositionRecord getShortPosition(const Stock& stock) const {
|
|
188
187
|
HKU_WARN("The subclass does not implement this method");
|
|
189
188
|
return PositionRecord();
|
|
190
189
|
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
namespace hku {
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* @ingroup
|
|
22
|
+
* @ingroup Strategy
|
|
23
23
|
* @{
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -28,6 +28,7 @@ namespace hku {
|
|
|
28
28
|
*/
|
|
29
29
|
class HKU_API Strategy {
|
|
30
30
|
CLASS_LOGGER_IMP(Strategy)
|
|
31
|
+
PARAMETER_SUPPORT_WITH_CHECK
|
|
31
32
|
|
|
32
33
|
public:
|
|
33
34
|
Strategy();
|
|
@@ -37,6 +38,9 @@ public:
|
|
|
37
38
|
explicit Strategy(const StrategyContext& context, const string& name = "Strategy",
|
|
38
39
|
const string& config_file = "");
|
|
39
40
|
|
|
41
|
+
Strategy(const Strategy&) = delete;
|
|
42
|
+
Strategy& operator=(const Strategy&) = delete;
|
|
43
|
+
|
|
40
44
|
virtual ~Strategy();
|
|
41
45
|
|
|
42
46
|
const string& name() const {
|
|
@@ -73,8 +77,7 @@ public:
|
|
|
73
77
|
/**
|
|
74
78
|
* 正确数据发生变化调用,即接收到相应行情数据变更
|
|
75
79
|
* @note 通常用于调试。且只要收到行情采集消息就会触发,不受开、闭市时间限制
|
|
76
|
-
* @param
|
|
77
|
-
* @param spot 接收到的具体数据
|
|
80
|
+
* @param changeFunc 回调函数
|
|
78
81
|
*/
|
|
79
82
|
void onChange(std::function<void(const Stock&, const SpotRecord& spot)>&& changeFunc);
|
|
80
83
|
|
|
@@ -82,13 +85,14 @@ public:
|
|
|
82
85
|
* 一批行情数据接受完毕后通知
|
|
83
86
|
* @note 通常仅用于调试打印,该批行情数据中不一定含有上下文中包含的 stock
|
|
84
87
|
* 且只要收到行情采集消息就会触发,不受开、闭市时间限制。
|
|
88
|
+
* @param recievedFucn 回调函数
|
|
85
89
|
*/
|
|
86
90
|
void onReceivedSpot(std::function<void(const Datetime&)>&& recievedFucn);
|
|
87
91
|
|
|
88
92
|
/**
|
|
89
93
|
* 启动策略执行,必须在已注册相关处理函数后执行
|
|
90
94
|
*/
|
|
91
|
-
void start();
|
|
95
|
+
void start(bool autoRecieveSpot = true);
|
|
92
96
|
|
|
93
97
|
private:
|
|
94
98
|
string m_name;
|
|
@@ -106,6 +110,7 @@ private:
|
|
|
106
110
|
TimeDelta m_run_daily_at_delta;
|
|
107
111
|
|
|
108
112
|
private:
|
|
113
|
+
void _initParam();
|
|
109
114
|
void _init();
|
|
110
115
|
void _receivedSpot(const SpotRecord& spot);
|
|
111
116
|
void _runDaily();
|
|
@@ -170,6 +175,12 @@ void HKU_API runInStrategy(const SYSPtr& sys, const Stock& stk, const KQuery& qu
|
|
|
170
175
|
void HKU_API runInStrategy(const PFPtr& pf, const KQuery& query, int adjust_cycle,
|
|
171
176
|
const OrderBrokerPtr& broker, const TradeCostPtr& costfunc);
|
|
172
177
|
|
|
178
|
+
/**
|
|
179
|
+
* 从 hikyuu 数据缓存服务器拉取更新最新的缓存数据
|
|
180
|
+
* @param addr 缓存服务地址,如: tcp://192.168.1.1:9201
|
|
181
|
+
* @param stklist 待更新的股票列表
|
|
182
|
+
* @param ktype 指定更新的K线类型
|
|
183
|
+
*/
|
|
173
184
|
void HKU_API getDataFromBufferServer(const std::string& addr, const StockList& stklist,
|
|
174
185
|
const KQuery::KType& ktype);
|
|
175
186
|
|
|
@@ -134,6 +134,9 @@ public:
|
|
|
134
134
|
* @param code 证券代码
|
|
135
135
|
* @param price 卖出价格
|
|
136
136
|
* @param num 卖出数量
|
|
137
|
+
* @param stoploss 新预期的止损价
|
|
138
|
+
* @param goalPrice 新预期的目标价位
|
|
139
|
+
* @param from 系统部件来源
|
|
137
140
|
*/
|
|
138
141
|
virtual void _sell(Datetime datetime, const string& market, const string& code, price_t price,
|
|
139
142
|
double num, price_t stoploss, price_t goalPrice, SystemPart from) = 0;
|
|
@@ -442,10 +442,9 @@ public:
|
|
|
442
442
|
|
|
443
443
|
/**
|
|
444
444
|
* 获取指定证券的空头持仓记录
|
|
445
|
-
* @param date 指定日期
|
|
446
445
|
* @param stock 指定的证券
|
|
447
446
|
*/
|
|
448
|
-
virtual PositionRecord getShortPosition(const Stock&) const {
|
|
447
|
+
virtual PositionRecord getShortPosition(const Stock& stock) const {
|
|
449
448
|
HKU_WARN("The subclass does not implement this method");
|
|
450
449
|
return PositionRecord();
|
|
451
450
|
}
|
|
@@ -47,7 +47,6 @@ public:
|
|
|
47
47
|
* @param date 指定日期
|
|
48
48
|
* @param se_list 系统实例选择器选出的系统实例
|
|
49
49
|
* @param running_list 当前运行中的系统实例
|
|
50
|
-
* @param ignore_list 忽略不进行调仓的运行中系统
|
|
51
50
|
* @return 需延迟执行卖出操作的系统列表,其中权重为相应需卖出的数量
|
|
52
51
|
*/
|
|
53
52
|
SystemWeightList adjustFunds(const Datetime& date, const SystemWeightList& se_list,
|
|
@@ -14,7 +14,7 @@ namespace hku {
|
|
|
14
14
|
class HKU_API OperatorSelector : public SelectorBase {
|
|
15
15
|
public:
|
|
16
16
|
OperatorSelector();
|
|
17
|
-
OperatorSelector(const string& name);
|
|
17
|
+
explicit OperatorSelector(const string& name);
|
|
18
18
|
OperatorSelector(const string& name, const SelectorPtr& se1, const SelectorPtr& se2);
|
|
19
19
|
virtual ~OperatorSelector();
|
|
20
20
|
|
|
@@ -43,6 +43,7 @@ protected:
|
|
|
43
43
|
protected:
|
|
44
44
|
static void sortSystemWeightList(SystemWeightList& swlist);
|
|
45
45
|
|
|
46
|
+
void build();
|
|
46
47
|
void cloneRebuild(const SelectorPtr& se1, const SelectorPtr& se2);
|
|
47
48
|
|
|
48
49
|
protected:
|
|
@@ -63,11 +64,19 @@ private:
|
|
|
63
64
|
#if HKU_SUPPORT_SERIALIZATION
|
|
64
65
|
friend class boost::serialization::access;
|
|
65
66
|
template <class Archive>
|
|
66
|
-
void
|
|
67
|
+
void save(Archive& ar, const unsigned int version) const {
|
|
67
68
|
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase);
|
|
68
69
|
ar& BOOST_SERIALIZATION_NVP(m_se1);
|
|
69
70
|
ar& BOOST_SERIALIZATION_NVP(m_se2);
|
|
70
71
|
}
|
|
72
|
+
|
|
73
|
+
template <class Archive>
|
|
74
|
+
void load(Archive& ar, const unsigned int version) {
|
|
75
|
+
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase);
|
|
76
|
+
ar& BOOST_SERIALIZATION_NVP(m_se1);
|
|
77
|
+
ar& BOOST_SERIALIZATION_NVP(m_se2);
|
|
78
|
+
build();
|
|
79
|
+
}
|
|
71
80
|
#endif
|
|
72
81
|
};
|
|
73
82
|
|
|
@@ -14,7 +14,7 @@ namespace hku {
|
|
|
14
14
|
class HKU_API OperatorValueSelector : public SelectorBase {
|
|
15
15
|
public:
|
|
16
16
|
OperatorValueSelector();
|
|
17
|
-
OperatorValueSelector(const string& name);
|
|
17
|
+
explicit OperatorValueSelector(const string& name);
|
|
18
18
|
OperatorValueSelector(const string& name, const SelectorPtr& se, double value);
|
|
19
19
|
virtual ~OperatorValueSelector();
|
|
20
20
|
|
|
@@ -36,12 +36,29 @@ private:
|
|
|
36
36
|
//============================================
|
|
37
37
|
#if HKU_SUPPORT_SERIALIZATION
|
|
38
38
|
friend class boost::serialization::access;
|
|
39
|
+
// template <class Archive>
|
|
40
|
+
// void serialize(Archive& ar, const unsigned int version) {
|
|
41
|
+
// ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase);
|
|
42
|
+
// ar& BOOST_SERIALIZATION_NVP(m_se);
|
|
43
|
+
// ar& BOOST_SERIALIZATION_NVP(m_value);
|
|
44
|
+
// }
|
|
39
45
|
template <class Archive>
|
|
40
|
-
void
|
|
46
|
+
void save(Archive& ar, const unsigned int version) const {
|
|
41
47
|
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase);
|
|
42
48
|
ar& BOOST_SERIALIZATION_NVP(m_se);
|
|
43
49
|
ar& BOOST_SERIALIZATION_NVP(m_value);
|
|
44
50
|
}
|
|
51
|
+
|
|
52
|
+
template <class Archive>
|
|
53
|
+
void load(Archive& ar, const unsigned int version) {
|
|
54
|
+
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(SelectorBase);
|
|
55
|
+
ar& BOOST_SERIALIZATION_NVP(m_se);
|
|
56
|
+
ar& BOOST_SERIALIZATION_NVP(m_value);
|
|
57
|
+
if (m_se) {
|
|
58
|
+
m_pro_sys_list = m_se->getProtoSystemList();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
45
62
|
#endif
|
|
46
63
|
};
|
|
47
64
|
|
|
@@ -365,7 +365,7 @@ public: \
|
|
|
365
365
|
* 子类需要实现重载以下虚函数接口:
|
|
366
366
|
* virtual void _checkParam(const string& name) const
|
|
367
367
|
* 基类需要实现以下接口:
|
|
368
|
-
* void baseCheckParam(const string& name)
|
|
368
|
+
* void baseCheckParam(const string& name) const
|
|
369
369
|
* void paramChanged()
|
|
370
370
|
* 另:python 中一般不需要引出 paramChanged/checkParam/_checkParam,python
|
|
371
371
|
* 类继承时可以自己在初始化时进行检查
|
|
@@ -196,7 +196,7 @@ public:
|
|
|
196
196
|
* @param start_time 允许运行的起始时间
|
|
197
197
|
* @param end_time 允许运行的结束时间
|
|
198
198
|
* @param repeat_num 重复次数,必须大于0,等于std::numeric_limits<int>::max()时表示无限循环
|
|
199
|
-
* @param
|
|
199
|
+
* @param duration 间隔时间,需大于 TimeDelta(0)
|
|
200
200
|
* @param f 待执行的延迟任务
|
|
201
201
|
* @param args 任务具体参数
|
|
202
202
|
* @return timer id
|
|
@@ -226,7 +226,7 @@ public:
|
|
|
226
226
|
* @tparam F 任务类型
|
|
227
227
|
* @tparam Args 任务参数
|
|
228
228
|
* @param repeat_num 重复次数,必须大于0,等于std::numeric_limits<int>::max()时表示无限循环
|
|
229
|
-
* @param
|
|
229
|
+
* @param duration 间隔时间,需大于 TimeDelta(0)
|
|
230
230
|
* @param f 待执行的延迟任务
|
|
231
231
|
* @param args 任务具体参数
|
|
232
232
|
* @return timer id
|
|
@@ -316,7 +316,7 @@ inline std::vector<std::string> split(const std::string &str, const std::string
|
|
|
316
316
|
|
|
317
317
|
/**
|
|
318
318
|
* byte 转 16 进制字符串, 如 "abcd" 转换为 "61626364"
|
|
319
|
-
* @param
|
|
319
|
+
* @param bytes 输入的 byte 数组
|
|
320
320
|
* @param in_len byte 数组长度
|
|
321
321
|
*/
|
|
322
322
|
inline std::string byteToHexStr(const char *bytes, size_t in_len) {
|
|
@@ -345,7 +345,7 @@ inline std::string byteToHexStr(const char *bytes, size_t in_len) {
|
|
|
345
345
|
|
|
346
346
|
/**
|
|
347
347
|
* byte 转 16 进制字符串, 如 "abcd" 转换为 "61626364"
|
|
348
|
-
* @param
|
|
348
|
+
* @param bytes std::string 格式的输入
|
|
349
349
|
*/
|
|
350
350
|
inline std::string byteToHexStr(const std::string &bytes) {
|
|
351
351
|
return byteToHexStr(bytes.c_str(), bytes.size());
|
|
@@ -353,7 +353,7 @@ inline std::string byteToHexStr(const std::string &bytes) {
|
|
|
353
353
|
|
|
354
354
|
/**
|
|
355
355
|
* byte 转 16 进制字符串, 如 "abcd" 转换为 "0x61 0x62 0x63 0x64"
|
|
356
|
-
* @param
|
|
356
|
+
* @param bytes 输入的 byte 数组
|
|
357
357
|
* @param in_len byte 数组长度
|
|
358
358
|
*/
|
|
359
359
|
inline std::string byteToHexStrForPrint(const char *bytes, size_t in_len) {
|
|
@@ -389,7 +389,7 @@ inline std::string byteToHexStrForPrint(const char *bytes, size_t in_len) {
|
|
|
389
389
|
|
|
390
390
|
/**
|
|
391
391
|
* byte 转 16 进制字符串, 如 "abcd" 转换为 "61626364"
|
|
392
|
-
* @param
|
|
392
|
+
* @param bytes 输入的 byte 数组
|
|
393
393
|
*/
|
|
394
394
|
inline std::string byteToHexStrForPrint(const std::string &bytes) {
|
|
395
395
|
return byteToHexStrForPrint(bytes.c_str(), bytes.size());
|
|
@@ -27,8 +27,7 @@ std::string HKU_UTILS_API base64_encode(unsigned char const* bytes_to_encode, si
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* 字符串编码为 base64
|
|
30
|
-
* @param
|
|
31
|
-
* @param in_len 待计算的字节长度
|
|
30
|
+
* @param src 输入字符串
|
|
32
31
|
* @note 通过 func(unsigned char *, unsigned int) 函数实现,而不是直接只提供 string_view
|
|
33
32
|
* 版本的原因是:c++17 string_view 处理 nullptr 时,程序会直接挂掉,无异常
|
|
34
33
|
*/
|
|
@@ -342,7 +342,7 @@ public:
|
|
|
342
342
|
};
|
|
343
343
|
|
|
344
344
|
/** \brief Reads a .mo-file
|
|
345
|
-
* \param[in]
|
|
345
|
+
* \param[in] data The path to the file to load.
|
|
346
346
|
* \return SUCCESS on success or one of the other error-codes in eErrorCode on error.
|
|
347
347
|
*
|
|
348
348
|
* This is the core-feature. This method loads the .mo-file and stores
|
|
@@ -357,7 +357,7 @@ public:
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
/** \brief Reads a .mo-file
|
|
360
|
-
* \param[in]
|
|
360
|
+
* \param[in] filename The path to the file to load.
|
|
361
361
|
* \return SUCCESS on success or one of the other error-codes in eErrorCode on error.
|
|
362
362
|
*
|
|
363
363
|
* This is the core-feature. This method loads the .mo-file and stores
|
|
@@ -37,8 +37,6 @@ namespace hku {
|
|
|
37
37
|
* 对消息进行解码,消息类型和消息体必须匹配
|
|
38
38
|
* @tparam T 消息体类型
|
|
39
39
|
* @param msg 消息
|
|
40
|
-
* @param out 解码输出的消息
|
|
41
|
-
* @exception yas::io_exception 消息解码失败
|
|
42
40
|
* @exception NodeErrorCode 消息类型不匹配
|
|
43
41
|
*/
|
|
44
42
|
inline json decodeMsg(nng_msg *msg) {
|
|
@@ -68,7 +66,7 @@ inline void encodeMsg(nng_msg *msg, const json &in) {
|
|
|
68
66
|
|
|
69
67
|
/**
|
|
70
68
|
* 构造错误消息响应
|
|
71
|
-
* @param msg[out] 消息
|
|
69
|
+
* @param msg [out] 消息
|
|
72
70
|
* @param errcode 错误码
|
|
73
71
|
* @param errmsg 错误消息
|
|
74
72
|
*/
|
|
@@ -47,10 +47,9 @@ public:
|
|
|
47
47
|
* 构造函数,创建指定数量的线程
|
|
48
48
|
* @param n 指定的线程数
|
|
49
49
|
* @param until_empty 任务队列为空时,自动停止运行
|
|
50
|
-
* @param exit_thread_callback 工作线程结束时回调函数
|
|
51
50
|
*/
|
|
52
|
-
explicit MQStealThreadPool(size_t n, bool
|
|
53
|
-
: m_done(false), m_worker_num(n),
|
|
51
|
+
explicit MQStealThreadPool(size_t n, bool until_empty = true)
|
|
52
|
+
: m_done(false), m_worker_num(n), m_runnging_until_empty(until_empty) {
|
|
54
53
|
try {
|
|
55
54
|
m_interrupt_flags.resize(m_worker_num, nullptr);
|
|
56
55
|
for (size_t i = 0; i < m_worker_num; i++) {
|
|
@@ -189,7 +188,7 @@ public:
|
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
// 指示各工作线程在未获取到工作任务时,停止运行
|
|
192
|
-
if (
|
|
191
|
+
if (m_runnging_until_empty) {
|
|
193
192
|
while (true) {
|
|
194
193
|
bool can_quit = true;
|
|
195
194
|
for (size_t i = 0; i < m_worker_num; i++) {
|
|
@@ -234,9 +233,9 @@ public:
|
|
|
234
233
|
|
|
235
234
|
private:
|
|
236
235
|
typedef FuncWrapper task_type;
|
|
237
|
-
std::atomic_bool m_done;
|
|
238
|
-
size_t m_worker_num;
|
|
239
|
-
bool
|
|
236
|
+
std::atomic_bool m_done; // 线程池全局需终止指示
|
|
237
|
+
size_t m_worker_num; // 工作线程数量
|
|
238
|
+
bool m_runnging_until_empty; // 运行直到队列空时停止
|
|
240
239
|
|
|
241
240
|
std::vector<std::unique_ptr<MQStealQueue<task_type>>> m_queues; // 线程任务队列
|
|
242
241
|
std::vector<InterruptFlag*> m_interrupt_flags; // 线程终止标志
|
hikyuu/include/hikyuu/version.h
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
#define HKU_VERSION_H
|
|
13
13
|
|
|
14
14
|
// clang-format off
|
|
15
|
-
#define HKU_VERSION "2.1.
|
|
15
|
+
#define HKU_VERSION "2.1.5"
|
|
16
16
|
#define HKU_VERSION_MAJOR 2
|
|
17
17
|
#define HKU_VERSION_MINOR 1
|
|
18
|
-
#define HKU_VERSION_ALTER
|
|
19
|
-
#define HKU_VERSION_BUILD
|
|
18
|
+
#define HKU_VERSION_ALTER 5
|
|
19
|
+
#define HKU_VERSION_BUILD 202409110737
|
|
20
20
|
#define HKU_VERSION_MODE "RELEASE"
|
|
21
|
-
#define HKU_VERSION_GIT "2.1.
|
|
21
|
+
#define HKU_VERSION_GIT "2.1.5 release.6f6597d9 (RELEASE)"
|
|
22
22
|
// clang-format on
|
|
23
23
|
|
|
24
24
|
#endif /* HKU_VERSION_H */
|