hikyuu 2.0.9__cp310-none-win_amd64.whl → 2.1.1__cp310-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. hikyuu/analysis/analysis.py +6 -5
  2. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  3. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  4. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  5. hikyuu/cpp/core310.pyd +0 -0
  6. hikyuu/cpp/hikyuu.dll +0 -0
  7. hikyuu/cpp/sqlite3.dll +0 -0
  8. hikyuu/data/common.py +1 -4
  9. hikyuu/draw/drawplot/matplotlib_draw.py +3 -2
  10. hikyuu/extend.py +3 -1
  11. hikyuu/flat/Spot.py +0 -139
  12. hikyuu/flat/SpotList.py +1 -59
  13. hikyuu/gui/HikyuuTDX.py +17 -11
  14. hikyuu/gui/data/UseTdxImportToH5Thread.py +1 -1
  15. hikyuu/hub.py +1 -1
  16. hikyuu/include/hikyuu/Block.h +2 -2
  17. hikyuu/include/hikyuu/DataType.h +2 -1
  18. hikyuu/include/hikyuu/KRecord.h +1 -1
  19. hikyuu/include/hikyuu/StockManager.h +3 -0
  20. hikyuu/include/hikyuu/analysis/combinate.h +1 -1
  21. hikyuu/include/hikyuu/config.h +3 -12
  22. hikyuu/include/hikyuu/global/agent/hikyuu/flat/__init__.py +1 -0
  23. hikyuu/include/hikyuu/global/agent/spot_generated.h +3 -225
  24. hikyuu/include/hikyuu/indicator/crt/BLOCKSETNUM.h +1 -9
  25. hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -5
  26. hikyuu/include/hikyuu/strategy/AccountTradeManager.h +3 -1
  27. hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -5
  28. hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +1 -1
  29. hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -5
  30. hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +1 -1
  31. hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +1 -1
  32. hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +24 -1
  33. hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
  34. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Fixed.h +5 -2
  35. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor.h +2 -5
  36. hikyuu/include/hikyuu/trade_sys/selector/crt/SE_Operator.h +43 -0
  37. hikyuu/include/hikyuu/trade_sys/selector/imp/FixedSelector.h +1 -0
  38. hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +9 -2
  39. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorAddSelector.h +19 -0
  40. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorAddValueSelector.h +19 -0
  41. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorDivSelector.h +19 -0
  42. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorDivValueSelector.h +19 -0
  43. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorInvertDivValueSelector.h +19 -0
  44. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorInvertSubValueSelector.h +19 -0
  45. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorMulSelector.h +19 -0
  46. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorMulValueSelector.h +19 -0
  47. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorSelector.h +99 -0
  48. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorSubSelector.h +19 -0
  49. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorSubValueSelector.h +19 -0
  50. hikyuu/include/hikyuu/trade_sys/selector/imp/OperatorValueSelector.h +77 -0
  51. hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -5
  52. hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +1 -1
  53. hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -6
  54. hikyuu/include/hikyuu/trade_sys/system/System.h +21 -13
  55. hikyuu/include/hikyuu/utilities/FilterNode.h +267 -0
  56. hikyuu/include/hikyuu/utilities/LRUCache11.h +230 -0
  57. hikyuu/include/hikyuu/{Log.h → utilities/Log.h} +91 -113
  58. hikyuu/include/hikyuu/utilities/Null.h +1 -0
  59. hikyuu/include/hikyuu/utilities/Parameter.h +2 -1
  60. hikyuu/include/hikyuu/utilities/ResourcePool.h +636 -0
  61. hikyuu/include/hikyuu/utilities/SpendTimer.h +10 -9
  62. hikyuu/include/hikyuu/utilities/TimerManager.h +2 -2
  63. hikyuu/include/hikyuu/utilities/any_to_string.h +142 -0
  64. hikyuu/include/hikyuu/utilities/arithmetic.h +69 -33
  65. hikyuu/include/hikyuu/utilities/base64.h +59 -0
  66. hikyuu/include/hikyuu/utilities/config.h +41 -0
  67. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +41 -31
  68. hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +24 -13
  69. hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +48 -48
  70. hikyuu/include/hikyuu/utilities/db_connect/DBConnect.h +10 -0
  71. hikyuu/include/hikyuu/utilities/db_connect/DBConnectBase.h +5 -22
  72. hikyuu/include/hikyuu/utilities/db_connect/DBUpgrade.h +3 -3
  73. hikyuu/include/hikyuu/utilities/db_connect/SQLException.h +1 -1
  74. hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +1 -1
  75. hikyuu/include/hikyuu/utilities/db_connect/SQLStatementBase.h +7 -7
  76. hikyuu/include/hikyuu/utilities/db_connect/TableMacro.h +1 -2
  77. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +9 -9
  78. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +18 -18
  79. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +3 -3
  80. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +2 -2
  81. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteUtil.h +6 -6
  82. hikyuu/include/hikyuu/{exception.h → utilities/exception.h} +1 -0
  83. hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +229 -0
  84. hikyuu/include/hikyuu/utilities/http_client/__init__.py +1 -0
  85. hikyuu/include/hikyuu/utilities/http_client/nng_wrap.h +517 -0
  86. hikyuu/include/hikyuu/utilities/http_client/url.h +25 -0
  87. hikyuu/include/hikyuu/utilities/{IniParser.h → ini_parser/IniParser.h} +10 -5
  88. hikyuu/include/hikyuu/utilities/ini_parser/__init__.py +1 -0
  89. hikyuu/include/hikyuu/utilities/md5.h +41 -0
  90. hikyuu/include/hikyuu/utilities/mo/__init__.py +1 -0
  91. hikyuu/include/hikyuu/utilities/mo/mo.h +48 -0
  92. hikyuu/include/hikyuu/utilities/mo/moFileReader.h +836 -0
  93. hikyuu/include/hikyuu/{global → utilities}/node/NodeClient.h +25 -18
  94. hikyuu/include/hikyuu/{global → utilities}/node/NodeError.h +1 -1
  95. hikyuu/include/hikyuu/{global → utilities}/node/NodeMessage.h +3 -2
  96. hikyuu/include/hikyuu/utilities/node/NodeServer.h +246 -0
  97. hikyuu/include/hikyuu/utilities/node/__init__.py +1 -0
  98. hikyuu/include/hikyuu/utilities/os.h +20 -14
  99. hikyuu/include/hikyuu/utilities/snowflake.h +110 -0
  100. hikyuu/include/hikyuu/utilities/string_view.h +70 -0
  101. hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +5 -5
  102. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +5 -5
  103. hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +5 -5
  104. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +5 -5
  105. hikyuu/include/hikyuu/version.h +5 -5
  106. hikyuu/sqlite3.dll +0 -0
  107. hikyuu/vcruntime140.dll +0 -0
  108. hikyuu/vcruntime140_1.dll +0 -0
  109. hikyuu-2.1.1.dist-info/METADATA +115 -0
  110. {hikyuu-2.0.9.dist-info → hikyuu-2.1.1.dist-info}/RECORD +115 -82
  111. {hikyuu-2.0.9.dist-info → hikyuu-2.1.1.dist-info}/top_level.txt +6 -1
  112. hikyuu/README.rst +0 -79
  113. hikyuu/cpp/boost_atomic-mt.dll +0 -0
  114. hikyuu/cpp/boost_filesystem-mt.dll +0 -0
  115. hikyuu-2.0.9.dist-info/METADATA +0 -126
  116. /hikyuu/include/hikyuu/global/{node → agent/hikyuu}/__init__.py +0 -0
  117. {hikyuu-2.0.9.dist-info → hikyuu-2.1.1.dist-info}/LICENSE +0 -0
  118. {hikyuu-2.0.9.dist-info → hikyuu-2.1.1.dist-info}/WHEEL +0 -0
  119. {hikyuu-2.0.9.dist-info → hikyuu-2.1.1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,230 @@
1
+ /*
2
+ * LRUCache11 - a templated C++11 based LRU cache class that allows
3
+ * specification of
4
+ * key, value and optionally the map container type (defaults to
5
+ * std::unordered_map)
6
+ * By using the std::unordered_map and a linked list of keys it allows O(1) insert, delete
7
+ * and
8
+ * refresh operations.
9
+ *
10
+ * This is a header-only library and all you need is the LRUCache11.hpp file
11
+ *
12
+ * Github: https://github.com/mohaps/lrucache11
13
+ *
14
+ * This is a follow-up to the LRUCache project -
15
+ * https://github.com/mohaps/lrucache
16
+ *
17
+ * Copyright (c) 2012-22 SAURAV MOHAPATRA <mohaps@gmail.com>
18
+ *
19
+ * Permission to use, copy, modify, and distribute this software for any
20
+ * purpose with or without fee is hereby granted, provided that the above
21
+ * copyright notice and this permission notice appear in all copies.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
24
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
25
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
26
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
28
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
29
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30
+ */
31
+ #pragma once
32
+ #include <algorithm>
33
+ #include <cstdint>
34
+ #include <list>
35
+ #include <mutex>
36
+ #include <stdexcept>
37
+ #include <thread>
38
+ #include <unordered_map>
39
+
40
+ namespace lru11 {
41
+ /*
42
+ * a noop lockable concept that can be used in place of std::mutex
43
+ */
44
+ class NullLock {
45
+ public:
46
+ void lock() {}
47
+ void unlock() {}
48
+ bool try_lock() {
49
+ return true;
50
+ }
51
+ };
52
+
53
+ /**
54
+ * error raised when a key not in cache is passed to get()
55
+ */
56
+ class KeyNotFound : public std::invalid_argument {
57
+ public:
58
+ KeyNotFound() : std::invalid_argument("key_not_found") {}
59
+ };
60
+
61
+ template <typename K, typename V>
62
+ struct KeyValuePair {
63
+ public:
64
+ K key;
65
+ V value;
66
+
67
+ KeyValuePair(K k, V v) : key(std::move(k)), value(std::move(v)) {}
68
+ };
69
+
70
+ /**
71
+ * The LRU Cache class templated by
72
+ * Key - key type
73
+ * Value - value type
74
+ * MapType - an associative container like std::unordered_map
75
+ * LockType - a lock type derived from the Lock class (default:
76
+ *NullLock = no synchronization)
77
+ *
78
+ * The default NullLock based template is not thread-safe, however passing
79
+ *Lock=std::mutex will make it
80
+ * thread-safe
81
+ */
82
+ template <class Key, class Value, class Lock = NullLock,
83
+ class Map =
84
+ std::unordered_map<Key, typename std::list<KeyValuePair<Key, Value>>::iterator>>
85
+ class Cache {
86
+ public:
87
+ typedef KeyValuePair<Key, Value> node_type;
88
+ typedef std::list<KeyValuePair<Key, Value>> list_type;
89
+ typedef Map map_type;
90
+ typedef Lock lock_type;
91
+ using Guard = std::lock_guard<lock_type>;
92
+ /**
93
+ * the maxSize is the soft limit of keys and (maxSize + elasticity) is the
94
+ * hard limit
95
+ * the cache is allowed to grow till (maxSize + elasticity) and is pruned back
96
+ * to maxSize keys
97
+ * set maxSize = 0 for an unbounded cache (but in that case, you're better off
98
+ * using a std::unordered_map
99
+ * directly anyway! :)
100
+ */
101
+ explicit Cache(size_t maxSize = 64, size_t elasticity = 10)
102
+ : maxSize_(maxSize), elasticity_(elasticity) {}
103
+ virtual ~Cache() = default;
104
+ size_t size() const {
105
+ Guard g(lock_);
106
+ return cache_.size();
107
+ }
108
+ bool empty() const {
109
+ Guard g(lock_);
110
+ return cache_.empty();
111
+ }
112
+ void clear() {
113
+ Guard g(lock_);
114
+ cache_.clear();
115
+ keys_.clear();
116
+ }
117
+ void insert(const Key& k, const Value& v) {
118
+ Guard g(lock_);
119
+ const auto iter = cache_.find(k);
120
+ if (iter != cache_.end()) {
121
+ iter->second->value = v;
122
+ keys_.splice(keys_.begin(), keys_, iter->second);
123
+ return;
124
+ }
125
+
126
+ keys_.emplace_front(k, v);
127
+ cache_[k] = keys_.begin();
128
+ prune();
129
+ }
130
+ void insert(const Key& k, Value&& v) {
131
+ Guard g(lock_);
132
+ const auto iter = cache_.find(k);
133
+ if (iter != cache_.end()) {
134
+ iter->second->value = std::move(v);
135
+ keys_.splice(keys_.begin(), keys_, iter->second);
136
+ return;
137
+ }
138
+
139
+ keys_.emplace_front(k, std::move(v));
140
+ cache_[k] = keys_.begin();
141
+ prune();
142
+ }
143
+ bool tryGet(const Key& kIn, Value& vOut) {
144
+ Guard g(lock_);
145
+ const auto iter = cache_.find(kIn);
146
+ if (iter == cache_.end()) {
147
+ return false;
148
+ }
149
+ keys_.splice(keys_.begin(), keys_, iter->second);
150
+ vOut = iter->second->value;
151
+ return true;
152
+ }
153
+ /**
154
+ * The const reference returned here is only
155
+ * guaranteed to be valid till the next insert/delete
156
+ * 修改为非常量引用,以便修改。但请注意这是危险操作!
157
+ */
158
+ Value& get(const Key& k) {
159
+ Guard g(lock_);
160
+ const auto iter = cache_.find(k);
161
+ if (iter == cache_.end()) {
162
+ throw KeyNotFound();
163
+ }
164
+ keys_.splice(keys_.begin(), keys_, iter->second);
165
+ return iter->second->value;
166
+ }
167
+ /**
168
+ * returns a copy of the stored object (if found)
169
+ */
170
+ Value getCopy(const Key& k) {
171
+ return get(k);
172
+ }
173
+ bool remove(const Key& k) {
174
+ Guard g(lock_);
175
+ auto iter = cache_.find(k);
176
+ if (iter == cache_.end()) {
177
+ return false;
178
+ }
179
+ keys_.erase(iter->second);
180
+ cache_.erase(iter);
181
+ return true;
182
+ }
183
+ bool contains(const Key& k) const {
184
+ Guard g(lock_);
185
+ return cache_.find(k) != cache_.end();
186
+ }
187
+
188
+ size_t getMaxSize() const {
189
+ return maxSize_;
190
+ }
191
+ size_t getElasticity() const {
192
+ return elasticity_;
193
+ }
194
+ size_t getMaxAllowedSize() const {
195
+ return maxSize_ + elasticity_;
196
+ }
197
+ template <typename F>
198
+ void cwalk(F& f) const {
199
+ Guard g(lock_);
200
+ std::for_each(keys_.begin(), keys_.end(), f);
201
+ }
202
+
203
+ protected:
204
+ size_t prune() {
205
+ size_t maxAllowed = maxSize_ + elasticity_;
206
+ if (maxSize_ == 0 || cache_.size() < maxAllowed) {
207
+ return 0;
208
+ }
209
+ size_t count = 0;
210
+ while (cache_.size() > maxSize_) {
211
+ cache_.erase(keys_.back().key);
212
+ keys_.pop_back();
213
+ ++count;
214
+ }
215
+ return count;
216
+ }
217
+
218
+ private:
219
+ // Disallow copying.
220
+ Cache(const Cache&) = delete;
221
+ Cache& operator=(const Cache&) = delete;
222
+
223
+ mutable Lock lock_;
224
+ Map cache_;
225
+ list_type keys_;
226
+ size_t maxSize_;
227
+ size_t elasticity_;
228
+ };
229
+
230
+ } // namespace lru11
@@ -16,13 +16,19 @@
16
16
  #include "config.h"
17
17
  #include "exception.h"
18
18
 
19
+ #ifndef HKU_LOG_ACTIVE_LEVEL
20
+ #define HKU_LOG_ACTIVE_LEVEL 0
21
+ #endif
22
+
19
23
  // clang-format off
20
- #if USE_SPDLOG_LOGGER
21
- #include <spdlog/spdlog.h>
22
- #include <spdlog/fmt/ostr.h>
23
- #if HKU_USE_SPDLOG_ASYNC_LOGGER
24
- #include "spdlog/async.h"
25
- #endif
24
+ #ifndef SPDLOG_ACTIVE_LEVEL
25
+ #define SPDLOG_ACTIVE_LEVEL HKU_LOG_ACTIVE_LEVEL
26
+ #endif
27
+
28
+ #include <spdlog/spdlog.h>
29
+ #include <spdlog/fmt/ostr.h>
30
+ #if HKU_USE_SPDLOG_ASYNC_LOGGER
31
+ #include "spdlog/async.h"
26
32
  #endif
27
33
  // clang-format on
28
34
 
@@ -30,30 +36,24 @@
30
36
  #include <fmt/format.h>
31
37
  #include <fmt/chrono.h>
32
38
 
33
- #ifdef HKU_ENABLE_STACK_TRACE
39
+ #ifndef HKU_ENABLE_STACK_TRACE
40
+ #define HKU_ENABLE_STACK_TRACE 0
41
+ #endif
42
+
43
+ #if HKU_ENABLE_STACK_TRACE
34
44
  #include <boost/stacktrace.hpp>
35
45
  #endif
36
46
 
37
- #ifndef HKU_API
38
- #define HKU_API
47
+ #ifndef HKU_UTILS_API
48
+ #define HKU_UTILS_API
39
49
  #endif
40
50
 
41
51
  namespace hku {
42
52
 
43
- /**
44
- * @ingroup Utilities
45
- * @addtogroup logging Logging tools 日志工具
46
- * @details 打印等级:
47
- * TRACE < DEBUG < INFO < WARN < ERROR < FATAL
48
- * @{
49
- */
50
-
51
- bool HKU_API isLogInMainThread();
52
-
53
53
  /**********************************************
54
54
  * Use SPDLOG for logging
55
55
  *********************************************/
56
- #if USE_SPDLOG_LOGGER
56
+
57
57
  /** 日志级别 */
58
58
  enum LOG_LEVEL {
59
59
  LOG_TRACE = SPDLOG_LEVEL_TRACE, ///< 跟踪
@@ -65,19 +65,27 @@ enum LOG_LEVEL {
65
65
  LOG_OFF = SPDLOG_LEVEL_OFF, ///< 关闭日志打印
66
66
  };
67
67
 
68
+ /**
69
+ * 初始化 logger
70
+ * @param not_use_color 不使用彩色输出
71
+ * @param filename 日志文件名,为空时默认为当前目录下 "./hikyuu.log",需自行保存存放目录存在且可写入
72
+ */
73
+ void HKU_UTILS_API initLogger(bool not_use_color = false,
74
+ const std::string& filename = std::string());
75
+
68
76
  /**
69
77
  * 获取当前日志级别
70
78
  * @return
71
79
  */
72
- LOG_LEVEL HKU_API get_log_level();
80
+ LOG_LEVEL HKU_UTILS_API get_log_level();
73
81
 
74
82
  /**
75
83
  * 设置日志级别
76
84
  * @param level 指定的日志级别
77
85
  */
78
- void HKU_API set_log_level(LOG_LEVEL level);
86
+ void HKU_UTILS_API set_log_level(LOG_LEVEL level);
79
87
 
80
- std::shared_ptr<spdlog::logger> HKU_API getHikyuuLogger();
88
+ std::shared_ptr<spdlog::logger> HKU_UTILS_API getHikyuuLogger();
81
89
 
82
90
  #define HKU_TRACE(...) SPDLOG_LOGGER_TRACE(hku::getHikyuuLogger(), __VA_ARGS__)
83
91
  #define HKU_DEBUG(...) SPDLOG_LOGGER_DEBUG(hku::getHikyuuLogger(), __VA_ARGS__)
@@ -86,76 +94,6 @@ std::shared_ptr<spdlog::logger> HKU_API getHikyuuLogger();
86
94
  #define HKU_ERROR(...) SPDLOG_LOGGER_ERROR(hku::getHikyuuLogger(), __VA_ARGS__)
87
95
  #define HKU_FATAL(...) SPDLOG_LOGGER_CRITICAL(hku::getHikyuuLogger(), __VA_ARGS__)
88
96
 
89
- void initLogger(bool inJupyter = false);
90
-
91
- #else
92
- enum LOG_LEVEL {
93
- LOG_TRACE = 0,
94
- LOG_DEBUG = 1,
95
- LOG_INFO = 2,
96
- LOG_WARN = 3,
97
- LOG_ERROR = 4,
98
- LOG_FATAL = 5,
99
- LOG_OFF = 6,
100
- };
101
-
102
- LOG_LEVEL HKU_API get_log_level();
103
- void HKU_API set_log_level(LOG_LEVEL level);
104
- void initLogger(bool inJupyter = false);
105
-
106
- /** 获取系统当前时间,精确到毫秒,如:2001-01-02 13:01:02.001 */
107
- std::string HKU_API getLocalTime();
108
-
109
- #if LOG_ACTIVE_LEVEL <= 0
110
- #define HKU_TRACE(...) \
111
- fmt::print("[{}] [HKU-T] - {} ({}:{})\n", getLocalTime(), fmt::format(__VA_ARGS__), __FILE__, \
112
- __LINE__);
113
- #else
114
- #define HKU_TRACE(...)
115
- #endif
116
-
117
- #if LOG_ACTIVE_LEVEL <= 1
118
- #define HKU_DEBUG(...) \
119
- fmt::print("[{}] [HKU-D] - {} ({}:{})\n", getLocalTime(), fmt::format(__VA_ARGS__), __FILE__, \
120
- __LINE__);
121
- #else
122
- #define HKU_DEBUG(...)
123
- #endif
124
-
125
- #if LOG_ACTIVE_LEVEL <= 2
126
- #define HKU_INFO(...) \
127
- fmt::print("[{}] [HKU-I] - {} ({}:{})\n", getLocalTime(), fmt::format(__VA_ARGS__), __FILE__, \
128
- __LINE__);
129
- #else
130
- #define HKU_INFO(...)
131
- #endif
132
-
133
- #if LOG_ACTIVE_LEVEL <= 3
134
- #define HKU_WARN(...) \
135
- fmt::print("[{}] [HKU-W] - {} ({}:{})\n", getLocalTime(), fmt::format(__VA_ARGS__), __FILE__, \
136
- __LINE__);
137
- #else
138
- #define HKU_WARN(...)
139
- #endif
140
-
141
- #if LOG_ACTIVE_LEVEL <= 4
142
- #define HKU_ERROR(...) \
143
- fmt::print("[{}] [HKU-E] - {} ({}:{})\n", getLocalTime(), fmt::format(__VA_ARGS__), __FILE__, \
144
- __LINE__);
145
- #else
146
- #define HKU_ERROR(...)
147
- #endif
148
-
149
- #if LOG_ACTIVE_LEVEL <= 5
150
- #define HKU_FATAL(...) \
151
- fmt::print("[{}] [HKU-F] - {} ({}:{})\n", getLocalTime(), fmt::format(__VA_ARGS__), __FILE__, \
152
- __LINE__);
153
- #else
154
- #define HKU_FATAL(...)
155
- #endif
156
-
157
- #endif /* USE_SPDLOG_LOGGER */
158
-
159
97
  ///////////////////////////////////////////////////////////////////////////////
160
98
  //
161
99
  // clang/gcc 下使用 __PRETTY_FUNCTION__ 会包含函数参数,可以在编译时指定
@@ -166,7 +104,7 @@ std::string HKU_API getLocalTime();
166
104
  #define HKU_FUNCTION __FUNCTION__
167
105
  #endif
168
106
 
169
- #ifndef HKU_ENABLE_STACK_TRACE
107
+ #if !HKU_ENABLE_STACK_TRACE
170
108
  /**
171
109
  * 若表达式为 false,将抛出 hku::exception 异常, 并附带传入信息
172
110
  * @note 用于外部入参及结果检查
@@ -212,23 +150,9 @@ std::string HKU_API getLocalTime();
212
150
  __FILE__, __LINE__)); \
213
151
  } \
214
152
  } while (0)
215
- #endif // #ifndef HKU_ENABLE_STACK_TRACE
153
+ #endif // #if !HKU_ENABLE_STACK_TRACE
216
154
 
217
- #if HKU_DEBUG_MODE
218
- #define HKU_ASSERT_DEBUG(expr)
219
- #else
220
- /** 仅在 debug 模式下生效 */
221
- #define HKU_ASSERT_DEBUG(expr) \
222
- do { \
223
- if (!(expr)) { \
224
- std::string err_msg(fmt::format("HKU_ASSERT({})", #expr)); \
225
- throw hku::exception( \
226
- fmt::format("{} [{}] ({}:{})", err_msg, HKU_FUNCTION, __FILE__, __LINE__)); \
227
- } \
228
- } while (0)
229
-
230
- #endif /* #if HKU_DEBUG_MODE */
231
- #ifdef HKU_ENABLE_STACK_TRACE
155
+ #if HKU_ENABLE_STACK_TRACE
232
156
  /**
233
157
  * 若表达式为 false,将抛出 hku::exception 异常
234
158
  * @note 仅用于内部入参检查,编译时可通过 HKU_DISABLE_ASSERT 宏关闭
@@ -253,9 +177,9 @@ std::string HKU_API getLocalTime();
253
177
  } \
254
178
  } while (0)
255
179
 
256
- #endif // #ifndef HKU_ENABLE_STACK_TRACE
180
+ #endif // #if HKU_ENABLE_STACK_TRACE
257
181
 
258
- #ifndef HKU_ENABLE_STACK_TRACE
182
+ #if !HKU_ENABLE_STACK_TRACE
259
183
  /** 抛出 hku::exception 及传入信息 */
260
184
  #define HKU_THROW(...) \
261
185
  do { \
@@ -286,7 +210,7 @@ std::string HKU_API getLocalTime();
286
210
  throw except( \
287
211
  fmt::format("EXCEPTION: {} [{}] ({}:{})", errmsg, HKU_FUNCTION, __FILE__, __LINE__)); \
288
212
  } while (0)
289
- #endif // #ifndef HKU_ENABLE_STACK_TRACE
213
+ #endif // #if !HKU_ENABLE_STACK_TRACE
290
214
 
291
215
  /**
292
216
  * 满足指定条件时,打印 TRACE 信息
@@ -420,12 +344,66 @@ std::string HKU_API getLocalTime();
420
344
 
421
345
  /** 用于 catch (...) 中打印,减少编译后代码大小 */
422
346
  extern std::string g_unknown_error_msg;
347
+ #define HKU_THROW_UNKNOWN HKU_THROW(g_unknown_error_msg);
423
348
  #define HKU_TRACE_UNKNOWN HKU_TRACE(g_unknown_error_msg)
424
349
  #define HKU_DEBUG_UNKNOWN HKU_DEBUG(g_unknown_error_msg)
425
350
  #define HKU_INFO_UNKNOWN HKU_INFO(g_unknown_error_msg)
426
351
  #define HKU_ERROR_UNKNOWN HKU_ERROR(g_unknown_error_msg)
427
352
  #define HKU_FATAL_UNKNOWN HKU_FATAL(g_unknown_error_msg)
428
353
 
354
+ #if CPP_STANDARD >= CPP_STANDARD_17
355
+ #define CLASS_LOGGER_IMP(cls) \
356
+ protected: \
357
+ inline static const char* ms_logger = #cls;
358
+ #else
359
+ #define CLASS_LOGGER_IMP(cls) \
360
+ protected: \
361
+ const char* ms_logger = #cls;
362
+ #endif
363
+
364
+ #define CLS_TRACE(...) HKU_TRACE(fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
365
+ #define CLS_DEBUG(...) HKU_DEBUG(fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
366
+ #define CLS_INFO(...) HKU_INFO(fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
367
+ #define CLS_WARN(...) HKU_WARN(fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
368
+ #define CLS_ERROR(...) HKU_ERROR(fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
369
+ #define CLS_FATAL(...) HKU_FATAL(fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
370
+
371
+ #define CLS_TRACE_IF(expr, ...) \
372
+ HKU_TRACE_IF(expr, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
373
+ #define CLS_DEBUG_IF(expr, ...) \
374
+ HKU_DEBUG_IF(expr, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
375
+ #define CLS_INFO_IF(expr, ...) \
376
+ HKU_INFO_IF(expr, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
377
+ #define CLS_WARN_IF(expr, ...) \
378
+ HKU_WARN_IF(expr, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
379
+ #define CLS_ERROR_IF(expr, ...) \
380
+ HKU_ERROR_IF(expr, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
381
+ #define CLS_FATAL_IF(expr, ...) \
382
+ HKU_FATAL_IF(expr, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
383
+
384
+ #define CLS_IF_RETURN(expr, ret) HKU_IF_RETURN(expr, ret)
385
+ #define CLS_TRACE_IF_RETURN(expr, ret, ...) \
386
+ HKU_TRACE_IF_RETURN(expr, ret, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
387
+ #define CLS_DEBUG_IF_RETURN(expr, ret, ...) \
388
+ HKU_DEBUG_IF_RETURN(expr, ret, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
389
+ #define CLS_INFO_IF_RETURN(expr, ret, ...) \
390
+ HKU_INFO_IF_RETURN(expr, ret, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
391
+ #define CLS_WARN_IF_RETURN(expr, ret, ...) \
392
+ HKU_WARN_IF_RETURN(expr, ret, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
393
+ #define CLS_ERROR_IF_RETURN(expr, ret, ...) \
394
+ HKU_ERROR_IF_RETURN(expr, ret, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
395
+ #define CLS_FATAL_IF_RETURN(expr, ret, ...) \
396
+ HKU_FATAL_IF_RETURN(expr, ret, fmt::format("[{}] {}", ms_logger, fmt::format(__VA_ARGS__)))
397
+
398
+ #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__)))
406
+
429
407
  /** @} */
430
408
 
431
409
  } /* namespace hku */
@@ -10,6 +10,7 @@
10
10
  #define NULL_H_
11
11
 
12
12
  #include <cstddef>
13
+ #include <cstdint>
13
14
  #include <limits>
14
15
  #include <type_traits>
15
16
  #include "osdef.h"
@@ -17,7 +17,8 @@
17
17
  #include <map>
18
18
  #include <boost/any.hpp>
19
19
 
20
- #include "../config.h"
20
+ #include "hikyuu/config.h"
21
+ #include "hikyuu/utilities/config.h"
21
22
 
22
23
  #if HKU_SUPPORT_SERIALIZATION
23
24
  #include <boost/lexical_cast.hpp>