hikyuu 2.7.1__py3-none-win_amd64.whl → 2.7.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.
- hikyuu/__init__.py +4 -1
- hikyuu/__init__.pyi +23 -11
- hikyuu/analysis/__init__.pyi +5 -1
- hikyuu/analysis/analysis.pyi +6 -2
- hikyuu/core.pyi +7 -3
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +55 -6
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +55 -6
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +55 -6
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +55 -6
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu_plugin.mo +0 -0
- hikyuu/data/clickhouse_upgrade/0001.sql +2 -0
- hikyuu/data/common_clickhouse.py +1 -3
- hikyuu/data/hku_config_template.py +6 -0
- hikyuu/data/mysql_upgrade/0029.sql +2 -0
- hikyuu/data/pytdx_to_clickhouse.py +85 -31
- hikyuu/data/pytdx_to_h5.py +73 -28
- hikyuu/data/pytdx_to_mysql.py +65 -21
- hikyuu/data/pytdx_weight_to_clickhouse.py +2 -0
- hikyuu/data/pytdx_weight_to_mysql.py +2 -0
- hikyuu/data/pytdx_weight_to_sqlite.py +2 -0
- hikyuu/data/sqlite_upgrade/0029.sql +4 -0
- hikyuu/draw/drawplot/bokeh_draw.pyi +10 -6
- hikyuu/draw/drawplot/echarts_draw.pyi +10 -6
- hikyuu/draw/drawplot/matplotlib_draw.py +8 -2
- hikyuu/draw/drawplot/matplotlib_draw.pyi +10 -6
- hikyuu/extend.pyi +8 -4
- hikyuu/gui/HikyuuTDX.py +12 -2
- hikyuu/gui/data/MainWindow.py +166 -142
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/StockManager.h +4 -0
- hikyuu/include/hikyuu/StrategyContext.h +4 -4
- hikyuu/include/hikyuu/global/sysinfo.h +24 -5
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +1 -1
- hikyuu/include/hikyuu/plugin/KDataToClickHouseImporter.h +40 -0
- hikyuu/include/hikyuu/plugin/KDataToMySQLImporter.h +40 -0
- hikyuu/include/hikyuu/plugin/checkdata.h +20 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +2 -0
- hikyuu/include/hikyuu/plugin/interface/CheckDataPluginInterface.h +25 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +2 -0
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToClickHousePluginInterface.h +44 -0
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToMySQLPluginInterface.h +42 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +6 -0
- hikyuu/include/hikyuu/python/convert_any.h +9 -6
- hikyuu/include/hikyuu/strategy/Strategy.h +1 -1
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +2 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/crt/AF_FixedAmount.h +26 -0
- hikyuu/include/hikyuu/trade_sys/allocatefunds/imp/FixAmountFunds.h +18 -0
- hikyuu/include/hikyuu/utilities/Log.h +6 -7
- hikyuu/include/hikyuu/utilities/Parameter.h +17 -0
- hikyuu/include/hikyuu/utilities/config.h +28 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginBase.h +17 -2
- hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +41 -22
- hikyuu/include/hikyuu/utilities/thread/GlobalStealThreadPool.h +1 -2
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +285 -0
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +296 -0
- hikyuu/include/hikyuu/utilities/thread/WorkStealQueue.h +9 -8
- hikyuu/include/hikyuu/utilities/thread/algorithm.h +64 -14
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/checkdata.dll +0 -0
- hikyuu/plugin/clickhousedriver.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/dataserver_parquet.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/plugin/extind.dll +0 -0
- hikyuu/plugin/hkuextra.dll +0 -0
- hikyuu/plugin/import2ch.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/import2mysql.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/trade_manage/__init__.pyi +10 -6
- hikyuu/trade_manage/trade.pyi +10 -6
- hikyuu/trade_sys/trade_sys.py +3 -1
- hikyuu/util/__init__.pyi +1 -1
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.7.1.dist-info → hikyuu-2.7.2.dist-info}/METADATA +5 -1
- {hikyuu-2.7.1.dist-info → hikyuu-2.7.2.dist-info}/RECORD +89 -73
- hikyuu/data/pytdx_to_taos.py +0 -736
- {hikyuu-2.7.1.dist-info → hikyuu-2.7.2.dist-info}/WHEEL +0 -0
- {hikyuu-2.7.1.dist-info → hikyuu-2.7.2.dist-info}/entry_points.txt +0 -0
- {hikyuu-2.7.1.dist-info → hikyuu-2.7.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
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/ImportKDataToMySQLPluginInterface.h"
|
|
12
|
+
|
|
13
|
+
namespace hku {
|
|
14
|
+
|
|
15
|
+
class HKU_API KDataToMySQLImporter {
|
|
16
|
+
public:
|
|
17
|
+
KDataToMySQLImporter();
|
|
18
|
+
virtual ~KDataToMySQLImporter();
|
|
19
|
+
|
|
20
|
+
bool setConfig(const string& host, int port, const string& user, const string& pwd);
|
|
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 addTimeLineList(const string& market, const string& code, const TimeLineList& timeline);
|
|
28
|
+
|
|
29
|
+
void addTransList(const string& market, const string& code, const TransRecordList& translist);
|
|
30
|
+
|
|
31
|
+
void updateIndex(const string& market, const string& code, const KQuery::KType& ktype);
|
|
32
|
+
|
|
33
|
+
void remove(const string& market, const string& code, const KQuery::KType& ktype,
|
|
34
|
+
Datetime start);
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
ImportKDataToMySQLPluginInterface* m_plugin{nullptr};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace hku
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-12-20
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "hikyuu/DataType.h"
|
|
11
|
+
#include "interface/CheckDataPluginInterface.h"
|
|
12
|
+
|
|
13
|
+
namespace hku {
|
|
14
|
+
|
|
15
|
+
std::pair<std::string, vector<std::string>> HKU_API checkData(const StockList& stock_list,
|
|
16
|
+
const Datetime& start_date,
|
|
17
|
+
const Datetime& end_date,
|
|
18
|
+
const KQuery::KType& check_ktype);
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-05-19
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "hikyuu/Stock.h"
|
|
11
|
+
#include "hikyuu/utilities/plugin/PluginBase.h"
|
|
12
|
+
|
|
13
|
+
namespace hku {
|
|
14
|
+
|
|
15
|
+
class CheckDataPluginInterface : public PluginBase {
|
|
16
|
+
public:
|
|
17
|
+
CheckDataPluginInterface() = default;
|
|
18
|
+
virtual ~CheckDataPluginInterface() = default;
|
|
19
|
+
|
|
20
|
+
virtual std::pair<std::string, vector<std::string>> checkData(
|
|
21
|
+
const StockList& stock_list, const Datetime& start_date, const Datetime& end_date,
|
|
22
|
+
const KQuery::KType& check_ktype) = 0;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace hku
|
|
@@ -0,0 +1,44 @@
|
|
|
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/TimeLineRecord.h"
|
|
13
|
+
#include "hikyuu/TransRecord.h"
|
|
14
|
+
#include "hikyuu/utilities/plugin/PluginBase.h"
|
|
15
|
+
|
|
16
|
+
namespace hku {
|
|
17
|
+
|
|
18
|
+
class ImportKDataToClickHousePluginInterface : public PluginBase {
|
|
19
|
+
public:
|
|
20
|
+
ImportKDataToClickHousePluginInterface() = default;
|
|
21
|
+
virtual ~ImportKDataToClickHousePluginInterface() = default;
|
|
22
|
+
|
|
23
|
+
virtual bool setConfig(const string& host, int port, const string& user, const string& pwd) = 0;
|
|
24
|
+
|
|
25
|
+
virtual Datetime getLastDatetime(const string& market, const string& code,
|
|
26
|
+
const KQuery::KType& ktype) = 0;
|
|
27
|
+
|
|
28
|
+
virtual void addKRecordList(const string& market, const string& code,
|
|
29
|
+
const vector<KRecord>& krecords, const KQuery::KType& ktype) = 0;
|
|
30
|
+
|
|
31
|
+
virtual void addTimeLineList(const string& market, const string& code,
|
|
32
|
+
const TimeLineList& timeline) = 0;
|
|
33
|
+
|
|
34
|
+
virtual void addTransList(const string& market, const string& code,
|
|
35
|
+
const TransRecordList& translist) = 0;
|
|
36
|
+
|
|
37
|
+
virtual void updateIndex(const string& market, const string& code,
|
|
38
|
+
const KQuery::KType& ktype) = 0;
|
|
39
|
+
|
|
40
|
+
virtual void remove(const string& market, const string& code, const KQuery::KType& ktype,
|
|
41
|
+
Datetime start) = 0;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace hku
|
|
@@ -0,0 +1,42 @@
|
|
|
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 ImportKDataToMySQLPluginInterface : public PluginBase {
|
|
17
|
+
public:
|
|
18
|
+
ImportKDataToMySQLPluginInterface() = default;
|
|
19
|
+
virtual ~ImportKDataToMySQLPluginInterface() = default;
|
|
20
|
+
|
|
21
|
+
virtual bool setConfig(const string& host, int port, const string& user, const string& pwd) = 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
|
+
virtual void addTimeLineList(const string& market, const string& code,
|
|
33
|
+
const TimeLineList& timeline) = 0;
|
|
34
|
+
|
|
35
|
+
virtual void addTransList(const string& market, const string& code,
|
|
36
|
+
const TransRecordList& translist) = 0;
|
|
37
|
+
|
|
38
|
+
virtual void remove(const string& market, const string& code, const KQuery::KType& ktype,
|
|
39
|
+
Datetime start) = 0;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
} // namespace hku
|
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
#include "DevicePluginInterface.h"
|
|
14
14
|
#include "DataServerPluginInterface.h"
|
|
15
15
|
#include "ImportKDataToHdf5PluginInterface.h"
|
|
16
|
+
#include "ImportKDataToClickHousePluginInterface.h"
|
|
17
|
+
#include "ImportKDataToMySQLPluginInterface.h"
|
|
16
18
|
#include "ExtendIndicatorsPluginInterface.h"
|
|
17
19
|
#include "TMReportPluginInterface.h"
|
|
18
20
|
#include "DataDriverPluginInterface.h"
|
|
19
21
|
#include "HkuExtraPluginInterface.h"
|
|
22
|
+
#include "CheckDataPluginInterface.h"
|
|
20
23
|
|
|
21
24
|
namespace hku {
|
|
22
25
|
|
|
@@ -24,9 +27,12 @@ namespace hku {
|
|
|
24
27
|
#define HKU_PLUGIN_DEVICE "device"
|
|
25
28
|
#define HKU_PLUGIN_DATASERVER "dataserver"
|
|
26
29
|
#define HKU_PLUGIN_IMPORTKDATATOHDF5 "import2hdf5"
|
|
30
|
+
#define HKU_PLUGIN_IMPORTKDATATOCLICKHOUSE "import2ch"
|
|
31
|
+
#define HKU_PLUGIN_IMPORTKDATATOMYSQL "import2mysql"
|
|
27
32
|
#define HKU_PLUGIN_EXTEND_INDICATOR "extind"
|
|
28
33
|
#define HKU_PLUGIN_TMREPORT "tmreport"
|
|
29
34
|
#define HKU_PLUGIN_CLICKHOUSE_DRIVER "clickhousedriver"
|
|
30
35
|
#define HKU_PLUGIN_HKU_EXTRA "hkuextra"
|
|
36
|
+
#define HKU_PLUGIN_CHECK_DATA "checkdata"
|
|
31
37
|
|
|
32
38
|
} // namespace hku
|
|
@@ -104,12 +104,12 @@ public:
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
if (PyLong_Check(src)) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
value = static_cast<
|
|
107
|
+
long long ll_val = PyLong_AsLongLong(src);
|
|
108
|
+
if (ll_val < std::numeric_limits<int>::min() ||
|
|
109
|
+
ll_val > std::numeric_limits<int>::max()) {
|
|
110
|
+
value = static_cast<int64_t>(ll_val);
|
|
111
111
|
} else {
|
|
112
|
-
value =
|
|
112
|
+
value = static_cast<int>(ll_val);
|
|
113
113
|
}
|
|
114
114
|
return true;
|
|
115
115
|
}
|
|
@@ -192,8 +192,11 @@ public:
|
|
|
192
192
|
} else {
|
|
193
193
|
Py_RETURN_FALSE;
|
|
194
194
|
}
|
|
195
|
+
} else if (x.type() == typeid(int64_t)) {
|
|
196
|
+
long long ll_val = (long long)boost::any_cast<int64_t>(x);
|
|
197
|
+
return PyLong_FromLongLong(ll_val);
|
|
195
198
|
} else if (x.type() == typeid(int)) {
|
|
196
|
-
return Py_BuildValue("
|
|
199
|
+
return Py_BuildValue("i", boost::any_cast<int>(x));
|
|
197
200
|
} else if (x.type() == typeid(double)) {
|
|
198
201
|
return Py_BuildValue("d", boost::any_cast<double>(x));
|
|
199
202
|
} else if (x.type() == typeid(std::string)) {
|
|
@@ -35,7 +35,7 @@ public:
|
|
|
35
35
|
Strategy();
|
|
36
36
|
explicit Strategy(const string& name, const string& config_file = "");
|
|
37
37
|
Strategy(const vector<string>& codeList, const vector<KQuery::KType>& ktypeList,
|
|
38
|
-
const unordered_map<string,
|
|
38
|
+
const unordered_map<string, int64_t>& preloadNum = {}, const string& name = "Strategy",
|
|
39
39
|
const string& config_file = "");
|
|
40
40
|
explicit Strategy(const StrategyContext& context, const string& name = "Strategy",
|
|
41
41
|
const string& config_file = "");
|
|
@@ -38,7 +38,8 @@ enum BUSINESS {
|
|
|
38
38
|
BUSINESS_RETURN_STOCK = 12, /**< 归还股票资产 */
|
|
39
39
|
BUSINESS_SELL_SHORT = 13, /**< 卖空 */
|
|
40
40
|
BUSINESS_BUY_SHORT = 14, /**< 卖空后回补 */
|
|
41
|
-
|
|
41
|
+
BUSINESS_SUOGU = 15, /**< 缩扩股 */
|
|
42
|
+
BUSINESS_INVALID = 16 /**< 无效类型 */
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2019 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025年12月9日
|
|
5
|
+
* Author: stone
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
#ifndef TRADE_SYS_ALLOCATEFUNDS_CRT_AF_FIXEDAMOUNT_H_
|
|
10
|
+
#define TRADE_SYS_ALLOCATEFUNDS_CRT_AF_FIXEDAMOUNT_H_
|
|
11
|
+
|
|
12
|
+
#include "../AllocateFundsBase.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @brief 固定金额分配,每个选中的资产都不能超过此金额交易
|
|
18
|
+
* @param amount 指定的固定交易金额
|
|
19
|
+
* @return AFPtr
|
|
20
|
+
* @ingroup AllocateFunds
|
|
21
|
+
*/
|
|
22
|
+
AFPtr HKU_API AF_FixedAmount(double amount = 20000.0);
|
|
23
|
+
|
|
24
|
+
} /* namespace hku */
|
|
25
|
+
|
|
26
|
+
#endif /* TRADE_SYS_ALLOCATEFUNDS_CRT_AF_FIXEDAMOUNT_H_ */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include "../AllocateFundsBase.h"
|
|
3
|
+
|
|
4
|
+
namespace hku {
|
|
5
|
+
|
|
6
|
+
class FixedAmountFunds : public AllocateFundsBase {
|
|
7
|
+
ALLOCATEFUNDS_IMP(FixedAmountFunds)
|
|
8
|
+
ALLOCATEFUNDS_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
9
|
+
|
|
10
|
+
public:
|
|
11
|
+
FixedAmountFunds();
|
|
12
|
+
virtual ~FixedAmountFunds();
|
|
13
|
+
virtual void _checkParam(const string& name) const override;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
} /* namespace hku */
|
|
17
|
+
|
|
18
|
+
|
|
@@ -343,13 +343,12 @@ std::shared_ptr<spdlog::logger> HKU_UTILS_API getHikyuuLogger();
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
/** 用于 catch (...) 中打印,减少编译后代码大小 */
|
|
346
|
-
|
|
347
|
-
#define
|
|
348
|
-
#define
|
|
349
|
-
#define
|
|
350
|
-
#define
|
|
351
|
-
#define
|
|
352
|
-
#define HKU_FATAL_UNKNOWN HKU_FATAL("{}", g_unknown_error_msg)
|
|
346
|
+
#define HKU_THROW_UNKNOWN HKU_THROW("Unknown error!")
|
|
347
|
+
#define HKU_TRACE_UNKNOWN HKU_TRACE("Unknown error!")
|
|
348
|
+
#define HKU_DEBUG_UNKNOWN HKU_DEBUG("Unknown error!")
|
|
349
|
+
#define HKU_INFO_UNKNOWN HKU_INFO("Unknown error!");
|
|
350
|
+
#define HKU_ERROR_UNKNOWN HKU_ERROR("Unknown error!");
|
|
351
|
+
#define HKU_FATAL_UNKNOWN HKU_FATAL("Unknown error!");
|
|
353
352
|
|
|
354
353
|
#if CPP_STANDARD >= CPP_STANDARD_20
|
|
355
354
|
#define CLASS_LOGGER_IMP(cls) \
|
|
@@ -503,6 +503,23 @@ inline void Parameter::set(const string& name, const boost::any& value) {
|
|
|
503
503
|
m_params[name] = value;
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
+
template <>
|
|
507
|
+
inline int64_t Parameter::get(const string& name) const {
|
|
508
|
+
param_map_t::const_iterator iter;
|
|
509
|
+
iter = m_params.find(name);
|
|
510
|
+
if (iter == m_params.end()) {
|
|
511
|
+
throw std::out_of_range("out_of_range in Parameter::get : " + name);
|
|
512
|
+
}
|
|
513
|
+
try {
|
|
514
|
+
if (iter->second.type() == typeid(int)) {
|
|
515
|
+
return boost::any_cast<int>(iter->second);
|
|
516
|
+
}
|
|
517
|
+
return boost::any_cast<int64_t>(iter->second);
|
|
518
|
+
} catch (...) {
|
|
519
|
+
throw std::runtime_error("failed conversion param: " + name);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
506
523
|
HKU_API bool operator==(const Parameter&, const Parameter&);
|
|
507
524
|
HKU_API bool operator!=(const Parameter&, const Parameter&);
|
|
508
525
|
HKU_API bool operator<(const Parameter&, const Parameter&);
|
|
@@ -6,33 +6,61 @@
|
|
|
6
6
|
|
|
7
7
|
// clang-format off
|
|
8
8
|
|
|
9
|
+
#ifndef HKU_ENABLE_MYSQL
|
|
9
10
|
#define HKU_ENABLE_MYSQL 1
|
|
10
11
|
#if HKU_ENABLE_MYSQL && HKU_OS_WINDOWS
|
|
11
12
|
#ifndef NOMINMAX
|
|
12
13
|
#define NOMINMAX
|
|
13
14
|
#endif
|
|
14
15
|
#endif
|
|
16
|
+
#endif
|
|
15
17
|
|
|
18
|
+
#ifndef HKU_ENABLE_SQLITE
|
|
16
19
|
#define HKU_ENABLE_SQLITE 1
|
|
20
|
+
#endif
|
|
21
|
+
#ifndef HKU_ENABLE_SQLCIPHER
|
|
17
22
|
#define HKU_ENABLE_SQLCIPHER 0
|
|
23
|
+
#endif
|
|
24
|
+
#ifndef HKU_SQL_TRACE
|
|
18
25
|
/* #define HKU_SQL_TRACE 0 */
|
|
26
|
+
#endif
|
|
19
27
|
|
|
28
|
+
#ifndef HKU_SUPPORT_DATETIME
|
|
20
29
|
#define HKU_SUPPORT_DATETIME 1
|
|
30
|
+
#endif
|
|
21
31
|
|
|
32
|
+
#ifndef HKU_ENABLE_INI_PARSER
|
|
22
33
|
#define HKU_ENABLE_INI_PARSER 1
|
|
34
|
+
#endif
|
|
23
35
|
|
|
36
|
+
#ifndef HKU_ENABLE_STACK_TRACE
|
|
24
37
|
#define HKU_ENABLE_STACK_TRACE 0
|
|
38
|
+
#endif
|
|
25
39
|
|
|
40
|
+
#ifndef HKU_CLOSE_SPEND_TIME
|
|
26
41
|
#define HKU_CLOSE_SPEND_TIME 0
|
|
42
|
+
#endif
|
|
27
43
|
|
|
44
|
+
#ifndef HKU_USE_SPDLOG_ASYNC_LOGGER
|
|
28
45
|
#define HKU_USE_SPDLOG_ASYNC_LOGGER 0
|
|
46
|
+
#endif
|
|
47
|
+
#ifndef HKU_LOG_ACTIVE_LEVEL
|
|
29
48
|
#define HKU_LOG_ACTIVE_LEVEL 2
|
|
49
|
+
#endif
|
|
30
50
|
|
|
51
|
+
#ifndef HKU_ENABLE_HTTP_CLIENT
|
|
31
52
|
#define HKU_ENABLE_HTTP_CLIENT 1
|
|
53
|
+
#endif
|
|
54
|
+
#ifndef HKU_ENABLE_HTTP_CLIENT_SSL
|
|
32
55
|
#define HKU_ENABLE_HTTP_CLIENT_SSL 0
|
|
56
|
+
#endif
|
|
57
|
+
#ifndef HKU_ENABLE_HTTP_CLIENT_ZIP
|
|
33
58
|
#define HKU_ENABLE_HTTP_CLIENT_ZIP 0
|
|
59
|
+
#endif
|
|
34
60
|
|
|
61
|
+
#ifndef HKU_ENABLE_NODE
|
|
35
62
|
#define HKU_ENABLE_NODE 1
|
|
63
|
+
#endif
|
|
36
64
|
|
|
37
65
|
// clang-format on
|
|
38
66
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <string>
|
|
13
13
|
#include "hikyuu/utilities/config.h"
|
|
14
14
|
#include "hikyuu/utilities/osdef.h"
|
|
15
|
+
#include "hikyuu/utilities/Log.h"
|
|
15
16
|
|
|
16
17
|
namespace hku {
|
|
17
18
|
|
|
@@ -35,12 +36,26 @@ public:
|
|
|
35
36
|
#if HKU_OS_WINDOWS
|
|
36
37
|
#define HKU_PLUGIN_DEFINE(plugin) \
|
|
37
38
|
extern "C" __declspec(dllexport) hku::PluginBase* createPlugin() { \
|
|
38
|
-
|
|
39
|
+
try { \
|
|
40
|
+
return new plugin(); \
|
|
41
|
+
} catch (const std::exception& e) { \
|
|
42
|
+
HKU_ERROR("{}", e.what()); \
|
|
43
|
+
return nullptr; \
|
|
44
|
+
} catch (...) { \
|
|
45
|
+
return nullptr; \
|
|
46
|
+
} \
|
|
39
47
|
}
|
|
40
48
|
#else
|
|
41
49
|
#define HKU_PLUGIN_DEFINE(plugin) \
|
|
42
50
|
extern "C" hku::PluginBase* createPlugin() { \
|
|
43
|
-
|
|
51
|
+
try { \
|
|
52
|
+
return new plugin(); \
|
|
53
|
+
} catch (const std::exception& e) { \
|
|
54
|
+
HKU_ERROR("{}", e.what()); \
|
|
55
|
+
return nullptr; \
|
|
56
|
+
} catch (...) { \
|
|
57
|
+
return nullptr; \
|
|
58
|
+
} \
|
|
44
59
|
}
|
|
45
60
|
#endif
|
|
46
61
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#include <string>
|
|
11
11
|
#include <memory>
|
|
12
12
|
#include <unordered_map>
|
|
13
|
-
#include <
|
|
13
|
+
#include <shared_mutex>
|
|
14
14
|
#include "hikyuu/utilities/Log.h"
|
|
15
15
|
#include "hikyuu/utilities/plugin/PluginLoader.h"
|
|
16
16
|
|
|
@@ -38,35 +38,54 @@ public:
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
template <typename PluginInterfaceT>
|
|
41
|
-
PluginInterfaceT* getPlugin(const std::string& pluginname) noexcept
|
|
41
|
+
PluginInterfaceT* getPlugin(const std::string& pluginname) noexcept {
|
|
42
|
+
PluginInterfaceT* ret{nullptr};
|
|
43
|
+
try {
|
|
44
|
+
{
|
|
45
|
+
std::shared_lock<std::shared_mutex> read_lock(m_mutex);
|
|
46
|
+
auto it = m_plugins.find(pluginname);
|
|
47
|
+
if (it != m_plugins.end()) {
|
|
48
|
+
ret = it->second->instance<PluginInterfaceT>();
|
|
49
|
+
return ret;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
std::unique_ptr<PluginLoader> loader = std::make_unique<PluginLoader>(m_plugin_path);
|
|
54
|
+
if (!loader->load(pluginname)) {
|
|
55
|
+
HKU_DEBUG("Load plugin {} failed: {}", pluginname, loader->getFileName(pluginname));
|
|
56
|
+
return ret;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
std::unique_lock<std::shared_mutex> write_lock(m_mutex);
|
|
61
|
+
auto it = m_plugins.find(pluginname);
|
|
62
|
+
if (it != m_plugins.end()) {
|
|
63
|
+
// 复用已插入的插件实例
|
|
64
|
+
ret = it->second->instance<PluginInterfaceT>();
|
|
65
|
+
} else {
|
|
66
|
+
// 插入新加载的插件
|
|
67
|
+
auto [it, success] =
|
|
68
|
+
m_plugins.insert(std::make_pair(pluginname, std::move(loader)));
|
|
69
|
+
if (success) {
|
|
70
|
+
ret = it->second->instance<PluginInterfaceT>();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return ret;
|
|
52
74
|
}
|
|
75
|
+
} catch (const std::exception& e) {
|
|
76
|
+
HKU_ERROR("Load plugin {} failed: {}", pluginname, e.what());
|
|
77
|
+
ret = nullptr;
|
|
78
|
+
} catch (...) {
|
|
79
|
+
HKU_ERROR("Load plugin {} failed: unknown exception", pluginname);
|
|
80
|
+
ret = nullptr;
|
|
53
81
|
}
|
|
54
|
-
return
|
|
82
|
+
return ret;
|
|
55
83
|
}
|
|
56
84
|
|
|
57
85
|
private:
|
|
58
86
|
std::string m_plugin_path;
|
|
59
87
|
std::unordered_map<std::string, std::unique_ptr<PluginLoader>> m_plugins;
|
|
60
|
-
std::
|
|
88
|
+
std::shared_mutex m_mutex;
|
|
61
89
|
};
|
|
62
90
|
|
|
63
|
-
template <typename PluginInterfaceT>
|
|
64
|
-
PluginInterfaceT* PluginManager::getPlugin(const std::string& pluginname) noexcept {
|
|
65
|
-
auto it = m_plugins.find(pluginname);
|
|
66
|
-
if (it == m_plugins.end()) {
|
|
67
|
-
it = load(pluginname);
|
|
68
|
-
}
|
|
69
|
-
return it != m_plugins.end() ? it->second->instance<PluginInterfaceT>() : nullptr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
91
|
} // namespace hku
|