hikyuu 2.6.0__py3-none-win_amd64.whl → 2.6.2__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. hikyuu/__init__.py +19 -50
  2. hikyuu/__init__.pyi +530 -525
  3. hikyuu/analysis/__init__.pyi +498 -497
  4. hikyuu/analysis/analysis.pyi +499 -498
  5. hikyuu/core.pyi +500 -499
  6. hikyuu/cpp/__init__.pyi +2 -2
  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/core310.pyi +60 -8
  12. hikyuu/cpp/core311.pyd +0 -0
  13. hikyuu/cpp/core311.pyi +60 -8
  14. hikyuu/cpp/core312.pyd +0 -0
  15. hikyuu/cpp/core312.pyi +60 -8
  16. hikyuu/cpp/core313.pyd +0 -0
  17. hikyuu/cpp/core313.pyi +60 -8
  18. hikyuu/cpp/core39.pyd +0 -0
  19. hikyuu/cpp/core39.pyi +60 -8
  20. hikyuu/cpp/hikyuu.dll +0 -0
  21. hikyuu/cpp/hikyuu.lib +0 -0
  22. hikyuu/cpp/sqlite3.dll +0 -0
  23. hikyuu/draw/drawplot/__init__.pyi +9 -9
  24. hikyuu/draw/drawplot/bokeh_draw.pyi +519 -514
  25. hikyuu/draw/drawplot/common.pyi +1 -1
  26. hikyuu/draw/drawplot/echarts_draw.pyi +521 -516
  27. hikyuu/draw/drawplot/matplotlib_draw.pyi +531 -526
  28. hikyuu/draw/elder.pyi +11 -11
  29. hikyuu/draw/kaufman.pyi +18 -18
  30. hikyuu/draw/volume.pyi +10 -10
  31. hikyuu/extend.py +0 -14
  32. hikyuu/extend.pyi +506 -509
  33. hikyuu/gui/HikyuuTDX.py +66 -12
  34. hikyuu/gui/data/ImportQmtToH5Task.py +209 -0
  35. hikyuu/gui/data/ImportTdxToH5Task.py +8 -1
  36. hikyuu/gui/data/MainWindow.py +68 -50
  37. hikyuu/gui/data/UseQmtImportToH5Thread.py +316 -0
  38. hikyuu/gui/data/UseTdxImportToH5Thread.py +221 -65
  39. hikyuu/gui/importdata.py +24 -11
  40. hikyuu/hub.pyi +6 -6
  41. hikyuu/include/hikyuu/KData.h +5 -0
  42. hikyuu/include/hikyuu/KDataImp.h +4 -0
  43. hikyuu/include/hikyuu/data_driver/kdata/mysql/KRecordTable.h +41 -2
  44. hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +6 -2
  45. hikyuu/include/hikyuu/indicator/crt/COUNT.h +3 -3
  46. hikyuu/include/hikyuu/indicator/crt/DISCARD.h +1 -1
  47. hikyuu/include/hikyuu/indicator/crt/ISINF.h +1 -1
  48. hikyuu/include/hikyuu/indicator/crt/ISINFA.h +1 -1
  49. hikyuu/include/hikyuu/indicator/crt/ISNA.h +1 -1
  50. hikyuu/include/hikyuu/indicator/crt/LAST.h +2 -2
  51. hikyuu/include/hikyuu/indicator/crt/MAX.h +1 -1
  52. hikyuu/include/hikyuu/indicator/crt/MIN.h +1 -1
  53. hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +1 -15
  54. hikyuu/include/hikyuu/indicator/crt/SUMBARS.h +1 -1
  55. hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +33 -0
  56. hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +33 -0
  57. hikyuu/include/hikyuu/plugin/interface/plugins.h +2 -0
  58. hikyuu/include/hikyuu/strategy/Strategy.h +3 -6
  59. hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +2 -1
  60. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +12 -9
  61. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +1 -1
  62. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +12 -12
  63. hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +2 -2
  64. hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +1 -1
  65. hikyuu/include/hikyuu/trade_sys/system/System.h +12 -3
  66. hikyuu/include/hikyuu/trade_sys/system/imp/DelegateSystem.h +0 -1
  67. hikyuu/include/hikyuu/trade_sys/system/imp/WalkForwardSystem.h +0 -1
  68. hikyuu/include/hikyuu/utilities/arithmetic.h +32 -22
  69. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +1 -0
  70. hikyuu/include/hikyuu/version.h +4 -4
  71. hikyuu/plugin/backtest.dll +0 -0
  72. hikyuu/plugin/dataserver.dll +0 -0
  73. hikyuu/plugin/device.dll +0 -0
  74. hikyuu/plugin/import2hdf5.dll +0 -0
  75. hikyuu/trade_manage/__init__.pyi +518 -513
  76. hikyuu/trade_manage/broker.pyi +3 -3
  77. hikyuu/trade_manage/broker_easytrader.pyi +1 -1
  78. hikyuu/trade_manage/trade.pyi +518 -513
  79. hikyuu/util/__init__.py +1 -0
  80. hikyuu/util/__init__.pyi +3 -2
  81. hikyuu/util/mylog.py +30 -3
  82. hikyuu/util/mylog.pyi +3 -1
  83. hikyuu/util/singleton.pyi +1 -1
  84. {hikyuu-2.6.0.dist-info → hikyuu-2.6.2.dist-info}/METADATA +1 -1
  85. {hikyuu-2.6.0.dist-info → hikyuu-2.6.2.dist-info}/RECORD +89 -84
  86. {hikyuu-2.6.0.dist-info → hikyuu-2.6.2.dist-info}/LICENSE +0 -0
  87. {hikyuu-2.6.0.dist-info → hikyuu-2.6.2.dist-info}/WHEEL +0 -0
  88. {hikyuu-2.6.0.dist-info → hikyuu-2.6.2.dist-info}/entry_points.txt +0 -0
  89. {hikyuu-2.6.0.dist-info → hikyuu-2.6.2.dist-info}/top_level.txt +0 -0
@@ -9,7 +9,7 @@
9
9
  #ifndef INDICATOR_CRT_ISNA_H_
10
10
  #define INDICATOR_CRT_ISNA_H_
11
11
 
12
- #include "CVAL.h"
12
+ #include "../Indicator.h"
13
13
 
14
14
  namespace hku {
15
15
 
@@ -39,7 +39,7 @@ inline Indicator LAST(int m = 10, int n = 5) {
39
39
 
40
40
  inline Indicator LAST(const IndParam& m, int n = 5) {
41
41
  Indicator ind_m = m.get();
42
- Indicator ind_n = CVAL(ind_m, 5);
42
+ Indicator ind_n = CVAL(ind_m, n);
43
43
  Indicator max = MAX(ind_m, ind_n);
44
44
  Indicator min = MIN(ind_m, ind_n);
45
45
  Indicator result = REF(EVERY(max - min + 1), min);
@@ -49,7 +49,7 @@ inline Indicator LAST(const IndParam& m, int n = 5) {
49
49
 
50
50
  inline Indicator LAST(int m, const IndParam& n) {
51
51
  Indicator ind_n = n.get();
52
- Indicator ind_m = CVAL(ind_n, 5);
52
+ Indicator ind_m = CVAL(ind_n, m);
53
53
  Indicator max = MAX(ind_m, ind_n);
54
54
  Indicator min = MIN(ind_m, ind_n);
55
55
  Indicator result = REF(EVERY(max - min + 1), min);
@@ -9,7 +9,7 @@
9
9
  #ifndef INDICATOR_CRT_MAX_H_
10
10
  #define INDICATOR_CRT_MAX_H_
11
11
 
12
- #include "CVAL.h"
12
+ #include "../Indicator.h"
13
13
 
14
14
  namespace hku {
15
15
 
@@ -9,7 +9,7 @@
9
9
  #ifndef INDICATOR_CRT_MIN_H_
10
10
  #define INDICATOR_CRT_MIN_H_
11
11
 
12
- #include "CVAL.h"
12
+ #include "../Indicator.h"
13
13
 
14
14
  namespace hku {
15
15
 
@@ -23,21 +23,7 @@ namespace hku {
23
23
  */
24
24
  Indicator HKU_API PRICELIST(const PriceList& data, int discard = 0);
25
25
  Indicator HKU_API PRICELIST(const PriceList& data, const DatetimeList& ds, int discard = 0);
26
-
27
- /**
28
- * 将某指标转化为PRICELIST
29
- * @param ind 源数据
30
- * @param result_index 源数据中指定的结果集
31
- * @ingroup Indicator
32
- */
33
- Indicator HKU_API PRICELIST(const Indicator& ind, int result_index = 0);
34
-
35
- /**
36
- * 将某指标转化为PRICELIST
37
- * @param result_index 源数据中指定的结果集
38
- * @ingroup Indicator
39
- */
40
- Indicator HKU_API PRICELIST(int result_index = 0);
26
+ Indicator HKU_API PRICELIST();
41
27
 
42
28
  /**
43
29
  * 包装数组成Indicator,用于计算其他指标
@@ -11,7 +11,7 @@
11
11
  #ifndef INDICATOR_CRT_SUMBARS_H_
12
12
  #define INDICATOR_CRT_SUMBARS_H_
13
13
 
14
- #include "CVAL.h"
14
+ #include "../Indicator.h"
15
15
 
16
16
  namespace hku {
17
17
 
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-05-06
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "hikyuu/DataType.h"
11
+ #include "interface/ImportKDataToHdf5PluginInterface.h"
12
+
13
+ namespace hku {
14
+
15
+ class HKU_API KDataToHdf5Importer {
16
+ public:
17
+ KDataToHdf5Importer();
18
+ virtual ~KDataToHdf5Importer();
19
+
20
+ bool setConfig(const string& datapath, const vector<string>& markets = {"SH", "SZ", "BJ"});
21
+
22
+ Datetime getLastDatetime(const string& market, const string& code, const KQuery::KType& ktype);
23
+
24
+ void addKRecordList(const string& market, const string& code, const vector<KRecord>& krecords,
25
+ const KQuery::KType& ktype);
26
+
27
+ void updateIndex(const string& market, const string& code, const KQuery::KType& ktype);
28
+
29
+ private:
30
+ ImportKDataToHdf5PluginInterface* m_plugin{nullptr};
31
+ };
32
+
33
+ } // namespace hku
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (c) 2025 hikyuu.org
3
+ *
4
+ * Created on: 2025-04-08
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "hikyuu/KRecord.h"
11
+ #include "hikyuu/KQuery.h"
12
+ #include "hikyuu/utilities/plugin/PluginBase.h"
13
+
14
+ namespace hku {
15
+
16
+ class ImportKDataToHdf5PluginInterface : public PluginBase {
17
+ public:
18
+ ImportKDataToHdf5PluginInterface() = default;
19
+ virtual ~ImportKDataToHdf5PluginInterface() = default;
20
+
21
+ virtual bool setConfig(const string& datapath, const vector<string>& markets) = 0;
22
+
23
+ virtual Datetime getLastDatetime(const string& market, const string& code,
24
+ const KQuery::KType& ktype) = 0;
25
+
26
+ virtual void addKRecordList(const string& market, const string& code,
27
+ const vector<KRecord>& krecords, const KQuery::KType& ktype) = 0;
28
+
29
+ virtual void updateIndex(const string& market, const string& code,
30
+ const KQuery::KType& ktype) = 0;
31
+ };
32
+
33
+ } // namespace hku
@@ -10,11 +10,13 @@
10
10
  #include "BackTestPluginInterface.h"
11
11
  #include "DevicePluginInterface.h"
12
12
  #include "DataServerPluginInterface.h"
13
+ #include "ImportKDataToHdf5PluginInterface.h"
13
14
 
14
15
  namespace hku {
15
16
 
16
17
  #define HKU_PLUGIN_BACKTEST "backtest"
17
18
  #define HKU_PLUGIN_DEVICE "device"
18
19
  #define HKU_PLUGIN_DATASERVER "dataserver"
20
+ #define HKU_PLUGIN_IMPORTKDATATOHDF5 "import2hdf5"
19
21
 
20
22
  }
@@ -120,12 +120,6 @@ public:
120
120
  m_sp = slippage;
121
121
  }
122
122
 
123
- KData getKData(const Stock& stk, const Datetime& start_date, const Datetime& end_date,
124
- const KQuery::KType& ktype,
125
- KQuery::RecoverType recover_type = KQuery::NO_RECOVER) const {
126
- return stk.getKData(KQueryByDate(start_date, end_date, ktype, recover_type));
127
- }
128
-
129
123
  KData getLastKData(const Stock& stk, const Datetime& start_date, const KQuery::KType& ktype,
130
124
  KQuery::RecoverType recover_type = KQuery::NO_RECOVER) const {
131
125
  return getKData(stk, start_date, Null<Datetime>(), ktype, recover_type);
@@ -134,6 +128,9 @@ public:
134
128
  KData getLastKData(const Stock& stk, size_t lastnum, const KQuery::KType& ktype,
135
129
  KQuery::RecoverType recover_type = KQuery::NO_RECOVER) const;
136
130
 
131
+ virtual KData getKData(const Stock& stk, const Datetime& start_date, const Datetime& end_date,
132
+ const KQuery::KType& ktype,
133
+ KQuery::RecoverType recover_type = KQuery::NO_RECOVER) const;
137
134
  virtual Datetime today() const {
138
135
  return Datetime::today();
139
136
  }
@@ -116,7 +116,8 @@ private:
116
116
 
117
117
  protected:
118
118
  // 跟踪打印当前TM持仓情况
119
- void traceMomentTM(const Datetime& date);
119
+ void traceMomentTMAfterRunAtOpen(const Datetime& date);
120
+ void traceMomentTMAfterRunAtClose(const Datetime& date);
120
121
 
121
122
  protected:
122
123
  string m_name;
@@ -87,6 +87,9 @@ public:
87
87
  */
88
88
  const SystemList& getRealSystemList() const;
89
89
 
90
+ /** 获取指定时刻收盘时选中的标的 */
91
+ SystemWeightList getSelected(Datetime date);
92
+
90
93
  /**
91
94
  * @brief 复位
92
95
  * @note 复位不会清除已有的原型系统
@@ -111,7 +114,7 @@ public:
111
114
  virtual void _calculate() = 0;
112
115
 
113
116
  /** 子类获取指定时刻收盘时选中的标的 */
114
- virtual SystemWeightList getSelected(Datetime date) = 0;
117
+ virtual SystemWeightList _getSelected(Datetime date) = 0;
115
118
 
116
119
  virtual bool isMatchAF(const AFPtr& af) = 0;
117
120
 
@@ -141,7 +144,7 @@ protected:
141
144
  KQuery m_query;
142
145
  KQuery m_proto_query;
143
146
 
144
- SystemList m_pro_sys_list; // 原型系统列表
147
+ SystemList m_pro_sys_list; // 原型系统列表
145
148
  SystemList m_real_sys_list; // PF组合中实际运行的系统,有PF执行时设定,顺序与原型列表一一对应
146
149
 
147
150
  //============================================
@@ -197,13 +200,13 @@ private: \
197
200
  #define SELECTOR_NO_PRIVATE_MEMBER_SERIALIZATION
198
201
  #endif
199
202
 
200
- #define SELECTOR_IMP(classname) \
201
- public: \
202
- virtual SelectorPtr _clone() override { \
203
- return std::make_shared<classname>(); \
204
- } \
205
- virtual SystemWeightList getSelected(Datetime date) override; \
206
- virtual bool isMatchAF(const AFPtr& af) override; \
203
+ #define SELECTOR_IMP(classname) \
204
+ public: \
205
+ virtual SelectorPtr _clone() override { \
206
+ return std::make_shared<classname>(); \
207
+ } \
208
+ virtual SystemWeightList _getSelected(Datetime date) override; \
209
+ virtual bool isMatchAF(const AFPtr& af) override; \
207
210
  virtual void _calculate() override;
208
211
 
209
212
  /**
@@ -21,7 +21,7 @@ public:
21
21
  virtual void _checkParam(const string& name) const override;
22
22
  virtual void _reset() override;
23
23
  virtual SelectorPtr _clone() override;
24
- virtual SystemWeightList getSelected(Datetime date) override;
24
+ virtual SystemWeightList _getSelected(Datetime date) override;
25
25
  virtual bool isMatchAF(const AFPtr& af) override;
26
26
  virtual void _calculate() override;
27
27
 
@@ -22,7 +22,7 @@ public:
22
22
  virtual SelectorPtr _clone() override;
23
23
  virtual bool isMatchAF(const AFPtr& af) override;
24
24
  virtual void _calculate() override;
25
- virtual SystemWeightList getSelected(Datetime date) override {
25
+ virtual SystemWeightList _getSelected(Datetime date) override {
26
26
  return SystemWeightList();
27
27
  }
28
28
 
@@ -80,17 +80,17 @@ private:
80
80
  #endif
81
81
  };
82
82
 
83
- #define OPERATOR_SELECTOR_IMP(classname, name) \
84
- public: \
85
- classname() : OperatorSelector(name) {} \
86
- classname(const SelectorPtr& se1, const SelectorPtr& se2) \
87
- : OperatorSelector(name, se1, se2) {} \
88
- virtual ~classname() {} \
89
- \
90
- virtual SystemWeightList getSelected(Datetime date) override; \
91
- \
92
- virtual SelectorPtr _clone() override { \
93
- HKU_THROW("OperatorSelector Could't support clone!"); \
83
+ #define OPERATOR_SELECTOR_IMP(classname, name) \
84
+ public: \
85
+ classname() : OperatorSelector(name) {} \
86
+ classname(const SelectorPtr& se1, const SelectorPtr& se2) \
87
+ : OperatorSelector(name, se1, se2) {} \
88
+ virtual ~classname() {} \
89
+ \
90
+ virtual SystemWeightList _getSelected(Datetime date) override; \
91
+ \
92
+ virtual SelectorPtr _clone() override { \
93
+ HKU_THROW("OperatorSelector Could't support clone!"); \
94
94
  }
95
95
 
96
96
  #if HKU_SUPPORT_SERIALIZATION
@@ -22,7 +22,7 @@ public:
22
22
  virtual SelectorPtr _clone() override;
23
23
  virtual bool isMatchAF(const AFPtr& af) override;
24
24
  virtual void _calculate() override;
25
- virtual SystemWeightList getSelected(Datetime date) override {
25
+ virtual SystemWeightList _getSelected(Datetime date) override {
26
26
  return SystemWeightList();
27
27
  }
28
28
 
@@ -68,7 +68,7 @@ public:
68
68
  classname(const SelectorPtr& se, double value) : OperatorValueSelector(name, se, value) {} \
69
69
  virtual ~classname() {} \
70
70
  \
71
- virtual SystemWeightList getSelected(Datetime date) override; \
71
+ virtual SystemWeightList _getSelected(Datetime date) override; \
72
72
  \
73
73
  virtual SelectorPtr _clone() override { \
74
74
  auto p = std::make_shared<classname>(); \
@@ -22,7 +22,7 @@ public:
22
22
  virtual void _checkParam(const string& name) const override;
23
23
  virtual void calculate(const SystemList& pf_realSysList, const KQuery& query) override;
24
24
 
25
- virtual SystemWeightList getSelected(Datetime date) override;
25
+ virtual SystemWeightList _getSelected(Datetime date) override;
26
26
  virtual SelectorPtr _clone() override;
27
27
  virtual void _reset() override;
28
28
 
@@ -251,11 +251,20 @@ public:
251
251
  virtual void clearDelayBuyRequest();
252
252
 
253
253
  // 当前是否存在延迟的操作请求,供Portfolio
254
- virtual bool haveDelaySellRequest() const;
254
+ bool haveDelaySellRequest() const {
255
+ return m_sellRequest.valid;
256
+ }
257
+
258
+ bool haveDelayBuyRequest() const {
259
+ return m_buyRequest.valid;
260
+ }
255
261
 
256
262
  // 处理延迟买入请求,仅供 PF 调用
257
263
  virtual TradeRecord pfProcessDelaySellRequest(const Datetime& date);
258
264
 
265
+ // 处理延迟买入请求,仅供 PF 调用
266
+ virtual TradeRecord pfProcessDelayBuyRequest(const Datetime& date);
267
+
259
268
  private:
260
269
  bool _environmentIsValid(const Datetime& datetime);
261
270
  bool _conditionIsValid(const Datetime& datetime);
@@ -329,8 +338,8 @@ protected:
329
338
  bool m_pre_ev_valid;
330
339
  bool m_pre_cn_valid;
331
340
 
332
- int m_buy_days; // 每一次买入清零,计算一次加1,即买入后的天数
333
- int m_sell_short_days; // 每一次卖空清零
341
+ int m_buy_days; // 每一次买入清零,计算一次加1,即买入后的天数
342
+ int m_sell_short_days; // 每一次卖空清零
334
343
  TradeRecordList m_trade_list; // 保存实际执行的交易记录
335
344
  price_t m_lastTakeProfit; // 上一次多头止损价,用于保证止赢价单调递增
336
345
  price_t m_lastShortTakeProfit; // 上一次空头止赢价
@@ -28,7 +28,6 @@ public:
28
28
  virtual TradeRecord sellForceOnOpen(const Datetime& date, double num, Part from) override;
29
29
  virtual TradeRecord sellForceOnClose(const Datetime& date, double num, Part from) override;
30
30
  virtual void clearDelayBuyRequest() override;
31
- virtual bool haveDelaySellRequest() const override;
32
31
  virtual TradeRecord pfProcessDelaySellRequest(const Datetime& date) override;
33
32
 
34
33
  private:
@@ -36,7 +36,6 @@ public:
36
36
  virtual TradeRecord sellForceOnOpen(const Datetime& date, double num, Part from) override;
37
37
  virtual TradeRecord sellForceOnClose(const Datetime& date, double num, Part from) override;
38
38
  virtual void clearDelayBuyRequest() override;
39
- virtual bool haveDelaySellRequest() const override;
40
39
  virtual TradeRecord pfProcessDelaySellRequest(const Datetime& date) override;
41
40
 
42
41
  private:
@@ -85,29 +85,39 @@ std::string HKU_UTILS_API gb_to_utf8(const std::string &szinput);
85
85
  template <typename ValueT>
86
86
  ValueT roundEx(ValueT number, int ndigits = 0) {
87
87
  // 切换至:ROUND_HALF_EVEN 银行家舍入法
88
- ValueT pow1, pow2, y, z;
89
- ValueT x = number;
90
- if (ndigits >= 0) {
91
- pow1 = pow(ValueT(10.0), ValueT(ndigits));
92
- pow2 = 1.0;
93
- y = (x * pow1) * pow2;
94
- } else {
95
- pow1 = pow(ValueT(10.0), ValueT(-ndigits));
96
- pow2 = 1.0;
97
- y = x / pow1;
98
- }
99
-
100
- z = std::round(y);
101
- if (std::fabs(y - z) == 0.5)
102
- /* halfway between two integers; use round-half-even */
103
- z = 2.0 * std::round(y / 2.0);
104
-
105
- if (ndigits >= 0)
106
- z = (z / pow2) / pow1;
88
+ // ValueT pow1, pow2, y, z;
89
+ // ValueT x = number;
90
+ // if (ndigits >= 0) {
91
+ // pow1 = pow(ValueT(10.0), ValueT(ndigits));
92
+ // pow2 = 1.0;
93
+ // y = (x * pow1) * pow2;
94
+ // } else {
95
+ // pow1 = pow(ValueT(10.0), ValueT(-ndigits));
96
+ // pow2 = 1.0;
97
+ // y = x / pow1;
98
+ // }
99
+
100
+ // z = std::round(y);
101
+ // if (std::fabs(y - z) == 0.5)
102
+ // /* halfway between two integers; use round-half-even */
103
+ // z = 2.0 * std::round(y / 2.0);
104
+
105
+ // if (ndigits >= 0)
106
+ // z = (z / pow2) / pow1;
107
+ // else
108
+ // z *= pow1;
109
+
110
+ // 国内一般使用传统四舍五入法
111
+ if (ndigits < 0)
112
+ return number; // 无效位数直接返回原值
113
+
114
+ const double factor = std::pow(10.0, ndigits);
115
+ const double epsilon = 1e-10 * factor; // 动态调整epsilon避免精度误差
116
+
117
+ if (number >= 0)
118
+ return static_cast<ValueT>(std::floor(number * factor + 0.5 + epsilon) / factor);
107
119
  else
108
- z *= pow1;
109
-
110
- return z;
120
+ return static_cast<ValueT>(std::ceil(number * factor - 0.5 - epsilon) / factor);
111
121
  }
112
122
 
113
123
  /**
@@ -94,6 +94,7 @@ public:
94
94
  * <pre>
95
95
  * 1、YYYYMMDDhhmm,如 200101010000
96
96
  * 2、YYYYMMDD, 如 20010101
97
+ * 3、YYYYMMDDhhmmss,如 20010101000000
97
98
  * </pre>
98
99
  */
99
100
  explicit Datetime(unsigned long long);
@@ -12,13 +12,13 @@
12
12
  #define HKU_VERSION_H
13
13
 
14
14
  // clang-format off
15
- #define HKU_VERSION "2.6.0"
15
+ #define HKU_VERSION "2.6.2"
16
16
  #define HKU_VERSION_MAJOR 2
17
17
  #define HKU_VERSION_MINOR 6
18
- #define HKU_VERSION_ALTER 0
19
- #define HKU_VERSION_BUILD 202504301710
18
+ #define HKU_VERSION_ALTER 2
19
+ #define HKU_VERSION_BUILD 202505141721
20
20
  #define HKU_VERSION_MODE "RELEASE"
21
- #define HKU_VERSION_GIT "2.6.0 release.3bd470a3 (RELEASE)"
21
+ #define HKU_VERSION_GIT "2.6.2 release.16442c98 (RELEASE)"
22
22
  // clang-format on
23
23
 
24
24
  #endif /* HKU_VERSION_H */
Binary file
Binary file
hikyuu/plugin/device.dll CHANGED
Binary file
Binary file