hikyuu 2.7.3__py3-none-win_amd64.whl → 2.7.6__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 +3 -1
- hikyuu/__init__.pyi +11 -10
- hikyuu/analysis/__init__.pyi +1 -0
- hikyuu/analysis/analysis.pyi +2 -1
- hikyuu/core.pyi +3 -2
- hikyuu/cpp/core310.pyd +0 -0
- hikyuu/cpp/core310.pyi +80 -46
- hikyuu/cpp/core311.pyd +0 -0
- hikyuu/cpp/core311.pyi +80 -46
- hikyuu/cpp/core312.pyd +0 -0
- hikyuu/cpp/core312.pyi +80 -46
- hikyuu/cpp/core313.pyd +0 -0
- hikyuu/cpp/core313.pyi +80 -46
- hikyuu/cpp/hikyuu.dll +0 -0
- hikyuu/cpp/hikyuu.lib +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 +1 -1
- 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/draw/__init__.pyi +1 -1
- hikyuu/draw/drawplot/__init__.pyi +1 -1
- hikyuu/draw/drawplot/bokeh_draw.pyi +6 -5
- hikyuu/draw/drawplot/echarts_draw.pyi +6 -5
- hikyuu/draw/drawplot/matplotlib_draw.py +19 -11
- hikyuu/draw/drawplot/matplotlib_draw.pyi +6 -5
- 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 +3 -2
- 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 +11 -10
- 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/BlockInfoDriver.h +6 -0
- hikyuu/include/hikyuu/data_driver/KDataDriver.h +4 -3
- 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/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 -2
- hikyuu/include/hikyuu/trade_sys/allocatefunds/AllocateFundsBase.h +8 -3
- hikyuu/include/hikyuu/trade_sys/condition/ConditionBase.h +5 -2
- hikyuu/include/hikyuu/trade_sys/environment/EnvironmentBase.h +6 -2
- hikyuu/include/hikyuu/trade_sys/moneymanager/MoneyManagerBase.h +5 -2
- hikyuu/include/hikyuu/trade_sys/multifactor/MultiFactorBase.h +23 -19
- hikyuu/include/hikyuu/trade_sys/multifactor/NormalizeBase.h +6 -3
- hikyuu/include/hikyuu/trade_sys/multifactor/ScoresFilterBase.h +5 -2
- 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 +5 -2
- hikyuu/include/hikyuu/trade_sys/profitgoal/ProfitGoalBase.h +4 -2
- hikyuu/include/hikyuu/trade_sys/selector/SelectorBase.h +12 -2
- 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 -2
- hikyuu/include/hikyuu/trade_sys/slippage/SlippageBase.h +5 -2
- hikyuu/include/hikyuu/trade_sys/stoploss/StoplossBase.h +5 -2
- hikyuu/include/hikyuu/trade_sys/system/System.h +5 -2
- 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/ThreadPool.h +0 -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 +6 -5
- hikyuu/trade_manage/trade.pyi +6 -5
- hikyuu/util/__init__.pyi +1 -1
- hikyuu/util/singleton.pyi +1 -1
- {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/METADATA +1 -1
- {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/RECORD +217 -210
- {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/WHEEL +0 -0
- {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/entry_points.txt +0 -0
- {hikyuu-2.7.3.dist-info → hikyuu-2.7.6.dist-info}/top_level.txt +0 -0
|
@@ -93,8 +93,8 @@ public:
|
|
|
93
93
|
/** 子类克隆接口 */
|
|
94
94
|
virtual EnvironmentPtr _clone() = 0;
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
return
|
|
96
|
+
bool isPythonObject() const noexcept {
|
|
97
|
+
return m_is_python_object;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
protected:
|
|
@@ -104,6 +104,8 @@ protected:
|
|
|
104
104
|
vector<price_t> m_values;
|
|
105
105
|
mutable std::shared_mutex m_mutex;
|
|
106
106
|
|
|
107
|
+
bool m_is_python_object{false};
|
|
108
|
+
|
|
107
109
|
//============================================
|
|
108
110
|
// 序列化支持
|
|
109
111
|
//============================================
|
|
@@ -118,6 +120,7 @@ private:
|
|
|
118
120
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
119
121
|
ar& BOOST_SERIALIZATION_NVP(m_date_index);
|
|
120
122
|
ar& BOOST_SERIALIZATION_NVP(m_values);
|
|
123
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
template <class Archive>
|
|
@@ -127,6 +130,7 @@ private:
|
|
|
127
130
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
128
131
|
ar& BOOST_SERIALIZATION_NVP(m_date_index);
|
|
129
132
|
ar& BOOST_SERIALIZATION_NVP(m_values);
|
|
133
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
|
@@ -152,8 +152,8 @@ public:
|
|
|
152
152
|
/** 子类克隆私有变量接口 */
|
|
153
153
|
virtual MoneyManagerPtr _clone() = 0;
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
return
|
|
155
|
+
bool isPythonObject() const noexcept {
|
|
156
|
+
return m_is_python_object;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
protected:
|
|
@@ -161,6 +161,7 @@ protected:
|
|
|
161
161
|
KQuery m_query;
|
|
162
162
|
TradeManagerPtr m_tm;
|
|
163
163
|
unordered_map<Stock, std::pair<size_t, size_t>> m_buy_sell_counts;
|
|
164
|
+
bool m_is_python_object{false};
|
|
164
165
|
|
|
165
166
|
//============================================
|
|
166
167
|
// 序列化支持
|
|
@@ -172,6 +173,7 @@ private:
|
|
|
172
173
|
void save(Archive& ar, const unsigned int version) const {
|
|
173
174
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
174
175
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
176
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
175
177
|
// m_query、m_tm都是系统运行时临时设置,不需要序列化
|
|
176
178
|
// ar & BOOST_SERIALIZATION_NVP(m_query);
|
|
177
179
|
// ar & BOOST_SERIALIZATION_NVP(m_tm);
|
|
@@ -181,6 +183,7 @@ private:
|
|
|
181
183
|
void load(Archive& ar, const unsigned int version) {
|
|
182
184
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
183
185
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
186
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
184
187
|
}
|
|
185
188
|
|
|
186
189
|
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
|
@@ -164,34 +164,44 @@ public:
|
|
|
164
164
|
virtual MultiFactorPtr _clone() = 0;
|
|
165
165
|
virtual IndicatorList _calculate(const vector<IndicatorList>&) = 0;
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
return
|
|
167
|
+
bool isPythonObject() const noexcept {
|
|
168
|
+
return m_is_python_object;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
/**
|
|
172
|
+
* 执行计算。默认取结果时,会自动计算。但并行使用mf时,应主动调用该接口
|
|
173
|
+
* @note 因获取scores非常频繁,所以为使用锁。
|
|
174
|
+
* 这样的话,在并行时并不完备。在需要并行计算时可主动调用该接口。
|
|
175
|
+
*/
|
|
173
176
|
void calculate();
|
|
174
177
|
|
|
178
|
+
private:
|
|
175
179
|
void initParam();
|
|
176
180
|
|
|
177
181
|
// 构造每个指标构造行业哑变量,以便进行行业中性化处理
|
|
178
182
|
unordered_map<string, PriceList> _buildDummyIndex();
|
|
179
183
|
|
|
180
|
-
void _buildIndex();
|
|
181
|
-
void _buildIndexDesc(); // 创建降序排列的索引
|
|
182
|
-
void _buildIndexAsc(); // 创建升序排列的索引
|
|
183
|
-
void _buildIndexNone(); // build index when no index
|
|
184
|
+
void _buildIndex(); // 计算完成后创建截面索引
|
|
184
185
|
|
|
185
|
-
IndicatorList _getAllReturns(int ndays) const;
|
|
186
186
|
void _checkData();
|
|
187
187
|
|
|
188
188
|
protected:
|
|
189
|
+
IndicatorList _getAllReturns(int ndays) const;
|
|
190
|
+
|
|
191
|
+
protected:
|
|
192
|
+
bool m_is_python_object{false};
|
|
189
193
|
string m_name;
|
|
190
|
-
IndicatorList m_inds; //
|
|
194
|
+
IndicatorList m_inds; // 输入的原始因子公式列表
|
|
191
195
|
StockList m_stks; // 证券组合
|
|
192
|
-
Stock m_ref_stk; //
|
|
196
|
+
Stock m_ref_stk; // 指定的参考证券, 仅为对齐日期
|
|
193
197
|
KQuery m_query; // 计算的日期范围条件
|
|
194
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
|
+
|
|
195
205
|
// 以下变量为计算后生成
|
|
196
206
|
DatetimeList m_ref_dates; // 依据参考证券和query计算的参考日期,合成因子和该日期对齐
|
|
197
207
|
unordered_map<Stock, size_t> m_stk_map; // 证券->合成后因子位置索引
|
|
@@ -200,12 +210,6 @@ protected:
|
|
|
200
210
|
vector<ScoreRecordList> m_stk_factor_by_date;
|
|
201
211
|
Indicator m_ic;
|
|
202
212
|
|
|
203
|
-
NormPtr m_norm; // 全局标准化/归一化操作
|
|
204
|
-
unordered_map<string, NormPtr> m_special_norms; // 对特定指标执行特定的标准化操作
|
|
205
|
-
unordered_map<string, string> m_special_category; // 对特定指标执行行业中性化时指定的板块分类
|
|
206
|
-
unordered_map<string, IndicatorList>
|
|
207
|
-
m_special_style_inds; // 对特定指标执行风格因子中性化时指定的风格因子
|
|
208
|
-
|
|
209
213
|
private:
|
|
210
214
|
std::mutex m_mutex;
|
|
211
215
|
bool m_calculated{false};
|
|
@@ -218,13 +222,13 @@ private:
|
|
|
218
222
|
friend class boost::serialization::access;
|
|
219
223
|
template <class Archive>
|
|
220
224
|
void save(Archive& ar, const unsigned int version) const {
|
|
225
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
221
226
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
222
227
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
223
228
|
ar& BOOST_SERIALIZATION_NVP(m_inds);
|
|
224
229
|
ar& BOOST_SERIALIZATION_NVP(m_stks);
|
|
225
230
|
ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
|
|
226
231
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
227
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
|
|
228
232
|
ar& BOOST_SERIALIZATION_NVP(m_special_norms);
|
|
229
233
|
ar& BOOST_SERIALIZATION_NVP(m_special_category);
|
|
230
234
|
// 以下不需要保存,加载后重新计算
|
|
@@ -238,13 +242,13 @@ private:
|
|
|
238
242
|
|
|
239
243
|
template <class Archive>
|
|
240
244
|
void load(Archive& ar, const unsigned int version) {
|
|
245
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
241
246
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
242
247
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
243
248
|
ar& BOOST_SERIALIZATION_NVP(m_inds);
|
|
244
249
|
ar& BOOST_SERIALIZATION_NVP(m_stks);
|
|
245
250
|
ar& BOOST_SERIALIZATION_NVP(m_ref_stk);
|
|
246
251
|
ar& BOOST_SERIALIZATION_NVP(m_query);
|
|
247
|
-
ar& BOOST_SERIALIZATION_NVP(m_ref_dates);
|
|
248
252
|
ar& BOOST_SERIALIZATION_NVP(m_special_norms);
|
|
249
253
|
ar& BOOST_SERIALIZATION_NVP(m_special_category);
|
|
250
254
|
// ar& BOOST_SERIALIZATION_NVP(m_stk_map);
|
|
@@ -42,12 +42,13 @@ public:
|
|
|
42
42
|
|
|
43
43
|
virtual PriceList normalize(const PriceList& data) = 0;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
return
|
|
45
|
+
bool isPythonObject() const noexcept {
|
|
46
|
+
return m_is_python_object;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
protected:
|
|
50
50
|
string m_name;
|
|
51
|
+
bool m_is_python_object{false};
|
|
51
52
|
|
|
52
53
|
//============================================
|
|
53
54
|
// 序列化支持
|
|
@@ -58,12 +59,14 @@ private:
|
|
|
58
59
|
template <class Archive>
|
|
59
60
|
void save(Archive& ar, const unsigned int version) const {
|
|
60
61
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
62
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
61
63
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
template <class Archive>
|
|
65
67
|
void load(Archive& ar, const unsigned int version) {
|
|
66
68
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
69
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
67
70
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -72,7 +75,7 @@ private:
|
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
#if HKU_SUPPORT_SERIALIZATION
|
|
75
|
-
BOOST_SERIALIZATION_ASSUME_ABSTRACT(
|
|
78
|
+
BOOST_SERIALIZATION_ASSUME_ABSTRACT(NormalizeBase)
|
|
76
79
|
#endif
|
|
77
80
|
|
|
78
81
|
#if HKU_SUPPORT_SERIALIZATION
|
|
@@ -49,13 +49,14 @@ public:
|
|
|
49
49
|
public:
|
|
50
50
|
friend HKU_API ScoresFilterPtr operator|(const ScoresFilterPtr& a, const ScoresFilterPtr& b);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
return
|
|
52
|
+
bool isPythonObject() const noexcept {
|
|
53
|
+
return m_is_python_object;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
protected:
|
|
57
57
|
string m_name;
|
|
58
58
|
ScoresFilterPtr m_child;
|
|
59
|
+
bool m_is_python_object{false};
|
|
59
60
|
|
|
60
61
|
//============================================
|
|
61
62
|
// 序列化支持
|
|
@@ -68,6 +69,7 @@ private:
|
|
|
68
69
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
69
70
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
70
71
|
ar& BOOST_SERIALIZATION_NVP(m_child);
|
|
72
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
template <class Archive>
|
|
@@ -75,6 +77,7 @@ private:
|
|
|
75
77
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
76
78
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
77
79
|
ar& BOOST_SERIALIZATION_NVP(m_child);
|
|
80
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
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
|
|
|
@@ -113,8 +113,8 @@ public:
|
|
|
113
113
|
*/
|
|
114
114
|
virtual json lastSuggestion() const;
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
return
|
|
116
|
+
bool isPythonObject() const noexcept {
|
|
117
|
+
return m_is_python_object;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
private:
|
|
@@ -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,6 +173,7 @@ 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()
|
|
@@ -82,10 +82,12 @@ public:
|
|
|
82
82
|
/** 子类计算接口,由setTO调用 */
|
|
83
83
|
virtual void _calculate() {}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
return
|
|
85
|
+
bool isPythonObject() const noexcept {
|
|
86
|
+
return m_is_python_object;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
bool m_is_python_object{false};
|
|
90
|
+
|
|
89
91
|
protected:
|
|
90
92
|
string m_name;
|
|
91
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,8 +168,8 @@ public:
|
|
|
163
168
|
/** 在已有过滤基础上追加过滤,仅用于 MF 相关的 Selector,从 MF 获取 Score 列表时进行过滤 */
|
|
164
169
|
void addScoresFilter(const ScoresFilterPtr& filter);
|
|
165
170
|
|
|
166
|
-
|
|
167
|
-
return
|
|
171
|
+
bool isPythonObject() const noexcept {
|
|
172
|
+
return m_is_python_object;
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
private:
|
|
@@ -176,6 +181,7 @@ protected:
|
|
|
176
181
|
|
|
177
182
|
protected:
|
|
178
183
|
string m_name;
|
|
184
|
+
bool m_is_python_object{false};
|
|
179
185
|
bool m_calculated{false}; // 是否已计算过
|
|
180
186
|
bool m_proto_calculated{false};
|
|
181
187
|
KQuery m_query;
|
|
@@ -195,6 +201,7 @@ private:
|
|
|
195
201
|
template <class Archive>
|
|
196
202
|
void save(Archive& ar, const unsigned int version) const {
|
|
197
203
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
204
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
198
205
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
199
206
|
ar& BOOST_SERIALIZATION_NVP(m_pro_sys_list);
|
|
200
207
|
ar& BOOST_SERIALIZATION_NVP(m_sc_filter);
|
|
@@ -204,6 +211,7 @@ private:
|
|
|
204
211
|
template <class Archive>
|
|
205
212
|
void load(Archive& ar, const unsigned int version) {
|
|
206
213
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
214
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
207
215
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
208
216
|
ar& BOOST_SERIALIZATION_NVP(m_pro_sys_list);
|
|
209
217
|
ar& BOOST_SERIALIZATION_NVP(m_sc_filter);
|
|
@@ -280,10 +288,12 @@ inline const SystemList& SelectorBase::getProtoSystemList() const {
|
|
|
280
288
|
|
|
281
289
|
inline void SelectorBase::setScoresFilter(const ScoresFilterPtr& filter) {
|
|
282
290
|
m_sc_filter = filter;
|
|
291
|
+
m_calculated = false;
|
|
283
292
|
}
|
|
284
293
|
|
|
285
294
|
inline void SelectorBase::addScoresFilter(const ScoresFilterPtr& filter) {
|
|
286
295
|
m_sc_filter = m_sc_filter | filter;
|
|
296
|
+
m_calculated = false;
|
|
287
297
|
}
|
|
288
298
|
|
|
289
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,8 +130,8 @@ public:
|
|
|
130
130
|
/** 子类计算接口,在setTO中调用 */
|
|
131
131
|
virtual void _calculate(const KData&) = 0;
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
return
|
|
133
|
+
bool isPythonObject() const noexcept {
|
|
134
|
+
return m_is_python_object;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
private:
|
|
@@ -140,6 +140,7 @@ private:
|
|
|
140
140
|
protected:
|
|
141
141
|
string m_name;
|
|
142
142
|
KData m_kdata;
|
|
143
|
+
bool m_is_python_object{false};
|
|
143
144
|
bool m_calculated{false}; // 仅针对 setTO 时的计算
|
|
144
145
|
|
|
145
146
|
/* 多头持仓 */
|
|
@@ -164,6 +165,7 @@ private:
|
|
|
164
165
|
void save(Archive& ar, const unsigned int version) const {
|
|
165
166
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
166
167
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
168
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
167
169
|
ar& BOOST_SERIALIZATION_NVP(m_hold_long);
|
|
168
170
|
ar& BOOST_SERIALIZATION_NVP(m_hold_short);
|
|
169
171
|
ar& BOOST_SERIALIZATION_NVP(m_buySig);
|
|
@@ -177,6 +179,7 @@ private:
|
|
|
177
179
|
void load(Archive& ar, const unsigned int version) {
|
|
178
180
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
179
181
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
182
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
180
183
|
ar& BOOST_SERIALIZATION_NVP(m_hold_long);
|
|
181
184
|
ar& BOOST_SERIALIZATION_NVP(m_hold_short);
|
|
182
185
|
ar& BOOST_SERIALIZATION_NVP(m_buySig);
|
|
@@ -71,13 +71,14 @@ public:
|
|
|
71
71
|
/** 子类计算接口,由setTO调用 */
|
|
72
72
|
virtual void _calculate() = 0;
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
return
|
|
74
|
+
bool isPythonObject() const noexcept {
|
|
75
|
+
return m_is_python_object;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
protected:
|
|
79
79
|
string m_name;
|
|
80
80
|
KData m_kdata;
|
|
81
|
+
bool m_is_python_object{false};
|
|
81
82
|
|
|
82
83
|
//============================================
|
|
83
84
|
// 序列化支持
|
|
@@ -88,12 +89,14 @@ private:
|
|
|
88
89
|
template <class Archive>
|
|
89
90
|
void save(Archive& ar, const unsigned int version) const {
|
|
90
91
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
92
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
91
93
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
template <class Archive>
|
|
95
97
|
void load(Archive& ar, const unsigned int version) {
|
|
96
98
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
99
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
97
100
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
98
101
|
}
|
|
99
102
|
|
|
@@ -86,11 +86,12 @@ public:
|
|
|
86
86
|
/** 子类计算接口,由setTO调用 */
|
|
87
87
|
virtual void _calculate() = 0;
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
return
|
|
89
|
+
bool isPythonObject() const noexcept {
|
|
90
|
+
return m_is_python_object;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
protected:
|
|
94
|
+
bool m_is_python_object{false};
|
|
94
95
|
string m_name;
|
|
95
96
|
TradeManagerPtr m_tm;
|
|
96
97
|
KData m_kdata;
|
|
@@ -103,6 +104,7 @@ private:
|
|
|
103
104
|
friend class boost::serialization::access;
|
|
104
105
|
template <class Archive>
|
|
105
106
|
void save(Archive& ar, const unsigned int version) const {
|
|
107
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
106
108
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
107
109
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
108
110
|
// m_kdata都是系统运行时临时设置,不需要序列化
|
|
@@ -111,6 +113,7 @@ private:
|
|
|
111
113
|
|
|
112
114
|
template <class Archive>
|
|
113
115
|
void load(Archive& ar, const unsigned int version) {
|
|
116
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
114
117
|
ar& BOOST_SERIALIZATION_NVP(m_name);
|
|
115
118
|
ar& BOOST_SERIALIZATION_NVP(m_params);
|
|
116
119
|
// m_kdata都是系统运行时临时设置,不需要序列化
|
|
@@ -276,8 +276,8 @@ public:
|
|
|
276
276
|
// 处理延迟买入请求,仅供 PF 调用
|
|
277
277
|
virtual TradeRecord pfProcessDelayBuyRequest(const Datetime& date);
|
|
278
278
|
|
|
279
|
-
|
|
280
|
-
return
|
|
279
|
+
bool isPythonObject() const noexcept {
|
|
280
|
+
return m_is_python_object;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
private:
|
|
@@ -351,6 +351,7 @@ protected:
|
|
|
351
351
|
KData m_kdata;
|
|
352
352
|
KData m_src_kdata; // 未复权的原始 K 线数据
|
|
353
353
|
|
|
354
|
+
bool m_is_python_object{false};
|
|
354
355
|
bool m_calculated; // 控制是否需要重新计算
|
|
355
356
|
bool m_pre_ev_valid;
|
|
356
357
|
bool m_pre_cn_valid;
|
|
@@ -393,6 +394,7 @@ private:
|
|
|
393
394
|
ar& BOOST_SERIALIZATION_NVP(m_kdata);
|
|
394
395
|
ar& BOOST_SERIALIZATION_NVP(m_stock);
|
|
395
396
|
|
|
397
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
396
398
|
ar& BOOST_SERIALIZATION_NVP(m_calculated);
|
|
397
399
|
ar& BOOST_SERIALIZATION_NVP(m_pre_ev_valid);
|
|
398
400
|
ar& BOOST_SERIALIZATION_NVP(m_pre_cn_valid);
|
|
@@ -427,6 +429,7 @@ private:
|
|
|
427
429
|
ar& BOOST_SERIALIZATION_NVP(m_kdata);
|
|
428
430
|
ar& BOOST_SERIALIZATION_NVP(m_stock);
|
|
429
431
|
|
|
432
|
+
ar& BOOST_SERIALIZATION_NVP(m_is_python_object);
|
|
430
433
|
ar& BOOST_SERIALIZATION_NVP(m_calculated);
|
|
431
434
|
ar& BOOST_SERIALIZATION_NVP(m_pre_ev_valid);
|
|
432
435
|
ar& BOOST_SERIALIZATION_NVP(m_pre_cn_valid);
|