diff --git a/hikyuu_cpp/hikyuu/KData.cpp b/hikyuu_cpp/hikyuu/KData.cpp index 1297477dd..daf32bbef 100644 --- a/hikyuu_cpp/hikyuu/KData.cpp +++ b/hikyuu_cpp/hikyuu/KData.cpp @@ -32,7 +32,7 @@ KData::KData(const Stock& stock, const KQuery& query) { } } -bool KData::operator==(const KData& thr) { +bool KData::operator==(const KData& thr) const { return this == &thr || m_imp == thr.m_imp || (getStock() == thr.getStock() && getQuery() == thr.getQuery()); } diff --git a/hikyuu_cpp/hikyuu/KData.h b/hikyuu_cpp/hikyuu/KData.h index 50b636be3..932ab9367 100644 --- a/hikyuu_cpp/hikyuu/KData.h +++ b/hikyuu_cpp/hikyuu/KData.h @@ -33,7 +33,8 @@ class HKU_API KData { size_t size() const; bool empty() const; - bool operator==(const KData&); + bool operator==(const KData&) const; + bool operator!=(const KData&) const; DatetimeList getDatetimeList() const; @@ -217,6 +218,10 @@ inline size_t KData::lastPos() const { return m_imp ? m_imp->lastPos() : 0; } +inline bool KData::operator!=(const KData& other) const { + return !(*this == other); +} + } /* namespace hku */ #if FMT_VERSION >= 90000 diff --git a/hikyuu_pywrap/_KData.cpp b/hikyuu_pywrap/_KData.cpp index 610632aa8..da0cf8ffe 100644 --- a/hikyuu_pywrap/_KData.cpp +++ b/hikyuu_pywrap/_KData.cpp @@ -88,6 +88,10 @@ void export_KData() { :param str filename: 指定保存的文件名称)") .def("__len__", &KData::size) + + .def(self == self) + .def(self != self) + #if HKU_PYTHON_SUPPORT_PICKLE .def_pickle(normal_pickle_suite()) #endif