hikyuu 2.1.0__cp39-none-win_amd64.whl → 2.1.1__cp39-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 (75) 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/core39.pyd +0 -0
  5. hikyuu/cpp/hikyuu.dll +0 -0
  6. hikyuu/extend.py +3 -1
  7. hikyuu/gui/HikyuuTDX.py +11 -6
  8. hikyuu/include/hikyuu/DataType.h +2 -1
  9. hikyuu/include/hikyuu/KRecord.h +1 -1
  10. hikyuu/include/hikyuu/StockManager.h +3 -0
  11. hikyuu/include/hikyuu/analysis/combinate.h +1 -1
  12. hikyuu/include/hikyuu/config.h +0 -12
  13. hikyuu/include/hikyuu/strategy/AccountTradeManager.h +3 -1
  14. hikyuu/include/hikyuu/utilities/FilterNode.h +267 -0
  15. hikyuu/include/hikyuu/utilities/LRUCache11.h +230 -0
  16. hikyuu/include/hikyuu/{Log.h → utilities/Log.h} +91 -113
  17. hikyuu/include/hikyuu/utilities/Null.h +1 -0
  18. hikyuu/include/hikyuu/utilities/Parameter.h +2 -1
  19. hikyuu/include/hikyuu/utilities/ResourcePool.h +636 -0
  20. hikyuu/include/hikyuu/utilities/SpendTimer.h +10 -9
  21. hikyuu/include/hikyuu/utilities/TimerManager.h +2 -2
  22. hikyuu/include/hikyuu/utilities/any_to_string.h +142 -0
  23. hikyuu/include/hikyuu/utilities/arithmetic.h +69 -33
  24. hikyuu/include/hikyuu/utilities/base64.h +59 -0
  25. hikyuu/include/hikyuu/utilities/config.h +41 -0
  26. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +41 -31
  27. hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +24 -13
  28. hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +48 -48
  29. hikyuu/include/hikyuu/utilities/db_connect/DBConnect.h +10 -0
  30. hikyuu/include/hikyuu/utilities/db_connect/DBConnectBase.h +5 -22
  31. hikyuu/include/hikyuu/utilities/db_connect/DBUpgrade.h +3 -3
  32. hikyuu/include/hikyuu/utilities/db_connect/SQLException.h +1 -1
  33. hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +1 -1
  34. hikyuu/include/hikyuu/utilities/db_connect/SQLStatementBase.h +7 -7
  35. hikyuu/include/hikyuu/utilities/db_connect/TableMacro.h +1 -2
  36. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +9 -9
  37. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +18 -18
  38. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +3 -3
  39. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +2 -2
  40. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteUtil.h +6 -6
  41. hikyuu/include/hikyuu/{exception.h → utilities/exception.h} +1 -0
  42. hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +229 -0
  43. hikyuu/include/hikyuu/utilities/http_client/nng_wrap.h +517 -0
  44. hikyuu/include/hikyuu/utilities/http_client/url.h +25 -0
  45. hikyuu/include/hikyuu/utilities/{IniParser.h → ini_parser/IniParser.h} +10 -5
  46. hikyuu/include/hikyuu/utilities/ini_parser/__init__.py +1 -0
  47. hikyuu/include/hikyuu/utilities/md5.h +41 -0
  48. hikyuu/include/hikyuu/utilities/mo/__init__.py +1 -0
  49. hikyuu/include/hikyuu/utilities/mo/mo.h +48 -0
  50. hikyuu/include/hikyuu/utilities/mo/moFileReader.h +836 -0
  51. hikyuu/include/hikyuu/{global → utilities}/node/NodeClient.h +25 -18
  52. hikyuu/include/hikyuu/{global → utilities}/node/NodeError.h +1 -1
  53. hikyuu/include/hikyuu/{global → utilities}/node/NodeMessage.h +3 -2
  54. hikyuu/include/hikyuu/utilities/node/NodeServer.h +246 -0
  55. hikyuu/include/hikyuu/utilities/node/__init__.py +1 -0
  56. hikyuu/include/hikyuu/utilities/os.h +16 -15
  57. hikyuu/include/hikyuu/utilities/snowflake.h +110 -0
  58. hikyuu/include/hikyuu/utilities/string_view.h +70 -0
  59. hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +3 -3
  60. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +3 -3
  61. hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +3 -3
  62. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +3 -3
  63. hikyuu/include/hikyuu/version.h +4 -4
  64. hikyuu/sqlite3.dll +0 -0
  65. hikyuu/vcruntime140.dll +0 -0
  66. hikyuu/vcruntime140_1.dll +0 -0
  67. hikyuu-2.1.1.dist-info/METADATA +115 -0
  68. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/RECORD +73 -53
  69. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/top_level.txt +4 -1
  70. hikyuu/README.rst +0 -79
  71. hikyuu-2.1.0.dist-info/METADATA +0 -126
  72. /hikyuu/include/hikyuu/{global/node → utilities/http_client}/__init__.py +0 -0
  73. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/LICENSE +0 -0
  74. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/WHEEL +0 -0
  75. {hikyuu-2.1.0.dist-info → hikyuu-2.1.1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,142 @@
1
+ /*
2
+ * Copyright (c) 2023 hikyuu.org
3
+ *
4
+ * Created on: 2023-01-15
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <string>
11
+
12
+ #include "osdef.h"
13
+ #include "cppdef.h"
14
+ #if !HKU_OS_IOS && CPP_STANDARD >= CPP_STANDARD_17
15
+ #include <any>
16
+ #else
17
+ #include <boost/any.hpp>
18
+ #endif
19
+
20
+ #if defined(HKU_SUPPORT_DATETIME)
21
+ #include "hikyuu/utilities/datetime/Datetime.h"
22
+ #endif
23
+
24
+ namespace hku {
25
+
26
+ #if !HKU_OS_IOS && CPP_STANDARD >= CPP_STANDARD_17
27
+ using any_t = std::any;
28
+ using std::any_cast;
29
+ #else
30
+ using any_t = boost::any;
31
+ using boost::any_cast;
32
+ #endif
33
+
34
+ //------------------------------------------------------------------------------
35
+ //
36
+ // 常见基本类型包装的 any_t 和 std::string 的互相转换函数
37
+ // any_to_string 要用户自定义类型需包含从 std::string 进行构造的构造函数
38
+ // string_to_any 需要用户自定义实现 std::to_string 特化方法
39
+ //
40
+ //------------------------------------------------------------------------------
41
+
42
+ template <typename ValueT>
43
+ inline std::string any_to_string(const any_t& data) {
44
+ return any_cast<ValueT>(data).str();
45
+ }
46
+
47
+ template <typename ValueT>
48
+ inline any_t string_to_any(const std::string& data) {
49
+ return any_t(ValueT(data));
50
+ }
51
+
52
+ template <>
53
+ inline std::string any_to_string<int>(const any_t& data) {
54
+ return std::to_string(any_cast<int>(data));
55
+ }
56
+
57
+ template <>
58
+ inline std::string any_to_string<long>(const any_t& data) {
59
+ return std::to_string(any_cast<long>(data));
60
+ }
61
+
62
+ template <>
63
+ inline std::string any_to_string<long long>(const any_t& data) {
64
+ return std::to_string(any_cast<long long>(data));
65
+ }
66
+
67
+ template <>
68
+ inline std::string any_to_string<unsigned int>(const any_t& data) {
69
+ return std::to_string(any_cast<unsigned int>(data));
70
+ }
71
+
72
+ template <>
73
+ inline std::string any_to_string<unsigned long>(const any_t& data) {
74
+ return std::to_string(any_cast<unsigned long>(data));
75
+ }
76
+
77
+ template <>
78
+ inline std::string any_to_string<unsigned long long>(const any_t& data) {
79
+ return std::to_string(any_cast<unsigned long long>(data));
80
+ }
81
+
82
+ template <>
83
+ inline std::string any_to_string<float>(const any_t& data) {
84
+ return std::to_string(any_cast<float>(data));
85
+ }
86
+
87
+ template <>
88
+ inline std::string any_to_string<double>(const any_t& data) {
89
+ return std::to_string(any_cast<double>(data));
90
+ }
91
+
92
+ template <>
93
+ inline std::string any_to_string<long double>(const any_t& data) {
94
+ return std::to_string(any_cast<long double>(data));
95
+ }
96
+
97
+ template <>
98
+ inline any_t string_to_any<int>(const std::string& data) {
99
+ return any_t(std::stoi(data));
100
+ }
101
+
102
+ template <>
103
+ inline any_t string_to_any<long>(const std::string& data) {
104
+ return any_t(std::stol(data));
105
+ }
106
+
107
+ template <>
108
+ inline any_t string_to_any<long long>(const std::string& data) {
109
+ return any_t(std::stoll(data));
110
+ }
111
+
112
+ template <>
113
+ inline any_t string_to_any<unsigned int>(const std::string& data) {
114
+ return any_t((unsigned int)(std::stoul(data)));
115
+ }
116
+
117
+ template <>
118
+ inline any_t string_to_any<unsigned long>(const std::string& data) {
119
+ return any_t(std::stoul(data));
120
+ }
121
+
122
+ template <>
123
+ inline any_t string_to_any<unsigned long long>(const std::string& data) {
124
+ return any_t(std::stoull(data));
125
+ }
126
+
127
+ template <>
128
+ inline any_t string_to_any<float>(const std::string& data) {
129
+ return any_t(std::stof(data));
130
+ }
131
+
132
+ template <>
133
+ inline any_t string_to_any<double>(const std::string& data) {
134
+ return any_t(std::stod(data));
135
+ }
136
+
137
+ template <>
138
+ inline any_t string_to_any<long double>(const std::string& data) {
139
+ return any_t(std::stold(data));
140
+ }
141
+
142
+ } // namespace hku
@@ -15,11 +15,12 @@
15
15
  #include <cctype>
16
16
  #include <vector>
17
17
  #include <string>
18
- #include <string_view>
19
18
  #include <algorithm>
20
19
 
21
- #ifndef HKU_API
22
- #define HKU_API
20
+ #include "string_view.h"
21
+
22
+ #ifndef HKU_UTILS_API
23
+ #define HKU_UTILS_API
23
24
  #endif
24
25
 
25
26
  namespace hku {
@@ -30,13 +31,13 @@ namespace hku {
30
31
  */
31
32
 
32
33
  #if defined(_MSC_VER)
33
- std::string HKU_API utf8_to_gb(const char* szinput);
34
- std::string HKU_API utf8_to_gb(const std::string& szinput);
35
- std::string HKU_API gb_to_utf8(const char* szinput);
36
- std::string HKU_API gb_to_utf8(const std::string& szinput);
34
+ std::string HKU_UTILS_API utf8_to_gb(const char *szinput);
35
+ std::string HKU_UTILS_API utf8_to_gb(const std::string &szinput);
36
+ std::string HKU_UTILS_API gb_to_utf8(const char *szinput);
37
+ std::string HKU_UTILS_API gb_to_utf8(const std::string &szinput);
37
38
  #else
38
- std::string HKU_API utf8_to_gb(const std::string& szinput);
39
- std::string HKU_API gb_to_utf8(const std::string& szinput);
39
+ std::string HKU_UTILS_API utf8_to_gb(const std::string &szinput);
40
+ std::string HKU_UTILS_API gb_to_utf8(const std::string &szinput);
40
41
  #endif
41
42
 
42
43
  #define UTF8ToGB hku::utf8_to_gb
@@ -81,7 +82,6 @@ std::string HKU_API gb_to_utf8(const std::string& szinput);
81
82
  * @param ndigits 保留小数位数
82
83
  * @return 处理过的数据
83
84
  */
84
- // double HKU_API roundEx(double number, int ndigits = 0);
85
85
  template <typename ValueT>
86
86
  ValueT roundEx(ValueT number, int ndigits = 0) {
87
87
  // 切换至:ROUND_HALF_EVEN 银行家舍入法
@@ -189,17 +189,17 @@ ValueT roundDown(ValueT number, int ndigits = 0) {
189
189
  #endif
190
190
 
191
191
  /** 转小写字符串 */
192
- inline void to_lower(std::string& s) {
192
+ inline void to_lower(std::string &s) {
193
193
  std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); });
194
194
  }
195
195
 
196
196
  /** 转大写字符串 */
197
- inline void to_upper(std::string& s) {
197
+ inline void to_upper(std::string &s) {
198
198
  std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::toupper(c); });
199
199
  }
200
200
 
201
201
  /** 删除字符串两端空格 */
202
- inline void trim(std::string& s) {
202
+ inline void trim(std::string &s) {
203
203
  if (s.empty()) {
204
204
  return;
205
205
  }
@@ -210,12 +210,13 @@ inline void trim(std::string& s) {
210
210
  s.erase(s.find_last_not_of("\n") + 1);
211
211
  }
212
212
 
213
+ #if CPP_STANDARD >= CPP_STANDARD_17
213
214
  /**
214
215
  * 分割字符串
215
216
  * @param str 待封的字符串
216
217
  * @param c 分割符
217
218
  */
218
- inline std::vector<std::string_view> split(const std::string& str, char c) {
219
+ inline std::vector<std::string_view> split(const std::string &str, char c) {
219
220
  std::vector<std::string_view> result;
220
221
  std::string_view view(str);
221
222
  size_t prepos = 0;
@@ -226,9 +227,7 @@ inline std::vector<std::string_view> split(const std::string& str, char c) {
226
227
  pos = view.find_first_of(c, prepos);
227
228
  }
228
229
 
229
- if (prepos < str.size() - 1) {
230
- result.emplace_back(str.substr(prepos));
231
- }
230
+ result.emplace_back(view.substr(prepos));
232
231
  return result;
233
232
  }
234
233
 
@@ -239,7 +238,7 @@ inline std::vector<std::string_view> split(const std::string& str, char c) {
239
238
  * @return string_view 组成的 vector
240
239
  * @note 注意返回结果的生命周期应小于输入的字符串相同!
241
240
  */
242
- inline std::vector<std::string_view> split(const std::string_view& view, char c) {
241
+ inline std::vector<std::string_view> split(const std::string_view &view, char c) {
243
242
  std::vector<std::string_view> result;
244
243
  size_t prepos = 0;
245
244
  size_t pos = view.find_first_of(c);
@@ -249,14 +248,12 @@ inline std::vector<std::string_view> split(const std::string_view& view, char c)
249
248
  pos = view.find_first_of(c, prepos);
250
249
  }
251
250
 
252
- if (prepos < view.size() - 1) {
253
- result.emplace_back(view.substr(prepos));
254
- }
251
+ result.emplace_back(view.substr(prepos));
255
252
  return result;
256
253
  }
257
254
 
258
- inline std::vector<std::string_view> split(const std::string_view& str,
259
- const std::string& split_str) {
255
+ inline std::vector<std::string_view> split(const std::string_view &str,
256
+ const std::string &split_str) {
260
257
  std::vector<std::string_view> result;
261
258
  size_t split_str_len = split_str.size();
262
259
  if (split_str_len == 0) {
@@ -272,25 +269,64 @@ inline std::vector<std::string_view> split(const std::string_view& str,
272
269
  pos = str.find(split_str, prepos);
273
270
  }
274
271
 
275
- if (prepos < str.size() - 1) {
276
- result.emplace_back(str.substr(prepos));
272
+ result.emplace_back(str.substr(prepos));
273
+ return result;
274
+ }
275
+
276
+ #else
277
+ /**
278
+ * 分割字符串
279
+ * @param str 待封的字符串
280
+ * @param c 分割符
281
+ */
282
+ inline std::vector<std::string> split(const std::string &str, char c) {
283
+ std::vector<std::string> result;
284
+ size_t prepos = 0;
285
+ size_t pos = str.find_first_of(c);
286
+ while (pos != std::string::npos) {
287
+ result.emplace_back(str.substr(prepos, pos - prepos));
288
+ prepos = pos + 1;
289
+ pos = str.find_first_of(c, prepos);
290
+ }
291
+
292
+ result.emplace_back(str.substr(prepos));
293
+ return result;
294
+ }
295
+
296
+ inline std::vector<std::string> split(const std::string &str, const std::string &split_str) {
297
+ std::vector<std::string> result;
298
+ size_t split_str_len = split_str.size();
299
+ if (split_str_len == 0) {
300
+ result.emplace_back(str);
301
+ return result;
277
302
  }
303
+
304
+ size_t prepos = 0;
305
+ size_t pos = str.find(split_str);
306
+ while (pos != std::string::npos) {
307
+ result.emplace_back(str.substr(prepos, pos - prepos));
308
+ prepos = pos + split_str_len;
309
+ pos = str.find(split_str, prepos);
310
+ }
311
+
312
+ result.emplace_back(str.substr(prepos));
278
313
  return result;
279
314
  }
315
+ #endif /* #if CPP_STANDARD >= CPP_STANDARD_17 */
280
316
 
281
317
  /**
282
318
  * byte 转 16 进制字符串, 如 "abcd" 转换为 "61626364"
283
319
  * @param in_byte 输入的 byte 数组
284
320
  * @param in_len byte 数组长度
285
321
  */
286
- inline std::string byteToHexStr(const char* bytes, size_t in_len) {
322
+ inline std::string byteToHexStr(const char *bytes, size_t in_len) {
287
323
  std::string hexstr;
288
- const unsigned char* in_byte = (const unsigned char*)bytes;
324
+ const unsigned char *in_byte = (const unsigned char *)bytes;
289
325
  if (in_byte == nullptr) {
290
326
  return hexstr;
291
327
  }
292
328
 
293
- char* buf = new char[2 * in_len + 1];
329
+ char *buf = new char[2 * in_len + 1];
294
330
  size_t buf_ix = 0;
295
331
 
296
332
  for (size_t i = 0; i < in_len; ++i) {
@@ -311,7 +347,7 @@ inline std::string byteToHexStr(const char* bytes, size_t in_len) {
311
347
  * byte 转 16 进制字符串, 如 "abcd" 转换为 "61626364"
312
348
  * @param in_byte std::string 格式的输入
313
349
  */
314
- inline std::string byteToHexStr(const std::string& bytes) {
350
+ inline std::string byteToHexStr(const std::string &bytes) {
315
351
  return byteToHexStr(bytes.c_str(), bytes.size());
316
352
  }
317
353
 
@@ -320,14 +356,14 @@ inline std::string byteToHexStr(const std::string& bytes) {
320
356
  * @param in_byte 输入的 byte 数组
321
357
  * @param in_len byte 数组长度
322
358
  */
323
- inline std::string byteToHexStrForPrint(const char* bytes, size_t in_len) {
359
+ inline std::string byteToHexStrForPrint(const char *bytes, size_t in_len) {
324
360
  std::string hexstr;
325
- const unsigned char* in_byte = (const unsigned char*)bytes;
361
+ const unsigned char *in_byte = (const unsigned char *)bytes;
326
362
  if (in_byte == nullptr) {
327
363
  return hexstr;
328
364
  }
329
365
 
330
- char* buf = new char[5 * in_len + 1];
366
+ char *buf = new char[5 * in_len + 1];
331
367
  size_t buf_ix = 0;
332
368
 
333
369
  for (size_t i = 0; i < in_len; ++i) {
@@ -355,7 +391,7 @@ inline std::string byteToHexStrForPrint(const char* bytes, size_t in_len) {
355
391
  * byte 转 16 进制字符串, 如 "abcd" 转换为 "61626364"
356
392
  * @param in_byte 输入的 byte 数组
357
393
  */
358
- inline std::string byteToHexStrForPrint(const std::string& bytes) {
394
+ inline std::string byteToHexStrForPrint(const std::string &bytes) {
359
395
  return byteToHexStrForPrint(bytes.c_str(), bytes.size());
360
396
  }
361
397
 
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright (c) hikyuu.org
3
+ *
4
+ * Created on: 2020-6-2
5
+ * Author: fasiondog
6
+ */
7
+
8
+ #pragma once
9
+ #ifndef HKU_UTILS_BASE64_H
10
+ #define HKU_UTILS_BASE64_H
11
+
12
+ #include <memory>
13
+ #include "string_view.h"
14
+
15
+ #ifndef HKU_UTILS_API
16
+ #define HKU_UTILS_API
17
+ #endif
18
+
19
+ namespace hku {
20
+
21
+ /**
22
+ * 将二进制 bytes 数组编码成 base64 字符串
23
+ * @param bytes_to_encode 内存起始地址
24
+ * @param in_len 待计算的字节长度
25
+ */
26
+ std::string HKU_UTILS_API base64_encode(unsigned char const* bytes_to_encode, size_t in_len);
27
+
28
+ /**
29
+ * 字符串编码为 base64
30
+ * @param bytes_to_encode 内存起始地址
31
+ * @param in_len 待计算的字节长度
32
+ * @note 通过 func(unsigned char *, unsigned int) 函数实现,而不是直接只提供 string_view
33
+ * 版本的原因是:c++17 string_view 处理 nullptr 时,程序会直接挂掉,无异常
34
+ */
35
+ inline std::string base64_encode(string_view src) {
36
+ return base64_encode((unsigned char const*)src.data(), src.size());
37
+ }
38
+
39
+ /**
40
+ * 将 base64 字符串解码
41
+ * @param encoded_string base64 编码的字符串
42
+ * @param in_len 字符串长度
43
+ * @return string 实际解码后的二进制内容保存在返回的字符串对象中
44
+ * @note 如果传入的base64编码字符串中含有非法字符,不会告警,仅处理到能处理的字符
45
+ */
46
+ std::string HKU_UTILS_API base64_decode(unsigned char const* encoded_string, size_t in_len);
47
+
48
+ /**
49
+ * 将 base64 字符串解码
50
+ * @param encoded_string base64 编码的字符串
51
+ * @return string 实际解码后的二进制内容保存在返回的字符串对象中
52
+ */
53
+ inline std::string base64_decode(string_view encoded_string) {
54
+ return base64_decode((unsigned char const*)encoded_string.data(), encoded_string.size());
55
+ }
56
+
57
+ } // namespace hku
58
+
59
+ #endif // HKU_UTILS_BASE64_H
@@ -0,0 +1,41 @@
1
+ #pragma once
2
+ #ifndef HKU_UTILS_CONFIG_H_
3
+ #define HKU_UTILS_CONFIG_H_
4
+
5
+ #include "osdef.h"
6
+
7
+ // clang-format off
8
+
9
+ #define HKU_ENABLE_MYSQL 1
10
+ #if HKU_ENABLE_MYSQL && HKU_OS_WINDOWS
11
+ #ifndef NOMINMAX
12
+ #define NOMINMAX
13
+ #endif
14
+ #endif
15
+
16
+ #define HKU_ENABLE_SQLITE 1
17
+ #define HKU_ENABLE_SQLCIPHER 0
18
+ /* #define HKU_SQL_TRACE 0 */
19
+
20
+ #define HKU_SUPPORT_DATETIME 1
21
+
22
+ #define HKU_ENABLE_INI_PARSER 1
23
+
24
+ #define HKU_ENABLE_STACK_TRACE 0
25
+
26
+ #define HKU_CLOSE_SPEND_TIME 0
27
+
28
+ #define HKU_USE_SPDLOG_ASYNC_LOGGER 0
29
+ #define HKU_LOG_ACTIVE_LEVEL "2"
30
+
31
+ #define HKU_ENABLE_MO 0
32
+
33
+ #define HKU_ENABLE_HTTP_CLIENT 1
34
+ #define HKU_ENABLE_HTTP_CLIENT_SSL 0
35
+ #define HKU_ENABLE_HTTP_CLIENT_ZIP 0
36
+
37
+ /* #undef HKU_ENABLE_NODE */
38
+
39
+ // clang-format on
40
+
41
+ #endif /* HKU_UTILS_CONFIG_H_ */
@@ -17,14 +17,19 @@
17
17
  #include <string>
18
18
  #include <vector>
19
19
  #include <fmt/ostream.h>
20
+
21
+ #include "hikyuu/utilities/config.h"
22
+ #if !HKU_SUPPORT_DATETIME
23
+ #error "Don't support datetime, you can config with --datetime=y"
24
+ #endif
20
25
  #include "TimeDelta.h"
21
26
 
22
27
  #if defined(_MSC_VER)
23
28
  #pragma warning(disable : 4251)
24
29
  #endif
25
30
 
26
- #ifndef HKU_API
27
- #define HKU_API
31
+ #ifndef HKU_UTILS_API
32
+ #define HKU_UTILS_API
28
33
  #endif
29
34
 
30
35
  namespace hku {
@@ -37,7 +42,7 @@ namespace bd = boost::gregorian;
37
42
  * @details 构造失败将抛出异常 std::out_of_range
38
43
  * @ingroup DataType
39
44
  */
40
- class HKU_API Datetime {
45
+ class HKU_UTILS_API Datetime {
41
46
  public:
42
47
  /** 返回所能表示的最小日期:1400-Jan-01 00:00:00 */
43
48
  static Datetime min();
@@ -61,7 +66,7 @@ public:
61
66
  /** 默认构造函数,Null<Datetime> */
62
67
  Datetime();
63
68
 
64
- Datetime(const Datetime&);
69
+ Datetime(const Datetime &);
65
70
 
66
71
  /**
67
72
  * 构造函数
@@ -78,10 +83,10 @@ public:
78
83
  long millisec = 0, long microsec = 0);
79
84
 
80
85
  /** 从boost::gregorian::date构造日期类型 */
81
- explicit Datetime(const bd::date&);
86
+ explicit Datetime(const bd::date &);
82
87
 
83
88
  /** 从boost::posix_time::ptime构造 */
84
- explicit Datetime(const bt::ptime&);
89
+ explicit Datetime(const bt::ptime &);
85
90
 
86
91
  /**
87
92
  * 通过数字方式构造日期类型
@@ -103,9 +108,9 @@ public:
103
108
  * 4、"20010101T181159"
104
109
  * </pre>
105
110
  */
106
- explicit Datetime(const std::string&);
111
+ explicit Datetime(const std::string &);
107
112
 
108
- Datetime& operator=(const Datetime&);
113
+ Datetime &operator=(const Datetime &);
109
114
 
110
115
  /** 年份,如果是 Null 将抛出异常 */
111
116
  long year() const;
@@ -283,7 +288,7 @@ private:
283
288
  bt::ptime m_data;
284
289
  };
285
290
 
286
- HKU_API std::ostream& operator<<(std::ostream&, const Datetime&);
291
+ HKU_UTILS_API std::ostream &operator<<(std::ostream &, const Datetime &);
287
292
 
288
293
  /**
289
294
  * 日期列表
@@ -297,41 +302,41 @@ typedef std::vector<Datetime> DatetimeList;
297
302
  * @param end 结束日期
298
303
  * @return [start, end)范围内的日历日期
299
304
  */
300
- DatetimeList HKU_API getDateRange(const Datetime& start, const Datetime& end);
305
+ DatetimeList HKU_UTILS_API getDateRange(const Datetime &start, const Datetime &end);
301
306
 
302
307
  ///////////////////////////////////////////////////////////////////////////////
303
308
  //
304
309
  // 关系比较函数, 不直接在类中定义是为了支持 Null<>() == d,Null可以放在左边
305
310
  //
306
311
  ///////////////////////////////////////////////////////////////////////////////
307
- bool operator==(const Datetime&, const Datetime&);
308
- bool operator!=(const Datetime&, const Datetime&);
309
- bool operator>(const Datetime&, const Datetime&);
310
- bool operator<(const Datetime&, const Datetime&);
311
- bool operator>=(const Datetime&, const Datetime&);
312
- bool operator<=(const Datetime&, const Datetime&);
313
-
314
- inline bool operator==(const Datetime& d1, const Datetime& d2) {
312
+ bool operator==(const Datetime &, const Datetime &);
313
+ bool operator!=(const Datetime &, const Datetime &);
314
+ bool operator>(const Datetime &, const Datetime &);
315
+ bool operator<(const Datetime &, const Datetime &);
316
+ bool operator>=(const Datetime &, const Datetime &);
317
+ bool operator<=(const Datetime &, const Datetime &);
318
+
319
+ inline bool operator==(const Datetime &d1, const Datetime &d2) {
315
320
  return d1.ptime() == d2.ptime();
316
321
  }
317
322
 
318
- inline bool operator!=(const Datetime& d1, const Datetime& d2) {
323
+ inline bool operator!=(const Datetime &d1, const Datetime &d2) {
319
324
  return d1.ptime() != d2.ptime();
320
325
  }
321
326
 
322
- inline bool operator>(const Datetime& d1, const Datetime& d2) {
327
+ inline bool operator>(const Datetime &d1, const Datetime &d2) {
323
328
  return d1.ptime() > d2.ptime();
324
329
  }
325
330
 
326
- inline bool operator<(const Datetime& d1, const Datetime& d2) {
331
+ inline bool operator<(const Datetime &d1, const Datetime &d2) {
327
332
  return d1.ptime() < d2.ptime();
328
333
  }
329
334
 
330
- inline bool operator>=(const Datetime& d1, const Datetime& d2) {
335
+ inline bool operator>=(const Datetime &d1, const Datetime &d2) {
331
336
  return d1.ptime() >= d2.ptime();
332
337
  }
333
338
 
334
- inline bool operator<=(const Datetime& d1, const Datetime& d2) {
339
+ inline bool operator<=(const Datetime &d1, const Datetime &d2) {
335
340
  return d1.ptime() <= d2.ptime();
336
341
  }
337
342
 
@@ -340,11 +345,11 @@ inline bool operator<=(const Datetime& d1, const Datetime& d2) {
340
345
  // 加、减法运算补充
341
346
  //
342
347
  ///////////////////////////////////////////////////////////////////////////////
343
- inline Datetime operator+(const TimeDelta& delta, const Datetime& date) {
348
+ inline Datetime operator+(const TimeDelta &delta, const Datetime &date) {
344
349
  return date + delta;
345
350
  }
346
351
 
347
- inline TimeDelta operator-(const Datetime& d1, const Datetime& d2) {
352
+ inline TimeDelta operator-(const Datetime &d1, const Datetime &d2) {
348
353
  return TimeDelta(d1.ptime() - d2.ptime());
349
354
  }
350
355
 
@@ -359,11 +364,11 @@ inline Datetime::Datetime() {
359
364
  m_data = bt::ptime(d, bt::time_duration(0, 0, 0));
360
365
  }
361
366
 
362
- inline Datetime::Datetime(const Datetime& d) : m_data(d.m_data) {}
367
+ inline Datetime::Datetime(const Datetime &d) : m_data(d.m_data) {}
363
368
 
364
- inline Datetime::Datetime(const bd::date& d) : m_data(bt::ptime(d, bt::time_duration(0, 0, 0))) {}
369
+ inline Datetime::Datetime(const bd::date &d) : m_data(bt::ptime(d, bt::time_duration(0, 0, 0))) {}
365
370
 
366
- inline Datetime::Datetime(const bt::ptime& d) : m_data(d) {}
371
+ inline Datetime::Datetime(const bt::ptime &d) : m_data(d) {}
367
372
 
368
373
  inline bt::ptime Datetime::ptime() const {
369
374
  return m_data;
@@ -404,21 +409,26 @@ namespace std {
404
409
  template <>
405
410
  class hash<hku::Datetime> {
406
411
  public:
407
- size_t operator()(hku::Datetime const& d) const noexcept {
412
+ size_t operator()(hku::Datetime const &d) const noexcept {
408
413
  return d.ticks(); // or use boost::hash_combine
409
414
  }
410
415
  };
416
+
417
+ inline string to_string(const hku::Datetime &date) {
418
+ return date.str();
419
+ }
420
+
411
421
  } // namespace std
412
422
 
413
423
  #if FMT_VERSION >= 90000
414
424
  template <>
415
425
  struct fmt::formatter<hku::Datetime> {
416
- constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
426
+ constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
417
427
  return ctx.end();
418
428
  }
419
429
 
420
430
  template <typename FormatContext>
421
- auto format(const hku::Datetime& d, FormatContext& ctx) const -> decltype(ctx.out()) {
431
+ auto format(const hku::Datetime &d, FormatContext &ctx) const -> decltype(ctx.out()) {
422
432
  return fmt::format_to(ctx.out(), "{}", d.str());
423
433
  }
424
434
  };