hikyuu 2.7.0__py3-none-manylinux2014_aarch64.whl → 2.7.5__py3-none-manylinux2014_aarch64.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 +28 -8
- hikyuu/__init__.pyi +26 -14
- hikyuu/analysis/__init__.pyi +7 -1
- hikyuu/analysis/analysis.pyi +8 -2
- hikyuu/core.pyi +9 -3
- hikyuu/cpp/core310.pyi +172 -68
- hikyuu/cpp/core310.so +0 -0
- hikyuu/cpp/core311.pyi +172 -68
- hikyuu/cpp/core311.so +0 -0
- hikyuu/cpp/core312.pyi +172 -68
- hikyuu/cpp/core312.so +0 -0
- hikyuu/cpp/core313.pyi +172 -68
- hikyuu/cpp/core313.so +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu_plugin.mo +0 -0
- hikyuu/cpp/libboost_atomic.so +0 -0
- hikyuu/cpp/libboost_atomic.so.1.90.0 +0 -0
- hikyuu/cpp/{libboost_charconv-mt.so → libboost_charconv.so} +0 -0
- hikyuu/cpp/{libboost_charconv-mt.so.1.88.0 → libboost_charconv.so.1.90.0} +0 -0
- hikyuu/cpp/libboost_chrono.so +0 -0
- hikyuu/cpp/libboost_chrono.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_container.so +0 -0
- hikyuu/cpp/libboost_container.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_date_time.so +0 -0
- hikyuu/cpp/libboost_date_time.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_locale.so +0 -0
- hikyuu/cpp/libboost_locale.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_random.so +0 -0
- hikyuu/cpp/libboost_random.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_serialization.so +0 -0
- hikyuu/cpp/libboost_serialization.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_thread.so +0 -0
- hikyuu/cpp/libboost_thread.so.1.90.0 +0 -0
- hikyuu/cpp/libboost_wserialization.so +0 -0
- hikyuu/cpp/libboost_wserialization.so.1.90.0 +0 -0
- hikyuu/cpp/libhikyuu.so +0 -0
- hikyuu/cpp/libmimalloc.so +0 -0
- hikyuu/cpp/libmimalloc.so.3 +0 -0
- hikyuu/cpp/libmimalloc.so.3.1 +0 -0
- hikyuu/cpp/libsqlite3.so +0 -0
- hikyuu/data/clickhouse_upgrade/0001.sql +2 -0
- hikyuu/data/clickhouse_upgrade/0002.sql +9 -0
- hikyuu/data/common_clickhouse.py +1 -3
- hikyuu/data/common_mysql.py +1 -1
- hikyuu/data/download_block.py +1 -1
- hikyuu/data/em_block_to_mysql.py +16 -4
- hikyuu/data/em_block_to_sqlite.py +16 -4
- hikyuu/data/hku_config_template.py +31 -4
- hikyuu/data/mysql_upgrade/0029.sql +2 -0
- hikyuu/data/mysql_upgrade/0030.sql +3 -0
- hikyuu/data/pytdx_to_clickhouse.py +86 -32
- 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/data/sqlite_upgrade/0030.sql +5 -0
- hikyuu/data/tdx_to_clickhouse.py +2 -2
- hikyuu/data/tdx_to_h5.py +11 -11
- hikyuu/data/tdx_to_mysql.py +2 -2
- hikyuu/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/__init__.pyi +1 -1
- hikyuu/draw/drawplot/bokeh_draw.pyi +17 -9
- hikyuu/draw/drawplot/echarts_draw.pyi +17 -9
- hikyuu/draw/drawplot/matplotlib_draw.py +23 -9
- hikyuu/draw/drawplot/matplotlib_draw.pyi +17 -9
- hikyuu/examples/notebook/001-overview.ipynb +112 -78
- hikyuu/examples/notebook/004-IndicatorOverview.ipynb +52 -65
- hikyuu/examples/notebook/006-TradeManager.ipynb +402 -291
- hikyuu/examples/notebook/008-Pickle.ipynb +25 -17
- hikyuu/examples/notebook/009-RealData.ipynb +36 -38
- hikyuu/examples/notebook/Demo/Demo2.ipynb +146 -116
- hikyuu/extend.pyi +10 -4
- hikyuu/gui/HikyuuTDX.py +42 -3
- hikyuu/gui/data/MainWindow.py +189 -129
- hikyuu/gui/data/UseTdxImportToH5Thread.py +4 -2
- hikyuu/gui/start_qmt.py +1 -1
- hikyuu/hub.pyi +6 -6
- hikyuu/include/hikyuu/Block.h +9 -9
- hikyuu/include/hikyuu/HistoryFinanceInfo.h +3 -3
- hikyuu/include/hikyuu/KData.h +51 -28
- hikyuu/include/hikyuu/KDataImp.h +12 -7
- hikyuu/include/hikyuu/KDataPrivatedBufferImp.h +13 -7
- hikyuu/include/hikyuu/KDataSharedBufferImp.h +8 -6
- hikyuu/include/hikyuu/KQuery.h +11 -11
- hikyuu/include/hikyuu/KRecord.h +1 -1
- hikyuu/include/hikyuu/MarketInfo.h +10 -10
- hikyuu/include/hikyuu/Stock.h +30 -30
- hikyuu/include/hikyuu/StockManager.h +28 -12
- hikyuu/include/hikyuu/StockTypeInfo.h +9 -9
- hikyuu/include/hikyuu/StockWeight.h +9 -9
- hikyuu/include/hikyuu/StrategyContext.h +4 -4
- hikyuu/include/hikyuu/TimeLineRecord.h +1 -1
- hikyuu/include/hikyuu/TransRecord.h +1 -1
- hikyuu/include/hikyuu/data_driver/BaseInfoDriver.h +2 -1
- hikyuu/include/hikyuu/data_driver/BlockInfoDriver.h +6 -0
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +6 -7
- hikyuu/include/hikyuu/data_driver/kdata/mysql/MySQLKDataDriver.h +5 -1
- hikyuu/include/hikyuu/data_driver/kdata/sqlite/SQLiteKDataDriver.h +1 -1
- hikyuu/include/hikyuu/global/sysinfo.h +24 -5
- hikyuu/include/hikyuu/indicator/IndParam.h +1 -1
- hikyuu/include/hikyuu/indicator/Indicator.h +56 -27
- hikyuu/include/hikyuu/indicator/Indicator2InImp.h +0 -4
- hikyuu/include/hikyuu/indicator/IndicatorImp.h +147 -74
- hikyuu/include/hikyuu/indicator/crt/CONTEXT.h +11 -1
- hikyuu/include/hikyuu/indicator/crt/IC.h +19 -14
- hikyuu/include/hikyuu/indicator/crt/ICIR.h +4 -7
- hikyuu/include/hikyuu/indicator/imp/IAbs.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IAcos.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IAd.h +0 -2
- hikyuu/include/hikyuu/indicator/imp/IAdvance.h +3 -0
- hikyuu/include/hikyuu/indicator/imp/IAma.h +3 -0
- hikyuu/include/hikyuu/indicator/imp/IAsin.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IAtan.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IAtr.h +2 -3
- hikyuu/include/hikyuu/indicator/imp/IBackset.h +2 -4
- hikyuu/include/hikyuu/indicator/imp/IBlockSetNum.h +3 -0
- hikyuu/include/hikyuu/indicator/imp/ICeil.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IContext.h +0 -3
- hikyuu/include/hikyuu/indicator/imp/ICorr.h +3 -0
- hikyuu/include/hikyuu/indicator/imp/ICos.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ICost.h +0 -2
- hikyuu/include/hikyuu/indicator/imp/ICount.h +2 -1
- hikyuu/include/hikyuu/indicator/imp/ICval.h +1 -4
- hikyuu/include/hikyuu/indicator/imp/ICycle.h +0 -2
- hikyuu/include/hikyuu/indicator/imp/IDecline.h +3 -0
- hikyuu/include/hikyuu/indicator/imp/IDevsq.h +4 -1
- hikyuu/include/hikyuu/indicator/imp/IDiff.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IDma.h +2 -0
- hikyuu/include/hikyuu/indicator/imp/IDropna.h +0 -4
- hikyuu/include/hikyuu/indicator/imp/IEma.h +3 -1
- hikyuu/include/hikyuu/indicator/imp/IEvery.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IExist.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IExp.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IFilter.h +4 -5
- hikyuu/include/hikyuu/indicator/imp/IFinance.h +1 -2
- hikyuu/include/hikyuu/indicator/imp/IFloor.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IHhvbars.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IHighLine.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IHsl.h +0 -2
- hikyuu/include/hikyuu/indicator/imp/IIc.h +3 -6
- hikyuu/include/hikyuu/indicator/imp/IInBlock.h +1 -2
- hikyuu/include/hikyuu/indicator/imp/IIntpart.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IIsInf.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IIsInfa.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IIsLastBar.h +0 -1
- hikyuu/include/hikyuu/indicator/imp/IIsNa.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IJumpDown.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IJumpUp.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IKData.h +1 -2
- hikyuu/include/hikyuu/indicator/imp/ILiuTongPan.h +0 -2
- hikyuu/include/hikyuu/indicator/imp/ILn.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ILog.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ILowLine.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/ILowLineBars.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IMa.h +6 -1
- hikyuu/include/hikyuu/indicator/imp/IMacd.h +2 -0
- hikyuu/include/hikyuu/indicator/imp/INot.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IPow.h +3 -1
- hikyuu/include/hikyuu/indicator/imp/IQuantileTrunc.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IRecover.h +3 -0
- hikyuu/include/hikyuu/indicator/imp/IRef.h +3 -1
- hikyuu/include/hikyuu/indicator/imp/IResult.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IReverse.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IRoc.h +6 -1
- hikyuu/include/hikyuu/indicator/imp/IRocp.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IRocr.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IRocr100.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IRound.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IRoundDown.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IRoundUp.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ISaftyLoss.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ISign.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ISin.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ISlope.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/ISma.h +2 -0
- hikyuu/include/hikyuu/indicator/imp/ISpearman.h +3 -0
- hikyuu/include/hikyuu/indicator/imp/ISqrt.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/IStdev.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IStdp.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/ISum.h +6 -1
- hikyuu/include/hikyuu/indicator/imp/ITan.h +1 -0
- hikyuu/include/hikyuu/indicator/imp/ITime.h +1 -2
- hikyuu/include/hikyuu/indicator/imp/ITimeLine.h +0 -2
- hikyuu/include/hikyuu/indicator/imp/ITr.h +1 -2
- hikyuu/include/hikyuu/indicator/imp/IVar.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IVarp.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IVigor.h +0 -2
- hikyuu/include/hikyuu/indicator/imp/IWma.h +5 -1
- hikyuu/include/hikyuu/indicator/imp/IZongGuBen.h +1 -2
- hikyuu/include/hikyuu/indicator_talib/imp/TaAdosc.h +0 -2
- hikyuu/include/hikyuu/indicator_talib/imp/TaSar.h +0 -2
- hikyuu/include/hikyuu/indicator_talib/imp/TaSarext.h +0 -4
- hikyuu/include/hikyuu/indicator_talib/imp/TaStoch.h +0 -3
- hikyuu/include/hikyuu/indicator_talib/imp/TaStochf.h +0 -2
- hikyuu/include/hikyuu/indicator_talib/imp/TaUltosc.h +0 -2
- hikyuu/include/hikyuu/indicator_talib/imp/ta_defines.h +2 -4
- hikyuu/include/hikyuu/indicator_talib/imp/ta_imp.h +70 -90
- 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/extind.h +3 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +4 -0
- hikyuu/include/hikyuu/plugin/interface/CheckDataPluginInterface.h +25 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +4 -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/python/pybind_utils.h +22 -5
- hikyuu/include/hikyuu/strategy/Strategy.h +1 -1
- hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -3
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +9 -3
- hikyuu/include/hikyuu/trade_manage/TradeRecord.h +2 -1
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +8 -4
- 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/trade_sys/condition/ConditionBase.h +5 -3
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +6 -3
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -3
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +23 -20
- hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +6 -4
- hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +5 -3
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_EqualWeight.h +3 -3
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICIRWeight.h +4 -4
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_ICWeight.h +4 -4
- hikyuu/include/hikyuu/trade_sys/multifactor/crt/MF_Weight.h +4 -4
- hikyuu/include/hikyuu/trade_sys/portfolio/Portfolio.h +16 -13
- hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +13 -13
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +12 -3
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/crt/SE_MultiFactor2.h +1 -1
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector.h +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/MultiFactorSelector2.h +1 -0
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/OptimalSelectorBase.h +0 -2
- hikyuu/include/hikyuu/trade_sys/selector/imp/optimal/PerformanceOptimalSelector.h +0 -4
- hikyuu/include/hikyuu/trade_sys/signal/SignalBase.h +5 -3
- hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -3
- hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +5 -3
- hikyuu/include/hikyuu/trade_sys/system/System.h +6 -4
- hikyuu/include/hikyuu/utilities/Log.h +6 -7
- hikyuu/include/hikyuu/utilities/LruCache.h +299 -0
- hikyuu/include/hikyuu/utilities/Parameter.h +17 -0
- hikyuu/include/hikyuu/utilities/arithmetic.h +2 -2
- hikyuu/include/hikyuu/utilities/config.h +28 -0
- hikyuu/include/hikyuu/utilities/omp_macro.h +25 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginBase.h +17 -2
- hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +46 -22
- hikyuu/include/hikyuu/utilities/thread/GlobalStealThreadPool.h +71 -19
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +1 -5
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +286 -0
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -0
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +297 -0
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +1 -4
- hikyuu/include/hikyuu/utilities/thread/WorkStealQueue.h +9 -8
- hikyuu/include/hikyuu/utilities/thread/algorithm.h +350 -14
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/plugin/libbacktest.so +0 -0
- hikyuu/plugin/libcheckdata.so +0 -0
- hikyuu/plugin/libclickhousedriver.so +0 -0
- hikyuu/plugin/libdataserver.so +0 -0
- hikyuu/plugin/libdataserver_parquet.so +0 -0
- hikyuu/plugin/libdevice.so +0 -0
- hikyuu/plugin/libextind.so +0 -0
- hikyuu/plugin/libhkuextra.so +0 -0
- hikyuu/plugin/libimport2ch.so +0 -0
- hikyuu/plugin/libimport2hdf5.so +0 -0
- hikyuu/plugin/libimport2mysql.so +0 -0
- hikyuu/plugin/libtmreport.so +0 -0
- hikyuu/test/Indicator.py +1 -2
- hikyuu/trade_manage/__init__.pyi +14 -8
- hikyuu/trade_manage/trade.pyi +14 -8
- hikyuu/trade_sys/trade_sys.py +54 -5
- hikyuu/util/__init__.pyi +2 -2
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.7.0.dist-info → hikyuu-2.7.5.dist-info}/METADATA +10 -4
- {hikyuu-2.7.0.dist-info → hikyuu-2.7.5.dist-info}/RECORD +282 -252
- hikyuu/cpp/libboost_chrono-mt.so +0 -0
- hikyuu/cpp/libboost_chrono-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_date_time-mt.so +0 -0
- hikyuu/cpp/libboost_date_time-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_serialization-mt.so +0 -0
- hikyuu/cpp/libboost_serialization-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_system-mt.so +0 -0
- hikyuu/cpp/libboost_system-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_thread-mt.so +0 -0
- hikyuu/cpp/libboost_thread-mt.so.1.88.0 +0 -0
- hikyuu/cpp/libboost_wserialization-mt.so +0 -0
- hikyuu/cpp/libboost_wserialization-mt.so.1.88.0 +0 -0
- hikyuu/data/pytdx_to_taos.py +0 -736
- {hikyuu-2.7.0.dist-info → hikyuu-2.7.5.dist-info}/WHEEL +0 -0
- {hikyuu-2.7.0.dist-info → hikyuu-2.7.5.dist-info}/entry_points.txt +0 -0
- {hikyuu-2.7.0.dist-info → hikyuu-2.7.5.dist-info}/top_level.txt +0 -0
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#ifndef INDICATORIMP_H_
|
|
10
10
|
#define INDICATORIMP_H_
|
|
11
11
|
|
|
12
|
+
#include <mimalloc.h>
|
|
12
13
|
#include "../config.h"
|
|
13
14
|
#include "../KData.h"
|
|
14
15
|
#include "../utilities/Parameter.h"
|
|
@@ -30,7 +31,7 @@ class HKU_API IndicatorImp : public enable_shared_from_this<IndicatorImp> {
|
|
|
30
31
|
friend HKU_API std::ostream& operator<<(std::ostream& os, const IndicatorImp& imp);
|
|
31
32
|
|
|
32
33
|
public:
|
|
33
|
-
enum OPType {
|
|
34
|
+
enum OPType : uint8_t {
|
|
34
35
|
LEAF, ///< 叶子节点
|
|
35
36
|
OP, /// OP(OP1,OP2) OP1->calcalue(OP2->calculate(ind))
|
|
36
37
|
ADD, ///< 加
|
|
@@ -56,6 +57,7 @@ public:
|
|
|
56
57
|
#else
|
|
57
58
|
typedef double value_t;
|
|
58
59
|
#endif
|
|
60
|
+
typedef vector<value_t, mi_stl_allocator<value_t>> buffer_t;
|
|
59
61
|
|
|
60
62
|
public:
|
|
61
63
|
/** 默认构造函数 */
|
|
@@ -68,13 +70,15 @@ public:
|
|
|
68
70
|
typedef shared_ptr<IndicatorImp> IndicatorImpPtr;
|
|
69
71
|
IndicatorImpPtr operator()(const Indicator& ind);
|
|
70
72
|
|
|
71
|
-
size_t getResultNumber() const;
|
|
73
|
+
size_t getResultNumber() const noexcept;
|
|
74
|
+
OPType getOPType() const noexcept;
|
|
72
75
|
|
|
73
|
-
size_t discard() const;
|
|
76
|
+
size_t discard() const noexcept;
|
|
74
77
|
|
|
75
|
-
void setDiscard(size_t discard);
|
|
78
|
+
void setDiscard(size_t discard) noexcept;
|
|
79
|
+
void updateDiscard(bool force = false) noexcept;
|
|
76
80
|
|
|
77
|
-
size_t size() const;
|
|
81
|
+
size_t size() const noexcept;
|
|
78
82
|
|
|
79
83
|
value_t get(size_t pos, size_t num = 0) const;
|
|
80
84
|
|
|
@@ -112,8 +116,8 @@ public:
|
|
|
112
116
|
/** 数据中是否包含 nan 值 */
|
|
113
117
|
bool existNan(size_t result_idx = 0) const;
|
|
114
118
|
|
|
115
|
-
const string& name() const;
|
|
116
|
-
void name(const string& name);
|
|
119
|
+
const string& name() const noexcept;
|
|
120
|
+
void name(const string& name) noexcept;
|
|
117
121
|
|
|
118
122
|
/** 返回形如:Name(param1=val,param2=val,...) */
|
|
119
123
|
string long_name() const;
|
|
@@ -121,7 +125,7 @@ public:
|
|
|
121
125
|
virtual string formula() const;
|
|
122
126
|
virtual string str() const;
|
|
123
127
|
|
|
124
|
-
bool isLeaf() const;
|
|
128
|
+
bool isLeaf() const noexcept;
|
|
125
129
|
|
|
126
130
|
Indicator calculate();
|
|
127
131
|
|
|
@@ -129,7 +133,7 @@ public:
|
|
|
129
133
|
|
|
130
134
|
void setContext(const KData&);
|
|
131
135
|
|
|
132
|
-
KData getContext() const;
|
|
136
|
+
const KData& getContext() const;
|
|
133
137
|
|
|
134
138
|
void add(OPType, IndicatorImpPtr left, IndicatorImpPtr right);
|
|
135
139
|
|
|
@@ -137,6 +141,12 @@ public:
|
|
|
137
141
|
|
|
138
142
|
IndicatorImpPtr clone();
|
|
139
143
|
|
|
144
|
+
bool isPythonObject() const noexcept;
|
|
145
|
+
|
|
146
|
+
/** 仅用于两个结果集数量相同、长度相同的指标交换数据,不交换其他参数。失败抛出异常 */
|
|
147
|
+
void swap(IndicatorImp* other);
|
|
148
|
+
void swap(IndicatorImp* other, size_t other_result_idx, size_t self_result_idx);
|
|
149
|
+
|
|
140
150
|
bool haveIndParam(const string& name) const;
|
|
141
151
|
void setIndParam(const string& name, const Indicator& ind);
|
|
142
152
|
void setIndParam(const string& name, const IndParam& ind);
|
|
@@ -151,28 +161,46 @@ public:
|
|
|
151
161
|
// ===================
|
|
152
162
|
virtual void _calculate(const Indicator&);
|
|
153
163
|
|
|
164
|
+
// ====== start 动态周期计算相关接口 ======
|
|
165
|
+
/** 动态周期计算,子类可重载该函数,默认不支持动态周期计算 */
|
|
154
166
|
virtual void _dyn_run_one_step(const Indicator& ind, size_t curPos, size_t step) {}
|
|
155
167
|
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
return
|
|
168
|
+
/** 是否必须串行计算 */
|
|
169
|
+
bool isSerial() const noexcept {
|
|
170
|
+
return m_is_serial;
|
|
159
171
|
}
|
|
172
|
+
// ====== end 动态周期计算相关接口 ======
|
|
160
173
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
174
|
+
// ====== start 增量计算相关接口 =======
|
|
175
|
+
/** 是否支持增量计算 */
|
|
176
|
+
virtual bool supportIncrementCalculate() const;
|
|
177
|
+
|
|
178
|
+
virtual size_t min_increment_start() const {
|
|
179
|
+
return 0;
|
|
164
180
|
}
|
|
165
181
|
|
|
182
|
+
virtual void _increment_calculate(const Indicator& ind, size_t start_pos) {}
|
|
183
|
+
// ====== end 增量计算相关接口 =======
|
|
184
|
+
|
|
166
185
|
virtual IndicatorImpPtr _clone() {
|
|
167
186
|
return make_shared<IndicatorImp>();
|
|
168
187
|
}
|
|
169
188
|
|
|
170
|
-
|
|
171
|
-
return
|
|
189
|
+
bool isNeedContext() const noexcept {
|
|
190
|
+
return m_need_context;
|
|
172
191
|
}
|
|
173
192
|
|
|
174
193
|
virtual void _dyn_calculate(const Indicator&);
|
|
175
194
|
|
|
195
|
+
public:
|
|
196
|
+
static void enableIncrementCalculate(bool flag) {
|
|
197
|
+
ms_enable_increment_calculate = flag;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static bool enableIncrementCalculate() {
|
|
201
|
+
return ms_enable_increment_calculate;
|
|
202
|
+
}
|
|
203
|
+
|
|
176
204
|
public:
|
|
177
205
|
// ===================
|
|
178
206
|
// 内部特殊用途公共接口
|
|
@@ -184,21 +212,21 @@ public:
|
|
|
184
212
|
/** 判断指标公式中是否包含指定名称的指标(特殊用途) */
|
|
185
213
|
bool contains(const string& name) const;
|
|
186
214
|
|
|
187
|
-
value_t* data(size_t result_idx = 0);
|
|
188
|
-
value_t const* data(size_t result_idx = 0) const;
|
|
215
|
+
value_t* data(size_t result_idx = 0) noexcept;
|
|
216
|
+
value_t const* data(size_t result_idx = 0) const noexcept;
|
|
189
217
|
|
|
190
218
|
void getAllSubNodes(vector<IndicatorImpPtr>& nodes) const;
|
|
191
219
|
|
|
192
|
-
IndicatorImpPtr getRightNode() const;
|
|
193
|
-
IndicatorImpPtr getLeftNode() const;
|
|
194
|
-
IndicatorImpPtr getThreeNode() const;
|
|
220
|
+
IndicatorImpPtr getRightNode() const noexcept;
|
|
221
|
+
IndicatorImpPtr getLeftNode() const noexcept;
|
|
222
|
+
IndicatorImpPtr getThreeNode() const noexcept;
|
|
195
223
|
void printTree(bool show_long_name = false) const;
|
|
196
224
|
void printAllSubTrees(bool show_long_name = false) const;
|
|
197
225
|
void printLeaves(bool show_long_name = false) const;
|
|
198
226
|
|
|
199
227
|
/* 特殊指标需自己实现 selfAlike 函数的, needSelfAlikeCompare 应返回 true */
|
|
200
|
-
|
|
201
|
-
return
|
|
228
|
+
bool needSelfAlikeCompare() const noexcept {
|
|
229
|
+
return m_need_self_alike_compare;
|
|
202
230
|
}
|
|
203
231
|
|
|
204
232
|
// 特殊指标需自己实现 selfAlike 函数,返回true表示两个指标等效
|
|
@@ -213,8 +241,11 @@ public:
|
|
|
213
241
|
virtual void getSeparateKTypeLeafSubNodes(vector<IndicatorImpPtr>& nodes) const {}
|
|
214
242
|
|
|
215
243
|
private:
|
|
216
|
-
void initContext();
|
|
217
244
|
bool needCalculate();
|
|
245
|
+
bool can_inner_calculate();
|
|
246
|
+
bool can_increment_calculate();
|
|
247
|
+
bool increment_execute_leaf_or_op(const Indicator& ind);
|
|
248
|
+
size_t increment_execute();
|
|
218
249
|
void execute_add();
|
|
219
250
|
void execute_sub();
|
|
220
251
|
void execute_mul();
|
|
@@ -230,6 +261,7 @@ private:
|
|
|
230
261
|
void execute_or();
|
|
231
262
|
void execute_weave();
|
|
232
263
|
void execute_if();
|
|
264
|
+
size_t increment_execute_if();
|
|
233
265
|
|
|
234
266
|
static void inner_repeatALikeNodes(vector<IndicatorImpPtr>& sub_nodes);
|
|
235
267
|
void repeatALikeNodes();
|
|
@@ -252,19 +284,24 @@ private:
|
|
|
252
284
|
protected:
|
|
253
285
|
static size_t _get_step_start(size_t pos, size_t step, size_t discard);
|
|
254
286
|
|
|
255
|
-
|
|
256
|
-
void _update_discard();
|
|
257
|
-
|
|
258
|
-
virtual bool isPythonObject() const;
|
|
287
|
+
void onlySetContext(const KData&);
|
|
259
288
|
|
|
260
289
|
protected:
|
|
261
290
|
string m_name;
|
|
262
|
-
size_t m_discard;
|
|
263
|
-
size_t m_result_num;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
291
|
+
size_t m_discard{0};
|
|
292
|
+
size_t m_result_num{0};
|
|
293
|
+
KData m_context;
|
|
294
|
+
KData m_old_context;
|
|
295
|
+
|
|
296
|
+
buffer_t* m_pBuffer[MAX_RESULT_NUM];
|
|
297
|
+
|
|
298
|
+
bool m_need_context{false};
|
|
299
|
+
bool m_is_python_object{false};
|
|
300
|
+
bool m_need_self_alike_compare{false};
|
|
301
|
+
bool m_is_serial{false};
|
|
302
|
+
bool m_need_calculate{true};
|
|
303
|
+
bool m_param_changed{true};
|
|
304
|
+
OPType m_optype{LEAF};
|
|
268
305
|
IndicatorImpPtr m_left;
|
|
269
306
|
IndicatorImpPtr m_right;
|
|
270
307
|
IndicatorImpPtr m_three;
|
|
@@ -273,11 +310,11 @@ protected:
|
|
|
273
310
|
IndicatorImp* m_parent{nullptr}; // can't use shared_from_this in python, so not weak_ptr
|
|
274
311
|
|
|
275
312
|
public:
|
|
276
|
-
static void
|
|
277
|
-
static void
|
|
313
|
+
static void initEngine();
|
|
314
|
+
static void releaseEngine();
|
|
278
315
|
|
|
279
316
|
protected:
|
|
280
|
-
static
|
|
317
|
+
static bool ms_enable_increment_calculate;
|
|
281
318
|
|
|
282
319
|
#if HKU_SUPPORT_SERIALIZATION
|
|
283
320
|
private:
|
|
@@ -289,7 +326,14 @@ private:
|
|
|
289
326
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
290
327
|
ar& BOOST_SERIALIZATION_NVP(m_discard);
|
|
291
328
|
ar& BOOST_SERIALIZATION_NVP(m_result_num);
|
|
329
|
+
ar& BOOST_SERIALIZATION_NVP(m_context);
|
|
330
|
+
ar& BOOST_SERIALIZATION_NVP(m_old_context);
|
|
331
|
+
ar& BOOST_SERIALIZATION_NVP(m_need_context);
|
|
332
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
333
|
+
ar& BOOST_SERIALIZATION_NVP(m_need_self_alike_compare);
|
|
334
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_serial);
|
|
292
335
|
ar& BOOST_SERIALIZATION_NVP(m_need_calculate);
|
|
336
|
+
ar& BOOST_SERIALIZATION_NVP(m_param_changed);
|
|
293
337
|
ar& BOOST_SERIALIZATION_NVP(m_optype);
|
|
294
338
|
ar& BOOST_SERIALIZATION_NVP(m_left);
|
|
295
339
|
ar& BOOST_SERIALIZATION_NVP(m_right);
|
|
@@ -308,7 +352,7 @@ private:
|
|
|
308
352
|
for (size_t i = 0; i < act_result_num; ++i) {
|
|
309
353
|
size_t count = size();
|
|
310
354
|
ar& bs::make_nvp<size_t>(format("count_{}", i).c_str(), count);
|
|
311
|
-
|
|
355
|
+
buffer_t& values = *m_pBuffer[i];
|
|
312
356
|
for (size_t j = 0; j < count; j++) {
|
|
313
357
|
if (std::isnan(values[j])) {
|
|
314
358
|
ar& boost::serialization::make_nvp<string>("item", nan);
|
|
@@ -329,7 +373,14 @@ private:
|
|
|
329
373
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
330
374
|
ar& BOOST_SERIALIZATION_NVP(m_discard);
|
|
331
375
|
ar& BOOST_SERIALIZATION_NVP(m_result_num);
|
|
376
|
+
ar& BOOST_SERIALIZATION_NVP(m_context);
|
|
377
|
+
ar& BOOST_SERIALIZATION_NVP(m_old_context);
|
|
378
|
+
ar& BOOST_SERIALIZATION_NVP(m_need_context);
|
|
379
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
380
|
+
ar& BOOST_SERIALIZATION_NVP(m_need_self_alike_compare);
|
|
381
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_serial);
|
|
332
382
|
ar& BOOST_SERIALIZATION_NVP(m_need_calculate);
|
|
383
|
+
ar& BOOST_SERIALIZATION_NVP(m_param_changed);
|
|
333
384
|
ar& BOOST_SERIALIZATION_NVP(m_optype);
|
|
334
385
|
ar& BOOST_SERIALIZATION_NVP(m_left);
|
|
335
386
|
ar& BOOST_SERIALIZATION_NVP(m_right);
|
|
@@ -338,11 +389,11 @@ private:
|
|
|
338
389
|
|
|
339
390
|
size_t act_result_num = 0;
|
|
340
391
|
ar& BOOST_SERIALIZATION_NVP(act_result_num);
|
|
392
|
+
_readyBuffer(0, act_result_num);
|
|
341
393
|
for (size_t i = 0; i < act_result_num; ++i) {
|
|
342
|
-
m_pBuffer[i] = new vector<value_t>();
|
|
343
394
|
size_t count = 0;
|
|
344
395
|
ar& bs::make_nvp<size_t>(format("count_{}", i).c_str(), count);
|
|
345
|
-
|
|
396
|
+
buffer_t& values = *m_pBuffer[i];
|
|
346
397
|
values.resize(count);
|
|
347
398
|
for (size_t j = 0; j < count; j++) {
|
|
348
399
|
std::string vstr;
|
|
@@ -364,10 +415,6 @@ private:
|
|
|
364
415
|
#endif
|
|
365
416
|
};
|
|
366
417
|
|
|
367
|
-
#if HKU_SUPPORT_SERIALIZATION
|
|
368
|
-
BOOST_SERIALIZATION_ASSUME_ABSTRACT(IndicatorImp)
|
|
369
|
-
#endif
|
|
370
|
-
|
|
371
418
|
#if HKU_SUPPORT_SERIALIZATION
|
|
372
419
|
#define INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION \
|
|
373
420
|
private: \
|
|
@@ -387,21 +434,15 @@ public: \
|
|
|
387
434
|
return make_shared<classname>(); \
|
|
388
435
|
}
|
|
389
436
|
|
|
390
|
-
#define
|
|
391
|
-
public:
|
|
392
|
-
virtual void
|
|
393
|
-
virtual void _dyn_run_one_step(const Indicator& ind, size_t curPos, size_t step) override; \
|
|
394
|
-
virtual bool supportIndParam() const override { \
|
|
395
|
-
return true; \
|
|
396
|
-
} \
|
|
397
|
-
virtual IndicatorImpPtr _clone() override { \
|
|
398
|
-
return make_shared<classname>(); \
|
|
399
|
-
}
|
|
437
|
+
#define INDICATOR_IMP_SUPPORT_DYNAMIC_CYCLE \
|
|
438
|
+
public: \
|
|
439
|
+
virtual void _dyn_run_one_step(const Indicator& ind, size_t curPos, size_t step) override;
|
|
400
440
|
|
|
401
|
-
#define
|
|
402
|
-
public:
|
|
403
|
-
virtual
|
|
404
|
-
|
|
441
|
+
#define INDICATOR_IMP_SUPPORT_INCREMENT \
|
|
442
|
+
public: \
|
|
443
|
+
virtual void _increment_calculate(const Indicator& ind, size_t start_pos) override; \
|
|
444
|
+
virtual bool supportIncrementCalculate() const override { \
|
|
445
|
+
return true; \
|
|
405
446
|
}
|
|
406
447
|
|
|
407
448
|
/** 获取 OPType 名称字符串 */
|
|
@@ -412,38 +453,49 @@ typedef shared_ptr<IndicatorImp> IndicatorImpPtr;
|
|
|
412
453
|
HKU_API std::ostream& operator<<(std::ostream&, const IndicatorImp&);
|
|
413
454
|
HKU_API std::ostream& operator<<(std::ostream&, const IndicatorImpPtr&);
|
|
414
455
|
|
|
415
|
-
inline
|
|
456
|
+
inline IndicatorImp::OPType IndicatorImp::getOPType() const noexcept {
|
|
457
|
+
return m_optype;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
inline size_t IndicatorImp::getResultNumber() const noexcept {
|
|
416
461
|
return m_result_num;
|
|
417
462
|
}
|
|
418
463
|
|
|
419
|
-
inline size_t IndicatorImp::discard() const {
|
|
464
|
+
inline size_t IndicatorImp::discard() const noexcept {
|
|
420
465
|
return m_discard;
|
|
421
466
|
}
|
|
422
467
|
|
|
423
|
-
inline size_t IndicatorImp::size() const {
|
|
468
|
+
inline size_t IndicatorImp::size() const noexcept {
|
|
424
469
|
return m_pBuffer[0] ? m_pBuffer[0]->size() : 0;
|
|
425
470
|
}
|
|
426
471
|
|
|
427
|
-
inline const string& IndicatorImp::name() const {
|
|
472
|
+
inline const string& IndicatorImp::name() const noexcept {
|
|
428
473
|
return m_name;
|
|
429
474
|
}
|
|
430
475
|
|
|
431
|
-
inline void IndicatorImp::name(const string& name) {
|
|
476
|
+
inline void IndicatorImp::name(const string& name) noexcept {
|
|
432
477
|
m_name = name;
|
|
433
478
|
}
|
|
434
479
|
|
|
435
|
-
inline bool IndicatorImp::isLeaf() const {
|
|
480
|
+
inline bool IndicatorImp::isLeaf() const noexcept {
|
|
436
481
|
return m_optype == LEAF ? true : false;
|
|
437
482
|
}
|
|
438
483
|
|
|
439
|
-
inline KData IndicatorImp::getContext() const {
|
|
440
|
-
return
|
|
484
|
+
inline const KData& IndicatorImp::getContext() const {
|
|
485
|
+
return m_context;
|
|
441
486
|
}
|
|
442
487
|
|
|
443
488
|
inline void IndicatorImp::setContext(const Stock& stock, const KQuery& query) {
|
|
444
489
|
setContext(stock.getKData(query));
|
|
445
490
|
}
|
|
446
491
|
|
|
492
|
+
inline void IndicatorImp::onlySetContext(const KData& k) {
|
|
493
|
+
if (m_context != k) {
|
|
494
|
+
m_old_context = m_context;
|
|
495
|
+
m_context = k;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
447
499
|
inline const IndicatorImp::ind_param_map_t& IndicatorImp::getIndParams() const {
|
|
448
500
|
return m_ind_params;
|
|
449
501
|
}
|
|
@@ -452,11 +504,11 @@ inline bool IndicatorImp::haveIndParam(const string& name) const {
|
|
|
452
504
|
return m_ind_params.find(name) != m_ind_params.end();
|
|
453
505
|
}
|
|
454
506
|
|
|
455
|
-
inline IndicatorImp::value_t* IndicatorImp::data(size_t result_idx) {
|
|
507
|
+
inline IndicatorImp::value_t* IndicatorImp::data(size_t result_idx) noexcept {
|
|
456
508
|
return m_pBuffer[result_idx] ? m_pBuffer[result_idx]->data() : nullptr;
|
|
457
509
|
}
|
|
458
510
|
|
|
459
|
-
inline IndicatorImp::value_t const* IndicatorImp::data(size_t result_idx) const {
|
|
511
|
+
inline IndicatorImp::value_t const* IndicatorImp::data(size_t result_idx) const noexcept {
|
|
460
512
|
return m_pBuffer[result_idx] ? m_pBuffer[result_idx]->data() : nullptr;
|
|
461
513
|
}
|
|
462
514
|
|
|
@@ -464,22 +516,43 @@ inline size_t IndicatorImp::_get_step_start(size_t pos, size_t step, size_t disc
|
|
|
464
516
|
return step == 0 || pos < discard + step ? discard : pos + 1 - step;
|
|
465
517
|
}
|
|
466
518
|
|
|
467
|
-
inline bool IndicatorImp::isPythonObject() const {
|
|
468
|
-
return
|
|
519
|
+
inline bool IndicatorImp::isPythonObject() const noexcept {
|
|
520
|
+
return m_is_python_object;
|
|
469
521
|
}
|
|
470
522
|
|
|
471
|
-
inline IndicatorImpPtr IndicatorImp::getRightNode() const {
|
|
523
|
+
inline IndicatorImpPtr IndicatorImp::getRightNode() const noexcept {
|
|
472
524
|
return m_right;
|
|
473
525
|
}
|
|
474
526
|
|
|
475
|
-
inline IndicatorImpPtr IndicatorImp::getLeftNode() const {
|
|
527
|
+
inline IndicatorImpPtr IndicatorImp::getLeftNode() const noexcept {
|
|
476
528
|
return m_left;
|
|
477
529
|
}
|
|
478
530
|
|
|
479
|
-
inline IndicatorImpPtr IndicatorImp::getThreeNode() const {
|
|
531
|
+
inline IndicatorImpPtr IndicatorImp::getThreeNode() const noexcept {
|
|
480
532
|
return m_three;
|
|
481
533
|
}
|
|
482
534
|
|
|
535
|
+
inline std::ostream& operator<<(std::ostream& os, const IndicatorImp::buffer_t& p) {
|
|
536
|
+
if (p.empty()) {
|
|
537
|
+
os << "[]";
|
|
538
|
+
return os;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
size_t len = p.size();
|
|
542
|
+
const size_t print = 3;
|
|
543
|
+
os << "[";
|
|
544
|
+
for (size_t i = 0; i < len; i++) {
|
|
545
|
+
if ((i < print) || (i + print >= len)) {
|
|
546
|
+
os << p[i];
|
|
547
|
+
if (i + 1 != len)
|
|
548
|
+
os << ", ";
|
|
549
|
+
} else if (i == 3)
|
|
550
|
+
os << "..., ";
|
|
551
|
+
}
|
|
552
|
+
os << "]";
|
|
553
|
+
return os;
|
|
554
|
+
}
|
|
555
|
+
|
|
483
556
|
} /* namespace hku */
|
|
484
557
|
|
|
485
558
|
#if FMT_VERSION >= 90000
|
|
@@ -24,10 +24,20 @@ Indicator HKU_API CONTEXT(const Indicator& ind, bool fill_null = false, bool use
|
|
|
24
24
|
Indicator HKU_API CONTEXT(bool fill_null = false, bool use_self_ktype = false,
|
|
25
25
|
bool use_self_recover_type = false);
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @brief 通过指定股票,设置指标独立上下文指标
|
|
29
|
+
* @param ind 输入指标公式,如果自身携带上下文,将被忽略
|
|
30
|
+
* @param stk 指定股票
|
|
31
|
+
* @param fill_null 是否填充空值,默认为 false
|
|
32
|
+
* @return Indicator
|
|
33
|
+
*/
|
|
34
|
+
Indicator HKU_API CONTEXT(const Indicator& ind, const Stock& stk, bool fill_null = false);
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
* 获取指标上下文
|
|
29
38
|
* @note Indicator::getContext()方法获取的是当前的上下文,但对于 CONTEXT
|
|
30
|
-
*
|
|
39
|
+
* 独立上下文指标无法获取其指定的独立上下文,需用此方法获取。
|
|
40
|
+
* 该指标一旦作为公式,参与计算,其上下文可能发生变化,但其stock保持不变,仅query范围发生改变
|
|
31
41
|
* @param ind
|
|
32
42
|
* @return KData
|
|
33
43
|
*/
|
|
@@ -18,32 +18,37 @@ namespace hku {
|
|
|
18
18
|
天的收益”(比如过去 5 天的收益),并称之为 “当前 IC”。(否则当前值都会是缺失NA)
|
|
19
19
|
如需严格“t 时刻因子值→t+1 时刻收益“计算,请设置 strict=True (注意此模式下, 后n位为 NA)
|
|
20
20
|
* @param stks 证券组合
|
|
21
|
-
* @param query 查询条件
|
|
22
|
-
* @param ref_stk 参照证券,默认 sh000300 沪深300
|
|
23
21
|
* @param n 时间窗口 (对应 n 日收益率)
|
|
24
22
|
* @param spearman 使用 spearman 相关系数,否则为 pearson
|
|
25
23
|
* @param strict 严格模式, 遵循IC定义“t 时刻因子值→t+1 时刻收益”
|
|
26
24
|
* @return Indicator
|
|
27
25
|
* @ingroup Indicator
|
|
28
26
|
*/
|
|
29
|
-
Indicator HKU_API IC(const StockList& stks,
|
|
30
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true,
|
|
31
|
-
bool strict = false);
|
|
27
|
+
Indicator HKU_API IC(const StockList& stks, int n = 1, bool spearman = true, bool strict = false);
|
|
32
28
|
|
|
33
|
-
Indicator HKU_API IC(const Block& blk,
|
|
34
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true,
|
|
35
|
-
bool strict = false);
|
|
29
|
+
Indicator HKU_API IC(const Block& blk, int n = 1, bool spearman = true, bool strict = false);
|
|
36
30
|
|
|
37
|
-
inline Indicator IC(const Indicator& ind, const StockList& stks,
|
|
38
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true,
|
|
31
|
+
inline Indicator IC(const Indicator& ind, const StockList& stks, int n = 1, bool spearman = true,
|
|
39
32
|
bool strict = false) {
|
|
40
|
-
return IC(stks,
|
|
33
|
+
return IC(stks, n, spearman, strict)(ind);
|
|
41
34
|
}
|
|
42
35
|
|
|
43
|
-
inline Indicator IC(const Indicator& ind, const Block& blk,
|
|
44
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, bool spearman = true,
|
|
36
|
+
inline Indicator IC(const Indicator& ind, const Block& blk, int n = 1, bool spearman = true,
|
|
45
37
|
bool strict = false) {
|
|
46
|
-
return IC(blk,
|
|
38
|
+
return IC(blk, n, spearman, strict)(ind);
|
|
47
39
|
}
|
|
48
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @brief 计算指定的因子列表相对于指定的收益列表的
|
|
43
|
+
* IC,其中,inds和returns均为已经计算好并按日期对齐后的结果。inds不需要按n右移。
|
|
44
|
+
* @note 仅为数值计算,返回结果无对齐日期
|
|
45
|
+
* @param inds 因子列表,inds不需要按n右移。
|
|
46
|
+
* @param returns 收益列表
|
|
47
|
+
* @param n 时间窗口 (对应 n 日收益率)
|
|
48
|
+
* @param use_spearman 使用 spearman 相关系数,否则为 pearson
|
|
49
|
+
* @param strict 严格模式, 遵循IC定义“t 时刻因子值→t+1 时刻收益”
|
|
50
|
+
*/
|
|
51
|
+
Indicator HKU_API IC(IndicatorList inds, IndicatorList returns, int n = 1, bool use_spearman = true,
|
|
52
|
+
bool strict = false);
|
|
53
|
+
|
|
49
54
|
} // namespace hku
|
|
@@ -22,7 +22,6 @@ namespace hku {
|
|
|
22
22
|
* @param ind 因子公式
|
|
23
23
|
* @param stks 证券组合
|
|
24
24
|
* @param query 查询条件
|
|
25
|
-
* @param ref_stk 参照证券,默认 sh000300 沪深300
|
|
26
25
|
* @param n IC对应的N日收益率
|
|
27
26
|
* @param rolling_n 滚动时间窗口
|
|
28
27
|
* @param spearman 使用 spearman 相关系数,否则为 pearson
|
|
@@ -30,10 +29,9 @@ namespace hku {
|
|
|
30
29
|
* @return Indicator
|
|
31
30
|
* @ingroup Indicator
|
|
32
31
|
*/
|
|
33
|
-
inline Indicator ICIR(const Indicator& ind, const StockList& stks,
|
|
34
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, int rolling_n = 120,
|
|
32
|
+
inline Indicator ICIR(const Indicator& ind, const StockList& stks, int n = 1, int rolling_n = 120,
|
|
35
33
|
bool spearman = true, bool strict = false) {
|
|
36
|
-
Indicator ic = IC(ind, stks,
|
|
34
|
+
Indicator ic = IC(ind, stks, n, spearman, strict);
|
|
37
35
|
Indicator x = MA(ic, rolling_n) / STDEV(ic, rolling_n);
|
|
38
36
|
x.name("ICIR");
|
|
39
37
|
x.setParam<int>("n", n);
|
|
@@ -41,10 +39,9 @@ inline Indicator ICIR(const Indicator& ind, const StockList& stks, const KQuery&
|
|
|
41
39
|
return x;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
inline Indicator ICIR(const Indicator& ind, const Block& blk,
|
|
45
|
-
const Stock& ref_stk = getStock("sh000300"), int n = 1, int rolling_n = 120,
|
|
42
|
+
inline Indicator ICIR(const Indicator& ind, const Block& blk, int n = 1, int rolling_n = 120,
|
|
46
43
|
bool spearman = true, bool strict = false) {
|
|
47
|
-
Indicator ic = IC(ind, blk,
|
|
44
|
+
Indicator ic = IC(ind, blk, n, spearman, strict);
|
|
48
45
|
Indicator x = MA(ic, rolling_n) / STDEV(ic, rolling_n);
|
|
49
46
|
x.name("ICIR");
|
|
50
47
|
x.setParam<int>("n", n);
|
|
@@ -23,6 +23,9 @@ public:
|
|
|
23
23
|
IAdvance();
|
|
24
24
|
virtual ~IAdvance();
|
|
25
25
|
virtual void _checkParam(const string& name) const override;
|
|
26
|
+
|
|
27
|
+
virtual bool supportIncrementCalculate() const override;
|
|
28
|
+
virtual void _increment_calculate(const Indicator& ind, size_t start_pos) override;
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
} /* namespace hku */
|
|
@@ -21,6 +21,7 @@ namespace hku {
|
|
|
21
21
|
*/
|
|
22
22
|
class IAma : public IndicatorImp {
|
|
23
23
|
INDICATOR_IMP(IAma)
|
|
24
|
+
INDICATOR_IMP_SUPPORT_INCREMENT
|
|
24
25
|
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
25
26
|
|
|
26
27
|
public:
|
|
@@ -30,6 +31,8 @@ public:
|
|
|
30
31
|
virtual void _checkParam(const string& name) const override;
|
|
31
32
|
virtual void _dyn_calculate(const Indicator&) override;
|
|
32
33
|
|
|
34
|
+
virtual size_t min_increment_start() const override;
|
|
35
|
+
|
|
33
36
|
private:
|
|
34
37
|
void _dyn_one_circle(const Indicator& ind, size_t curPos, int n, int fast_n, int slow_n);
|
|
35
38
|
};
|
|
@@ -15,16 +15,15 @@ namespace hku {
|
|
|
15
15
|
|
|
16
16
|
class IAtr : public IndicatorImp {
|
|
17
17
|
INDICATOR_IMP(IAtr)
|
|
18
|
-
|
|
18
|
+
INDICATOR_IMP_SUPPORT_INCREMENT
|
|
19
19
|
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
20
20
|
|
|
21
21
|
public:
|
|
22
22
|
IAtr();
|
|
23
|
-
explicit IAtr(const KData&, int n);
|
|
24
23
|
virtual ~IAtr();
|
|
25
24
|
virtual void _checkParam(const string& name) const override;
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
} /* namespace hku */
|
|
29
28
|
|
|
30
|
-
#endif /* INDICATOR_IMP_ATR_H_ */
|
|
29
|
+
#endif /* INDICATOR_IMP_ATR_H_ */
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
namespace hku {
|
|
17
17
|
|
|
18
18
|
class IBackset : public IndicatorImp {
|
|
19
|
-
|
|
19
|
+
INDICATOR_IMP(IBackset)
|
|
20
|
+
INDICATOR_IMP_SUPPORT_DYNAMIC_CYCLE
|
|
20
21
|
INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION
|
|
21
22
|
|
|
22
23
|
public:
|
|
@@ -24,9 +25,6 @@ public:
|
|
|
24
25
|
virtual ~IBackset();
|
|
25
26
|
|
|
26
27
|
virtual void _checkParam(const string& name) const override;
|
|
27
|
-
virtual bool isSerial() const override {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
} /* namespace hku */
|