hikyuu 2.1.1__cp312-none-win_amd64.whl → 2.1.3__cp312-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.
Files changed (58) hide show
  1. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  2. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  3. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  4. hikyuu/cpp/core312.pyd +0 -0
  5. hikyuu/cpp/hikyuu.dll +0 -0
  6. hikyuu/cpp/sqlite3.dll +0 -0
  7. hikyuu/data/mysql_upgrade/0019.sql +6 -0
  8. hikyuu/data/sqlite_upgrade/0020.sql +4 -0
  9. hikyuu/examples/notebook/006-TradeManager.ipynb +41 -39
  10. hikyuu/examples/notebook/008-Pickle.ipynb +27 -35
  11. hikyuu/fetcher/stock/zh_stock_a_qmt.py +58 -0
  12. hikyuu/gui/HikyuuTDX.py +2 -1
  13. hikyuu/gui/data/MainWindow.py +126 -126
  14. hikyuu/gui/spot_server.py +16 -7
  15. hikyuu/gui/start_qmt.py +36 -0
  16. hikyuu/include/hikyuu/Stock.h +1 -1
  17. hikyuu/include/hikyuu/StrategyContext.h +7 -2
  18. hikyuu/include/hikyuu/data_driver/base_info/table/HistoryFinanceTable.h +2 -2
  19. hikyuu/include/hikyuu/doc.h +2 -2
  20. hikyuu/include/hikyuu/global/GlobalSpotAgent.h +1 -0
  21. hikyuu/include/hikyuu/global/GlobalTaskGroup.h +4 -2
  22. hikyuu/include/hikyuu/global/SpotRecord.h +52 -0
  23. hikyuu/include/hikyuu/global/agent/SpotAgent.h +14 -41
  24. hikyuu/include/hikyuu/hikyuu.h +1 -0
  25. hikyuu/include/hikyuu/strategy/{AccountTradeManager.h → BrokerTradeManager.h} +98 -98
  26. hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +36 -0
  27. hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +37 -0
  28. hikyuu/include/hikyuu/strategy/Strategy.h +177 -0
  29. hikyuu/include/hikyuu/trade_manage/FundsRecord.h +8 -8
  30. hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +66 -14
  31. hikyuu/include/hikyuu/trade_manage/PositionRecord.h +12 -12
  32. hikyuu/include/hikyuu/trade_manage/TradeManager.h +9 -0
  33. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +19 -0
  34. hikyuu/include/hikyuu/utilities/TimerManager.h +23 -9
  35. hikyuu/include/hikyuu/utilities/arithmetic.h +2 -2
  36. hikyuu/include/hikyuu/utilities/config.h +1 -1
  37. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +1 -0
  38. hikyuu/include/hikyuu/utilities/exception.h +15 -17
  39. hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +1 -1
  40. hikyuu/include/hikyuu/utilities/mo/moFileReader.h +1 -1
  41. hikyuu/include/hikyuu/version.h +4 -4
  42. hikyuu/interactive.py +46 -137
  43. hikyuu/strategy/__init__.py +0 -1
  44. hikyuu/strategy/strategy_demo1.py +53 -0
  45. hikyuu/strategy/strategy_demo2.py +47 -0
  46. hikyuu/strategy/strategy_demo3.py +24 -0
  47. hikyuu/trade_manage/broker.py +27 -11
  48. hikyuu/trade_manage/broker_easytrader.py +52 -6
  49. hikyuu/trade_manage/broker_mail.py +17 -20
  50. {hikyuu-2.1.1.dist-info → hikyuu-2.1.3.dist-info}/METADATA +1 -1
  51. {hikyuu-2.1.1.dist-info → hikyuu-2.1.3.dist-info}/RECORD +55 -47
  52. {hikyuu-2.1.1.dist-info → hikyuu-2.1.3.dist-info}/top_level.txt +0 -1
  53. hikyuu/include/hikyuu/strategy/StrategyBase.h +0 -156
  54. hikyuu/strategy/demo/__init__.py +0 -3
  55. hikyuu/strategy/strategy.py +0 -27
  56. {hikyuu-2.1.1.dist-info → hikyuu-2.1.3.dist-info}/LICENSE +0 -0
  57. {hikyuu-2.1.1.dist-info → hikyuu-2.1.3.dist-info}/WHEEL +0 -0
  58. {hikyuu-2.1.1.dist-info → hikyuu-2.1.3.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,177 @@
1
+ /*
2
+ * Copyright(C) 2021 hikyuu.org
3
+ *
4
+ * Create on: 2021-02-16
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <future>
11
+ #include "hikyuu/DataType.h"
12
+ #include "hikyuu/StrategyContext.h"
13
+ #include "hikyuu/global/SpotRecord.h"
14
+ #include "hikyuu/utilities/thread/FuncWrapper.h"
15
+ #include "hikyuu/utilities/thread/ThreadSafeQueue.h"
16
+ #include "hikyuu/trade_sys/portfolio/Portfolio.h"
17
+ #include "BrokerTradeManager.h"
18
+
19
+ namespace hku {
20
+
21
+ /**
22
+ * @ingroup Stratgy
23
+ * @{
24
+ */
25
+
26
+ /**
27
+ * @brief 策略运行时
28
+ */
29
+ class HKU_API Strategy {
30
+ CLASS_LOGGER_IMP(Strategy)
31
+
32
+ public:
33
+ Strategy();
34
+ explicit Strategy(const string& name, const string& config_file = "");
35
+ Strategy(const vector<string>& codeList, const vector<KQuery::KType>& ktypeList,
36
+ const string& name = "Strategy", const string& config_file = "");
37
+ explicit Strategy(const StrategyContext& context, const string& name = "Strategy",
38
+ const string& config_file = "");
39
+
40
+ virtual ~Strategy();
41
+
42
+ const string& name() const {
43
+ return m_name;
44
+ }
45
+
46
+ void name(const string& name) {
47
+ m_name = name;
48
+ }
49
+
50
+ const StrategyContext& context() const {
51
+ return m_context;
52
+ }
53
+
54
+ /**
55
+ * 每日开盘时间内,以 delta 为周期循环定时执行指定任务
56
+ * @param func 待执行的任务
57
+ * @param delta 间隔时间
58
+ * @param market 指定的市场
59
+ * @param ignoreMarket 是否忽略市场时间限制,如为 true,则为定时循环不受开闭市时间限制
60
+ */
61
+ void runDaily(std::function<void()>&& func, const TimeDelta& delta,
62
+ const std::string& market = "SH", bool ignoreMarket = false);
63
+
64
+ /**
65
+ * 每日在指定时刻执行任务
66
+ * @param func 待执行的任务
67
+ * @param delta 指定时刻
68
+ * @param ignoreHoliday 忽略节假日,即节假日不执行
69
+ */
70
+ void runDailyAt(std::function<void()>&& func, const TimeDelta& delta,
71
+ bool ignoreHoliday = true);
72
+
73
+ /**
74
+ * 正确数据发生变化调用,即接收到相应行情数据变更
75
+ * @note 通常用于调试。且只要收到行情采集消息就会触发,不受开、闭市时间限制
76
+ * @param stk 数据发生变化的 stock
77
+ * @param spot 接收到的具体数据
78
+ */
79
+ void onChange(std::function<void(const Stock&, const SpotRecord& spot)>&& changeFunc);
80
+
81
+ /**
82
+ * 一批行情数据接受完毕后通知
83
+ * @note 通常仅用于调试打印,该批行情数据中不一定含有上下文中包含的 stock
84
+ * 且只要收到行情采集消息就会触发,不受开、闭市时间限制。
85
+ */
86
+ void onReceivedSpot(std::function<void(const Datetime&)>&& recievedFucn);
87
+
88
+ /**
89
+ * 启动策略执行,必须在已注册相关处理函数后执行
90
+ */
91
+ void start();
92
+
93
+ private:
94
+ string m_name;
95
+ string m_config_file;
96
+ StrategyContext m_context;
97
+ std::function<void(const Datetime&)> m_on_recieved_spot;
98
+ std::function<void(const Stock&, const SpotRecord& spot)> m_on_change;
99
+
100
+ std::function<void()> m_run_daily_func;
101
+ TimeDelta m_run_daily_delta;
102
+ string m_run_daily_market;
103
+ bool m_ignoreMarket{false};
104
+
105
+ std::function<void()> m_run_daily_at_func;
106
+ TimeDelta m_run_daily_at_delta;
107
+
108
+ private:
109
+ void _init();
110
+ void _receivedSpot(const SpotRecord& spot);
111
+ void _runDaily();
112
+ void _runDailyAt();
113
+
114
+ private:
115
+ static std::atomic_bool ms_keep_running;
116
+ static void sig_handler(int sig);
117
+
118
+ typedef FuncWrapper event_type;
119
+ ThreadSafeQueue<event_type> m_event_queue; // 消息队列
120
+
121
+ /** 先消息队列提交任务后返回的对应 future 的类型 */
122
+ template <typename ResultType>
123
+ using event_handle = std::future<ResultType>;
124
+
125
+ #ifdef _MSC_VER
126
+ #pragma warning(push)
127
+ #pragma warning(disable : 4996)
128
+ #endif
129
+
130
+ /** 向线程池提交任务 */
131
+ template <typename FunctionType>
132
+ event_handle<typename std::result_of<FunctionType()>::type> event(FunctionType f) {
133
+ typedef typename std::result_of<FunctionType()>::type result_type;
134
+ std::packaged_task<result_type()> task(f);
135
+ event_handle<result_type> res(task.get_future());
136
+ m_event_queue.push(std::move(task));
137
+ return res;
138
+ }
139
+
140
+ #ifdef _MSC_VER
141
+ #pragma warning(pop)
142
+ #endif
143
+
144
+ void _startEventLoop();
145
+ };
146
+
147
+ typedef shared_ptr<Strategy> StrategyPtr;
148
+
149
+ /**
150
+ * @brief 在策略运行时中执行系统交易 SYS
151
+ * @note 目前仅支持 buy_delay| sell_delay 均为 false 的系统,即 close 时执行交易
152
+ * @param sys 交易系统
153
+ * @param stk 交易对象
154
+ * @param query 查询条件
155
+ * @param broker 订单代理
156
+ * @param costfunc 成本函数
157
+ */
158
+ void HKU_API runInStrategy(const SYSPtr& sys, const Stock& stk, const KQuery& query,
159
+ const OrderBrokerPtr& broker, const TradeCostPtr& costfunc);
160
+
161
+ /**
162
+ * @brief 在策略运行时中执行组合策略 PF
163
+ * @note 目前仅支持 buy_delay| sell_delay 均为 false 的系统,即 close 时执行交易
164
+ * @param pf 资产组合
165
+ * @param query 查询条件
166
+ * @param adjust_cycle 调仓周期
167
+ * @param broker 订单代理
168
+ * @param costfunc 成本函数
169
+ */
170
+ void HKU_API runInStrategy(const PFPtr& pf, const KQuery& query, int adjust_cycle,
171
+ const OrderBrokerPtr& broker, const TradeCostPtr& costfunc);
172
+
173
+ void HKU_API getDataFromBufferServer(const std::string& addr, const StockList& stklist,
174
+ const KQuery::KType& ktype);
175
+
176
+ /** @} */
177
+ } // namespace hku
@@ -20,17 +20,17 @@ namespace hku {
20
20
  */
21
21
  class HKU_API FundsRecord {
22
22
  public:
23
- FundsRecord();
23
+ FundsRecord() = default;
24
24
  FundsRecord(price_t cash, price_t market_value, price_t short_market_value, price_t base_cash,
25
25
  price_t base_asset, price_t borrow_cash, price_t borrow_asset);
26
26
 
27
- price_t cash; /**< 当前现金 */
28
- price_t market_value; /**< 当前多头市值 */
29
- price_t short_market_value; /**< 当前空头仓位市值 */
30
- price_t base_cash; /**< 当前投入本金principal */
31
- price_t base_asset; /**< 当前投入的资产价值 */
32
- price_t borrow_cash; /**< 当前借入的资金,即负债 */
33
- price_t borrow_asset; /**< 当前借入证券资产价值 */
27
+ price_t cash{0.0}; /**< 当前现金 */
28
+ price_t market_value{0.0}; /**< 当前多头市值 */
29
+ price_t short_market_value{0.0}; /**< 当前空头仓位市值 */
30
+ price_t base_cash{0.0}; /**< 当前投入本金principal */
31
+ price_t base_asset{0.0}; /**< 当前投入的资产价值 */
32
+ price_t borrow_cash{0.0}; /**< 当前借入的资金,即负债 */
33
+ price_t borrow_asset{0.0}; /**< 当前借入证券资产价值 */
34
34
 
35
35
  // 当前总资产 = 现金 + 多头市值 + 空头数量×(借入价格 - 当前价格)
36
36
  // = cash + market_value + borrow_asset - short_market_value
@@ -11,9 +11,28 @@
11
11
 
12
12
  #include "../DataType.h"
13
13
  #include "../utilities/Parameter.h"
14
+ #include "../trade_sys/system/SystemPart.h"
14
15
 
15
16
  namespace hku {
16
17
 
18
+ struct HKU_API BrokerPositionRecord {
19
+ Stock stock;
20
+ price_t number{0.0}; // 数量
21
+ price_t money{0.0}; // 买入花费总资金
22
+
23
+ BrokerPositionRecord() = default;
24
+ BrokerPositionRecord(const Stock& stock, price_t number, price_t money);
25
+ BrokerPositionRecord(const BrokerPositionRecord&) = default;
26
+ BrokerPositionRecord(BrokerPositionRecord&& rv);
27
+
28
+ BrokerPositionRecord& operator=(const BrokerPositionRecord&) = default;
29
+ BrokerPositionRecord& operator=(BrokerPositionRecord&& rv);
30
+
31
+ string str() const;
32
+ };
33
+
34
+ HKU_API std::ostream& operator<<(std::ostream& os, const BrokerPositionRecord&);
35
+
17
36
  /**
18
37
  * 订单代理基类,实现实际的订单操作及程序化的订单。
19
38
  * @details 可通过向 TradeManager.regBroker 向 TradeManager 注册多个订单代理实例。
@@ -49,10 +68,12 @@ public:
49
68
  * @param code 证券代码
50
69
  * @param price 买入价格
51
70
  * @param num 买入数量
52
- * @return 操作执行的时刻。实盘时,应返回委托单时间或服务器交易时间。
71
+ * @param stoploss 预期的止损价
72
+ * @param goalPrice 预期的目标价位
73
+ * @param from 系统部件来源
53
74
  */
54
- Datetime buy(Datetime datetime, const string& market, const string& code, price_t price,
55
- double num);
75
+ void buy(Datetime datetime, const string& market, const string& code, price_t price, double num,
76
+ price_t stoploss, price_t goalPrice, SystemPart from) noexcept;
56
77
 
57
78
  /**
58
79
  * 执行卖出操作
@@ -61,34 +82,65 @@ public:
61
82
  * @param code 证券代码
62
83
  * @param price 卖出价格
63
84
  * @param num 卖出数量
64
- * @return 操作执行的时刻。实盘时,应返回委托单时间或服务器交易时间。
85
+ * @param stoploss 新的预期止损价
86
+ * @param goalPrice 新的预期目标价位
87
+ * @param from 系统部件来源
65
88
  */
66
- Datetime sell(Datetime datetime, const string& market, const string& code, price_t price,
67
- double num);
89
+ void sell(Datetime datetime, const string& market, const string& code, price_t price,
90
+ double num, price_t stoploss, price_t goalPrice, SystemPart from) noexcept;
68
91
 
69
92
  /**
70
- * 执行实际买入操作
93
+ * 获取当前资产信息
94
+ * @return string json字符串
95
+ * <pre>
96
+ * 接口规范:
97
+ * {
98
+ * "datetime": "2001-01-01 18:00:00.12345",
99
+ * "cash": 0.0,
100
+ * "positions": [
101
+ * {"market": "SZ", "code": "000001", "number": 100.0, "stoploss": 0.0, "goal_price": 0.0,
102
+ * "cost_price": 0.0},
103
+ * {"market": "SH", "code": "600001", "number": 100.0, "stoploss": 0.0, "goal_price": 0.0,
104
+ * "cost_price": 0.0},
105
+ * ]
106
+ * }
107
+ *
108
+ * 说明:
109
+ * cash: 当前可用资金
110
+ * number 应该为:现有持仓 + 正在买入 - 正在卖出
111
+ * cost_price: 每股买入成本价
112
+ * </pre>
113
+ */
114
+ string getAssetInfo() noexcept;
115
+
116
+ /**
117
+ * 子类实现接口,执行实际买入操作
71
118
  * @param datetime 策略指示时间
72
119
  * @param market 市场标识
73
120
  * @param code 证券代码
74
121
  * @param price 买入价格
75
122
  * @param num 买入数量
76
- * @return 操作执行的时刻。实盘时,应返回委托单时间或服务器交易时间。
123
+ * @param stoploss 预期的止损价
124
+ * @param goalPrice 预期的目标价位
125
+ * @param from 系统部件来源
77
126
  */
78
- virtual Datetime _buy(Datetime datetime, const string& market, const string& code,
79
- price_t price, double num) = 0;
127
+ virtual void _buy(Datetime datetime, const string& market, const string& code, price_t price,
128
+ double num, price_t stoploss, price_t goalPrice, SystemPart from) = 0;
80
129
 
81
130
  /**
82
- * 执行实际卖出操作
131
+ * 子类实现接口,执行实际卖出操作
83
132
  * @param datetime 策略指示时间
84
133
  * @param market 市场标识
85
134
  * @param code 证券代码
86
135
  * @param price 卖出价格
87
136
  * @param num 卖出数量
88
- * @return 操作执行的时刻。实盘时,应返回委托单时间或服务器交易时间。
89
137
  */
90
- virtual Datetime _sell(Datetime datetime, const string& market, const string& code,
91
- price_t price, double num) = 0;
138
+ virtual void _sell(Datetime datetime, const string& market, const string& code, price_t price,
139
+ double num, price_t stoploss, price_t goalPrice, SystemPart from) = 0;
140
+
141
+ virtual string _getAssetInfo() {
142
+ return string();
143
+ }
92
144
 
93
145
  protected:
94
146
  string m_name;
@@ -26,19 +26,19 @@ public:
26
26
  price_t buyMoney, price_t totalCost, price_t totalRisk, price_t sellMoney);
27
27
 
28
28
  /** 仅用于python的__str__ */
29
- string toString() const;
29
+ string str() const;
30
30
 
31
- Stock stock; ///< 交易对象
32
- Datetime takeDatetime; ///< 初次建仓日期
33
- Datetime cleanDatetime; ///< 平仓日期,当前持仓记录中为Null<Datetime>()
34
- double number; ///< 当前持仓数量
35
- price_t stoploss; ///< 当前止损价
36
- price_t goalPrice; ///< 当前的目标价格
37
- double totalNumber; ///< 累计持仓数量
38
- price_t buyMoney; ///< 累计买入资金
39
- price_t totalCost; ///< 累计交易总成本
40
- price_t totalRisk; ///< 累计交易风险 = 各次 (买入价格-止损)*买入数量, 不包含交易成本
41
- price_t sellMoney; ///< 累计卖出资金
31
+ Stock stock; ///< 交易对象
32
+ Datetime takeDatetime; ///< 初次建仓日期
33
+ Datetime cleanDatetime; ///< 平仓日期,当前持仓记录中为Null<Datetime>()
34
+ double number{0.0}; ///< 当前持仓数量
35
+ price_t stoploss{0.0}; ///< 当前止损价
36
+ price_t goalPrice{0.0}; ///< 当前的目标价格
37
+ double totalNumber{0.0}; ///< 累计持仓数量
38
+ price_t buyMoney{0.0}; ///< 累计买入资金
39
+ price_t totalCost{0.0}; ///< 累计交易总成本
40
+ price_t totalRisk{0.0}; ///< 累计交易风险 = 各次 (买入价格-止损)*买入数量, 不包含交易成本
41
+ price_t sellMoney{0.0}; ///< 累计卖出资金
42
42
 
43
43
  //===================
44
44
  // 序列化支持
@@ -344,6 +344,15 @@ public:
344
344
  */
345
345
  virtual bool addTradeRecord(const TradeRecord& tr) override;
346
346
 
347
+ /**
348
+ * 直接加入持仓记录
349
+ * @note 特殊用途构建初始持仓,可能引起混乱
350
+ * @param pr 持仓记录
351
+ * @return true 成功
352
+ * @return false 失败
353
+ */
354
+ virtual bool addPosition(const PositionRecord& pr) override;
355
+
347
356
  /** 字符串输出 */
348
357
  virtual string str() const override;
349
358
 
@@ -668,6 +668,17 @@ public:
668
668
  return false;
669
669
  }
670
670
 
671
+ /**
672
+ * 直接加入持仓记录
673
+ * @param pr 持仓记录
674
+ * @return true 成功
675
+ * @return false 失败
676
+ */
677
+ virtual bool addPosition(const PositionRecord& pr) {
678
+ HKU_WARN("The subclass does not implement this method");
679
+ return false;
680
+ }
681
+
671
682
  /** 字符串输出 */
672
683
  virtual string str() const {
673
684
  HKU_WARN("The subclass does not implement this method");
@@ -682,6 +693,14 @@ public:
682
693
  HKU_WARN("The subclass does not implement this method");
683
694
  }
684
695
 
696
+ /**
697
+ * 从订单代理实例同步当前账户资产信息(包含资金、持仓等)
698
+ * @param broker 订单代理实例
699
+ */
700
+ virtual void fetchAssetInfoFromBroker(const OrderBrokerPtr& broker) {
701
+ HKU_WARN("The subclass does not implement this method");
702
+ }
703
+
685
704
  protected:
686
705
  string m_name; // 账户名称
687
706
  TradeCostPtr m_costfunc; // 成本算法
@@ -35,7 +35,23 @@ public:
35
35
  * @param work_num 定时任务执行线程池线程数量
36
36
  */
37
37
  explicit TimerManager(size_t work_num = 1)
38
- : m_stop(true), m_current_timer_id(-1), m_work_num(work_num) {
38
+ : m_stop(true),
39
+ m_current_timer_id(-1),
40
+ m_work_num(work_num),
41
+ m_tg(nullptr),
42
+ m_use_extend_tg(false) {
43
+ HKU_ASSERT(work_num >= 1);
44
+ start();
45
+ }
46
+
47
+ /**
48
+ * 指定线程池方式构造,以便共享其他线程池
49
+ * @note 请自行保证 tg 的生命周期在 TimerManager 存活期间始终有效
50
+ * @param tg 指定任务组线程池
51
+ */
52
+ explicit TimerManager(ThreadPool* tg)
53
+ : m_stop(true), m_current_timer_id(-1), m_work_num(1), m_tg(tg), m_use_extend_tg(true) {
54
+ HKU_ASSERT(m_tg);
39
55
  start();
40
56
  }
41
57
 
@@ -60,11 +76,7 @@ public:
60
76
  std::priority_queue<IntervalS> new_queue;
61
77
  m_queue.swap(new_queue);
62
78
  if (!m_tg) {
63
- #if CPP_STANDARD >= CPP_STANDARD_14
64
- m_tg = std::make_unique<ThreadPool>(m_work_num);
65
- #else
66
- m_tg = std::unique_ptr<ThreadPool>(new ThreadPool(m_work_num));
67
- #endif
79
+ m_tg = new ThreadPool(m_work_num);
68
80
  }
69
81
 
70
82
  /*
@@ -152,9 +164,10 @@ public:
152
164
  m_detect_thread.join();
153
165
  }
154
166
 
155
- if (m_tg) {
167
+ if (!m_use_extend_tg && m_tg) {
156
168
  m_tg->stop();
157
- m_tg.reset();
169
+ delete m_tg;
170
+ m_tg = nullptr;
158
171
  }
159
172
  }
160
173
 
@@ -532,7 +545,8 @@ private:
532
545
  std::unordered_map<int, Timer*> m_timers;
533
546
  int m_current_timer_id;
534
547
  size_t m_work_num; // 任务执行线程池线程数量
535
- std::unique_ptr<ThreadPool> m_tg;
548
+ ThreadPool* m_tg{nullptr};
549
+ bool m_use_extend_tg{false};
536
550
  };
537
551
 
538
552
  } // namespace hku
@@ -88,11 +88,11 @@ ValueT roundEx(ValueT number, int ndigits = 0) {
88
88
  ValueT pow1, pow2, y, z;
89
89
  ValueT x = number;
90
90
  if (ndigits >= 0) {
91
- pow1 = std::pow<ValueT>(10.0, (ValueT)ndigits);
91
+ pow1 = pow(ValueT(10.0), ValueT(ndigits));
92
92
  pow2 = 1.0;
93
93
  y = (x * pow1) * pow2;
94
94
  } else {
95
- pow1 = std::pow<ValueT>(10.0, (ValueT)-ndigits);
95
+ pow1 = pow(ValueT(10.0), ValueT(-ndigits));
96
96
  pow2 = 1.0;
97
97
  y = x / pow1;
98
98
  }
@@ -34,7 +34,7 @@
34
34
  #define HKU_ENABLE_HTTP_CLIENT_SSL 0
35
35
  #define HKU_ENABLE_HTTP_CLIENT_ZIP 0
36
36
 
37
- /* #undef HKU_ENABLE_NODE */
37
+ #define HKU_ENABLE_NODE 1
38
38
 
39
39
  // clang-format on
40
40
 
@@ -106,6 +106,7 @@ public:
106
106
  * 2、"20010101"
107
107
  * 3、"2001-01-01 18:00:00.12345"
108
108
  * 4、"20010101T181159"
109
+ * 5、"20240822 11:30:06.230"
109
110
  * </pre>
110
111
  */
111
112
  explicit Datetime(const std::string &);
@@ -14,40 +14,38 @@
14
14
  #include <string>
15
15
  #include <exception>
16
16
 
17
+ #ifndef HKU_UTILS_API
18
+ #define HKU_UTILS_API
19
+ #endif
20
+
17
21
  namespace hku {
18
22
 
23
+ #if defined(_MSC_VER)
24
+ #pragma warning(push)
25
+ #pragma warning(disable : 4275)
26
+ #endif
27
+
19
28
  /**
20
29
  * @ingroup Utilities
21
30
  * @addtogroup Exception Exception 异常处理
22
31
  * @{
23
32
  */
24
33
 
25
- #if !defined(__clang__) && !defined(__GNUC__)
26
- class exception : public std::exception {
27
- public:
28
- exception() : std::exception("Unknown exception!") {}
29
- exception(const std::string& msg) // cppcheck-suppress noExplicitConstructor
30
- : std::exception(msg.c_str()) {}
31
- exception(const char* msg) : std::exception(msg) {} // cppcheck-suppress noExplicitConstructor
32
- virtual ~exception() noexcept {};
33
- };
34
-
35
- #else
36
- // llvm 中的 std::exception 不接受参数
37
- class exception : public std::exception {
34
+ class HKU_UTILS_API exception : public std::exception {
38
35
  public:
39
36
  exception() : m_msg("Unknown exception!") {}
40
37
  exception(const char *msg) : m_msg(msg) {} // cppcheck-suppress noExplicitConstructor
41
38
  exception(const std::string &msg) : m_msg(msg) {} // cppcheck-suppress noExplicitConstructor
42
39
  virtual ~exception() noexcept {}
43
- virtual const char *what() const noexcept {
44
- return m_msg.c_str();
45
- }
40
+ virtual const char *what() const noexcept;
46
41
 
47
42
  protected:
48
43
  std::string m_msg;
49
44
  };
50
- #endif /* #ifdef __clang__ */
45
+
46
+ #if defined(_MSC_VER)
47
+ #pragma warning(pop)
48
+ #endif
51
49
 
52
50
  } /* namespace hku */
53
51
 
@@ -132,7 +132,7 @@ public:
132
132
  }
133
133
 
134
134
  void setUrl(const std::string& url) noexcept {
135
- m_url = std::move(nng::url(url));
135
+ m_url = nng::url(url);
136
136
  reset();
137
137
  }
138
138
 
@@ -588,7 +588,7 @@ public:
588
588
 
589
589
  // Beautify Output
590
590
  std::string fname;
591
- unsigned int pos = infile.find_last_of(MO_PATHSEP);
591
+ size_t pos = infile.find_last_of(MO_PATHSEP);
592
592
  if (pos != std::string::npos) {
593
593
  fname = infile.substr(pos + 1, infile.length());
594
594
  } else {
@@ -12,13 +12,13 @@
12
12
  #define HKU_VERSION_H
13
13
 
14
14
  // clang-format off
15
- #define HKU_VERSION "2.1.1"
15
+ #define HKU_VERSION "2.1.3"
16
16
  #define HKU_VERSION_MAJOR 2
17
17
  #define HKU_VERSION_MINOR 1
18
- #define HKU_VERSION_ALTER 1
19
- #define HKU_VERSION_BUILD 202408091425
18
+ #define HKU_VERSION_ALTER 3
19
+ #define HKU_VERSION_BUILD 202408272229
20
20
  #define HKU_VERSION_MODE "RELEASE"
21
- #define HKU_VERSION_GIT "2.1.1 release.664f60e9 (RELEASE)"
21
+ #define HKU_VERSION_GIT "2.1.3 release.35fa3739 (RELEASE)"
22
22
  // clang-format on
23
23
 
24
24
  #endif /* HKU_VERSION_H */