mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-01 03:18:18 +08:00
try add operator(k) for indicator
This commit is contained in:
parent
8dd85d3cea
commit
4df93ba3ae
@ -31,6 +31,12 @@ string Indicator::formula() const {
|
||||
return m_imp ? m_imp->formula() : "Indicator";
|
||||
}
|
||||
|
||||
Indicator Indicator::operator()(const KData& k) {
|
||||
Indicator result = clone();
|
||||
result.setContext(k);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Indicator::setContext(const Stock& stock, const KQuery& query) {
|
||||
if (m_imp) m_imp->setContext(stock, query);
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ public:
|
||||
|
||||
/** 使用已有参数计算新值,返回全新的Indicator */
|
||||
Indicator operator()(const Indicator& ind);
|
||||
|
||||
/** 同 setContext */
|
||||
Indicator operator()(const KData& k);
|
||||
|
||||
/** 指标名称 */
|
||||
string name() const;
|
||||
|
@ -48,6 +48,9 @@ void (Indicator::*ind_write_name)(const string&) = &Indicator::name;
|
||||
void (Indicator::*setContext_1)(const Stock&, const KQuery&) = &Indicator::setContext;
|
||||
void (Indicator::*setContext_2)(const KData&) = &Indicator::setContext;
|
||||
|
||||
Indicator (Indicator::*call_1)operator()(const Indicator&) = &Indicator::operator();
|
||||
Indicator (Indicator::*call_2)operator()(const KData&) = &Indicator::operator();
|
||||
|
||||
void export_Indicator() {
|
||||
|
||||
class_<Indicator>("Indicator", init<>())
|
||||
@ -72,7 +75,9 @@ void export_Indicator() {
|
||||
.def("getContext", &Indicator::getContext)
|
||||
.def("getImp", &Indicator::getImp)
|
||||
.def("__len__", &Indicator::size)
|
||||
.def("__call__", &Indicator::operator())
|
||||
//.def("__call__", &Indicator::operator())
|
||||
.def("__call__", call_1)
|
||||
.def("__call__", call_2)
|
||||
#if HKU_PYTHON_SUPPORT_PICKLE
|
||||
.def_pickle(normal_pickle_suite<Indicator>())
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user