hikyuu 2.6.8.4__py3-none-win_amd64.whl → 2.6.9__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 +5 -12
- hikyuu/__init__.pyi +33 -8
- hikyuu/analysis/__init__.pyi +26 -0
- hikyuu/analysis/analysis.pyi +27 -1
- hikyuu/core.py +2 -0
- hikyuu/core.pyi +28 -2
- hikyuu/cpp/arrow.dll +0 -0
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_system-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +446 -13
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +446 -13
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +446 -13
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +446 -13
- hikyuu/cpp/core39.pyd +0 -0
- hikyuu/cpp/core39.pyi +446 -13
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/msvcp140-a118642f3ae8774fb9dc223e15c4a52e.dll +0 -0
- hikyuu/cpp/parquet.dll +0 -0
- hikyuu/cpp/sqlite3.dll +0 -0
- hikyuu/data/clickhouse_upgrade/createdb.sql +105 -105
- hikyuu/data/common.py +3 -3
- hikyuu/data/common_clickhouse.py +1 -1
- hikyuu/data/download_block.py +318 -0
- hikyuu/data/em_block_to_clickhouse.py +26 -74
- hikyuu/data/em_block_to_mysql.py +25 -75
- hikyuu/data/em_block_to_sqlite.py +26 -78
- hikyuu/data/hku_config_template.py +3 -3
- hikyuu/data/pytdx_to_clickhouse.py +15 -11
- hikyuu/data/pytdx_to_h5.py +6 -2
- hikyuu/data/pytdx_to_mysql.py +5 -1
- hikyuu/data/pytdx_weight_to_clickhouse.py +1 -1
- hikyuu/data/pytdx_weight_to_mysql.py +1 -1
- hikyuu/data/pytdx_weight_to_sqlite.py +1 -1
- hikyuu/data/zh_bond10_to_clickhouse.py +1 -1
- hikyuu/draw/drawplot/__init__.pyi +1 -1
- hikyuu/draw/drawplot/bokeh_draw.pyi +31 -6
- hikyuu/draw/drawplot/echarts_draw.pyi +31 -6
- hikyuu/draw/drawplot/matplotlib_draw.py +4 -74
- hikyuu/draw/drawplot/matplotlib_draw.pyi +31 -6
- hikyuu/examples/notebook/Demo/Demo1.ipynb +48 -33
- hikyuu/extend.pyi +29 -3
- hikyuu/fetcher/stock/zh_block_em.py +50 -18
- hikyuu/gui/HikyuuTDX.py +81 -30
- hikyuu/gui/data/CollectSpotThread.py +1 -1
- hikyuu/gui/data/EscapetimeThread.py +8 -14
- hikyuu/gui/data/ImportBlockInfoTask.py +3 -10
- hikyuu/gui/data/MainWindow.py +1168 -715
- hikyuu/gui/data/SchedImportThread.py +2 -2
- hikyuu/gui/data/UsePytdxImportToH5Thread.py +3 -3
- hikyuu/gui/data/UseQmtImportToH5Thread.py +2 -2
- hikyuu/gui/data/UseTdxImportToH5Thread.py +3 -3
- hikyuu/gui/data/tool.py +32 -25
- hikyuu/gui/dataserver.py +5 -3
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/DataType.h +4 -16
- hikyuu/include/hikyuu/KData.h +6 -3
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +1 -1
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +1 -1
- hikyuu/include/hikyuu/KQuery.h +2 -2
- hikyuu/include/hikyuu/Stock.h +3 -0
- hikyuu/include/hikyuu/StockManager.h +13 -3
- hikyuu/include/hikyuu/config.h +3 -0
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +8 -0
- hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +26 -1
- hikyuu/include/hikyuu/data_driver/base_info/mysql/MySQLBaseInfoDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/base_info/sqlite/SQLiteBaseInfoDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/block_info/mysql/MySQLBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/block_info/qianlong/QLBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/block_info/sqlite/SQLiteBlockInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/kdata/DoNothingKDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/cvs/KDataTempCsvDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/hdf5/H5KDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +1 -1
- hikyuu/include/hikyuu/data_driver/kdata/tdx/TdxKDataDriver.h +1 -1
- hikyuu/include/hikyuu/hikyuu.h +1 -1
- hikyuu/include/hikyuu/indicator/build_in.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/CYCLE.h +4 -4
- hikyuu/include/hikyuu/indicator/crt/HSL.h +2 -2
- hikyuu/include/hikyuu/indicator/crt/QUANTILE_TRUNC.h +30 -0
- hikyuu/include/hikyuu/indicator/crt/TURNOVER.h +1 -0
- hikyuu/include/hikyuu/indicator/crt/ZSCORE.h +2 -2
- hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +25 -0
- hikyuu/include/hikyuu/misc.h +38 -0
- hikyuu/include/hikyuu/plugin/dataserver.h +2 -1
- hikyuu/include/hikyuu/plugin/extind.h +37 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +0 -18
- hikyuu/include/hikyuu/plugin/hkuviews.h +36 -0
- hikyuu/include/hikyuu/plugin/interface/DataServerPluginInterface.h +2 -2
- hikyuu/include/hikyuu/plugin/interface/ExtendIndicatorsPluginInterface.h +12 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +0 -14
- hikyuu/include/hikyuu/plugin/interface/HkuViewsPluginInterface.h +34 -0
- hikyuu/include/hikyuu/plugin/interface/plugins.h +8 -1
- hikyuu/include/hikyuu/python/pybind_utils.h +6 -1
- hikyuu/include/hikyuu/strategy/RunSystemInStrategy.h +3 -0
- hikyuu/include/hikyuu/trade_manage/Performance.h +4 -4
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +10 -1
- hikyuu/include/hikyuu/trade_sys/moneymanager/imp/FixedCapitalFundsMM.h +0 -4
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +36 -3
- hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +125 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +125 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/build_in.h +3 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/buildin_norm.h +36 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/buildin_scfilter.h +51 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/GroupSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreLessOrEqualValueSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/IgnoreNanSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/MinAmountPercentSCFilter.h +25 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/PriceSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/TopNSCFilter.h +24 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/filter/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/EqualWeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICIRMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/ICMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/imp/WeightMultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormMinMax.h +23 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantile.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormQuantileUniform.h +28 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/NormZScore.h +25 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/__init__.py +1 -0
- hikyuu/include/hikyuu/trade_sys/multifactor/normalize/quantile_trunc.h +16 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/SimplePortfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/portfolio/imp/WithoutAFPortfolio.h +7 -0
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +49 -0
- hikyuu/include/hikyuu/trade_sys/selector/build_in.h +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +40 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +0 -3
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +49 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/logic/OperatorValueSelector.h +1 -1
- hikyuu/include/hikyuu/trade_sys/signal/imp/BandSignal2.h +0 -4
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/AddValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/DivValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/MulValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.h +1 -1
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/OperatorValueSignal.h +4 -4
- hikyuu/include/hikyuu/trade_sys/signal/imp/logic/SubValueSignal.h +2 -2
- hikyuu/include/hikyuu/trade_sys/system/System.h +14 -1
- hikyuu/include/hikyuu/utilities/SpendTimer.h +17 -7
- hikyuu/include/hikyuu/utilities/arithmetic.h +55 -0
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLConnect.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/mysql/MySQLStatement.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteConnect.h +1 -1
- hikyuu/include/hikyuu/utilities/db_connect/sqlite/SQLiteStatement.h +1 -1
- hikyuu/include/hikyuu/utilities/plugin/PluginLoader.h +4 -1
- hikyuu/include/hikyuu/version.h +4 -4
- 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/hkuviews.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/trade_manage/__init__.pyi +30 -5
- hikyuu/trade_manage/trade.pyi +30 -5
- hikyuu/util/__init__.pyi +1 -1
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/METADATA +13 -14
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/RECORD +174 -153
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/top_level.txt +2 -1
- hikyuu/data_driver/__init__.py +0 -49
- hikyuu/data_driver/jqdata_data_driver.py +0 -277
- hikyuu/data_driver/pytdx_data_driver.py +0 -292
- hikyuu/fetcher/stock/zh_stock_a_huatai.py +0 -51
- hikyuu/fetcher/stock/zh_stock_a_pytdx.py +0 -129
- hikyuu/gui/data/CollectToMemThread.py +0 -123
- hikyuu/gui/data/CollectToMySQLThread.py +0 -178
- hikyuu/gui/start_huatai_insight.py +0 -510
- hikyuu/tools/update_block_info.py +0 -168
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/WHEEL +0 -0
- {hikyuu-2.6.8.4.dist-info → hikyuu-2.6.9.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-10-03
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../Indicator.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 使用分位数法则进行数据截断处理
|
|
16
|
+
* @param int n 窗口大小
|
|
17
|
+
* @param quantile_min 最小分位数
|
|
18
|
+
* @param quantile_max 最大分位数
|
|
19
|
+
* @return Indicator
|
|
20
|
+
* @ingroup Indicator
|
|
21
|
+
*/
|
|
22
|
+
Indicator HKU_API QUANTILE_TRUNC(int n = 60, double quantile_min = 0.01,
|
|
23
|
+
double quantile_max = 0.99);
|
|
24
|
+
|
|
25
|
+
inline Indicator HKU_API QUANTILE_TRUNC(const Indicator& data, int n = 60,
|
|
26
|
+
double quantile_min = 0.01, double quantile_max = 0.99) {
|
|
27
|
+
return QUANTILE_TRUNC(n, quantile_min, quantile_max)(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
} // namespace hku
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
namespace hku {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* 对数据进行ZScore
|
|
15
|
+
* 对数据进行ZScore标准化(3sigma)进行极值处理
|
|
16
16
|
* @note 非窗口滚动,如需窗口滚动的标准化,直接 (x - MA(x, n)) / STDEV(x, n) 即可
|
|
17
|
-
* @param outExtreme
|
|
17
|
+
* @param outExtreme 指示剔除极值(即截断极值,超过限制的用限制值替代)
|
|
18
18
|
* @param nsigma 剔除极值时使用的 nsigma 倍 sigma
|
|
19
19
|
* @param recursive 是否进行递归剔除极值
|
|
20
20
|
* @return Indicator
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-10-03
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "../Indicator.h"
|
|
11
|
+
|
|
12
|
+
namespace hku {
|
|
13
|
+
|
|
14
|
+
/* 分位数截断处理 */
|
|
15
|
+
class IQuantileTrunc : public IndicatorImp {
|
|
16
|
+
INDICATOR_IMP(IQuantileTrunc)
|
|
17
|
+
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
18
|
+
|
|
19
|
+
public:
|
|
20
|
+
IQuantileTrunc();
|
|
21
|
+
virtual ~IQuantileTrunc();
|
|
22
|
+
virtual void _checkParam(const string& name) const override;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace hku
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 hikyuu.org
|
|
3
|
+
*
|
|
4
|
+
* Created on: 2025-10-17
|
|
5
|
+
* Author: fasiondog
|
|
6
|
+
*
|
|
7
|
+
* 部分杂类函数
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include "trade_sys/system/System.h"
|
|
13
|
+
#include "trade_sys/portfolio/Portfolio.h"
|
|
14
|
+
|
|
15
|
+
namespace hku {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @brief 并行运行系统
|
|
19
|
+
* @param system_list 系统列表
|
|
20
|
+
* @param query 系统运行查询条件
|
|
21
|
+
* @param reset 执行前是否依据系统部件共享属性复位
|
|
22
|
+
* @param resetAll 强制复位所有部件
|
|
23
|
+
* @return 各系统Query周期内各时间点的资金列表
|
|
24
|
+
*/
|
|
25
|
+
vector<FundsList> HKU_API parallel_run_sys(const SystemList& system_list, const KQuery& query,
|
|
26
|
+
bool reset = true, bool resetAll = false);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @brief 并行运行组合
|
|
30
|
+
* @param pf_list 组合列表
|
|
31
|
+
* @param query 组合运行查询条件
|
|
32
|
+
* @param force 强制复位
|
|
33
|
+
* @return vector<FundsList>
|
|
34
|
+
*/
|
|
35
|
+
vector<FundsList> HKU_API parallel_run_pf(const vector<PFPtr>& pf_list, const KQuery& query,
|
|
36
|
+
bool force = false);
|
|
37
|
+
|
|
38
|
+
} // namespace hku
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
namespace hku {
|
|
15
15
|
|
|
16
16
|
void HKU_API startDataServer(const std::string& addr = "tcp://0.0.0.0:9201", size_t work_num = 2,
|
|
17
|
-
bool save_tick = false, bool buf_tick = false
|
|
17
|
+
bool save_tick = false, bool buf_tick = false,
|
|
18
|
+
const std::string& parquet_path = std::string());
|
|
18
19
|
|
|
19
20
|
void HKU_API stopDataServer();
|
|
20
21
|
|
|
@@ -191,5 +191,42 @@ Indicator HKU_API AGG_VAR(const Indicator& ind, const KQuery::KType& ktype = KQu
|
|
|
191
191
|
Indicator HKU_API AGG_QUANTILE(const Indicator& ind, const KQuery::KType& ktype = KQuery::MIN,
|
|
192
192
|
bool fill_null = false, int unit = 1, double quantile = 0.75);
|
|
193
193
|
|
|
194
|
+
using agg_func_t = std::function<double(const DatetimeList& src_ds, const Indicator::value_t* src,
|
|
195
|
+
size_t group_start, size_t group_last)>;
|
|
196
|
+
Indicator HKU_API AGG_FUNC(const Indicator& ind, agg_func_t agg_func,
|
|
197
|
+
const KQuery::KType& ktype = KQuery::MIN, bool fill_null = false,
|
|
198
|
+
int unit = 1);
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @brief 按周期分组就散
|
|
202
|
+
* @param ktype 指定K线周期
|
|
203
|
+
* @param unit 分组周期单位,默认为1。按 ktype 参数 unit 个周期计算
|
|
204
|
+
* @return Indicator
|
|
205
|
+
*/
|
|
206
|
+
#define GROUP_FUNC_DEFINE(group_name) \
|
|
207
|
+
Indicator HKU_API group_name(const Indicator& ind, const KQuery::KType& ktype = KQuery::DAY, \
|
|
208
|
+
int unit = 1);
|
|
209
|
+
|
|
210
|
+
#define GROUP_FUNC_IMP(group_name) \
|
|
211
|
+
Indicator HKU_API group_name(const Indicator& ind, const KQuery::KType& ktype, int unit) { \
|
|
212
|
+
Parameter params; \
|
|
213
|
+
params.set<string>("ktype", ktype); \
|
|
214
|
+
params.set<int>("unit", unit); \
|
|
215
|
+
return getExtIndicator(#group_name, ind, params); \
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
GROUP_FUNC_DEFINE(GROUP_COUNT)
|
|
219
|
+
GROUP_FUNC_DEFINE(GROUP_SUM)
|
|
220
|
+
GROUP_FUNC_DEFINE(GROUP_MEAN)
|
|
221
|
+
GROUP_FUNC_DEFINE(GROUP_PROD)
|
|
222
|
+
GROUP_FUNC_DEFINE(GROUP_MIN)
|
|
223
|
+
GROUP_FUNC_DEFINE(GROUP_MAX)
|
|
224
|
+
|
|
225
|
+
using group_func_t =
|
|
226
|
+
std::function<void(Indicator::value_t* dst, const DatetimeList& src_ds,
|
|
227
|
+
const Indicator::value_t* src, size_t group_start, size_t group_last)>;
|
|
228
|
+
Indicator HKU_API GROUP_FUNC(const Indicator& ind, group_func_t group_func,
|
|
229
|
+
const KQuery::KType& ktype = KQuery::DAY, int unit = 1);
|
|
230
|
+
|
|
194
231
|
/** @} */
|
|
195
232
|
} // namespace hku
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <arrow/api.h>
|
|
11
10
|
#include "hikyuu/Stock.h"
|
|
12
11
|
#include "hikyuu/indicator/Indicator.h"
|
|
13
12
|
|
|
@@ -57,21 +56,4 @@ bool getStockExtraIndexRange(const Stock& stk, const KQuery& query, size_t& out_
|
|
|
57
56
|
|
|
58
57
|
KDataImpPtr getKDataImp(const Stock& stk, const KQuery& query);
|
|
59
58
|
|
|
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
59
|
} // namespace hku
|
|
@@ -0,0 +1,36 @@
|
|
|
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 <hikyuu/config.h>
|
|
11
|
+
|
|
12
|
+
#if HKU_ENABLE_ARROW
|
|
13
|
+
#include <arrow/api.h>
|
|
14
|
+
|
|
15
|
+
namespace hku {
|
|
16
|
+
|
|
17
|
+
//-------------------------------
|
|
18
|
+
// Views 扩展
|
|
19
|
+
//-------------------------------
|
|
20
|
+
|
|
21
|
+
std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
|
|
22
|
+
const IndicatorList& inds,
|
|
23
|
+
const KQuery& query, const string& market);
|
|
24
|
+
|
|
25
|
+
std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
|
|
26
|
+
const IndicatorList& inds,
|
|
27
|
+
const Datetime& date, size_t cal_len,
|
|
28
|
+
const KQuery::KType& ktype,
|
|
29
|
+
const string& market);
|
|
30
|
+
|
|
31
|
+
std::shared_ptr<arrow::Table> getMarketViewParallel(const StockList& stks, const Datetime& date,
|
|
32
|
+
const string& market);
|
|
33
|
+
|
|
34
|
+
} // namespace hku
|
|
35
|
+
|
|
36
|
+
#endif // HKU_ENABLE_ARROW
|
|
@@ -16,8 +16,8 @@ public:
|
|
|
16
16
|
DataServerPluginInterface() = default;
|
|
17
17
|
virtual ~DataServerPluginInterface() = default;
|
|
18
18
|
|
|
19
|
-
virtual void start(const std::string& addr, size_t work_num, bool save_tick,
|
|
20
|
-
|
|
19
|
+
virtual void start(const std::string& addr, size_t work_num, bool save_tick, bool buf_tick,
|
|
20
|
+
const std::string& parquet_path) noexcept = 0;
|
|
21
21
|
virtual void stop() noexcept = 0;
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -21,6 +21,18 @@ public:
|
|
|
21
21
|
|
|
22
22
|
virtual Indicator getIndicator(const std::string& name, const Indicator& ref_ind,
|
|
23
23
|
const Parameter& params) const = 0;
|
|
24
|
+
|
|
25
|
+
using agg_func_t =
|
|
26
|
+
std::function<Indicator::value_t(const DatetimeList& src_ds, const Indicator::value_t* src,
|
|
27
|
+
size_t group_start, size_t group_last)>;
|
|
28
|
+
virtual Indicator getAggFuncIndicator(const Indicator& ref_ind, agg_func_t agg_func,
|
|
29
|
+
const Parameter& params) const = 0;
|
|
30
|
+
|
|
31
|
+
using group_func_t =
|
|
32
|
+
std::function<void(Indicator::value_t* dst, const DatetimeList& src_ds,
|
|
33
|
+
const Indicator::value_t* src, size_t group_start, size_t group_last)>;
|
|
34
|
+
virtual Indicator getGroupFuncIndicator(const Indicator& ref_ind, group_func_t group_func,
|
|
35
|
+
const Parameter& params) const = 0;
|
|
24
36
|
};
|
|
25
37
|
|
|
26
38
|
} // namespace hku
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <arrow/api.h>
|
|
11
10
|
#include "hikyuu/utilities/plugin/PluginBase.h"
|
|
12
11
|
|
|
13
12
|
namespace hku {
|
|
@@ -36,19 +35,6 @@ public:
|
|
|
36
35
|
size_t& out_end) = 0;
|
|
37
36
|
|
|
38
37
|
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
38
|
};
|
|
53
39
|
|
|
54
40
|
} // namespace hku
|
|
@@ -0,0 +1,34 @@
|
|
|
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 HkuViewsPluginInterface : public PluginBase {
|
|
16
|
+
public:
|
|
17
|
+
HkuViewsPluginInterface() = default;
|
|
18
|
+
virtual ~HkuViewsPluginInterface() = default;
|
|
19
|
+
|
|
20
|
+
virtual std::shared_ptr<arrow::Table> getIndicatorsViewParallel(const StockList& stks,
|
|
21
|
+
const IndicatorList& inds,
|
|
22
|
+
const KQuery& query,
|
|
23
|
+
const string& market) = 0;
|
|
24
|
+
|
|
25
|
+
virtual std::shared_ptr<arrow::Table> getIndicatorsViewParallel(
|
|
26
|
+
const StockList& stks, const IndicatorList& inds, const Datetime& date, size_t cal_len,
|
|
27
|
+
const KQuery::KType& ktype, const string& market) = 0;
|
|
28
|
+
|
|
29
|
+
virtual std::shared_ptr<arrow::Table> getMarketViewParallel(const StockList& stks,
|
|
30
|
+
const Datetime& date,
|
|
31
|
+
const string& market) = 0;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
} // namespace hku
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
+
#include "hikyuu/config.h"
|
|
11
|
+
|
|
10
12
|
#include "BackTestPluginInterface.h"
|
|
11
13
|
#include "DevicePluginInterface.h"
|
|
12
14
|
#include "DataServerPluginInterface.h"
|
|
@@ -16,6 +18,10 @@
|
|
|
16
18
|
#include "DataDriverPluginInterface.h"
|
|
17
19
|
#include "HkuExtraPluginInterface.h"
|
|
18
20
|
|
|
21
|
+
#if HKU_ENABLE_ARROW
|
|
22
|
+
#include "HkuViewsPluginInterface.h"
|
|
23
|
+
#endif
|
|
24
|
+
|
|
19
25
|
namespace hku {
|
|
20
26
|
|
|
21
27
|
#define HKU_PLUGIN_BACKTEST "backtest"
|
|
@@ -26,5 +32,6 @@ namespace hku {
|
|
|
26
32
|
#define HKU_PLUGIN_TMREPORT "tmreport"
|
|
27
33
|
#define HKU_PLUGIN_CLICKHOUSE_DRIVER "clickhousedriver"
|
|
28
34
|
#define HKU_PLUGIN_HKU_EXTRA "hkuextra"
|
|
35
|
+
#define HKU_PLUGIN_HKU_VIEWS "hkuviews"
|
|
29
36
|
|
|
30
|
-
}
|
|
37
|
+
} // namespace hku
|
|
@@ -9,12 +9,15 @@
|
|
|
9
9
|
#ifndef HIKYUU_PYTHON_BIND_UTILS_H
|
|
10
10
|
#define HIKYUU_PYTHON_BIND_UTILS_H
|
|
11
11
|
|
|
12
|
+
#include <hikyuu/config.h>
|
|
13
|
+
#if HKU_ENABLE_ARROW
|
|
14
|
+
#include <arrow/api.h>
|
|
15
|
+
#endif
|
|
12
16
|
#include <pybind11/pybind11.h>
|
|
13
17
|
|
|
14
18
|
#include <pybind11/operators.h>
|
|
15
19
|
#include <pybind11/stl.h>
|
|
16
20
|
#include <pybind11/numpy.h>
|
|
17
|
-
#include <arrow/api.h>
|
|
18
21
|
#include <vector>
|
|
19
22
|
#include <string>
|
|
20
23
|
#include "convert_any.h"
|
|
@@ -124,12 +127,14 @@ inline bool check_pyfunction_arg_num(const py::object& func, size_t arg_num) {
|
|
|
124
127
|
*/
|
|
125
128
|
size_t utf8_to_utf32(const std::string& utf8_str, int32_t* out, size_t out_len) noexcept;
|
|
126
129
|
|
|
130
|
+
#if HKU_ENABLE_ARROW
|
|
127
131
|
/*
|
|
128
132
|
* 将arrow::Table转换为 pyarrow::Table
|
|
129
133
|
* @param table 待转换的arrow::Table
|
|
130
134
|
* @return 转换后的py::object
|
|
131
135
|
*/
|
|
132
136
|
py::object to_pyarrow_table(const std::shared_ptr<arrow::Table>& table);
|
|
137
|
+
#endif
|
|
133
138
|
|
|
134
139
|
} // namespace hku
|
|
135
140
|
|
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
|
-
#ifndef PERFORMANCE_H_
|
|
10
|
-
#define PERFORMANCE_H_
|
|
11
9
|
|
|
12
|
-
#include <boost/function.hpp>
|
|
13
10
|
#include "TradeManagerBase.h"
|
|
14
11
|
|
|
15
12
|
namespace hku {
|
|
16
13
|
|
|
14
|
+
#if defined(_MSC_VER)
|
|
15
|
+
#pragma warning(disable : 4251)
|
|
16
|
+
#endif
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
19
|
* 简单绩效统计
|
|
19
20
|
* @ingroup Performance
|
|
@@ -84,4 +85,3 @@ private:
|
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
} /* namespace hku */
|
|
87
|
-
#endif /* PERFORMANCE_H_ */
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include "../utilities/Parameter.h"
|
|
11
10
|
#include "TradeRecord.h"
|
|
12
11
|
#include "PositionRecord.h"
|
|
13
12
|
#include "PositionExtInfo.h"
|
|
@@ -17,6 +16,7 @@
|
|
|
17
16
|
#include "TradeCostBase.h"
|
|
18
17
|
#include "OrderBrokerBase.h"
|
|
19
18
|
#include "crt/TC_Zero.h"
|
|
19
|
+
#include "../utilities/Parameter.h"
|
|
20
20
|
|
|
21
21
|
namespace hku {
|
|
22
22
|
|
|
@@ -825,6 +825,15 @@ inline void TradeManagerBase::paramChanged() {}
|
|
|
825
825
|
typedef shared_ptr<TradeManagerBase> TradeManagerPtr;
|
|
826
826
|
typedef shared_ptr<TradeManagerBase> TMPtr;
|
|
827
827
|
|
|
828
|
+
/**
|
|
829
|
+
* 从账户列表中一次性获取资金列表
|
|
830
|
+
* @param tm_list
|
|
831
|
+
* @param ref_dates
|
|
832
|
+
* @return vector<FundsList>
|
|
833
|
+
* @ingroup TradeManagerClass
|
|
834
|
+
*/
|
|
835
|
+
vector<FundsList> HKU_API getFundsList(const vector<TMPtr>& tm_list, const DatetimeList& ref_dates);
|
|
836
|
+
|
|
828
837
|
inline std::ostream& operator<<(std::ostream& os, const TradeManagerBase& tm) {
|
|
829
838
|
os << tm.str();
|
|
830
839
|
return os;
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
|
-
#ifndef TRADE_SYS_MONEYMANAGER_IMP_FIXEDCAPITAL_FUNDS_MM_H_
|
|
10
|
-
#define TRADE_SYS_MONEYMANAGER_IMP_FIXEDCAPITAL_FUNDS_MM_H_
|
|
11
9
|
|
|
12
10
|
#include "../MoneyManagerBase.h"
|
|
13
11
|
|
|
@@ -24,5 +22,3 @@ public:
|
|
|
24
22
|
};
|
|
25
23
|
|
|
26
24
|
} /* namespace hku */
|
|
27
|
-
|
|
28
|
-
#endif /* TRADE_SYS_MONEYMANAGER_IMP_FIXEDCAPITAL_FUNDS_MM_H_ */
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
#include "hikyuu/KData.h"
|
|
11
|
-
#include "
|
|
11
|
+
#include "ScoresFilterBase.h"
|
|
12
|
+
#include "buildin_norm.h"
|
|
12
13
|
|
|
13
14
|
namespace hku {
|
|
14
15
|
|
|
@@ -108,6 +109,9 @@ public:
|
|
|
108
109
|
ScoreRecordList getScores(const Datetime& date, size_t start, size_t end,
|
|
109
110
|
std::function<bool(const Datetime&, const ScoreRecord&)>&& filter);
|
|
110
111
|
|
|
112
|
+
ScoreRecordList getScores(const Datetime& date, size_t start, size_t end,
|
|
113
|
+
const ScoresFilterPtr& filter);
|
|
114
|
+
|
|
111
115
|
/** 获取所有截面数据,已按降序排列 */
|
|
112
116
|
const vector<ScoreRecordList>& getAllScores();
|
|
113
117
|
|
|
@@ -128,12 +132,29 @@ public:
|
|
|
128
132
|
Indicator getICIR(int ir_n, int ic_n = 0);
|
|
129
133
|
|
|
130
134
|
/**
|
|
131
|
-
*
|
|
135
|
+
* 获取所有处理过的原始因子值(归一化、标准化)。每次都会计算。
|
|
132
136
|
* @note 考虑到内存占用,该数据没有缓存,一般用与测试或者想查看处理过的原始因子值
|
|
133
137
|
* @return vector<IndicatorList> stks x inds
|
|
134
138
|
*/
|
|
135
139
|
vector<IndicatorList> getAllSrcFactors();
|
|
136
140
|
|
|
141
|
+
/**
|
|
142
|
+
* 设置因子标准化/归一化操作
|
|
143
|
+
* @param norm 标准化操作
|
|
144
|
+
*/
|
|
145
|
+
void setNormalize(NormPtr norm);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 对指定名称的指标应用特定的标准化/归一化、行业中性化、风格因子中性化操作。
|
|
149
|
+
* @note 标准化操作、行业中性化、风格因子中性化彼此无关,可同时指定也可分开指定。
|
|
150
|
+
* @param name 指标名称
|
|
151
|
+
* @param norm 标准化操作
|
|
152
|
+
* @param category 指标所属板块类别(需要中性化指定)
|
|
153
|
+
* @param style_inds 指标风格列表
|
|
154
|
+
*/
|
|
155
|
+
void addSpecialNormalize(const string& name, NormalizePtr norm, const string& category = "",
|
|
156
|
+
const IndicatorList& style_inds = IndicatorList());
|
|
157
|
+
|
|
137
158
|
void reset();
|
|
138
159
|
|
|
139
160
|
typedef std::shared_ptr<MultiFactorBase> MultiFactorPtr;
|
|
@@ -154,7 +175,9 @@ private:
|
|
|
154
175
|
|
|
155
176
|
void initParam();
|
|
156
177
|
|
|
157
|
-
|
|
178
|
+
// 构造每个指标构造行业哑变量,以便进行行业中性化处理
|
|
179
|
+
unordered_map<string, PriceList> _buildDummyIndex();
|
|
180
|
+
|
|
158
181
|
void _buildIndex(); // 计算完成后创建截面索引
|
|
159
182
|
void _buildIndexDesc(); // 创建降序排列的索引
|
|
160
183
|
void _buildIndexAsc(); // 创建升序排列的索引
|
|
@@ -178,6 +201,12 @@ protected:
|
|
|
178
201
|
vector<ScoreRecordList> m_stk_factor_by_date;
|
|
179
202
|
Indicator m_ic;
|
|
180
203
|
|
|
204
|
+
NormPtr m_norm; // 全局标准化/归一化操作
|
|
205
|
+
unordered_map<string, NormPtr> m_special_norms; // 对特定指标执行特定的标准化操作
|
|
206
|
+
unordered_map<string, string> m_special_category; // 对特定指标执行行业中性化时指定的板块分类
|
|
207
|
+
unordered_map<string, IndicatorList>
|
|
208
|
+
m_special_style_inds; // 对特定指标执行风格因子中性化时指定的风格因子
|
|
209
|
+
|
|
181
210
|
private:
|
|
182
211
|
std::mutex m_mutex;
|
|
183
212
|
bool m_calculated{false};
|
|
@@ -197,6 +226,8 @@ private:
|
|
|
197
226
|
ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
|
|
198
227
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
199
228
|
ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
|
|
229
|
+
ar& BOOST_SERIALIZATION_NVP(m_special_norms);
|
|
230
|
+
ar& BOOST_SERIALIZATION_NVP(m_special_category);
|
|
200
231
|
// 以下不需要保存,加载后重新计算
|
|
201
232
|
// ar& BOOST_SERIALIZATION_NVP(m_stk_map);
|
|
202
233
|
// ar& BOOST_SERIALIZATION_NVP(m_all_factors);
|
|
@@ -215,6 +246,8 @@ private:
|
|
|
215
246
|
ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
|
|
216
247
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
217
248
|
ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
|
|
249
|
+
ar& BOOST_SERIALIZATION_NVP(m_special_norms);
|
|
250
|
+
ar& BOOST_SERIALIZATION_NVP(m_special_category);
|
|
218
251
|
// ar& BOOST_SERIALIZATION_NVP(m_stk_map);
|
|
219
252
|
// ar& BOOST_SERIALIZATION_NVP(m_all_factors);
|
|
220
253
|
// ar& BOOST_SERIALIZATION_NVP(m_date_index);
|