hikyuu 2.3.0__py3-none-win_amd64.whl → 2.5.0__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.
Files changed (179) hide show
  1. hikyuu/__init__.py +438 -6
  2. hikyuu/__init__.pyi +791 -0
  3. hikyuu/analysis/__init__.pyi +487 -0
  4. hikyuu/analysis/analysis.pyi +517 -0
  5. hikyuu/core.pyi +482 -0
  6. hikyuu/cpp/__init__.pyi +3 -0
  7. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  8. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  9. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  10. hikyuu/cpp/core310.pyd +0 -0
  11. hikyuu/cpp/core311.pyd +0 -0
  12. hikyuu/cpp/core312.pyd +0 -0
  13. hikyuu/cpp/core312.pyi +12867 -0
  14. hikyuu/cpp/core313.pyd +0 -0
  15. hikyuu/cpp/core38.pyd +0 -0
  16. hikyuu/cpp/core39.pyd +0 -0
  17. hikyuu/cpp/hikyuu.dll +0 -0
  18. hikyuu/cpp/hikyuu.lib +0 -0
  19. hikyuu/cpp/sqlite3.dll +0 -0
  20. hikyuu/data/common_mysql.py +24 -7
  21. hikyuu/data/common_pytdx.py +17 -1
  22. hikyuu/data/em_block_to_mysql.py +3 -2
  23. hikyuu/data/em_block_to_sqlite.py +8 -3
  24. hikyuu/data/mysql_upgrade/0025.sql +61 -0
  25. hikyuu/data/mysql_upgrade/0026.sql +9 -0
  26. hikyuu/data/sqlite_upgrade/0025.sql +63 -0
  27. hikyuu/data/sqlite_upgrade/0026.sql +10 -0
  28. hikyuu/draw/__init__.pyi +35 -0
  29. hikyuu/draw/drawplot/__init__.py +3 -0
  30. hikyuu/draw/drawplot/__init__.pyi +134 -0
  31. hikyuu/draw/drawplot/bokeh_draw.pyi +796 -0
  32. hikyuu/draw/drawplot/common.pyi +10 -0
  33. hikyuu/draw/drawplot/echarts_draw.py +219 -24
  34. hikyuu/draw/drawplot/echarts_draw.pyi +682 -0
  35. hikyuu/draw/drawplot/matplotlib_draw.py +18 -3
  36. hikyuu/draw/drawplot/matplotlib_draw.pyi +1101 -0
  37. hikyuu/draw/elder.pyi +44 -0
  38. hikyuu/draw/kaufman.pyi +38 -0
  39. hikyuu/draw/volume.pyi +31 -0
  40. hikyuu/examples/notebook/Demo/Demo2.ipynb +1 -1
  41. hikyuu/extend.py +9 -3
  42. hikyuu/extend.pyi +636 -0
  43. hikyuu/fetcher/stock/zh_block_em.py +118 -51
  44. hikyuu/gui/data/EscapetimeThread.py +4 -4
  45. hikyuu/gui/data/ImportBlockInfoTask.py +3 -2
  46. hikyuu/gui/data/ImportHistoryFinanceTask.py +2 -0
  47. hikyuu/gui/data/MainWindow.py +48 -42
  48. hikyuu/gui/importdata.py +13 -26
  49. hikyuu/hub.py +2 -4
  50. hikyuu/hub.pyi +254 -0
  51. hikyuu/include/hikyuu/DataType.h +5 -0
  52. hikyuu/include/hikyuu/Stock.h +7 -0
  53. hikyuu/include/hikyuu/indicator/Indicator.h +8 -1
  54. hikyuu/include/hikyuu/indicator/Indicator2InImp.h +65 -0
  55. hikyuu/include/hikyuu/indicator/IndicatorImp.h +4 -3
  56. hikyuu/include/hikyuu/indicator/build_in.h +12 -0
  57. hikyuu/include/hikyuu/indicator/crt/ADVANCE.h +3 -1
  58. hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -2
  59. hikyuu/include/hikyuu/indicator/crt/CORR.h +4 -2
  60. hikyuu/include/hikyuu/indicator/crt/COST.h +3 -0
  61. hikyuu/include/hikyuu/indicator/crt/CYCLE.h +24 -0
  62. hikyuu/include/hikyuu/indicator/crt/DECLINE.h +3 -1
  63. hikyuu/include/hikyuu/indicator/crt/DISCARD.h +27 -0
  64. hikyuu/include/hikyuu/indicator/crt/DMA.h +2 -1
  65. hikyuu/include/hikyuu/indicator/crt/HSL.h +1 -13
  66. hikyuu/include/hikyuu/indicator/crt/INBLOCK.h +31 -0
  67. hikyuu/include/hikyuu/indicator/crt/INDEX.h +60 -0
  68. hikyuu/include/hikyuu/indicator/crt/INSUM.h +5 -2
  69. hikyuu/include/hikyuu/indicator/crt/ISINF.h +28 -0
  70. hikyuu/include/hikyuu/indicator/crt/ISINFA.h +28 -0
  71. hikyuu/include/hikyuu/indicator/crt/ISNA.h +29 -0
  72. hikyuu/include/hikyuu/indicator/crt/JUMPDOWN.h +24 -0
  73. hikyuu/include/hikyuu/indicator/crt/JUMPUP.h +24 -0
  74. hikyuu/include/hikyuu/indicator/crt/LASTVALUE.h +29 -0
  75. hikyuu/include/hikyuu/indicator/crt/LIUTONGPAN.h +1 -0
  76. hikyuu/include/hikyuu/indicator/crt/REPLACE.h +29 -0
  77. hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
  78. hikyuu/include/hikyuu/indicator/crt/WINNER.h +38 -0
  79. hikyuu/include/hikyuu/indicator/imp/IContext.h +1 -1
  80. hikyuu/include/hikyuu/indicator/imp/ICorr.h +7 -22
  81. hikyuu/include/hikyuu/indicator/imp/ICost.h +31 -0
  82. hikyuu/include/hikyuu/indicator/imp/ICycle.h +30 -0
  83. hikyuu/include/hikyuu/indicator/imp/IDiscard.h +28 -0
  84. hikyuu/include/hikyuu/indicator/imp/IDma.h +7 -24
  85. hikyuu/include/hikyuu/indicator/imp/IHsl.h +30 -0
  86. hikyuu/include/hikyuu/indicator/imp/IInBlock.h +30 -0
  87. hikyuu/include/hikyuu/indicator/imp/IIndex.h +26 -0
  88. hikyuu/include/hikyuu/indicator/imp/IIsInf.h +26 -0
  89. hikyuu/include/hikyuu/indicator/imp/IIsInfa.h +26 -0
  90. hikyuu/include/hikyuu/indicator/imp/IIsNa.h +26 -0
  91. hikyuu/include/hikyuu/indicator/imp/IJumpDown.h +24 -0
  92. hikyuu/include/hikyuu/indicator/imp/IJumpUp.h +24 -0
  93. hikyuu/include/hikyuu/indicator/imp/ILastValue.h +26 -0
  94. hikyuu/include/hikyuu/indicator/imp/IReplace.h +26 -0
  95. hikyuu/include/hikyuu/indicator/imp/ISpearman.h +6 -21
  96. hikyuu/include/hikyuu/indicator/imp/IWinner.h +26 -0
  97. hikyuu/include/hikyuu/indicator_talib/imp/TaMavp.h +6 -20
  98. hikyuu/include/hikyuu/indicator_talib/imp/ta_defines.h +14 -65
  99. hikyuu/include/hikyuu/indicator_talib/imp/ta_imp.h +54 -90
  100. hikyuu/include/hikyuu/indicator_talib/ta_crt.h +11 -9
  101. hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +3 -4
  102. hikyuu/include/hikyuu/strategy/Strategy.h +4 -5
  103. hikyuu/include/hikyuu/trade_manage/TradeRecord.h +5 -1
  104. hikyuu/include/hikyuu/trade_sys/allocatefunds/build_in.h +1 -0
  105. hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_FixedWeightList.h +22 -0
  106. hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/FixedWeightListAllocateFunds.h +25 -0
  107. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +17 -4
  108. hikyuu/include/hikyuu/trade_sys/moneymanager/build_in.h +2 -0
  109. hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCapital.h +6 -0
  110. hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCapitalFunds.h +26 -0
  111. hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedCountTps.h +27 -0
  112. hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedRisk.h +6 -0
  113. hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_FixedUnits.h +6 -0
  114. hikyuu/include/hikyuu/trade_sys/moneymanager/crt/MM_WilliamsFixedRisk.h +7 -0
  115. hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +28 -0
  116. hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCountTpsMM.h +44 -0
  117. hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +1 -0
  118. hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_Weight.h +30 -0
  119. hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +41 -0
  120. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +38 -37
  121. hikyuu/include/hikyuu/trade_sys/portfolio/build_in.h +1 -0
  122. hikyuu/include/hikyuu/trade_sys/portfolio/crt/PF_Simple.h +25 -1
  123. hikyuu/include/hikyuu/trade_sys/portfolio/crt/PF_WithoutAF.h +50 -0
  124. hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +53 -0
  125. hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +57 -0
  126. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +7 -0
  127. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +51 -5
  128. hikyuu/include/hikyuu/trade_sys/signal/build_in.h +2 -0
  129. hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Bool.h +2 -1
  130. hikyuu/include/hikyuu/trade_sys/signal/crt/SG_Logic.h +37 -0
  131. hikyuu/include/hikyuu/trade_sys/signal/crt/SG_OneSide.h +28 -0
  132. hikyuu/include/hikyuu/trade_sys/signal/imp/OneSideSignal.h +46 -0
  133. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddSignal.h +19 -0
  134. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +19 -0
  135. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivSignal.h +19 -0
  136. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +22 -0
  137. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulSignal.h +19 -0
  138. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +19 -0
  139. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +68 -0
  140. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +67 -0
  141. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubSignal.h +19 -0
  142. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +22 -0
  143. hikyuu/include/hikyuu/trade_sys/signal/imp/logic/__init__.py +1 -0
  144. hikyuu/include/hikyuu/trade_sys/stoploss/crt/ST_Indicator.h +1 -1
  145. hikyuu/include/hikyuu/trade_sys/stoploss/imp/IndicatorStoploss.h +3 -4
  146. hikyuu/include/hikyuu/utilities/FilterNode.h +2 -2
  147. hikyuu/include/hikyuu/utilities/Log.h +42 -15
  148. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +1 -1
  149. hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +2 -2
  150. hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +4 -0
  151. hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +2 -2
  152. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +5 -1
  153. hikyuu/include/hikyuu/utilities/node/NodeServer.h +4 -4
  154. hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +2 -2
  155. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +2 -2
  156. hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +5 -5
  157. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +2 -2
  158. hikyuu/include/hikyuu/utilities/thread/algorithm.h +16 -10
  159. hikyuu/include/hikyuu/version.h +4 -4
  160. hikyuu/indicator/indicator.py +1 -0
  161. hikyuu/interactive.py +3 -266
  162. hikyuu/trade_manage/__init__.pyi +584 -0
  163. hikyuu/trade_manage/broker.pyi +54 -0
  164. hikyuu/trade_manage/broker_easytrader.pyi +21 -0
  165. hikyuu/trade_manage/broker_mail.pyi +55 -0
  166. hikyuu/trade_manage/trade.pyi +590 -0
  167. hikyuu/util/__init__.pyi +55 -0
  168. hikyuu/util/check.pyi +59 -0
  169. hikyuu/util/mylog.pyi +70 -0
  170. hikyuu/util/notebook.pyi +23 -0
  171. hikyuu/util/singleton.pyi +18 -0
  172. hikyuu/util/slice.pyi +8 -0
  173. {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/METADATA +3 -2
  174. {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/RECORD +178 -95
  175. {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/top_level.txt +1 -0
  176. hikyuu/deprecated.py +0 -651
  177. {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/LICENSE +0 -0
  178. {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/WHEEL +0 -0
  179. {hikyuu-2.3.0.dist-info → hikyuu-2.5.0.dist-info}/entry_points.txt +0 -0
@@ -249,10 +249,10 @@ public:
249
249
  * @param data 事件附加信息
250
250
  */
251
251
  void dispatch(const EventT& event, const any_t& data) {
252
- m_tg->submit([=] {
252
+ m_tg->submit([this, event, data] {
253
253
  auto iter = m_trees.find(event);
254
254
  HKU_WARN_IF_RETURN(iter == m_trees.end(), void(),
255
- "There is no matching handling method for the event({})!", event);
255
+ "There is no matching handling method for the event({})!", event);
256
256
  iter->second->run(data);
257
257
  });
258
258
  }
@@ -344,14 +344,18 @@ std::shared_ptr<spdlog::logger> HKU_UTILS_API getHikyuuLogger();
344
344
 
345
345
  /** 用于 catch (...) 中打印,减少编译后代码大小 */
346
346
  extern std::string g_unknown_error_msg;
347
- #define HKU_THROW_UNKNOWN HKU_THROW(g_unknown_error_msg);
348
- #define HKU_TRACE_UNKNOWN HKU_TRACE(g_unknown_error_msg)
349
- #define HKU_DEBUG_UNKNOWN HKU_DEBUG(g_unknown_error_msg)
350
- #define HKU_INFO_UNKNOWN HKU_INFO(g_unknown_error_msg)
351
- #define HKU_ERROR_UNKNOWN HKU_ERROR(g_unknown_error_msg)
352
- #define HKU_FATAL_UNKNOWN HKU_FATAL(g_unknown_error_msg)
353
-
354
- #if CPP_STANDARD >= CPP_STANDARD_17
347
+ #define HKU_THROW_UNKNOWN HKU_THROW("{}", g_unknown_error_msg);
348
+ #define HKU_TRACE_UNKNOWN HKU_TRACE("{}", g_unknown_error_msg)
349
+ #define HKU_DEBUG_UNKNOWN HKU_DEBUG("{}", g_unknown_error_msg)
350
+ #define HKU_INFO_UNKNOWN HKU_INFO("{}", g_unknown_error_msg)
351
+ #define HKU_ERROR_UNKNOWN HKU_ERROR("{}", g_unknown_error_msg)
352
+ #define HKU_FATAL_UNKNOWN HKU_FATAL("{}", g_unknown_error_msg)
353
+
354
+ #if CPP_STANDARD >= CPP_STANDARD_20
355
+ #define CLASS_LOGGER_IMP(cls) \
356
+ protected: \
357
+ static constexpr const char* ms_logger = #cls;
358
+ #elif CPP_STANDARD >= CPP_STANDARD_17
355
359
  #define CLASS_LOGGER_IMP(cls) \
356
360
  protected: \
357
361
  inline static const char* ms_logger = #cls;
@@ -396,13 +400,36 @@ protected: \
396
400
  HKU_FATAL_IF_RETURN(expr, ret, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
397
401
 
398
402
  #define CLS_ASSERT HKU_ASSERT
399
- #define CLS_CHECK(expr, ...) \
400
- HKU_CHECK(expr, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
401
- #define CLS_CHECK_THROW(expr, except, ...) \
402
- HKU_CHECK_THROW(expr, except, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
403
- #define CLS_THROW(...) HKU_THROW(fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
404
- #define CLS_THROW_EXCEPTION(except, ...) \
405
- HKU_THROW_EXCEPTION(except, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
403
+
404
+ #define CLS_CHECK(expr, ...) \
405
+ do { \
406
+ if (!(expr)) { \
407
+ throw hku::exception(fmt::format("[{}] CLS_CHECK({}) {} [{}] ({}:{})", ms_logger, \
408
+ #expr, fmt::format(__VA_ARGS__), HKU_FUNCTION, \
409
+ __FILE__, __LINE__)); \
410
+ } \
411
+ } while (0)
412
+
413
+ #define CLS_CHECK_THROW(expr, except, ...) \
414
+ do { \
415
+ if (!(expr)) { \
416
+ throw except(fmt::format("[{}] CLS_CHECK({}) {} [{}] ({}:{})", ms_logger, #expr, \
417
+ fmt::format(__VA_ARGS__), HKU_FUNCTION, __FILE__, __LINE__)); \
418
+ } \
419
+ } while (0)
420
+
421
+ #define CLS_THROW(...) \
422
+ do { \
423
+ throw hku::exception(fmt::format("[{}] EXCEPTION: {} [{}] ({}:{})", ms_logger, \
424
+ fmt::format(__VA_ARGS__), HKU_FUNCTION, __FILE__, \
425
+ __LINE__)); \
426
+ } while (0)
427
+
428
+ #define CLS_THROW_EXCEPTION(except, ...) \
429
+ do { \
430
+ throw except(fmt::format("[{}] EXCEPTION: {} [{}] ({}:{})", ms_logger, \
431
+ fmt::format(__VA_ARGS__), HKU_FUNCTION, __FILE__, __LINE__)); \
432
+ } while (0)
406
433
 
407
434
  /** @} */
408
435
 
@@ -424,7 +424,7 @@ inline string to_string(const hku::Datetime &date) {
424
424
  #if FMT_VERSION >= 90000
425
425
  template <>
426
426
  struct fmt::formatter<hku::Datetime> {
427
- constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
427
+ FMT_CONSTEXPR auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
428
428
  return ctx.end();
429
429
  }
430
430
 
@@ -59,7 +59,7 @@ public:
59
59
  explicit TimeDelta(bt::time_duration td);
60
60
 
61
61
  /** 从字符串构造,格式:-1 days, hh:mm:ss.000000) */
62
- explicit TimeDelta(const std::string& delta);
62
+ explicit TimeDelta(const std::string &delta);
63
63
 
64
64
  /** 赋值构造函数 */
65
65
  TimeDelta(const TimeDelta &) = default;
@@ -329,7 +329,7 @@ inline string to_string(const hku::TimeDelta &delta) {
329
329
  #if FMT_VERSION >= 90000
330
330
  template <>
331
331
  struct fmt::formatter<hku::TimeDelta> {
332
- constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
332
+ FMT_CONSTEXPR auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
333
333
  return ctx.end();
334
334
  }
335
335
 
@@ -245,4 +245,8 @@ inline DBCondition operator==(const Field &field, const char *val) {
245
245
  return DBCondition(fmt::format(R"(({}="{}"))", field.name, val));
246
246
  }
247
247
 
248
+ inline DBCondition operator!=(const Field &field, const char *val) {
249
+ return DBCondition(fmt::format(R"(({}<>"{}"))", field.name, val));
250
+ }
251
+
248
252
  } // namespace hku
@@ -154,7 +154,7 @@ private:
154
154
  if (m_connect && page != m_current_page) {
155
155
  m_buffer.clear();
156
156
  m_connect->batchLoad(
157
- m_buffer, fmt::format(m_sql_template, TableT::getTableName(), m_where,
157
+ m_buffer, fmt::format(fmt::runtime(m_sql_template), TableT::getTableName(), m_where,
158
158
  m_orderby_inner, page_size, page * page_size, m_orderby_outer));
159
159
  m_current_page = page;
160
160
  }
@@ -179,7 +179,7 @@ private:
179
179
  };
180
180
 
181
181
  template <class TableT, size_t page_size>
182
- class SQLResultSetIterator : public std::iterator<std::forward_iterator_tag, TableT> {
182
+ class SQLResultSetIterator {
183
183
  public:
184
184
  using ResultSet = SQLResultSet<TableT, page_size>;
185
185
 
@@ -41,13 +41,17 @@ public:
41
41
  virtual void commit() override;
42
42
  virtual void rollback() noexcept override;
43
43
 
44
+ public:
45
+ MYSQL *getRawMYSQL() const noexcept {
46
+ return m_mysql;
47
+ }
48
+
44
49
  private:
45
50
  bool tryConnect() noexcept;
46
51
  void connect();
47
52
  void close();
48
53
 
49
54
  private:
50
- friend class MySQLStatement;
51
55
  MYSQL *m_mysql;
52
56
  };
53
57
 
@@ -203,11 +203,11 @@ private:
203
203
  nng_ctx_send(work->ctx, work->aio);
204
204
 
205
205
  } catch (const NodeNngError& e) {
206
- CLS_FATAL(e.what());
206
+ CLS_FATAL("{}", e.what());
207
207
  work->state = Work::FINISH;
208
208
 
209
209
  } catch (const NodeError& e) {
210
- CLS_ERROR(e.what());
210
+ CLS_ERROR("{}", e.what());
211
211
  res["ret"] = e.errcode();
212
212
  res["msg"] = e.what();
213
213
  encodeMsg(msg, res);
@@ -216,7 +216,7 @@ private:
216
216
  nng_ctx_send(work->ctx, work->aio);
217
217
 
218
218
  } catch (const std::exception& e) {
219
- CLS_ERROR(e.what());
219
+ CLS_ERROR("{}", e.what());
220
220
  res["ret"] = NodeErrorCode::UNKNOWN_ERROR;
221
221
  res["msg"] = e.what();
222
222
  encodeMsg(msg, res);
@@ -226,7 +226,7 @@ private:
226
226
 
227
227
  } catch (...) {
228
228
  std::string errmsg = "Unknown error!";
229
- CLS_ERROR(errmsg);
229
+ CLS_ERROR("{}", errmsg);
230
230
  res["ret"] = NodeErrorCode::UNKNOWN_ERROR;
231
231
  res["msg"] = errmsg;
232
232
  nng_aio_set_msg(work->aio, msg);
@@ -104,12 +104,12 @@ public:
104
104
 
105
105
  /** 向线程池提交任务 */
106
106
  template <typename FunctionType>
107
- task_handle<typename std::result_of<FunctionType()>::type> submit(FunctionType f) {
107
+ auto submit(FunctionType f) {
108
108
  if (m_thread_need_stop.isSet() || m_done) {
109
109
  throw std::logic_error("You can't submit a task to the stopped MQStealThreadPool!");
110
110
  }
111
111
 
112
- typedef typename std::result_of<FunctionType()>::type result_type;
112
+ typedef typename std::invoke_result<FunctionType>::type result_type;
113
113
  std::packaged_task<result_type()> task(f);
114
114
  task_handle<result_type> res(task.get_future());
115
115
 
@@ -104,12 +104,12 @@ public:
104
104
 
105
105
  /** 向线程池提交任务 */
106
106
  template <typename FunctionType>
107
- task_handle<typename std::result_of<FunctionType()>::type> submit(FunctionType f) {
107
+ auto submit(FunctionType f) {
108
108
  if (m_thread_need_stop.isSet() || m_done) {
109
109
  throw std::logic_error("You can't submit a task to the stopped MQThreadPool!");
110
110
  }
111
111
 
112
- typedef typename std::result_of<FunctionType()>::type result_type;
112
+ typedef typename std::invoke_result<FunctionType>::type result_type;
113
113
  std::packaged_task<result_type()> task(f);
114
114
  task_handle<result_type> res(task.get_future());
115
115
 
@@ -107,12 +107,12 @@ public:
107
107
 
108
108
  /** 向线程池提交任务 */
109
109
  template <typename FunctionType>
110
- task_handle<typename std::result_of<FunctionType()>::type> submit(FunctionType f) {
110
+ auto submit(FunctionType f) {
111
111
  if (m_thread_need_stop.isSet() || m_done) {
112
112
  throw std::logic_error("You can't submit a task to the stopped StealThreadPool!!");
113
113
  }
114
114
 
115
- typedef typename std::result_of<FunctionType()>::type result_type;
115
+ typedef typename std::invoke_result<FunctionType>::type result_type;
116
116
  std::packaged_task<result_type()> task(f);
117
117
  task_handle<result_type> res(task.get_future());
118
118
  if (m_local_work_queue) {
@@ -241,8 +241,8 @@ private:
241
241
  // 线程本地变量
242
242
  #if CPP_STANDARD >= CPP_STANDARD_17
243
243
  inline static thread_local WorkStealQueue* m_local_work_queue = nullptr; // 本地任务队列
244
- inline static thread_local int m_index = -1; // 在线程池中的序号
245
- inline static thread_local InterruptFlag m_thread_need_stop; // 线程停止运行指示
244
+ inline static thread_local int m_index = -1; // 在线程池中的序号
245
+ inline static thread_local InterruptFlag m_thread_need_stop; // 线程停止运行指示
246
246
  #else
247
247
  static thread_local WorkStealQueue* m_local_work_queue; // 本地任务队列
248
248
  static thread_local int m_index; // 在线程池中的序号
@@ -280,7 +280,7 @@ private:
280
280
  task();
281
281
  } else {
282
282
  std::unique_lock<std::mutex> lk(m_cv_mutex);
283
- m_cv.wait(lk, [=] { return this->m_done || !this->m_master_work_queue.empty(); });
283
+ m_cv.wait(lk, [this] { return this->m_done || !this->m_master_work_queue.empty(); });
284
284
  }
285
285
  }
286
286
 
@@ -93,11 +93,11 @@ public:
93
93
 
94
94
  /** 向线程池提交任务 */
95
95
  template <typename FunctionType>
96
- task_handle<typename std::result_of<FunctionType()>::type> submit(FunctionType f) {
96
+ auto submit(FunctionType f) {
97
97
  if (m_thread_need_stop.isSet() || m_done) {
98
98
  throw std::logic_error("You can't submit a task to the stopped task group!");
99
99
  }
100
- typedef typename std::result_of<FunctionType()>::type result_type;
100
+ typedef typename std::invoke_result<FunctionType>::type result_type;
101
101
  std::packaged_task<result_type()> task(f);
102
102
  task_handle<result_type> res(task.get_future());
103
103
  m_master_work_queue.push(std::move(task));
@@ -26,19 +26,25 @@ inline std::vector<range_t> parallelIndexRange(size_t start, size_t end) {
26
26
  }
27
27
 
28
28
  size_t total = end - start;
29
+ if (total == 0) {
30
+ return ret;
31
+ }
32
+
29
33
  size_t cpu_num = std::thread::hardware_concurrency();
30
- if (total <= cpu_num) {
34
+ if (cpu_num == 1) {
31
35
  ret.emplace_back(start, end);
32
36
  return ret;
33
37
  }
34
38
 
35
39
  size_t per_num = total / cpu_num;
36
- for (size_t i = start; i < per_num; i++) {
37
- size_t first = i * cpu_num;
38
- ret.emplace_back(first, first + cpu_num);
40
+ if (per_num > 0) {
41
+ for (size_t i = 0; i < cpu_num; i++) {
42
+ size_t first = i * per_num + start;
43
+ ret.emplace_back(first, first + per_num);
44
+ }
39
45
  }
40
46
 
41
- for (size_t i = per_num * cpu_num; i < total; i++) {
47
+ for (size_t i = per_num * cpu_num + start; i < end; i++) {
42
48
  ret.emplace_back(i, i + 1);
43
49
  }
44
50
 
@@ -64,11 +70,11 @@ template <typename FunctionType, class TaskGroup = MQStealThreadPool>
64
70
  auto parallel_for_index(size_t start, size_t end, FunctionType f) {
65
71
  auto ranges = parallelIndexRange(start, end);
66
72
  TaskGroup tg;
67
- std::vector<std::future<std::vector<typename std::result_of<FunctionType(size_t)>::type>>>
73
+ std::vector<std::future<std::vector<typename std::invoke_result<FunctionType, size_t>::type>>>
68
74
  tasks;
69
75
  for (size_t i = 0, total = ranges.size(); i < total; i++) {
70
76
  tasks.emplace_back(tg.submit([func = f, range = ranges[i]]() {
71
- std::vector<typename std::result_of<FunctionType(size_t)>::type> one_ret;
77
+ std::vector<typename std::invoke_result<FunctionType, size_t>::type> one_ret;
72
78
  for (size_t ix = range.first; ix < range.second; ix++) {
73
79
  one_ret.emplace_back(func(ix));
74
80
  }
@@ -76,7 +82,7 @@ auto parallel_for_index(size_t start, size_t end, FunctionType f) {
76
82
  }));
77
83
  }
78
84
 
79
- std::vector<typename std::result_of<FunctionType(size_t)>::type> ret;
85
+ std::vector<typename std::invoke_result<FunctionType, size_t>::type> ret;
80
86
  for (auto& task : tasks) {
81
87
  auto one = task.get();
82
88
  for (auto&& value : one) {
@@ -91,12 +97,12 @@ template <typename FunctionType, class TaskGroup = MQStealThreadPool>
91
97
  auto parallel_for_range(size_t start, size_t end, FunctionType f) {
92
98
  auto ranges = parallelIndexRange(start, end);
93
99
  TaskGroup tg;
94
- std::vector<std::future<typename std::result_of<FunctionType(range_t)>::type>> tasks;
100
+ std::vector<std::future<typename std::invoke_result<FunctionType, range_t>::type>> tasks;
95
101
  for (size_t i = 0, total = ranges.size(); i < total; i++) {
96
102
  tasks.emplace_back(tg.submit([func = f, range = ranges[i]]() { return func(range); }));
97
103
  }
98
104
 
99
- typename std::result_of<FunctionType(range_t)>::type ret;
105
+ typename std::invoke_result<FunctionType, range_t>::type ret;
100
106
  for (auto& task : tasks) {
101
107
  auto one = task.get();
102
108
  for (auto&& value : one) {
@@ -12,13 +12,13 @@
12
12
  #define HKU_VERSION_H
13
13
 
14
14
  // clang-format off
15
- #define HKU_VERSION "2.3.0"
15
+ #define HKU_VERSION "2.5.0"
16
16
  #define HKU_VERSION_MAJOR 2
17
- #define HKU_VERSION_MINOR 3
17
+ #define HKU_VERSION_MINOR 5
18
18
  #define HKU_VERSION_ALTER 0
19
- #define HKU_VERSION_BUILD 202501010140
19
+ #define HKU_VERSION_BUILD 202502201617
20
20
  #define HKU_VERSION_MODE "RELEASE"
21
- #define HKU_VERSION_GIT "2.3.0 master.48495654 (RELEASE)"
21
+ #define HKU_VERSION_GIT "2.5.0 release.77e90dd2 (RELEASE)"
22
22
  // clang-format on
23
23
 
24
24
  #endif /* HKU_VERSION_H */
@@ -155,3 +155,4 @@ VOL = C_VOL()
155
155
  # 同名指标
156
156
  VALUE = PRICELIST
157
157
  CAPITAL = LIUTONGPAN
158
+ CONST = LASTVALUE