hikyuu 2.1.0__cp312-none-win_amd64.whl → 2.1.2__cp312-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. hikyuu/cpp/boost_date_time-mt.dll +0 -0
  2. hikyuu/cpp/boost_serialization-mt.dll +0 -0
  3. hikyuu/cpp/boost_wserialization-mt.dll +0 -0
  4. hikyuu/cpp/core312.pyd +0 -0
  5. hikyuu/cpp/hikyuu.dll +0 -0
  6. hikyuu/cpp/sqlite3.dll +0 -0
  7. hikyuu/examples/notebook/006-TradeManager.ipynb +41 -39
  8. hikyuu/examples/notebook/008-Pickle.ipynb +27 -35
  9. hikyuu/extend.py +3 -1
  10. hikyuu/fetcher/stock/zh_stock_a_qmt.py +49 -0
  11. hikyuu/gui/HikyuuTDX.py +13 -7
  12. hikyuu/gui/data/MainWindow.py +126 -126
  13. hikyuu/gui/spot_server.py +16 -7
  14. hikyuu/gui/start_qmt.py +36 -0
  15. hikyuu/include/hikyuu/DataType.h +2 -1
  16. hikyuu/include/hikyuu/KRecord.h +1 -1
  17. hikyuu/include/hikyuu/Stock.h +1 -1
  18. hikyuu/include/hikyuu/StockManager.h +3 -0
  19. hikyuu/include/hikyuu/StrategyContext.h +7 -2
  20. hikyuu/include/hikyuu/analysis/combinate.h +1 -1
  21. hikyuu/include/hikyuu/config.h +0 -12
  22. hikyuu/include/hikyuu/data_driver/base_info/table/HistoryFinanceTable.h +2 -2
  23. hikyuu/include/hikyuu/doc.h +2 -2
  24. hikyuu/include/hikyuu/global/GlobalSpotAgent.h +1 -0
  25. hikyuu/include/hikyuu/global/GlobalTaskGroup.h +4 -2
  26. hikyuu/include/hikyuu/global/SpotRecord.h +52 -0
  27. hikyuu/include/hikyuu/global/agent/SpotAgent.h +14 -41
  28. hikyuu/include/hikyuu/hikyuu.h +1 -0
  29. hikyuu/include/hikyuu/strategy/{AccountTradeManager.h → BrokerTradeManager.h} +97 -95
  30. hikyuu/include/hikyuu/strategy/RunPortfolioInStrategy.h +36 -0
  31. hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +37 -0
  32. hikyuu/include/hikyuu/strategy/Strategy.h +174 -0
  33. hikyuu/include/hikyuu/trade_manage/FundsRecord.h +8 -8
  34. hikyuu/include/hikyuu/trade_manage/OrderBrokerBase.h +66 -14
  35. hikyuu/include/hikyuu/trade_manage/PositionRecord.h +12 -12
  36. hikyuu/include/hikyuu/trade_manage/TradeManager.h +9 -0
  37. hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +19 -0
  38. hikyuu/include/hikyuu/utilities/FilterNode.h +267 -0
  39. hikyuu/include/hikyuu/utilities/LRUCache11.h +230 -0
  40. hikyuu/include/hikyuu/{Log.h → utilities/Log.h} +91 -113
  41. hikyuu/include/hikyuu/utilities/Null.h +1 -0
  42. hikyuu/include/hikyuu/utilities/Parameter.h +2 -1
  43. hikyuu/include/hikyuu/utilities/ResourcePool.h +636 -0
  44. hikyuu/include/hikyuu/utilities/SpendTimer.h +10 -9
  45. hikyuu/include/hikyuu/utilities/TimerManager.h +25 -11
  46. hikyuu/include/hikyuu/utilities/any_to_string.h +142 -0
  47. hikyuu/include/hikyuu/utilities/arithmetic.h +71 -35
  48. hikyuu/include/hikyuu/utilities/base64.h +59 -0
  49. hikyuu/include/hikyuu/utilities/config.h +41 -0
  50. hikyuu/include/hikyuu/utilities/datetime/Datetime.h +42 -31
  51. hikyuu/include/hikyuu/utilities/datetime/TimeDelta.h +24 -13
  52. hikyuu/include/hikyuu/utilities/db_connect/DBCondition.h +48 -48
  53. hikyuu/include/hikyuu/utilities/db_connect/DBConnect.h +10 -0
  54. hikyuu/include/hikyuu/utilities/db_connect/DBConnectBase.h +5 -22
  55. hikyuu/include/hikyuu/utilities/db_connect/DBUpgrade.h +3 -3
  56. hikyuu/include/hikyuu/utilities/db_connect/SQLException.h +1 -1
  57. hikyuu/include/hikyuu/utilities/db_connect/SQLResultSet.h +1 -1
  58. hikyuu/include/hikyuu/utilities/db_connect/SQLStatementBase.h +7 -7
  59. hikyuu/include/hikyuu/utilities/db_connect/TableMacro.h +1 -2
  60. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +9 -9
  61. hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +18 -18
  62. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +3 -3
  63. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +2 -2
  64. hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteUtil.h +6 -6
  65. hikyuu/include/hikyuu/{exception.h → utilities/exception.h} +15 -16
  66. hikyuu/include/hikyuu/utilities/http_client/HttpClient.h +229 -0
  67. hikyuu/include/hikyuu/utilities/http_client/nng_wrap.h +517 -0
  68. hikyuu/include/hikyuu/utilities/http_client/url.h +25 -0
  69. hikyuu/include/hikyuu/utilities/{IniParser.h → ini_parser/IniParser.h} +10 -5
  70. hikyuu/include/hikyuu/utilities/ini_parser/__init__.py +1 -0
  71. hikyuu/include/hikyuu/utilities/md5.h +41 -0
  72. hikyuu/include/hikyuu/utilities/mo/__init__.py +1 -0
  73. hikyuu/include/hikyuu/utilities/mo/mo.h +48 -0
  74. hikyuu/include/hikyuu/utilities/mo/moFileReader.h +836 -0
  75. hikyuu/include/hikyuu/{global → utilities}/node/NodeClient.h +25 -18
  76. hikyuu/include/hikyuu/{global → utilities}/node/NodeError.h +1 -1
  77. hikyuu/include/hikyuu/{global → utilities}/node/NodeMessage.h +3 -2
  78. hikyuu/include/hikyuu/utilities/node/NodeServer.h +246 -0
  79. hikyuu/include/hikyuu/utilities/node/__init__.py +1 -0
  80. hikyuu/include/hikyuu/utilities/os.h +16 -15
  81. hikyuu/include/hikyuu/utilities/snowflake.h +110 -0
  82. hikyuu/include/hikyuu/utilities/string_view.h +70 -0
  83. hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +3 -3
  84. hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +3 -3
  85. hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +3 -3
  86. hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +3 -3
  87. hikyuu/include/hikyuu/version.h +4 -4
  88. hikyuu/interactive.py +42 -137
  89. hikyuu/sqlite3.dll +0 -0
  90. hikyuu/strategy/__init__.py +0 -1
  91. hikyuu/strategy/strategy_demo1.py +53 -0
  92. hikyuu/strategy/strategy_demo2.py +47 -0
  93. hikyuu/strategy/strategy_demo3.py +24 -0
  94. hikyuu/trade_manage/broker.py +27 -11
  95. hikyuu/trade_manage/broker_easytrader.py +52 -6
  96. hikyuu/trade_manage/broker_mail.py +17 -20
  97. hikyuu/vcruntime140.dll +0 -0
  98. hikyuu/vcruntime140_1.dll +0 -0
  99. hikyuu-2.1.2.dist-info/METADATA +115 -0
  100. {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/RECORD +105 -79
  101. {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/top_level.txt +4 -2
  102. hikyuu/README.rst +0 -79
  103. hikyuu/include/hikyuu/strategy/StrategyBase.h +0 -156
  104. hikyuu/strategy/demo/__init__.py +0 -3
  105. hikyuu/strategy/strategy.py +0 -27
  106. hikyuu-2.1.0.dist-info/METADATA +0 -126
  107. /hikyuu/include/hikyuu/{global/node → utilities/http_client}/__init__.py +0 -0
  108. {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/LICENSE +0 -0
  109. {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/WHEEL +0 -0
  110. {hikyuu-2.1.0.dist-info → hikyuu-2.1.2.dist-info}/entry_points.txt +0 -0
@@ -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
  * 通过数字方式构造日期类型
@@ -101,11 +106,12 @@ public:
101
106
  * 2、"20010101"
102
107
  * 3、"2001-01-01 18:00:00.12345"
103
108
  * 4、"20010101T181159"
109
+ * 5、"20240822 11:30:06.230"
104
110
  * </pre>
105
111
  */
106
- explicit Datetime(const std::string&);
112
+ explicit Datetime(const std::string &);
107
113
 
108
- Datetime& operator=(const Datetime&);
114
+ Datetime &operator=(const Datetime &);
109
115
 
110
116
  /** 年份,如果是 Null 将抛出异常 */
111
117
  long year() const;
@@ -283,7 +289,7 @@ private:
283
289
  bt::ptime m_data;
284
290
  };
285
291
 
286
- HKU_API std::ostream& operator<<(std::ostream&, const Datetime&);
292
+ HKU_UTILS_API std::ostream &operator<<(std::ostream &, const Datetime &);
287
293
 
288
294
  /**
289
295
  * 日期列表
@@ -297,41 +303,41 @@ typedef std::vector<Datetime> DatetimeList;
297
303
  * @param end 结束日期
298
304
  * @return [start, end)范围内的日历日期
299
305
  */
300
- DatetimeList HKU_API getDateRange(const Datetime& start, const Datetime& end);
306
+ DatetimeList HKU_UTILS_API getDateRange(const Datetime &start, const Datetime &end);
301
307
 
302
308
  ///////////////////////////////////////////////////////////////////////////////
303
309
  //
304
310
  // 关系比较函数, 不直接在类中定义是为了支持 Null<>() == d,Null可以放在左边
305
311
  //
306
312
  ///////////////////////////////////////////////////////////////////////////////
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) {
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
+ bool operator<=(const Datetime &, const Datetime &);
319
+
320
+ inline bool operator==(const Datetime &d1, const Datetime &d2) {
315
321
  return d1.ptime() == d2.ptime();
316
322
  }
317
323
 
318
- inline bool operator!=(const Datetime& d1, const Datetime& d2) {
324
+ inline bool operator!=(const Datetime &d1, const Datetime &d2) {
319
325
  return d1.ptime() != d2.ptime();
320
326
  }
321
327
 
322
- inline bool operator>(const Datetime& d1, const Datetime& d2) {
328
+ inline bool operator>(const Datetime &d1, const Datetime &d2) {
323
329
  return d1.ptime() > d2.ptime();
324
330
  }
325
331
 
326
- inline bool operator<(const Datetime& d1, const Datetime& d2) {
332
+ inline bool operator<(const Datetime &d1, const Datetime &d2) {
327
333
  return d1.ptime() < d2.ptime();
328
334
  }
329
335
 
330
- inline bool operator>=(const Datetime& d1, const Datetime& d2) {
336
+ inline bool operator>=(const Datetime &d1, const Datetime &d2) {
331
337
  return d1.ptime() >= d2.ptime();
332
338
  }
333
339
 
334
- inline bool operator<=(const Datetime& d1, const Datetime& d2) {
340
+ inline bool operator<=(const Datetime &d1, const Datetime &d2) {
335
341
  return d1.ptime() <= d2.ptime();
336
342
  }
337
343
 
@@ -340,11 +346,11 @@ inline bool operator<=(const Datetime& d1, const Datetime& d2) {
340
346
  // 加、减法运算补充
341
347
  //
342
348
  ///////////////////////////////////////////////////////////////////////////////
343
- inline Datetime operator+(const TimeDelta& delta, const Datetime& date) {
349
+ inline Datetime operator+(const TimeDelta &delta, const Datetime &date) {
344
350
  return date + delta;
345
351
  }
346
352
 
347
- inline TimeDelta operator-(const Datetime& d1, const Datetime& d2) {
353
+ inline TimeDelta operator-(const Datetime &d1, const Datetime &d2) {
348
354
  return TimeDelta(d1.ptime() - d2.ptime());
349
355
  }
350
356
 
@@ -359,11 +365,11 @@ inline Datetime::Datetime() {
359
365
  m_data = bt::ptime(d, bt::time_duration(0, 0, 0));
360
366
  }
361
367
 
362
- inline Datetime::Datetime(const Datetime& d) : m_data(d.m_data) {}
368
+ inline Datetime::Datetime(const Datetime &d) : m_data(d.m_data) {}
363
369
 
364
- inline Datetime::Datetime(const bd::date& d) : m_data(bt::ptime(d, bt::time_duration(0, 0, 0))) {}
370
+ inline Datetime::Datetime(const bd::date &d) : m_data(bt::ptime(d, bt::time_duration(0, 0, 0))) {}
365
371
 
366
- inline Datetime::Datetime(const bt::ptime& d) : m_data(d) {}
372
+ inline Datetime::Datetime(const bt::ptime &d) : m_data(d) {}
367
373
 
368
374
  inline bt::ptime Datetime::ptime() const {
369
375
  return m_data;
@@ -404,21 +410,26 @@ namespace std {
404
410
  template <>
405
411
  class hash<hku::Datetime> {
406
412
  public:
407
- size_t operator()(hku::Datetime const& d) const noexcept {
413
+ size_t operator()(hku::Datetime const &d) const noexcept {
408
414
  return d.ticks(); // or use boost::hash_combine
409
415
  }
410
416
  };
417
+
418
+ inline string to_string(const hku::Datetime &date) {
419
+ return date.str();
420
+ }
421
+
411
422
  } // namespace std
412
423
 
413
424
  #if FMT_VERSION >= 90000
414
425
  template <>
415
426
  struct fmt::formatter<hku::Datetime> {
416
- constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
427
+ constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
417
428
  return ctx.end();
418
429
  }
419
430
 
420
431
  template <typename FormatContext>
421
- auto format(const hku::Datetime& d, FormatContext& ctx) const -> decltype(ctx.out()) {
432
+ auto format(const hku::Datetime &d, FormatContext &ctx) const -> decltype(ctx.out()) {
422
433
  return fmt::format_to(ctx.out(), "{}", d.str());
423
434
  }
424
435
  };
@@ -20,8 +20,8 @@
20
20
  #include <fmt/ostream.h>
21
21
  #include <boost/date_time/posix_time/posix_time.hpp>
22
22
 
23
- #ifndef HKU_API
24
- #define HKU_API
23
+ #ifndef HKU_UTILS_API
24
+ #define HKU_UTILS_API
25
25
  #endif
26
26
 
27
27
  namespace hku {
@@ -33,7 +33,7 @@ namespace bd = boost::gregorian;
33
33
  * 时长,用于时间计算
34
34
  * @ingroup DataType
35
35
  */
36
- class HKU_API TimeDelta {
36
+ class HKU_UTILS_API TimeDelta {
37
37
  public:
38
38
  /**
39
39
  * 构造函数
@@ -58,11 +58,14 @@ public:
58
58
  /** 通过 boost::posix_time::time_duration 构造 */
59
59
  explicit TimeDelta(bt::time_duration td);
60
60
 
61
+ /** 从字符串构造,格式:-1 days, hh:mm:ss.000000) */
62
+ explicit TimeDelta(const std::string& delta);
63
+
61
64
  /** 赋值构造函数 */
62
- TimeDelta(const TimeDelta&) = default;
65
+ TimeDelta(const TimeDelta &) = default;
63
66
 
64
67
  /** 赋值拷贝函数 */
65
- TimeDelta& operator=(const TimeDelta& other) {
68
+ TimeDelta &operator=(const TimeDelta &other) {
66
69
  if (this != &other) {
67
70
  m_duration = other.m_duration;
68
71
  }
@@ -259,8 +262,8 @@ private:
259
262
  static constexpr const int64_t m_one_day_ticks = 24 * 60 * 60 * 1000000LL;
260
263
  };
261
264
 
262
- std::ostream& operator<<(std::ostream& out, TimeDelta td);
263
- inline std::ostream& operator<<(std::ostream& out, TimeDelta td) {
265
+ std::ostream &operator<<(std::ostream &out, TimeDelta td);
266
+ inline std::ostream &operator<<(std::ostream &out, TimeDelta td) {
264
267
  out << td.str();
265
268
  return out;
266
269
  }
@@ -280,28 +283,28 @@ inline TimeDelta Days(int64_t days) {
280
283
  * @param hours 小时数
281
284
  * @ingroup DataType
282
285
  */
283
- TimeDelta HKU_API Hours(int64_t hours);
286
+ TimeDelta HKU_UTILS_API Hours(int64_t hours);
284
287
 
285
288
  /**
286
289
  * TimeDelta 快捷创建函数
287
290
  * @param mins 分钟数
288
291
  * @ingroup DataType
289
292
  */
290
- TimeDelta HKU_API Minutes(int64_t mins);
293
+ TimeDelta HKU_UTILS_API Minutes(int64_t mins);
291
294
 
292
295
  /**
293
296
  * TimeDelta 快捷创建函数
294
297
  * @param secs 秒数
295
298
  * @ingroup DataType
296
299
  */
297
- TimeDelta HKU_API Seconds(int64_t secs);
300
+ TimeDelta HKU_UTILS_API Seconds(int64_t secs);
298
301
 
299
302
  /**
300
303
  * TimeDelta 快捷创建函数
301
304
  * @param milliseconds 毫秒数
302
305
  * @ingroup DataType
303
306
  */
304
- TimeDelta HKU_API Milliseconds(int64_t milliseconds);
307
+ TimeDelta HKU_UTILS_API Milliseconds(int64_t milliseconds);
305
308
 
306
309
  /**
307
310
  * TimeDelta 快捷创建函数
@@ -315,15 +318,23 @@ inline TimeDelta Microseconds(int64_t microsecs) {
315
318
 
316
319
  } /* namespace hku */
317
320
 
321
+ namespace std {
322
+
323
+ inline string to_string(const hku::TimeDelta &delta) {
324
+ return delta.str();
325
+ }
326
+
327
+ } // namespace std
328
+
318
329
  #if FMT_VERSION >= 90000
319
330
  template <>
320
331
  struct fmt::formatter<hku::TimeDelta> {
321
- constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
332
+ constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
322
333
  return ctx.end();
323
334
  }
324
335
 
325
336
  template <typename FormatContext>
326
- auto format(const hku::TimeDelta& d, FormatContext& ctx) const -> decltype(ctx.out()) {
337
+ auto format(const hku::TimeDelta &d, FormatContext &ctx) const -> decltype(ctx.out()) {
327
338
  return fmt::format_to(ctx.out(), "{}", d.str());
328
339
  }
329
340
  };
@@ -13,23 +13,23 @@
13
13
  #include <vector>
14
14
  #include <fmt/format.h>
15
15
  #include <fmt/ranges.h>
16
- #include "../../Log.h"
16
+ #include "hikyuu/utilities/Log.h"
17
17
 
18
- #ifndef HKU_API
19
- #define HKU_API
18
+ #ifndef HKU_UTILS_API
19
+ #define HKU_UTILS_API
20
20
  #endif
21
21
 
22
22
  namespace hku {
23
23
 
24
24
  struct ASC {
25
- explicit ASC(const char* name) : name(name) {}
26
- explicit ASC(const std::string& name) : name(name) {}
25
+ explicit ASC(const char *name) : name(name) {}
26
+ explicit ASC(const std::string &name) : name(name) {}
27
27
  std::string name;
28
28
  };
29
29
 
30
30
  struct DESC {
31
- explicit DESC(const char* name) : name(name) {}
32
- explicit DESC(const std::string& name) : name(name) {}
31
+ explicit DESC(const char *name) : name(name) {}
32
+ explicit DESC(const std::string &name) : name(name) {}
33
33
  std::string name;
34
34
  };
35
35
 
@@ -38,50 +38,50 @@ struct LIMIT {
38
38
  int limit = 1;
39
39
  };
40
40
 
41
- class HKU_API DBCondition {
41
+ class HKU_UTILS_API DBCondition {
42
42
  public:
43
43
  DBCondition() = default;
44
- DBCondition(const DBCondition&) = default;
45
- DBCondition(DBCondition&& rv) : m_condition(std::move(rv.m_condition)) {}
44
+ DBCondition(const DBCondition &) = default;
45
+ DBCondition(DBCondition &&rv) : m_condition(std::move(rv.m_condition)) {}
46
46
 
47
- explicit DBCondition(const char* cond) : m_condition(cond) {}
48
- explicit DBCondition(const std::string& cond) : m_condition(cond) {}
47
+ explicit DBCondition(const char *cond) : m_condition(cond) {}
48
+ explicit DBCondition(const std::string &cond) : m_condition(cond) {}
49
49
 
50
- DBCondition& operator=(const DBCondition&) = default;
51
- DBCondition& operator=(DBCondition&& rv) {
50
+ DBCondition &operator=(const DBCondition &) = default;
51
+ DBCondition &operator=(DBCondition &&rv) {
52
52
  if (this != &rv) {
53
53
  m_condition = std::move(rv.m_condition);
54
54
  }
55
55
  return *this;
56
56
  }
57
57
 
58
- DBCondition& operator&(const DBCondition& other);
59
- DBCondition& operator|(const DBCondition& other);
58
+ DBCondition &operator&(const DBCondition &other);
59
+ DBCondition &operator|(const DBCondition &other);
60
60
 
61
61
  enum ORDERBY { ORDER_ASC, ORDER_DESC };
62
62
 
63
- void orderBy(const std::string& field, ORDERBY order) {
63
+ void orderBy(const std::string &field, ORDERBY order) {
64
64
  m_condition = order == ORDERBY::ORDER_ASC
65
65
  ? fmt::format("{} order by {} ASC", m_condition, field)
66
66
  : fmt::format("{} order by {} DESC", m_condition, field);
67
67
  }
68
68
 
69
- DBCondition& operator+(const ASC& asc) {
69
+ DBCondition &operator+(const ASC &asc) {
70
70
  orderBy(asc.name, ORDER_ASC);
71
71
  return *this;
72
72
  }
73
73
 
74
- DBCondition& operator+(const DESC& desc) {
74
+ DBCondition &operator+(const DESC &desc) {
75
75
  orderBy(desc.name, ORDER_DESC);
76
76
  return *this;
77
77
  }
78
78
 
79
- DBCondition& operator+(const LIMIT& limit) {
79
+ DBCondition &operator+(const LIMIT &limit) {
80
80
  m_condition = fmt::format("{} limit {}", m_condition, limit.limit);
81
81
  return *this;
82
82
  }
83
83
 
84
- const std::string& str() const {
84
+ const std::string &str() const {
85
85
  return m_condition;
86
86
  }
87
87
 
@@ -90,27 +90,27 @@ private:
90
90
  };
91
91
 
92
92
  struct Field {
93
- explicit Field(const char* name) : name(name) {}
94
- explicit Field(const std::string& name) : name(name) {}
93
+ explicit Field(const char *name) : name(name) {}
94
+ explicit Field(const std::string &name) : name(name) {}
95
95
 
96
96
  // in 和 not_in 不支持 字符串,一般不会用到 in ("stra", "strb") 的 SQL 操作
97
97
  template <typename T>
98
- DBCondition in(const std::vector<T>& vals) {
98
+ DBCondition in(const std::vector<T> &vals) {
99
99
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
100
100
  return DBCondition(fmt::format("({} in ({}))", name, fmt::join(vals, ",")));
101
101
  }
102
102
 
103
103
  template <typename T>
104
- DBCondition not_in(const std::vector<T>& vals) {
104
+ DBCondition not_in(const std::vector<T> &vals) {
105
105
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
106
106
  return DBCondition(fmt::format("({} not in ({}))", name, fmt::join(vals, ",")));
107
107
  }
108
108
 
109
- DBCondition like(const std::string& pattern) {
109
+ DBCondition like(const std::string &pattern) {
110
110
  return DBCondition(fmt::format(R"(({} like "{}"))", name, pattern));
111
111
  }
112
112
 
113
- DBCondition like(const char* pattern) {
113
+ DBCondition like(const char *pattern) {
114
114
  return DBCondition(fmt::format(R"(({} like "{}"))", name, pattern));
115
115
  }
116
116
 
@@ -120,7 +120,7 @@ struct Field {
120
120
  // linux下类成员函数模板特化必须放在类外实现
121
121
  // 否则编译时会报:explicit specialization in non-namespace scope
122
122
  template <>
123
- inline DBCondition Field::in<std::string>(const std::vector<std::string>& vals) {
123
+ inline DBCondition Field::in<std::string>(const std::vector<std::string> &vals) {
124
124
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
125
125
  std::ostringstream out;
126
126
  out << "(" << name << " in (";
@@ -133,7 +133,7 @@ inline DBCondition Field::in<std::string>(const std::vector<std::string>& vals)
133
133
  }
134
134
 
135
135
  template <>
136
- inline DBCondition Field::not_in<std::string>(const std::vector<std::string>& vals) {
136
+ inline DBCondition Field::not_in<std::string>(const std::vector<std::string> &vals) {
137
137
  HKU_CHECK(!vals.empty(), "input vals can't be empty!");
138
138
  std::ostringstream out;
139
139
  out << "(" << name << " not in (";
@@ -145,103 +145,103 @@ inline DBCondition Field::not_in<std::string>(const std::vector<std::string>& va
145
145
  return DBCondition(out.str());
146
146
  }
147
147
 
148
- inline std::ostream& operator<<(std::ostream& out, const DBCondition& d) {
148
+ inline std::ostream &operator<<(std::ostream &out, const DBCondition &d) {
149
149
  out << d.str();
150
150
  return out;
151
151
  }
152
152
 
153
153
  template <typename T>
154
- inline DBCondition operator==(const Field& field, T val) {
154
+ inline DBCondition operator==(const Field &field, T val) {
155
155
  std::ostringstream out;
156
156
  out << "(" << field.name << "=" << val << ")";
157
157
  return DBCondition(out.str());
158
158
  }
159
159
 
160
160
  template <typename T>
161
- inline DBCondition operator!=(const Field& field, T val) {
161
+ inline DBCondition operator!=(const Field &field, T val) {
162
162
  std::ostringstream out;
163
163
  out << "(" << field.name << "<>" << val << ")";
164
164
  return DBCondition(out.str());
165
165
  }
166
166
 
167
167
  template <typename T>
168
- inline DBCondition operator>(const Field& field, T val) {
168
+ inline DBCondition operator>(const Field &field, T val) {
169
169
  std::ostringstream out;
170
170
  out << "(" << field.name << ">" << val << ")";
171
171
  return DBCondition(out.str());
172
172
  }
173
173
 
174
174
  template <typename T>
175
- inline DBCondition operator>=(const Field& field, T val) {
175
+ inline DBCondition operator>=(const Field &field, T val) {
176
176
  std::ostringstream out;
177
177
  out << "(" << field.name << ">=" << val << ")";
178
178
  return DBCondition(out.str());
179
179
  }
180
180
 
181
181
  template <typename T>
182
- inline DBCondition operator<(const Field& field, T val) {
182
+ inline DBCondition operator<(const Field &field, T val) {
183
183
  std::ostringstream out;
184
184
  out << "(" << field.name << "<" << val << ")";
185
185
  return DBCondition(out.str());
186
186
  }
187
187
 
188
188
  template <typename T>
189
- inline DBCondition operator<=(const Field& field, T val) {
189
+ inline DBCondition operator<=(const Field &field, T val) {
190
190
  std::ostringstream out;
191
191
  out << "(" << field.name << "<=" << val << ")";
192
192
  return DBCondition(out.str());
193
193
  }
194
194
 
195
195
  template <>
196
- inline DBCondition operator!=(const Field& field, const char* val) {
196
+ inline DBCondition operator!=(const Field &field, const char *val) {
197
197
  return DBCondition(fmt::format(R"(({}<>"{}"))", field.name, val));
198
198
  }
199
199
 
200
200
  template <>
201
- inline DBCondition operator>(const Field& field, const char* val) {
201
+ inline DBCondition operator>(const Field &field, const char *val) {
202
202
  return DBCondition(fmt::format(R"(({}>"{}"))", field.name, val));
203
203
  }
204
204
 
205
205
  template <>
206
- inline DBCondition operator<(const Field& field, const char* val) {
206
+ inline DBCondition operator<(const Field &field, const char *val) {
207
207
  return DBCondition(fmt::format(R"(({}<"{}"))", field.name, val));
208
208
  }
209
209
 
210
210
  template <>
211
- inline DBCondition operator>=(const Field& field, const char* val) {
211
+ inline DBCondition operator>=(const Field &field, const char *val) {
212
212
  return DBCondition(fmt::format(R"(({}>="{}"))", field.name, val));
213
213
  }
214
214
 
215
215
  template <>
216
- inline DBCondition operator<=(const Field& field, const char* val) {
216
+ inline DBCondition operator<=(const Field &field, const char *val) {
217
217
  return DBCondition(fmt::format(R"(({}<="{}"))", field.name, val));
218
218
  }
219
219
 
220
- inline DBCondition operator==(const Field& field, const std::string& val) {
220
+ inline DBCondition operator==(const Field &field, const std::string &val) {
221
221
  return DBCondition(fmt::format(R"(({}="{}"))", field.name, val));
222
222
  }
223
223
 
224
- inline DBCondition operator!=(const Field& field, const std::string& val) {
224
+ inline DBCondition operator!=(const Field &field, const std::string &val) {
225
225
  return DBCondition(fmt::format(R"(({}<>"{}"))", field.name, val));
226
226
  }
227
227
 
228
- inline DBCondition operator>(const Field& field, const std::string& val) {
228
+ inline DBCondition operator>(const Field &field, const std::string &val) {
229
229
  return DBCondition(fmt::format(R"(({}>"{}"))", field.name, val));
230
230
  }
231
231
 
232
- inline DBCondition operator<(const Field& field, const std::string& val) {
232
+ inline DBCondition operator<(const Field &field, const std::string &val) {
233
233
  return DBCondition(fmt::format(R"(({}<"{}"))", field.name, val));
234
234
  }
235
235
 
236
- inline DBCondition operator>=(const Field& field, const std::string& val) {
236
+ inline DBCondition operator>=(const Field &field, const std::string &val) {
237
237
  return DBCondition(fmt::format(R"(({}>="{}"))", field.name, val));
238
238
  }
239
239
 
240
- inline DBCondition operator<=(const Field& field, const std::string& val) {
240
+ inline DBCondition operator<=(const Field &field, const std::string &val) {
241
241
  return DBCondition(fmt::format(R"(({}<="{}"))", field.name, val));
242
242
  }
243
243
 
244
- inline DBCondition operator==(const Field& field, const char* val) {
244
+ inline DBCondition operator==(const Field &field, const char *val) {
245
245
  return DBCondition(fmt::format(R"(({}="{}"))", field.name, val));
246
246
  }
247
247
 
@@ -17,4 +17,14 @@
17
17
  #include "TableMacro.h"
18
18
  #include "DBUpgrade.h"
19
19
 
20
+ #include "hikyuu/utilities/config.h"
21
+ #if HKU_ENABLE_MYSQL
22
+ #include "mysql/MySQLConnect.h"
23
+ #endif
24
+
25
+ #if HKU_ENABLE_SQLITE
26
+ #include "sqlite/SQLiteConnect.h"
27
+ #include "sqlite/SQLiteUtil.h"
28
+ #endif
29
+
20
30
  #endif /* HIKYUU_DB_CONNECT_H */