hikyuu 2.6.6__py3-none-win_amd64.whl → 2.6.8__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 +16 -2
- hikyuu/__init__.pyi +658 -627
- hikyuu/analysis/__init__.pyi +563 -519
- hikyuu/analysis/analysis.pyi +583 -541
- hikyuu/core.pyi +565 -521
- hikyuu/cpp/__init__.pyi +2 -2
- hikyuu/cpp/concrt140.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +1424 -865
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +1424 -865
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +1424 -865
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +1424 -863
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +1424 -865
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/hku_hdf5.dll +0 -0
- hikyuu/cpp/hku_hdf5_cpp.dll +0 -0
- hikyuu/cpp/hku_hdf5_hl.dll +0 -0
- hikyuu/cpp/hku_hdf5_hl_cpp.dll +0 -0
- hikyuu/cpp/i18n/zh_CN/__init__.py +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/msvcp140.dll +0 -0
- hikyuu/cpp/msvcp140_1.dll +0 -0
- hikyuu/cpp/msvcp140_2.dll +0 -0
- hikyuu/cpp/msvcp140_atomic_wait.dll +0 -0
- hikyuu/cpp/msvcp140_codecvt_ids.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/cpp/vcruntime140.dll +0 -0
- hikyuu/cpp/vcruntime140_1.dll +0 -0
- hikyuu/data/common_clickhouse.py +0 -47
- hikyuu/data/tdx_to_h5.py +1 -1
- hikyuu/draw/drawplot/__init__.pyi +32 -37
- hikyuu/draw/drawplot/bokeh_draw.pyi +651 -632
- hikyuu/draw/drawplot/common.pyi +3 -4
- hikyuu/draw/drawplot/echarts_draw.py +9 -8
- hikyuu/draw/drawplot/echarts_draw.pyi +598 -567
- hikyuu/draw/drawplot/matplotlib_draw.py +3 -3
- hikyuu/draw/drawplot/matplotlib_draw.pyi +872 -874
- hikyuu/draw/elder.pyi +19 -20
- hikyuu/draw/kaufman.py +1 -1
- hikyuu/draw/kaufman.pyi +18 -18
- hikyuu/draw/volume.pyi +10 -10
- hikyuu/examples/notebook/000-Index.ipynb +1 -1
- hikyuu/examples/notebook/001-overview.ipynb +78 -63
- hikyuu/examples/notebook/002-HowToGetStock.ipynb +259 -40
- hikyuu/examples/notebook/003-HowToGetKDataAndDraw.ipynb +49 -41
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +29 -29
- hikyuu/examples/notebook/005-Drawplot.ipynb +66 -37
- hikyuu/examples/notebook/006-TradeManager.ipynb +808 -61
- hikyuu/examples/notebook/007-SystemDetails.ipynb +23 -23
- hikyuu/examples/notebook/009-RealData.ipynb +3 -3
- hikyuu/examples/notebook/010-Portfolio.ipynb +761 -122
- hikyuu/extend.py +32 -98
- hikyuu/extend.pyi +597 -593
- hikyuu/gui/HikyuuTDX.py +2 -4
- hikyuu/gui/data/MainWindow.py +185 -174
- hikyuu/hub.pyi +69 -67
- hikyuu/include/hikyuu/DataType.h +3 -12
- hikyuu/include/hikyuu/KData.h +83 -25
- hikyuu/include/hikyuu/KDataImp.h +31 -46
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +73 -0
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +69 -0
- hikyuu/include/hikyuu/KQuery.h +38 -32
- hikyuu/include/hikyuu/KRecord.h +4 -1
- hikyuu/include/hikyuu/MarketInfo.h +1 -1
- hikyuu/include/hikyuu/Stock.h +24 -6
- hikyuu/include/hikyuu/StockManager.h +15 -6
- hikyuu/include/hikyuu/StockTypeInfo.h +6 -0
- hikyuu/include/hikyuu/TransRecord.h +2 -8
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +5 -0
- hikyuu/include/hikyuu/doc.h +4 -0
- hikyuu/include/hikyuu/global/GlobalSpotAgent.h +8 -0
- hikyuu/include/hikyuu/global/agent/SpotAgent.h +12 -7
- hikyuu/include/hikyuu/indicator/Indicator.h +48 -0
- hikyuu/include/hikyuu/indicator/Indicator2InImp.h +9 -0
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +83 -15
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/AMA.h +2 -1
- hikyuu/include/hikyuu/indicator/crt/ATR.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +3 -0
- hikyuu/include/hikyuu/indicator/crt/DMA.h +1 -1
- hikyuu/include/hikyuu/indicator/crt/IC.h +14 -6
- hikyuu/include/hikyuu/indicator/crt/ICIR.h +8 -4
- hikyuu/include/hikyuu/indicator/crt/INSUM.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/PRICELIST.h +2 -0
- hikyuu/include/hikyuu/indicator/crt/REFX.h +25 -0
- hikyuu/include/hikyuu/indicator/crt/SLICE.h +4 -4
- hikyuu/include/hikyuu/indicator/crt/SPEARMAN.h +3 -2
- hikyuu/include/hikyuu/indicator/imp/IContext.h +5 -0
- hikyuu/include/hikyuu/indicator/imp/ICval.h +6 -0
- hikyuu/include/hikyuu/indicator/imp/IDropna.h +9 -0
- hikyuu/include/hikyuu/indicator/imp/IIc.h +2 -1
- hikyuu/include/hikyuu/indicator/imp/IPriceList.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IRefX.h +23 -0
- hikyuu/include/hikyuu/lang.h +27 -0
- hikyuu/include/hikyuu/plugin/KDataToHdf5Importer.h +6 -1
- hikyuu/include/hikyuu/plugin/backtest.h +2 -0
- hikyuu/include/hikyuu/plugin/extind.h +45 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +77 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +54 -0
- hikyuu/include/hikyuu/plugin/interface/ImportKDataToHdf5PluginInterface.h +10 -1
- hikyuu/include/hikyuu/plugin/interface/TMReportPluginInterface.h +1 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +2 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +28 -11
- hikyuu/include/hikyuu/trade_manage/Performance.h +0 -1
- hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -0
- hikyuu/include/hikyuu/trade_manage/TradeManager.h +4 -0
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +1 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +6 -3
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +4 -0
- hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +5 -2
- hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -0
- hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +6 -1
- hikyuu/include/hikyuu/trade_sys/system/System.h +5 -0
- hikyuu/include/hikyuu/utilities/config.h +0 -2
- hikyuu/include/hikyuu/utilities/datetime/Datetime.h +2 -2
- hikyuu/include/hikyuu/utilities/os.h +7 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +2 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalMQStealThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalMQThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -1
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -1
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/include/hikyuu/views/arrow_common.h +38 -0
- hikyuu/include/hikyuu/views/arrow_views.h +117 -0
- hikyuu/indicator/__init__.py +0 -1
- hikyuu/indicator/indicator.py +17 -57
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/clickhousedriver.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/plugin/extind.dll +0 -0
- hikyuu/plugin/hkuextra.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/strategy/strategy_demo1.py +1 -1
- hikyuu/test/test_init.py +73 -14
- hikyuu/test/test_real_tdx_import.py +336 -0
- hikyuu/test/test_tdx_import.py +315 -0
- hikyuu/test/test_tdx_real_data_import.py +281 -0
- hikyuu/trade_manage/__init__.pyi +583 -553
- hikyuu/trade_manage/broker.pyi +19 -18
- hikyuu/trade_manage/broker_easytrader.pyi +6 -4
- hikyuu/trade_manage/broker_mail.pyi +22 -24
- hikyuu/trade_manage/trade.py +10 -65
- hikyuu/trade_manage/trade.pyi +583 -565
- hikyuu/trade_sys/__init__.py +15 -0
- hikyuu/util/__init__.pyi +0 -1
- hikyuu/util/check.pyi +17 -15
- hikyuu/util/mylog.pyi +8 -7
- hikyuu/util/notebook.pyi +9 -11
- hikyuu/util/singleton.pyi +8 -6
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/METADATA +8 -4
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/RECORD +172 -160
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/top_level.txt +2 -1
- hikyuu/cpp/i18n/zh_CN.mo +0 -0
- hikyuu/include/hikyuu/utilities/mo/mo.h +0 -64
- hikyuu/indicator/talib_wrap.py +0 -1273
- /hikyuu/include/hikyuu/utilities/{mo/moFileReader.h → moFileReader.h} +0 -0
- /hikyuu/include/hikyuu/{utilities/mo → views}/__init__.py +0 -0
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/LICENSE +0 -0
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.6.dist-info → hikyuu-2.6.8.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-08-06
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <arrow/api.h>
|
|
11
|
+
#include "hikyuu/Stock.h"
|
|
12
|
+
#include "hikyuu/indicator/Indicator.h"
|
|
13
|
+
|
|
14
|
+
namespace hku {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @brief 注册扩展 K 线类型, 按时间合成
|
|
18
|
+
* @param ktype 扩展 K 线类型
|
|
19
|
+
* @param basetype 对应的基础 K 线类型
|
|
20
|
+
* @param minutes 每根K线所包含的分钟数
|
|
21
|
+
* @param getPhaseEnd 获取K线所属的阶段结束时间
|
|
22
|
+
*/
|
|
23
|
+
void HKU_API registerExtraKType(const string& ktype, const string& basetype, int32_t minutes,
|
|
24
|
+
std::function<Datetime(const Datetime&)> getPhaseEnd);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 注册K线扩展类型,按 bar 数量合成
|
|
28
|
+
* @param ktype 扩展 K 线类型
|
|
29
|
+
* @param basetype 对应的基础 K 线类型
|
|
30
|
+
* @param nbars 每根K线所包含的基础K线数
|
|
31
|
+
*/
|
|
32
|
+
void HKU_API registerExtraKType(const string& ktype, const string& basetype, int32_t nbars);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 释放扩展K线
|
|
36
|
+
* @note 某些情况下,注册扩展K线时,使用了 python 定义的周期结束日期转换函数,退出时可能引起 python
|
|
37
|
+
* GIL 报错,需手工提前释放扩展K线
|
|
38
|
+
*/
|
|
39
|
+
void HKU_API releaseExtraKType();
|
|
40
|
+
|
|
41
|
+
//-------------------------------
|
|
42
|
+
// 以下函数为内部使用,无需引出
|
|
43
|
+
//-------------------------------
|
|
44
|
+
|
|
45
|
+
bool isExtraKType(const string& ktype);
|
|
46
|
+
|
|
47
|
+
int32_t getKTypeExtraMinutes(const string& ktype);
|
|
48
|
+
|
|
49
|
+
std::vector<string> getExtraKTypeList();
|
|
50
|
+
|
|
51
|
+
KRecordList getExtraKRecordList(const Stock& stk, const KQuery& query);
|
|
52
|
+
|
|
53
|
+
size_t getStockExtraCount(const Stock& stk, const string& ktype);
|
|
54
|
+
|
|
55
|
+
bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
|
|
56
|
+
size_t& out_end);
|
|
57
|
+
|
|
58
|
+
KDataImpPtr getKDataImp(const Stock& stk, const KQuery& query);
|
|
59
|
+
|
|
60
|
+
//-------------------------------
|
|
61
|
+
// Views 扩展
|
|
62
|
+
//-------------------------------
|
|
63
|
+
|
|
64
|
+
std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
|
|
65
|
+
const IndicatorList& inds,
|
|
66
|
+
const KQuery& query, const string& market);
|
|
67
|
+
|
|
68
|
+
std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
|
|
69
|
+
const IndicatorList& inds,
|
|
70
|
+
const Datetime& date, size_t cal_len,
|
|
71
|
+
const KQuery::KType& ktype,
|
|
72
|
+
const string& market);
|
|
73
|
+
|
|
74
|
+
std::shared_ptr<arrow::Table> getMarketViewParallel(const StockList& stks, const Datetime& date,
|
|
75
|
+
const string& market);
|
|
76
|
+
|
|
77
|
+
} // namespace hku
|
|
@@ -0,0 +1,54 @@
|
|
|
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 <arrow/api.h>
|
|
11
|
+
#include "hikyuu/utilities/plugin/PluginBase.h"
|
|
12
|
+
|
|
13
|
+
namespace hku {
|
|
14
|
+
|
|
15
|
+
class HkuExtraPluginInterface : public PluginBase {
|
|
16
|
+
public:
|
|
17
|
+
HkuExtraPluginInterface() = default;
|
|
18
|
+
virtual ~HkuExtraPluginInterface() = default;
|
|
19
|
+
|
|
20
|
+
virtual void registerKTypeExtra(const string& ktype, const string& basetype, int32_t minutes,
|
|
21
|
+
std::function<Datetime(const Datetime&)> getPhaseEnd) = 0;
|
|
22
|
+
|
|
23
|
+
virtual void releaseKExtra() = 0;
|
|
24
|
+
|
|
25
|
+
virtual bool isExtraKType(const string& ktype) = 0;
|
|
26
|
+
|
|
27
|
+
virtual std::vector<string> getExtraKTypeList() = 0;
|
|
28
|
+
|
|
29
|
+
virtual int32_t getKTypeExtraMinutes(const string& ktype) = 0;
|
|
30
|
+
|
|
31
|
+
virtual KRecordList getExtraKRecordList(const Stock& stk, const KQuery& query) = 0;
|
|
32
|
+
|
|
33
|
+
virtual size_t getStockExtraCount(const Stock& stk, const string& ktype) = 0;
|
|
34
|
+
|
|
35
|
+
virtual bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_start,
|
|
36
|
+
size_t& out_end) = 0;
|
|
37
|
+
|
|
38
|
+
virtual KDataImpPtr getKDataImp(const Stock& stk, const KQuery& query) = 0;
|
|
39
|
+
|
|
40
|
+
virtual std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
|
|
41
|
+
const IndicatorList& inds,
|
|
42
|
+
const KQuery& query,
|
|
43
|
+
const string& market) = 0;
|
|
44
|
+
|
|
45
|
+
virtual std::shared_ptr<arrow::Table> getIndicatorsViewParallel(
|
|
46
|
+
const StockList& stks, const IndicatorList& inds, const Datetime& date, size_t cal_len,
|
|
47
|
+
const KQuery::KType& ktype, const string& market) = 0;
|
|
48
|
+
|
|
49
|
+
virtual std::shared_ptr<arrow::Table> getMarketViewParallel(const StockList& stks,
|
|
50
|
+
const Datetime& date,
|
|
51
|
+
const string& market) = 0;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace hku
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
#include "hikyuu/KRecord.h"
|
|
11
11
|
#include "hikyuu/KQuery.h"
|
|
12
|
+
#include "hikyuu/TimeLineRecord.h"
|
|
13
|
+
#include "hikyuu/TransRecord.h"
|
|
12
14
|
#include "hikyuu/utilities/plugin/PluginBase.h"
|
|
13
15
|
|
|
14
16
|
namespace hku {
|
|
@@ -18,7 +20,8 @@ public:
|
|
|
18
20
|
ImportKDataToHdf5PluginInterface() = default;
|
|
19
21
|
virtual ~ImportKDataToHdf5PluginInterface() = default;
|
|
20
22
|
|
|
21
|
-
virtual bool setConfig(const string& datapath, const vector<string>& markets
|
|
23
|
+
virtual bool setConfig(const string& datapath, const vector<string>& markets,
|
|
24
|
+
const vector<string>& ktypes) = 0;
|
|
22
25
|
|
|
23
26
|
virtual Datetime getLastDatetime(const string& market, const string& code,
|
|
24
27
|
const KQuery::KType& ktype) = 0;
|
|
@@ -26,6 +29,12 @@ public:
|
|
|
26
29
|
virtual void addKRecordList(const string& market, const string& code,
|
|
27
30
|
const vector<KRecord>& krecords, const KQuery::KType& ktype) = 0;
|
|
28
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
|
+
|
|
29
38
|
virtual void updateIndex(const string& market, const string& code,
|
|
30
39
|
const KQuery::KType& ktype) = 0;
|
|
31
40
|
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#include "ExtendIndicatorsPluginInterface.h"
|
|
15
15
|
#include "TMReportPluginInterface.h"
|
|
16
16
|
#include "DataDriverPluginInterface.h"
|
|
17
|
+
#include "HkuExtraPluginInterface.h"
|
|
17
18
|
|
|
18
19
|
namespace hku {
|
|
19
20
|
|
|
@@ -24,5 +25,6 @@ namespace hku {
|
|
|
24
25
|
#define HKU_PLUGIN_EXTEND_INDICATOR "extind"
|
|
25
26
|
#define HKU_PLUGIN_TMREPORT "tmreport"
|
|
26
27
|
#define HKU_PLUGIN_CLICKHOUSE_DRIVER "clickhousedriver"
|
|
28
|
+
#define HKU_PLUGIN_HKU_EXTRA "hkuextra"
|
|
27
29
|
|
|
28
30
|
}
|
|
@@ -54,10 +54,11 @@ std::vector<T> python_bytes_to_vector(const py::bytes& obj) {
|
|
|
54
54
|
|
|
55
55
|
template <typename T>
|
|
56
56
|
std::vector<T> python_list_to_vector(const py::sequence& obj) {
|
|
57
|
+
// 如果 len(obj) 长度为零,即使类型不是所期望的也可能成功,但无风险
|
|
57
58
|
auto total = len(obj);
|
|
58
59
|
std::vector<T> vect(total);
|
|
59
60
|
for (auto i = 0; i < total; ++i) {
|
|
60
|
-
vect[i] =
|
|
61
|
+
vect[i] = py::cast<T>(obj[i]);
|
|
61
62
|
}
|
|
62
63
|
return vect;
|
|
63
64
|
}
|
|
@@ -86,16 +87,23 @@ std::string to_py_str(const T& item) {
|
|
|
86
87
|
// 直接使用 pybind11 重载 _clone,在 C++ 中会丢失 python 中的类型
|
|
87
88
|
// 参考:https://github.com/pybind/pybind11/issues/1049 进行修改
|
|
88
89
|
// PYBIND11_OVERLOAD(IndicatorImpPtr, IndicatorImp, _clone, );
|
|
89
|
-
#define PY_CLONE(pyclassname, classname)
|
|
90
|
-
public:
|
|
91
|
-
std::shared_ptr<classname> _clone() override {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
#define PY_CLONE(pyclassname, classname) \
|
|
91
|
+
public: \
|
|
92
|
+
std::shared_ptr<classname> _clone() override { \
|
|
93
|
+
if (isPythonObject()) { \
|
|
94
|
+
py::gil_scoped_acquire acquire; \
|
|
95
|
+
auto self = py::cast(this); \
|
|
96
|
+
auto cloned = self.attr("_clone")(); \
|
|
97
|
+
auto keep_python_state_alive = std::make_shared<py::object>(cloned); \
|
|
98
|
+
auto ptr = cloned.cast<pyclassname*>(); \
|
|
99
|
+
return std::shared_ptr<classname>(keep_python_state_alive, ptr); \
|
|
100
|
+
} \
|
|
101
|
+
return this->_clone(); \
|
|
102
|
+
} \
|
|
103
|
+
\
|
|
104
|
+
protected: \
|
|
105
|
+
inline bool isPythonObject() const override { \
|
|
106
|
+
return true; \
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
// 用于检查已 py::object 方式传递的函数参数个数是否符合预期
|
|
@@ -106,6 +114,15 @@ inline bool check_pyfunction_arg_num(py::object& func, size_t arg_num) {
|
|
|
106
114
|
return len(params) == arg_num;
|
|
107
115
|
}
|
|
108
116
|
|
|
117
|
+
/*
|
|
118
|
+
* 将utf8编码的字符串转换为utf32编码
|
|
119
|
+
* @param utf8_str 待转换的字符串
|
|
120
|
+
* @param out 存储转换结果的数组(需自行预先分配内存)
|
|
121
|
+
* @param out_len out数组的长度
|
|
122
|
+
* @return 实际转码点数
|
|
123
|
+
*/
|
|
124
|
+
size_t utf8_to_utf32(const std::string& utf8_str, int32_t* out, size_t out_len) noexcept;
|
|
125
|
+
|
|
109
126
|
} // namespace hku
|
|
110
127
|
|
|
111
128
|
#endif // HIKYUU_PYTHON_BIND_UTILS_H
|
|
@@ -225,6 +225,7 @@ public:
|
|
|
225
225
|
* @param goalPrice 目标价格
|
|
226
226
|
* @param planPrice 计划买入价格
|
|
227
227
|
* @param from 记录是哪个系统部件发出的买入指示
|
|
228
|
+
* @param remark 买入备注
|
|
228
229
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
229
230
|
*/
|
|
230
231
|
virtual TradeRecord buy(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -242,6 +243,7 @@ public:
|
|
|
242
243
|
* @param goalPrice 新的目标价格
|
|
243
244
|
* @param planPrice 原计划卖出价格
|
|
244
245
|
* @param from 记录是哪个系统部件发出的卖出指示
|
|
246
|
+
* @param remark 卖出备注
|
|
245
247
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
246
248
|
*/
|
|
247
249
|
virtual TradeRecord sell(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -259,6 +261,7 @@ public:
|
|
|
259
261
|
* @param goalPrice 目标价格
|
|
260
262
|
* @param planPrice 计划卖空价格
|
|
261
263
|
* @param from 记录是哪个系统部件发出的买入指示
|
|
264
|
+
* @param remark 备注
|
|
262
265
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
263
266
|
*/
|
|
264
267
|
virtual TradeRecord sellShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -276,6 +279,7 @@ public:
|
|
|
276
279
|
* @param goalPrice 目标价格
|
|
277
280
|
* @param planPrice 计划买入价格
|
|
278
281
|
* @param from 记录是哪个系统部件发出的卖出指示
|
|
282
|
+
* @param remark 备注
|
|
279
283
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
280
284
|
*/
|
|
281
285
|
virtual TradeRecord buyShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -521,6 +521,7 @@ public:
|
|
|
521
521
|
* @param goalPrice 目标价格
|
|
522
522
|
* @param planPrice 计划买入价格
|
|
523
523
|
* @param from 记录是哪个系统部件发出的买入指示
|
|
524
|
+
* @param remark 备注
|
|
524
525
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
525
526
|
*/
|
|
526
527
|
virtual TradeRecord buy(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -541,6 +542,7 @@ public:
|
|
|
541
542
|
* @param goalPrice 新的目标价格
|
|
542
543
|
* @param planPrice 原计划卖出价格
|
|
543
544
|
* @param from 记录是哪个系统部件发出的卖出指示
|
|
545
|
+
* @param remark 卖出备注
|
|
544
546
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
545
547
|
*/
|
|
546
548
|
virtual TradeRecord sell(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -561,6 +563,7 @@ public:
|
|
|
561
563
|
* @param goalPrice 目标价格
|
|
562
564
|
* @param planPrice 计划卖空价格
|
|
563
565
|
* @param from 记录是哪个系统部件发出的买入指示
|
|
566
|
+
* @param remark 备注
|
|
564
567
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
565
568
|
*/
|
|
566
569
|
virtual TradeRecord sellShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -581,6 +584,7 @@ public:
|
|
|
581
584
|
* @param goalPrice 目标价格
|
|
582
585
|
* @param planPrice 计划买入价格
|
|
583
586
|
* @param from 记录是哪个系统部件发出的卖出指示
|
|
587
|
+
* @param remark 备注
|
|
584
588
|
* @return 返回对应的交易记录,如果操作失败,business等于BUSINESS_INVALID
|
|
585
589
|
*/
|
|
586
590
|
virtual TradeRecord buyShort(const Datetime& datetime, const Stock& stock, price_t realPrice,
|
|
@@ -716,13 +720,13 @@ public:
|
|
|
716
720
|
* 统计截至某一时刻的系统绩效, datetime必须大于等于lastDatetime,
|
|
717
721
|
* 以便用于计算当前市值
|
|
718
722
|
* @param datetime 统计截止时刻
|
|
723
|
+
* @param ktype k线类型
|
|
719
724
|
*/
|
|
720
725
|
Performance getPerformance(const Datetime& datetime = Datetime::now(),
|
|
721
726
|
const KQuery::KType& ktype = KQuery::DAY);
|
|
722
727
|
|
|
723
728
|
/**
|
|
724
729
|
* @brief 获取指定时刻时账户的最大回撤百分比(负数)(仅根据收盘价计算)
|
|
725
|
-
* @param tm 指定账户
|
|
726
730
|
* @param date 指定日期(包含该时刻)
|
|
727
731
|
* @param ktype k线类型
|
|
728
732
|
* @return price_t
|
|
@@ -765,6 +769,11 @@ public:
|
|
|
765
769
|
std::vector<std::pair<Datetime, double>> getProfitPercentYearly(
|
|
766
770
|
const Datetime& datetime = Datetime::now());
|
|
767
771
|
|
|
772
|
+
protected:
|
|
773
|
+
virtual bool isPythonObject() const {
|
|
774
|
+
return false;
|
|
775
|
+
}
|
|
776
|
+
|
|
768
777
|
protected:
|
|
769
778
|
string m_name; // 账户名称
|
|
770
779
|
TradeCostPtr m_costfunc; // 成本算法
|
|
@@ -101,6 +101,11 @@ public:
|
|
|
101
101
|
static void adjustWeight(SystemWeightList& sw_list, double can_allocate_weight,
|
|
102
102
|
bool auto_adjust, bool ignore_zero);
|
|
103
103
|
|
|
104
|
+
protected:
|
|
105
|
+
virtual bool isPythonObject() const {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
104
109
|
private:
|
|
105
110
|
void initParam();
|
|
106
111
|
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
#include "hikyuu/KData.h"
|
|
11
11
|
#include "ScoreRecord.h"
|
|
12
12
|
|
|
13
|
-
#define MF_USE_MULTI_THREAD 1
|
|
14
|
-
|
|
15
13
|
namespace hku {
|
|
16
14
|
|
|
17
15
|
/**
|
|
@@ -114,7 +112,7 @@ public:
|
|
|
114
112
|
const vector<ScoreRecordList>& getAllScores();
|
|
115
113
|
|
|
116
114
|
/**
|
|
117
|
-
* 获取合成因子的IC, 长度与参考日期同
|
|
115
|
+
* 获取合成因子的IC, 长度与参考日期同 (非严格IC模式)
|
|
118
116
|
* @note ndays 对于使用 IC/ICIR 加权的新因子,最好保持好 ic_n 一致,
|
|
119
117
|
* 但对于等权计算的新因子,不一定非要使用 ic_n 计算。
|
|
120
118
|
* 所以,ndays 增加了一个特殊值 0, 表示直接使用 ic_n 参数计算 IC
|
|
@@ -145,6 +143,11 @@ public:
|
|
|
145
143
|
virtual MultiFactorPtr _clone() = 0;
|
|
146
144
|
virtual IndicatorList _calculate(const vector<IndicatorList>&) = 0;
|
|
147
145
|
|
|
146
|
+
protected:
|
|
147
|
+
virtual bool isPythonObject() const {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
148
151
|
private:
|
|
149
152
|
/** 执行计算 */
|
|
150
153
|
void calculate();
|
|
@@ -115,6 +115,10 @@ private:
|
|
|
115
115
|
const string& mode);
|
|
116
116
|
|
|
117
117
|
protected:
|
|
118
|
+
virtual bool isPythonObject() const {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
118
122
|
// 跟踪打印当前TM持仓情况
|
|
119
123
|
void traceMomentTMAfterRunAtOpen(const Datetime& date);
|
|
120
124
|
void traceMomentTMAfterRunAtClose(const Datetime& date);
|
|
@@ -48,7 +48,6 @@ public:
|
|
|
48
48
|
* 添加备选股票及其交易策略原型
|
|
49
49
|
* @param stock 备选股票
|
|
50
50
|
* @param protoSys 交易系统策略原型
|
|
51
|
-
* @return 如果 protoSys 无效 或 stock 无效,则返回 false, 否则返回 true
|
|
52
51
|
*/
|
|
53
52
|
void addStock(const Stock& stock, const SystemPtr& protoSys);
|
|
54
53
|
|
|
@@ -57,7 +56,6 @@ public:
|
|
|
57
56
|
* @note 如果存在无效的stock,则自动忽略,不会返回false
|
|
58
57
|
* @param stkList 备选股票列表
|
|
59
58
|
* @param protoSys 交易系统策略原型
|
|
60
|
-
* @return 如果 protoSys 无效则返回false,否则返回 true
|
|
61
59
|
*/
|
|
62
60
|
void addStockList(const StockList& stkList, const SystemPtr& protoSys);
|
|
63
61
|
|
|
@@ -134,6 +132,11 @@ public:
|
|
|
134
132
|
|
|
135
133
|
virtual string str() const;
|
|
136
134
|
|
|
135
|
+
protected:
|
|
136
|
+
virtual bool isPythonObject() const {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
137
140
|
private:
|
|
138
141
|
void initParam();
|
|
139
142
|
|
|
@@ -86,6 +86,11 @@ public:
|
|
|
86
86
|
/** 子类计算接口,由setTO调用 */
|
|
87
87
|
virtual void _calculate() = 0;
|
|
88
88
|
|
|
89
|
+
protected:
|
|
90
|
+
virtual bool isPythonObject() const {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
protected:
|
|
90
95
|
string m_name;
|
|
91
96
|
TradeManagerPtr m_tm;
|
|
@@ -156,7 +161,7 @@ public: \
|
|
|
156
161
|
|
|
157
162
|
/**
|
|
158
163
|
* 客户程序都应使用该指针类型,操作止损策略实例
|
|
159
|
-
* @ingroup
|
|
164
|
+
* @ingroup Stoploss
|
|
160
165
|
*/
|
|
161
166
|
typedef shared_ptr<StoplossBase> StoplossPtr;
|
|
162
167
|
typedef shared_ptr<StoplossBase> STPtr;
|
|
@@ -265,6 +265,11 @@ public:
|
|
|
265
265
|
// 处理延迟买入请求,仅供 PF 调用
|
|
266
266
|
virtual TradeRecord pfProcessDelayBuyRequest(const Datetime& date);
|
|
267
267
|
|
|
268
|
+
protected:
|
|
269
|
+
virtual bool isPythonObject() const {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
268
273
|
private:
|
|
269
274
|
bool _environmentIsValid(const Datetime& datetime);
|
|
270
275
|
bool _conditionIsValid(const Datetime& datetime);
|
|
@@ -193,10 +193,10 @@ public:
|
|
|
193
193
|
uint64_t ticks() const noexcept;
|
|
194
194
|
|
|
195
195
|
/** 时间戳,距离1970-01-01 00:00:00的微秒数 */
|
|
196
|
-
|
|
196
|
+
uint64_t timestamp() const noexcept;
|
|
197
197
|
|
|
198
198
|
/** 时间戳,距离1970-01-01 00:00:00的微秒数, 并扣除本地 UTC 偏差时间 */
|
|
199
|
-
|
|
199
|
+
uint64_t timestampUTC() const noexcept;
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* 转化为字符串,供打印阅读,格式:
|
|
@@ -105,4 +105,11 @@ std::string HKU_UTILS_API getPlatform();
|
|
|
105
105
|
/** 获取当前CPU架构名称 */
|
|
106
106
|
std::string HKU_UTILS_API getCpuArch();
|
|
107
107
|
|
|
108
|
+
/** 获取当前系统语言名称(全部小写返回) */
|
|
109
|
+
std::string HKU_UTILS_API getSystemLanguage();
|
|
110
|
+
|
|
111
|
+
uint64_t HKU_UTILS_API getMemoryMaxSize();
|
|
112
|
+
|
|
113
|
+
uint64_t HKU_UTILS_API getMemoryIdleSize();
|
|
114
|
+
|
|
108
115
|
} // namespace hku
|
|
@@ -46,7 +46,8 @@ public:
|
|
|
46
46
|
|
|
47
47
|
bool load(const std::string& pluginname) noexcept {
|
|
48
48
|
std::string filename = getFileName(pluginname);
|
|
49
|
-
HKU_WARN_IF_RETURN(!existFile(filename), false, "file({}) not exist!", filename);
|
|
49
|
+
// HKU_WARN_IF_RETURN(!existFile(filename), false, "file({}) not exist!", filename);
|
|
50
|
+
HKU_DEBUG_IF_RETURN(!existFile(filename), false, "file({}) not exist!", filename);
|
|
50
51
|
|
|
51
52
|
#if HKU_OS_WINDOWS
|
|
52
53
|
m_handle = LoadLibrary(HKU_PATH(filename).c_str());
|