hikyuu 2.7.2__py3-none-win_amd64.whl → 2.7.5__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 +21 -7
- hikyuu/__init__.pyi +16 -14
- hikyuu/analysis/__init__.pyi +2 -0
- hikyuu/analysis/analysis.pyi +3 -1
- hikyuu/core.pyi +4 -2
- hikyuu/cpp/boost_date_time-mt.dll +0 -0
- hikyuu/cpp/boost_serialization-mt.dll +0 -0
- hikyuu/cpp/boost_wserialization-mt.dll +0 -0
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +123 -62
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +123 -62
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +123 -62
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +123 -62
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +0 -0
- hikyuu/cpp/i18n/zh_CN/hikyuu.mo +0 -0
- hikyuu/cpp/mimalloc-redirect.dll +0 -0
- hikyuu/cpp/mimalloc.dll +0 -0
- hikyuu/data/clickhouse_upgrade/0002.sql +9 -0
- hikyuu/data/common_mysql.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 +21 -3
- hikyuu/data/mysql_upgrade/0030.sql +3 -0
- hikyuu/data/pytdx_to_h5.py +2 -2
- hikyuu/data/pytdx_to_mysql.py +5 -5
- 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/bokeh_draw.pyi +8 -6
- hikyuu/draw/drawplot/echarts_draw.pyi +8 -6
- hikyuu/draw/drawplot/matplotlib_draw.py +19 -11
- hikyuu/draw/drawplot/matplotlib_draw.pyi +8 -6
- 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 +5 -3
- hikyuu/gui/HikyuuTDX.py +20 -0
- hikyuu/gui/data/MainWindow.py +169 -133
- 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 +24 -12
- hikyuu/include/hikyuu/StockTypeInfo.h +9 -9
- hikyuu/include/hikyuu/StockWeight.h +9 -9
- 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 +1 -1
- 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 +146 -73
- 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/extind.h +3 -0
- hikyuu/include/hikyuu/plugin/hkuextra.h +2 -0
- hikyuu/include/hikyuu/plugin/interface/HkuExtraPluginInterface.h +2 -0
- hikyuu/include/hikyuu/python/pybind_utils.h +22 -5
- hikyuu/include/hikyuu/trade_manage/TradeCostBase.h +5 -3
- hikyuu/include/hikyuu/trade_manage/TradeManagerBase.h +9 -3
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +8 -4
- 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 +4 -3
- 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/LruCache.h +299 -0
- hikyuu/include/hikyuu/utilities/arithmetic.h +2 -2
- hikyuu/include/hikyuu/utilities/omp_macro.h +25 -0
- hikyuu/include/hikyuu/utilities/plugin/PluginManager.h +5 -0
- hikyuu/include/hikyuu/utilities/thread/GlobalStealThreadPool.h +72 -19
- hikyuu/include/hikyuu/utilities/thread/GlobalThreadPool.h +0 -4
- hikyuu/include/hikyuu/utilities/thread/MQStealThreadPool.h +1 -0
- hikyuu/include/hikyuu/utilities/thread/MQThreadPool.h +1 -0
- hikyuu/include/hikyuu/utilities/thread/StealThreadPool.h +1 -0
- hikyuu/include/hikyuu/utilities/thread/ThreadPool.h +1 -4
- hikyuu/include/hikyuu/utilities/thread/algorithm.h +286 -0
- hikyuu/include/hikyuu/version.h +4 -4
- hikyuu/plugin/backtest.dll +0 -0
- hikyuu/plugin/checkdata.dll +0 -0
- hikyuu/plugin/clickhousedriver.dll +0 -0
- hikyuu/plugin/dataserver.dll +0 -0
- hikyuu/plugin/dataserver_parquet.dll +0 -0
- hikyuu/plugin/device.dll +0 -0
- hikyuu/plugin/extind.dll +0 -0
- hikyuu/plugin/hkuextra.dll +0 -0
- hikyuu/plugin/import2ch.dll +0 -0
- hikyuu/plugin/import2hdf5.dll +0 -0
- hikyuu/plugin/import2mysql.dll +0 -0
- hikyuu/plugin/tmreport.dll +0 -0
- hikyuu/test/Indicator.py +1 -2
- hikyuu/trade_manage/__init__.pyi +7 -5
- hikyuu/trade_manage/trade.pyi +7 -5
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.7.2.dist-info → hikyuu-2.7.5.dist-info}/METADATA +2 -13
- {hikyuu-2.7.2.dist-info → hikyuu-2.7.5.dist-info}/RECORD +232 -225
- {hikyuu-2.7.2.dist-info → hikyuu-2.7.5.dist-info}/WHEEL +1 -1
- {hikyuu-2.7.2.dist-info → hikyuu-2.7.5.dist-info}/entry_points.txt +0 -0
- {hikyuu-2.7.2.dist-info → hikyuu-2.7.5.dist-info}/top_level.txt +0 -0
|
@@ -109,9 +109,8 @@ public:
|
|
|
109
109
|
return m_values.cend();
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return false;
|
|
112
|
+
bool isPythonObject() const noexcept {
|
|
113
|
+
return m_is_python_object;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
protected:
|
|
@@ -121,6 +120,7 @@ protected:
|
|
|
121
120
|
SGPtr m_sg;
|
|
122
121
|
map<Datetime, size_t> m_date_index;
|
|
123
122
|
vector<price_t> m_values;
|
|
123
|
+
bool m_is_python_object{false};
|
|
124
124
|
|
|
125
125
|
//============================================
|
|
126
126
|
// 序列化支持
|
|
@@ -134,6 +134,7 @@ private:
|
|
|
134
134
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
135
135
|
ar& BOOST_SERIALIZATION_NVP(m_date_index);
|
|
136
136
|
ar& BOOST_SERIALIZATION_NVP(m_values);
|
|
137
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
137
138
|
// m_kdata/m_tm/m_sg是系统运行时临时设置,不需要序列化
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -143,6 +144,7 @@ private:
|
|
|
143
144
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
144
145
|
ar& BOOST_SERIALIZATION_NVP(m_date_index);
|
|
145
146
|
ar& BOOST_SERIALIZATION_NVP(m_values);
|
|
147
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
146
148
|
// m_kdata/m_tm/m_sg是系统运行时临时设置,不需要序列化
|
|
147
149
|
}
|
|
148
150
|
|
|
@@ -93,9 +93,8 @@ public:
|
|
|
93
93
|
/** 子类克隆接口 */
|
|
94
94
|
virtual EnvironmentPtr _clone() = 0;
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return false;
|
|
96
|
+
bool isPythonObject() const noexcept {
|
|
97
|
+
return m_is_python_object;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
protected:
|
|
@@ -105,6 +104,8 @@ protected:
|
|
|
105
104
|
vector<price_t> m_values;
|
|
106
105
|
mutable std::shared_mutex m_mutex;
|
|
107
106
|
|
|
107
|
+
bool m_is_python_object{false};
|
|
108
|
+
|
|
108
109
|
//============================================
|
|
109
110
|
// 序列化支持
|
|
110
111
|
//============================================
|
|
@@ -119,6 +120,7 @@ private:
|
|
|
119
120
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
120
121
|
ar& BOOST_SERIALIZATION_NVP(m_date_index);
|
|
121
122
|
ar& BOOST_SERIALIZATION_NVP(m_values);
|
|
123
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
template <class Archive>
|
|
@@ -128,6 +130,7 @@ private:
|
|
|
128
130
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
129
131
|
ar& BOOST_SERIALIZATION_NVP(m_date_index);
|
|
130
132
|
ar& BOOST_SERIALIZATION_NVP(m_values);
|
|
133
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
|
@@ -152,9 +152,8 @@ public:
|
|
|
152
152
|
/** 子类克隆私有变量接口 */
|
|
153
153
|
virtual MoneyManagerPtr _clone() = 0;
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return false;
|
|
155
|
+
bool isPythonObject() const noexcept {
|
|
156
|
+
return m_is_python_object;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
protected:
|
|
@@ -162,6 +161,7 @@ protected:
|
|
|
162
161
|
KQuery m_query;
|
|
163
162
|
TradeManagerPtr m_tm;
|
|
164
163
|
unordered_map<Stock, std::pair<size_t, size_t>> m_buy_sell_counts;
|
|
164
|
+
bool m_is_python_object{false};
|
|
165
165
|
|
|
166
166
|
//============================================
|
|
167
167
|
// 序列化支持
|
|
@@ -173,6 +173,7 @@ private:
|
|
|
173
173
|
void save(Archive& ar, const unsigned int version) const {
|
|
174
174
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
175
175
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
176
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
176
177
|
// m_query、m_tm都是系统运行时临时设置,不需要序列化
|
|
177
178
|
// ar & BOOST_SERIALIZATION_NVP(m_query);
|
|
178
179
|
// ar & BOOST_SERIALIZATION_NVP(m_tm);
|
|
@@ -182,6 +183,7 @@ private:
|
|
|
182
183
|
void load(Archive& ar, const unsigned int version) {
|
|
183
184
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
184
185
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
186
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
|
@@ -164,35 +164,44 @@ public:
|
|
|
164
164
|
virtual MultiFactorPtr _clone() = 0;
|
|
165
165
|
virtual IndicatorList _calculate(const vector<IndicatorList>&) = 0;
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return false;
|
|
167
|
+
bool isPythonObject() const noexcept {
|
|
168
|
+
return m_is_python_object;
|
|
170
169
|
}
|
|
171
170
|
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
/**
|
|
172
|
+
* 执行计算。默认取结果时,会自动计算。但并行使用mf时,应主动调用该接口
|
|
173
|
+
* @note 因获取scores非常频繁,所以为使用锁。
|
|
174
|
+
* 这样的话,在并行时并不完备。在需要并行计算时可主动调用该接口。
|
|
175
|
+
*/
|
|
174
176
|
void calculate();
|
|
175
177
|
|
|
178
|
+
private:
|
|
176
179
|
void initParam();
|
|
177
180
|
|
|
178
181
|
// 构造每个指标构造行业哑变量,以便进行行业中性化处理
|
|
179
182
|
unordered_map<string, PriceList> _buildDummyIndex();
|
|
180
183
|
|
|
181
|
-
void _buildIndex();
|
|
182
|
-
void _buildIndexDesc(); // 创建降序排列的索引
|
|
183
|
-
void _buildIndexAsc(); // 创建升序排列的索引
|
|
184
|
-
void _buildIndexNone(); // build index when no index
|
|
184
|
+
void _buildIndex(); // 计算完成后创建截面索引
|
|
185
185
|
|
|
186
|
-
IndicatorList _getAllReturns(int ndays) const;
|
|
187
186
|
void _checkData();
|
|
188
187
|
|
|
189
188
|
protected:
|
|
189
|
+
IndicatorList _getAllReturns(int ndays) const;
|
|
190
|
+
|
|
191
|
+
protected:
|
|
192
|
+
bool m_is_python_object{false};
|
|
190
193
|
string m_name;
|
|
191
|
-
IndicatorList m_inds; //
|
|
194
|
+
IndicatorList m_inds; // 输入的原始因子公式列表
|
|
192
195
|
StockList m_stks; // 证券组合
|
|
193
|
-
Stock m_ref_stk; //
|
|
196
|
+
Stock m_ref_stk; // 指定的参考证券, 仅为对齐日期
|
|
194
197
|
KQuery m_query; // 计算的日期范围条件
|
|
195
198
|
|
|
199
|
+
NormPtr m_norm; // 全局标准化/归一化操作
|
|
200
|
+
unordered_map<string, NormPtr> m_special_norms; // 对特定指标执行特定的标准化操作
|
|
201
|
+
unordered_map<string, string> m_special_category; // 对特定指标执行行业中性化时指定的板块分类
|
|
202
|
+
unordered_map<string, IndicatorList>
|
|
203
|
+
m_special_style_inds; // 对特定指标执行风格因子中性化时指定的风格因子
|
|
204
|
+
|
|
196
205
|
// 以下变量为计算后生成
|
|
197
206
|
DatetimeList m_ref_dates; // 依据参考证券和query计算的参考日期,合成因子和该日期对齐
|
|
198
207
|
unordered_map<Stock, size_t> m_stk_map; // 证券->合成后因子位置索引
|
|
@@ -201,12 +210,6 @@ protected:
|
|
|
201
210
|
vector<ScoreRecordList> m_stk_factor_by_date;
|
|
202
211
|
Indicator m_ic;
|
|
203
212
|
|
|
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
|
-
|
|
210
213
|
private:
|
|
211
214
|
std::mutex m_mutex;
|
|
212
215
|
bool m_calculated{false};
|
|
@@ -219,13 +222,13 @@ private:
|
|
|
219
222
|
friend class boost::serialization::access;
|
|
220
223
|
template <class Archive>
|
|
221
224
|
void save(Archive& ar, const unsigned int version) const {
|
|
225
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
222
226
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
223
227
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
224
228
|
ar& BOOST_SERIALIZATION_NVP(m_inds);
|
|
225
229
|
ar& BOOST_SERIALIZATION_NVP(m_stks);
|
|
226
230
|
ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
|
|
227
231
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
228
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
|
|
229
232
|
ar& BOOST_SERIALIZATION_NVP(m_special_norms);
|
|
230
233
|
ar& BOOST_SERIALIZATION_NVP(m_special_category);
|
|
231
234
|
// 以下不需要保存,加载后重新计算
|
|
@@ -239,13 +242,13 @@ private:
|
|
|
239
242
|
|
|
240
243
|
template <class Archive>
|
|
241
244
|
void load(Archive& ar, const unsigned int version) {
|
|
245
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
242
246
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
243
247
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
244
248
|
ar& BOOST_SERIALIZATION_NVP(m_inds);
|
|
245
249
|
ar& BOOST_SERIALIZATION_NVP(m_stks);
|
|
246
250
|
ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
|
|
247
251
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
248
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
|
|
249
252
|
ar& BOOST_SERIALIZATION_NVP(m_special_norms);
|
|
250
253
|
ar& BOOST_SERIALIZATION_NVP(m_special_category);
|
|
251
254
|
// ar& BOOST_SERIALIZATION_NVP(m_stk_map);
|
|
@@ -42,13 +42,13 @@ public:
|
|
|
42
42
|
|
|
43
43
|
virtual PriceList normalize(const PriceList& data) = 0;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return false;
|
|
45
|
+
bool isPythonObject() const noexcept {
|
|
46
|
+
return m_is_python_object;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
protected:
|
|
51
50
|
string m_name;
|
|
51
|
+
bool m_is_python_object{false};
|
|
52
52
|
|
|
53
53
|
//============================================
|
|
54
54
|
// 序列化支持
|
|
@@ -59,12 +59,14 @@ private:
|
|
|
59
59
|
template <class Archive>
|
|
60
60
|
void save(Archive& ar, const unsigned int version) const {
|
|
61
61
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
62
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
62
63
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
template <class Archive>
|
|
66
67
|
void load(Archive& ar, const unsigned int version) {
|
|
67
68
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
69
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
68
70
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -73,7 +75,7 @@ private:
|
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
#if HKU_SUPPORT_SERIALIZATION
|
|
76
|
-
BOOST_SERIALIZATION_ASSUME_ABSTRACT(
|
|
78
|
+
BOOST_SERIALIZATION_ASSUME_ABSTRACT(NormalizeBase)
|
|
77
79
|
#endif
|
|
78
80
|
|
|
79
81
|
#if HKU_SUPPORT_SERIALIZATION
|
|
@@ -49,14 +49,14 @@ public:
|
|
|
49
49
|
public:
|
|
50
50
|
friend HKU_API ScoresFilterPtr operator|(const ScoresFilterPtr& a, const ScoresFilterPtr& b);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return false;
|
|
52
|
+
bool isPythonObject() const noexcept {
|
|
53
|
+
return m_is_python_object;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
protected:
|
|
58
57
|
string m_name;
|
|
59
58
|
ScoresFilterPtr m_child;
|
|
59
|
+
bool m_is_python_object{false};
|
|
60
60
|
|
|
61
61
|
//============================================
|
|
62
62
|
// 序列化支持
|
|
@@ -69,6 +69,7 @@ private:
|
|
|
69
69
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
70
70
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
71
71
|
ar& BOOST_SERIALIZATION_NVP(m_child);
|
|
72
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
template <class Archive>
|
|
@@ -76,6 +77,7 @@ private:
|
|
|
76
77
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
77
78
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
78
79
|
ar& BOOST_SERIALIZATION_NVP(m_child);
|
|
80
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
|
@@ -15,7 +15,7 @@ namespace hku {
|
|
|
15
15
|
* @param inds 原始因子列表
|
|
16
16
|
* @param stks 计算证券列表
|
|
17
17
|
* @param query 日期范围
|
|
18
|
-
* @param ref_stk
|
|
18
|
+
* @param ref_stk 参考证券, 用于日期对齐, 未指定时为 SH000001
|
|
19
19
|
* @param ic_n 默认 IC 对应的 N 日收益率
|
|
20
20
|
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
21
21
|
* @param mode 获取截面数据时排序模式: 0-降序, 1-升序, 2-不排序
|
|
@@ -23,8 +23,8 @@ namespace hku {
|
|
|
23
23
|
* @return MultiFactorPtr
|
|
24
24
|
*/
|
|
25
25
|
MultiFactorPtr HKU_API MF_EqualWeight(const IndicatorList& inds, const StockList& stks,
|
|
26
|
-
const KQuery& query, const Stock& ref_stk
|
|
27
|
-
bool spearman = true, int mode = 0,
|
|
26
|
+
const KQuery& query, const Stock& ref_stk = Stock(),
|
|
27
|
+
int ic_n = 5, bool spearman = true, int mode = 0,
|
|
28
28
|
bool save_all_factors = false);
|
|
29
29
|
|
|
30
30
|
MultiFactorPtr HKU_API MF_EqualWeight();
|
|
@@ -16,7 +16,7 @@ namespace hku {
|
|
|
16
16
|
* @param inds 原始因子列表
|
|
17
17
|
* @param stks 计算证券列表
|
|
18
18
|
* @param query 日期范围
|
|
19
|
-
* @param ref_stk
|
|
19
|
+
* @param ref_stk 参考证券,用于日期对齐,未指定时为 sh000001
|
|
20
20
|
* @param ic_n 默认 IC 对应的 N 日收益率
|
|
21
21
|
* @param ic_rolling_n IC 滚动窗口
|
|
22
22
|
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
@@ -25,9 +25,9 @@ namespace hku {
|
|
|
25
25
|
* @return MultiFactorPtr
|
|
26
26
|
*/
|
|
27
27
|
MultiFactorPtr HKU_API MF_ICIRWeight(const IndicatorList& inds, const StockList& stks,
|
|
28
|
-
const KQuery& query, const Stock& ref_stk
|
|
29
|
-
int
|
|
30
|
-
bool save_all_factors = false);
|
|
28
|
+
const KQuery& query, const Stock& ref_stk = Stock(),
|
|
29
|
+
int ic_n = 5, int ic_rolling_n = 120, bool spearman = true,
|
|
30
|
+
int mode = 0, bool save_all_factors = false);
|
|
31
31
|
|
|
32
32
|
MultiFactorPtr HKU_API MF_ICIRWeight();
|
|
33
33
|
} // namespace hku
|
|
@@ -16,7 +16,7 @@ namespace hku {
|
|
|
16
16
|
* @param inds 原始因子列表
|
|
17
17
|
* @param stks 计算证券列表
|
|
18
18
|
* @param query 日期范围
|
|
19
|
-
* @param ref_stk
|
|
19
|
+
* @param ref_stk 参考证券,用于日期对齐,未指定时为 sh000001
|
|
20
20
|
* @param ic_n 默认 IC 对应的 N 日收益率
|
|
21
21
|
* @param ic_rolling_n IC 滚动窗口
|
|
22
22
|
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
@@ -25,9 +25,9 @@ namespace hku {
|
|
|
25
25
|
* @return MultiFactorPtr
|
|
26
26
|
*/
|
|
27
27
|
MultiFactorPtr HKU_API MF_ICWeight(const IndicatorList& inds, const StockList& stks,
|
|
28
|
-
const KQuery& query, const Stock& ref_stk
|
|
29
|
-
int
|
|
30
|
-
bool save_all_factors = false);
|
|
28
|
+
const KQuery& query, const Stock& ref_stk = Stock(),
|
|
29
|
+
int ic_n = 5, int ic_rolling_n = 120, bool spearman = true,
|
|
30
|
+
int mode = 0, bool save_all_factors = false);
|
|
31
31
|
MultiFactorPtr HKU_API MF_ICWeight();
|
|
32
32
|
|
|
33
33
|
} // namespace hku
|
|
@@ -16,7 +16,7 @@ namespace hku {
|
|
|
16
16
|
* @param weights 权重列表
|
|
17
17
|
* @param stks 计算证券列表
|
|
18
18
|
* @param query 日期范围
|
|
19
|
-
* @param ref_stk
|
|
19
|
+
* @param ref_stk 参考证券,用于日期对齐,未指定时为 sh000001
|
|
20
20
|
* @param ic_n 默认 IC 对应的 N 日收益率
|
|
21
21
|
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
22
22
|
* @param mode 获取截面数据时排序模式: 0-降序, 1-升序, 2-不排序
|
|
@@ -24,9 +24,9 @@ namespace hku {
|
|
|
24
24
|
* @return MultiFactorPtr
|
|
25
25
|
*/
|
|
26
26
|
MultiFactorPtr HKU_API MF_Weight(const IndicatorList& inds, const PriceList& weights,
|
|
27
|
-
const StockList& stks, const KQuery& query,
|
|
28
|
-
int ic_n = 5, bool spearman = true,
|
|
29
|
-
bool save_all_factors = false);
|
|
27
|
+
const StockList& stks, const KQuery& query,
|
|
28
|
+
const Stock& ref_stk = Stock(), int ic_n = 5, bool spearman = true,
|
|
29
|
+
int mode = 0, bool save_all_factors = false);
|
|
30
30
|
|
|
31
31
|
MultiFactorPtr HKU_API MF_Weight();
|
|
32
32
|
|
|
@@ -88,7 +88,7 @@ public:
|
|
|
88
88
|
|
|
89
89
|
/** 克隆操作 */
|
|
90
90
|
typedef shared_ptr<Portfolio> PortfolioPtr;
|
|
91
|
-
PortfolioPtr clone()
|
|
91
|
+
PortfolioPtr clone();
|
|
92
92
|
|
|
93
93
|
/** 运行前准备 */
|
|
94
94
|
void readyForRun();
|
|
@@ -99,7 +99,7 @@ public:
|
|
|
99
99
|
virtual string str() const;
|
|
100
100
|
|
|
101
101
|
virtual void _reset() {}
|
|
102
|
-
virtual PortfolioPtr _clone()
|
|
102
|
+
virtual PortfolioPtr _clone() {
|
|
103
103
|
return std::make_shared<Portfolio>();
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -113,6 +113,10 @@ public:
|
|
|
113
113
|
*/
|
|
114
114
|
virtual json lastSuggestion() const;
|
|
115
115
|
|
|
116
|
+
bool isPythonObject() const noexcept {
|
|
117
|
+
return m_is_python_object;
|
|
118
|
+
}
|
|
119
|
+
|
|
116
120
|
private:
|
|
117
121
|
void initParam();
|
|
118
122
|
|
|
@@ -122,10 +126,6 @@ private:
|
|
|
122
126
|
const string& mode);
|
|
123
127
|
|
|
124
128
|
protected:
|
|
125
|
-
virtual bool isPythonObject() const {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
129
|
// 跟踪打印当前TM持仓情况
|
|
130
130
|
void traceMomentTMAfterRunAtOpen(const Datetime& date);
|
|
131
131
|
void traceMomentTMAfterRunAtClose(const Datetime& date);
|
|
@@ -139,6 +139,7 @@ protected:
|
|
|
139
139
|
|
|
140
140
|
KQuery m_query; // 关联的查询条件
|
|
141
141
|
bool m_need_calculate; // 是否需要计算标志
|
|
142
|
+
bool m_is_python_object{false};
|
|
142
143
|
|
|
143
144
|
SystemList m_real_sys_list; // 所有实际运行的子系统列表
|
|
144
145
|
|
|
@@ -160,6 +161,7 @@ private:
|
|
|
160
161
|
ar& BOOST_SERIALIZATION_NVP(m_se);
|
|
161
162
|
ar& BOOST_SERIALIZATION_NVP(m_af);
|
|
162
163
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
164
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
template <class Archive>
|
|
@@ -171,19 +173,20 @@ private:
|
|
|
171
173
|
ar& BOOST_SERIALIZATION_NVP(m_se);
|
|
172
174
|
ar& BOOST_SERIALIZATION_NVP(m_af);
|
|
173
175
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
176
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
|
177
180
|
#endif /* HKU_SUPPORT_SERIALIZATION */
|
|
178
181
|
};
|
|
179
182
|
|
|
180
|
-
#define PORTFOLIO_IMP(classname)
|
|
181
|
-
public:
|
|
182
|
-
virtual PortfolioPtr _clone()
|
|
183
|
-
return std::make_shared<classname>();
|
|
184
|
-
}
|
|
185
|
-
virtual void _reset() override;
|
|
186
|
-
virtual void _readyForRun() override;
|
|
183
|
+
#define PORTFOLIO_IMP(classname) \
|
|
184
|
+
public: \
|
|
185
|
+
virtual PortfolioPtr _clone() override { \
|
|
186
|
+
return std::make_shared<classname>(); \
|
|
187
|
+
} \
|
|
188
|
+
virtual void _reset() override; \
|
|
189
|
+
virtual void _readyForRun() override; \
|
|
187
190
|
virtual void _runMoment(const Datetime& date, const Datetime& nextCycle, bool adjust) override;
|
|
188
191
|
|
|
189
192
|
/**
|
|
@@ -82,11 +82,12 @@ public:
|
|
|
82
82
|
/** 子类计算接口,由setTO调用 */
|
|
83
83
|
virtual void _calculate() {}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return false;
|
|
85
|
+
bool isPythonObject() const noexcept {
|
|
86
|
+
return m_is_python_object;
|
|
88
87
|
}
|
|
89
88
|
|
|
89
|
+
bool m_is_python_object{false};
|
|
90
|
+
|
|
90
91
|
protected:
|
|
91
92
|
string m_name;
|
|
92
93
|
KData m_kdata;
|
|
@@ -153,6 +153,11 @@ public:
|
|
|
153
153
|
return m_mf;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
void setMF(const MFPtr& mf) {
|
|
157
|
+
m_mf = mf;
|
|
158
|
+
m_calculated = false;
|
|
159
|
+
}
|
|
160
|
+
|
|
156
161
|
ScoresFilterPtr getScoresFilter() const {
|
|
157
162
|
return m_sc_filter;
|
|
158
163
|
}
|
|
@@ -163,9 +168,8 @@ public:
|
|
|
163
168
|
/** 在已有过滤基础上追加过滤,仅用于 MF 相关的 Selector,从 MF 获取 Score 列表时进行过滤 */
|
|
164
169
|
void addScoresFilter(const ScoresFilterPtr& filter);
|
|
165
170
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return false;
|
|
171
|
+
bool isPythonObject() const noexcept {
|
|
172
|
+
return m_is_python_object;
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
private:
|
|
@@ -177,6 +181,7 @@ protected:
|
|
|
177
181
|
|
|
178
182
|
protected:
|
|
179
183
|
string m_name;
|
|
184
|
+
bool m_is_python_object{false};
|
|
180
185
|
bool m_calculated{false}; // 是否已计算过
|
|
181
186
|
bool m_proto_calculated{false};
|
|
182
187
|
KQuery m_query;
|
|
@@ -196,6 +201,7 @@ private:
|
|
|
196
201
|
template <class Archive>
|
|
197
202
|
void save(Archive& ar, const unsigned int version) const {
|
|
198
203
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
204
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
199
205
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
200
206
|
ar& BOOST_SERIALIZATION_NVP(m_pro_sys_list);
|
|
201
207
|
ar& BOOST_SERIALIZATION_NVP(m_sc_filter);
|
|
@@ -205,6 +211,7 @@ private:
|
|
|
205
211
|
template <class Archive>
|
|
206
212
|
void load(Archive& ar, const unsigned int version) {
|
|
207
213
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
214
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
208
215
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
209
216
|
ar& BOOST_SERIALIZATION_NVP(m_pro_sys_list);
|
|
210
217
|
ar& BOOST_SERIALIZATION_NVP(m_sc_filter);
|
|
@@ -281,10 +288,12 @@ inline const SystemList& SelectorBase::getProtoSystemList() const {
|
|
|
281
288
|
|
|
282
289
|
inline void SelectorBase::setScoresFilter(const ScoresFilterPtr& filter) {
|
|
283
290
|
m_sc_filter = filter;
|
|
291
|
+
m_calculated = false;
|
|
284
292
|
}
|
|
285
293
|
|
|
286
294
|
inline void SelectorBase::addScoresFilter(const ScoresFilterPtr& filter) {
|
|
287
295
|
m_sc_filter = m_sc_filter | filter;
|
|
296
|
+
m_calculated = false;
|
|
288
297
|
}
|
|
289
298
|
|
|
290
299
|
} /* namespace hku */
|
|
@@ -27,7 +27,7 @@ SelectorPtr HKU_API SE_MultiFactor(const MFPtr& mf, int topn = 10);
|
|
|
27
27
|
* @param topn 只选取时间截面中前 topn 个系统,小于等于0时代表不限制
|
|
28
28
|
* @param ic_n ic 对应的 ic_n 日收益率
|
|
29
29
|
* @param ic_rolling_n 计算滚动 IC (即 IC 的 n 日移动平均)周期
|
|
30
|
-
* @param ref_stk
|
|
30
|
+
* @param ref_stk 参考证券,用于日期对齐,未指定时为 sh000001
|
|
31
31
|
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
32
32
|
* @param mode "MF_ICIRWeight" | "MF_ICWeight" | "MF_EqualWeight" 因子合成算法名称
|
|
33
33
|
* @return SelectorPtr
|
|
@@ -26,7 +26,7 @@ SelectorPtr HKU_API SE_MultiFactor2(const MFPtr& mf,
|
|
|
26
26
|
* @param src_inds 原始因子公式
|
|
27
27
|
* @param ic_n ic 对应的 ic_n 日收益率
|
|
28
28
|
* @param ic_rolling_n 计算滚动 IC (即 IC 的 n 日移动平均)周期
|
|
29
|
-
* @param ref_stk
|
|
29
|
+
* @param ref_stk 参考证券,用于日期对齐,未指定时为 sh000001
|
|
30
30
|
* @param spearman 默认使用 spearman 计算相关系数,否则为 pearson
|
|
31
31
|
* @param mode "MF_ICIRWeight" | "MF_ICWeight" | "MF_EqualWeight" 因子合成算法名称
|
|
32
32
|
* @return SelectorPtr
|
|
@@ -54,8 +54,6 @@ public:
|
|
|
54
54
|
|
|
55
55
|
private:
|
|
56
56
|
void _initParams();
|
|
57
|
-
void _calculate_single(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
58
|
-
const DatetimeList& dates, size_t test_len, bool trace);
|
|
59
57
|
|
|
60
58
|
void _calculate_parallel(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
61
59
|
const DatetimeList& dates, size_t test_len, bool trace);
|
|
@@ -27,10 +27,6 @@ public:
|
|
|
27
27
|
virtual void _reset() override;
|
|
28
28
|
|
|
29
29
|
private:
|
|
30
|
-
void _calculate_single(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
31
|
-
const DatetimeList& dates, const string& key, int mode, size_t test_len,
|
|
32
|
-
bool trace);
|
|
33
|
-
|
|
34
30
|
void _calculate_parallel(const vector<std::pair<size_t, size_t>>& train_ranges,
|
|
35
31
|
const DatetimeList& dates, const string& key, int mode,
|
|
36
32
|
size_t test_len, bool trace);
|
|
@@ -130,9 +130,8 @@ public:
|
|
|
130
130
|
/** 子类计算接口,在setTO中调用 */
|
|
131
131
|
virtual void _calculate(const KData&) = 0;
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return false;
|
|
133
|
+
bool isPythonObject() const noexcept {
|
|
134
|
+
return m_is_python_object;
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
private:
|
|
@@ -141,6 +140,7 @@ private:
|
|
|
141
140
|
protected:
|
|
142
141
|
string m_name;
|
|
143
142
|
KData m_kdata;
|
|
143
|
+
bool m_is_python_object{false};
|
|
144
144
|
bool m_calculated{false}; // 仅针对 setTO 时的计算
|
|
145
145
|
|
|
146
146
|
/* 多头持仓 */
|
|
@@ -165,6 +165,7 @@ private:
|
|
|
165
165
|
void save(Archive& ar, const unsigned int version) const {
|
|
166
166
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
167
167
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
168
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
168
169
|
ar& BOOST_SERIALIZATION_NVP(m_hold_long);
|
|
169
170
|
ar& BOOST_SERIALIZATION_NVP(m_hold_short);
|
|
170
171
|
ar& BOOST_SERIALIZATION_NVP(m_buySig);
|
|
@@ -178,6 +179,7 @@ private:
|
|
|
178
179
|
void load(Archive& ar, const unsigned int version) {
|
|
179
180
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
180
181
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
182
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
181
183
|
ar& BOOST_SERIALIZATION_NVP(m_hold_long);
|
|
182
184
|
ar& BOOST_SERIALIZATION_NVP(m_hold_short);
|
|
183
185
|
ar& BOOST_SERIALIZATION_NVP(m_buySig);
|
|
@@ -71,14 +71,14 @@ public:
|
|
|
71
71
|
/** 子类计算接口,由setTO调用 */
|
|
72
72
|
virtual void _calculate() = 0;
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return false;
|
|
74
|
+
bool isPythonObject() const noexcept {
|
|
75
|
+
return m_is_python_object;
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
protected:
|
|
80
79
|
string m_name;
|
|
81
80
|
KData m_kdata;
|
|
81
|
+
bool m_is_python_object{false};
|
|
82
82
|
|
|
83
83
|
//============================================
|
|
84
84
|
// 序列化支持
|
|
@@ -89,12 +89,14 @@ private:
|
|
|
89
89
|
template <class Archive>
|
|
90
90
|
void save(Archive& ar, const unsigned int version) const {
|
|
91
91
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
92
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
92
93
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
template <class Archive>
|
|
96
97
|
void load(Archive& ar, const unsigned int version) {
|
|
97
98
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
99
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
98
100
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
99
101
|
}
|
|
100
102
|
|