From ce0e05bd98f0b02ea8ac34b05aaa73a46db9bc6e Mon Sep 17 00:00:00 2001 From: fasiondog Date: Thu, 11 Apr 2019 02:10:41 +0800 Subject: [PATCH] add LN, LOG ind --- docs/source/indicator/indicator.rst | 16 ++++ hikyuu/indicator/indicator_doc.py | 19 ++++ hikyuu_cpp/hikyuu/indicator/build_in.h | 4 +- hikyuu_cpp/hikyuu/indicator/crt/ABS.h | 13 ++- hikyuu_cpp/hikyuu/indicator/crt/EXP.h | 13 ++- hikyuu_cpp/hikyuu/indicator/crt/LN.h | 36 +++++++ hikyuu_cpp/hikyuu/indicator/crt/LOG.h | 34 +++++++ hikyuu_cpp/hikyuu/indicator/crt/SGN.h | 13 ++- hikyuu_cpp/hikyuu/indicator/imp/IExp.cpp | 4 +- hikyuu_cpp/hikyuu/indicator/imp/ILn.cpp | 53 +++++++++++ hikyuu_cpp/hikyuu/indicator/imp/ILn.h | 27 ++++++ hikyuu_cpp/hikyuu/indicator/imp/ILog.cpp | 53 +++++++++++ hikyuu_cpp/hikyuu/indicator/imp/ILog.h | 27 ++++++ .../libs/hikyuu/indicator/test_ABS.cpp | 5 + .../libs/hikyuu/indicator/test_BETWEEN.cpp | 1 - .../libs/hikyuu/indicator/test_EXP.cpp | 5 + .../libs/hikyuu/indicator/test_LN.cpp | 95 +++++++++++++++++++ .../libs/hikyuu/indicator/test_LOG.cpp | 95 +++++++++++++++++++ .../libs/hikyuu/indicator/test_SGN.cpp | 15 +++ hikyuu_pywrap/indicator/_build_in.cpp | 29 +++++- 20 files changed, 529 insertions(+), 28 deletions(-) create mode 100644 hikyuu_cpp/hikyuu/indicator/crt/LN.h create mode 100644 hikyuu_cpp/hikyuu/indicator/crt/LOG.h create mode 100644 hikyuu_cpp/hikyuu/indicator/imp/ILn.cpp create mode 100644 hikyuu_cpp/hikyuu/indicator/imp/ILn.h create mode 100644 hikyuu_cpp/hikyuu/indicator/imp/ILog.cpp create mode 100644 hikyuu_cpp/hikyuu/indicator/imp/ILog.h create mode 100644 hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LN.cpp create mode 100644 hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LOG.cpp diff --git a/docs/source/indicator/indicator.rst b/docs/source/indicator/indicator.rst index 221b677c..b8f3bb56 100644 --- a/docs/source/indicator/indicator.rst +++ b/docs/source/indicator/indicator.rst @@ -185,6 +185,22 @@ :param int n: N日时间窗口 :rtype: Indicator + +.. py:function:: LN([data]) + + 求自然对数, LN(X)以e为底的对数 + + :param data: 输入数据 + :rtype: Indicator + + +.. py:function:: LOG([data]) + + 以10为底的对数 + + :param data: 输入数据 + :rtype: Indicator + .. py:function:: LOW([data]) diff --git a/hikyuu/indicator/indicator_doc.py b/hikyuu/indicator/indicator_doc.py index 8443768b..f4819d93 100644 --- a/hikyuu/indicator/indicator_doc.py +++ b/hikyuu/indicator/indicator_doc.py @@ -222,6 +222,25 @@ LLV([data, n=20]) """ +LN.__doc__ = """ +LN([data]) + + 求自然对数, LN(X)以e为底的对数 + + :param data: 输入数据 + :rtype: Indicator +""" + +LOG.__doc__ = """ +LOG([data]) + + 以10为底的对数 + + :param data: 输入数据 + :rtype: Indicator +""" + + LOW.__doc__ = """ LOW([data]) diff --git a/hikyuu_cpp/hikyuu/indicator/build_in.h b/hikyuu_cpp/hikyuu/indicator/build_in.h index 0e636de7..8c32c883 100644 --- a/hikyuu_cpp/hikyuu/indicator/build_in.h +++ b/hikyuu_cpp/hikyuu/indicator/build_in.h @@ -21,8 +21,10 @@ #include "crt/EXP.h" #include "crt/HHV.h" #include "crt/HSL.h" -#include "crt/LLV.h" #include "crt/LIUTONGPAN.h" +#include "crt/LLV.h" +#include "crt/LN.h" +#include "crt/LOG.h" #include "crt/MA.h" #include "crt/MACD.h" #include "crt/MAX.h" diff --git a/hikyuu_cpp/hikyuu/indicator/crt/ABS.h b/hikyuu_cpp/hikyuu/indicator/crt/ABS.h index 78574565..72e36211 100644 --- a/hikyuu_cpp/hikyuu/indicator/crt/ABS.h +++ b/hikyuu_cpp/hikyuu/indicator/crt/ABS.h @@ -8,7 +8,7 @@ #ifndef INDICATOR_CRT_ABS_H_ #define INDICATOR_CRT_ABS_H_ -#include "../Indicator.h" +#include "CVAL.h" namespace hku { @@ -17,18 +17,17 @@ namespace hku { * @ingroup Indicator */ Indicator HKU_API ABS(); - -/** - * 求绝对值 - * @param ind 待计算的数据 - * @ingroup Indicator - */ +Indicator ABS(price_t); Indicator ABS(const Indicator& ind); inline Indicator ABS(const Indicator& ind) { return ABS()(ind); } +inline Indicator ABS(price_t val) { + return ABS(CVAL(val)); +} + } /* namespace */ #endif /* INDICATOR_CRT_ABS_H_ */ diff --git a/hikyuu_cpp/hikyuu/indicator/crt/EXP.h b/hikyuu_cpp/hikyuu/indicator/crt/EXP.h index 0815949a..1b150325 100644 --- a/hikyuu_cpp/hikyuu/indicator/crt/EXP.h +++ b/hikyuu_cpp/hikyuu/indicator/crt/EXP.h @@ -8,7 +8,7 @@ #ifndef INDICATOR_CRT_EXP_H_ #define INDICATOR_CRT_EXP_H_ -#include "../Indicator.h" +#include "CVAL.h" namespace hku { @@ -17,18 +17,17 @@ namespace hku { * @ingroup Indicator */ Indicator HKU_API EXP(); - -/** - * 指数, EXP(X)为e的X次幂 - * @param ind 待计算的数据 - * @ingroup Indicator - */ +Indicator EXP(price_t); Indicator EXP(const Indicator& ind); inline Indicator EXP(const Indicator& ind) { return EXP()(ind); } +inline Indicator EXP(price_t val) { + return EXP(CVAL(val)); +} + } /* namespace */ #endif /* INDICATOR_CRT_EXP_H_ */ diff --git a/hikyuu_cpp/hikyuu/indicator/crt/LN.h b/hikyuu_cpp/hikyuu/indicator/crt/LN.h new file mode 100644 index 00000000..6789a0dd --- /dev/null +++ b/hikyuu_cpp/hikyuu/indicator/crt/LN.h @@ -0,0 +1,36 @@ +/* + * LN.h + * + * Created on: 2019-4-11 + * Author: fasiondog + */ + +#ifndef INDICATOR_CRT_LN_H_ +#define INDICATOR_CRT_LN_H_ + +#include "CVAL.h" + +namespace hku { + +/** + * 求自然对数 + * 用法:LN(X)以e为底的对数 + * 例如:LN(CLOSE)求收盘价的对数 + * @ingroup Indicator + */ +Indicator HKU_API LN(); +Indicator LN(price_t); +Indicator LN(const Indicator& ind); + + +inline Indicator LN(const Indicator& ind) { + return LN()(ind); +} + +inline Indicator LN(price_t val) { + return LN(CVAL(val)); +} + +} /* namespace */ + +#endif /* INDICATOR_CRT_LN_H_ */ diff --git a/hikyuu_cpp/hikyuu/indicator/crt/LOG.h b/hikyuu_cpp/hikyuu/indicator/crt/LOG.h new file mode 100644 index 00000000..1df8e8cc --- /dev/null +++ b/hikyuu_cpp/hikyuu/indicator/crt/LOG.h @@ -0,0 +1,34 @@ +/* + * LOG.h + * + * Created on: 2019-4-11 + * Author: fasiondog + */ + +#ifndef INDICATOR_CRT_LOG_H_ +#define INDICATOR_CRT_LOG_H_ + +#include "CVAL.h" + +namespace hku { + +/** + * 以10为底的对数 + * 用法:LOG(X)取得X的对数 + * @ingroup Indicator + */ +Indicator HKU_API LOG(); +Indicator LOG(price_t); +Indicator LOG(const Indicator& ind); + +inline Indicator LOG(const Indicator& ind) { + return LOG()(ind); +} + +Indicator LOG(price_t val) { + return LOG(CVAL(val)); +} + +} /* namespace */ + +#endif /* INDICATOR_CRT_LOG_H_ */ diff --git a/hikyuu_cpp/hikyuu/indicator/crt/SGN.h b/hikyuu_cpp/hikyuu/indicator/crt/SGN.h index 8eca682e..ddf14fd0 100644 --- a/hikyuu_cpp/hikyuu/indicator/crt/SGN.h +++ b/hikyuu_cpp/hikyuu/indicator/crt/SGN.h @@ -8,7 +8,7 @@ #ifndef INDICATOR_CRT_SGN_H_ #define INDICATOR_CRT_SGN_H_ -#include "../Indicator.h" +#include "CVAL.h" namespace hku { @@ -17,18 +17,17 @@ namespace hku { * @ingroup Indicator */ Indicator HKU_API SGN(); - -/** - * 求符号值, SGN(X),当 X>0, X=0, X<0分别返回 1, 0, -1。 - * @param ind 待计算的数据 - * @ingroup Indicator - */ +Indicator SGN(price_t); Indicator SGN(const Indicator& ind); inline Indicator SGN(const Indicator& ind) { return SGN()(ind); } +inline Indicator SGN(price_t val) { + return SGN(CVAL(val)); +} + } #endif /* INDICATOR_CRT_SGN_H_ */ diff --git a/hikyuu_cpp/hikyuu/indicator/imp/IExp.cpp b/hikyuu_cpp/hikyuu/indicator/imp/IExp.cpp index 3d754a66..d81a11cb 100644 --- a/hikyuu_cpp/hikyuu/indicator/imp/IExp.cpp +++ b/hikyuu_cpp/hikyuu/indicator/imp/IExp.cpp @@ -34,15 +34,15 @@ void IExp::_calculate(const Indicator& data) { return; } + price_t null_price = Null(); for (size_t i = m_discard; i < total; ++i) { price_t x = std::exp(data[i]); if (std::isinf(x)) { - _set(Null(), i); + _set(null_price, i); } else { _set(std::exp(data[i]), i); } } - } diff --git a/hikyuu_cpp/hikyuu/indicator/imp/ILn.cpp b/hikyuu_cpp/hikyuu/indicator/imp/ILn.cpp new file mode 100644 index 00000000..6a5525d6 --- /dev/null +++ b/hikyuu_cpp/hikyuu/indicator/imp/ILn.cpp @@ -0,0 +1,53 @@ +/* + * ILn.cpp + * + * Created on: 2019年4月11日 + * Author: fasiondog + */ + +#include "ILn.h" + +#if HKU_SUPPORT_SERIALIZATION +BOOST_CLASS_EXPORT(hku::ILn) +#endif + + +namespace hku { + +ILn::ILn() : IndicatorImp("LN", 1) { + +} + +ILn::~ILn() { + +} + +bool ILn::check() { + return true; +} + +void ILn::_calculate(const Indicator& data) { + size_t total = data.size(); + m_discard = data.discard(); + if (m_discard >= total) { + m_discard = total; + return; + } + + price_t null_price = Null(); + for (size_t i = m_discard; i < total; ++i) { + if (data[i] < 0.0) { + _set(null_price, i); + } else { + _set(std::log(data[i]), i); + } + } +} + + +Indicator HKU_API LN() { + return Indicator(make_shared()); +} + + +} /* namespace hku */ diff --git a/hikyuu_cpp/hikyuu/indicator/imp/ILn.h b/hikyuu_cpp/hikyuu/indicator/imp/ILn.h new file mode 100644 index 00000000..5a0aa735 --- /dev/null +++ b/hikyuu_cpp/hikyuu/indicator/imp/ILn.h @@ -0,0 +1,27 @@ +/* + * ILn.h + * + * Copyright (c) 2019 fasiondog + * + * Created on: 2019-4-11 + * Author: fasiondog + */ + +#ifndef INDICATOR_IMP_ILN_H_ +#define INDICATOR_IMP_ILN_H_ + +#include "../Indicator.h" + +namespace hku { + +class ILn: public IndicatorImp { + INDICATOR_IMP(ILn) + INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION + +public: + ILn(); + virtual ~ILn(); +}; + +} /* namespace hku */ +#endif /* INDICATOR_IMP_ILN_H_ */ diff --git a/hikyuu_cpp/hikyuu/indicator/imp/ILog.cpp b/hikyuu_cpp/hikyuu/indicator/imp/ILog.cpp new file mode 100644 index 00000000..ef7dbf4e --- /dev/null +++ b/hikyuu_cpp/hikyuu/indicator/imp/ILog.cpp @@ -0,0 +1,53 @@ +/* + * ILog.cpp + * + * Created on: 2019年4月11日 + * Author: fasiondog + */ + +#include "ILog.h" + +#if HKU_SUPPORT_SERIALIZATION +BOOST_CLASS_EXPORT(hku::ILog) +#endif + + +namespace hku { + +ILog::ILog() : IndicatorImp("LOG", 1) { + +} + +ILog::~ILog() { + +} + +bool ILog::check() { + return true; +} + +void ILog::_calculate(const Indicator& data) { + size_t total = data.size(); + m_discard = data.discard(); + if (m_discard >= total) { + m_discard = total; + return; + } + + price_t null_price = Null(); + for (size_t i = m_discard; i < total; ++i) { + if (data[i] < 0.0) { + _set(null_price, i); + } else { + _set(std::log10(data[i]), i); + } + } +} + + +Indicator HKU_API LOG() { + return Indicator(make_shared()); +} + + +} /* namespace hku */ diff --git a/hikyuu_cpp/hikyuu/indicator/imp/ILog.h b/hikyuu_cpp/hikyuu/indicator/imp/ILog.h new file mode 100644 index 00000000..39ed1eca --- /dev/null +++ b/hikyuu_cpp/hikyuu/indicator/imp/ILog.h @@ -0,0 +1,27 @@ +/* + * ILog.h + * + * Copyright (c) 2019 fasiondog + * + * Created on: 2019-4-11 + * Author: fasiondog + */ + +#ifndef INDICATOR_IMP_ILog_H_ +#define INDICATOR_IMP_ILog_H_ + +#include "../Indicator.h" + +namespace hku { + +class ILog: public IndicatorImp { + INDICATOR_IMP(ILog) + INDICATOR_IMP_NO_PRIVATE_MEMBER_SERIALIZATION + +public: + ILog(); + virtual ~ILog(); +}; + +} /* namespace hku */ +#endif /* INDICATOR_IMP_ILog_H_ */ diff --git a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_ABS.cpp b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_ABS.cpp index f75ba16a..743bc5a0 100644 --- a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_ABS.cpp +++ b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_ABS.cpp @@ -43,6 +43,11 @@ BOOST_AUTO_TEST_CASE( test_ABS ) { for (int i = 0; i <10; ++i) { BOOST_CHECK(result[i] == -data[i]); } + + result = ABS(-11); + BOOST_CHECK(result.size() == 1); + BOOST_CHECK(result.discard() == 0); + BOOST_CHECK(result[0] == 11); } diff --git a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_BETWEEN.cpp b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_BETWEEN.cpp index 1da8f28d..9dbf338d 100644 --- a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_BETWEEN.cpp +++ b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_BETWEEN.cpp @@ -96,7 +96,6 @@ BOOST_AUTO_TEST_CASE( test_BETWEEN ) { BOOST_CHECK(result.size() == 1); BOOST_CHECK(result.discard() == 0); BOOST_CHECK(result[0] == 0); - } diff --git a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_EXP.cpp b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_EXP.cpp index 319c29bc..084222f7 100644 --- a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_EXP.cpp +++ b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_EXP.cpp @@ -43,6 +43,11 @@ BOOST_AUTO_TEST_CASE( test_EXP ) { for (int i = 0; i <10; ++i) { BOOST_CHECK(result[i] == std::exp(data[i])); } + + result = EXP(1); + BOOST_CHECK(result.size() == 1); + BOOST_CHECK(result.discard() == 0); + BOOST_CHECK(result[0] == std::exp(1)); } diff --git a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LN.cpp b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LN.cpp new file mode 100644 index 00000000..69083e48 --- /dev/null +++ b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LN.cpp @@ -0,0 +1,95 @@ +/* + * test_LN.cpp + * + * Created on: 2019年4月2日 + * Author: fasiondog + */ + +#ifdef TEST_ALL_IN_ONE + #include +#else + #define BOOST_TEST_MODULE test_hikyuu_indicator_suite + #include +#endif + +#include +#include +#include +#include +#include + +using namespace hku; + +/** + * @defgroup test_indicator_LN test_indicator_LN + * @ingroup test_hikyuu_indicator_suite + * @{ + */ + +/** @par 检测点 */ +BOOST_AUTO_TEST_CASE( test_LN ) { + Indicator result; + + PriceList a; + for (int i = 0; i < 10; ++i) { + a.push_back(i); + } + a.push_back(-1); + + Indicator data = PRICELIST(a); + + result = LN(data); + BOOST_CHECK(result.name() == "LN"); + BOOST_CHECK(result.size() == 11); + BOOST_CHECK(result.discard() == 0); + for (int i = 0; i <10; ++i) { + BOOST_CHECK_CLOSE(result[i], std::log(i), 0.00001); + } + BOOST_CHECK(result[10] == Null()); + + result = LN(10); + BOOST_CHECK(result.size() == 1); + BOOST_CHECK(result.discard() == 0); + BOOST_CHECK_CLOSE(result[0], std::log(10.0), 0.00001); +} + + +//----------------------------------------------------------------------------- +// test export +//----------------------------------------------------------------------------- +#if HKU_SUPPORT_SERIALIZATION + +/** @par 检测点 */ +BOOST_AUTO_TEST_CASE( test_LN_export ) { + StockManager& sm = StockManager::instance(); + string filename(sm.tmpdir()); + filename += "/LN.xml"; + + Stock stock = sm.getStock("sh000001"); + KData kdata = stock.getKData(KQuery(-20)); + Indicator x1 = LN(CLOSE(kdata)); + { + std::ofstream ofs(filename); + boost::archive::xml_oarchive oa(ofs); + oa << BOOST_SERIALIZATION_NVP(x1); + } + + Indicator x2; + { + std::ifstream ifs(filename); + boost::archive::xml_iarchive ia(ifs); + ia >> BOOST_SERIALIZATION_NVP(x2); + } + + BOOST_CHECK(x1.size() == x2.size()); + BOOST_CHECK(x1.discard() == x2.discard()); + BOOST_CHECK(x1.getResultNumber() == x2.getResultNumber()); + for (size_t i = 0; i < x1.size(); ++i) { + BOOST_CHECK_CLOSE(x1[i], x2[i], 0.00001); + } +} +#endif /* #if HKU_SUPPORT_SERIALIZATION */ + +/** @} */ + + diff --git a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LOG.cpp b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LOG.cpp new file mode 100644 index 00000000..1557ca63 --- /dev/null +++ b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_LOG.cpp @@ -0,0 +1,95 @@ +/* + * test_LOG.cpp + * + * Created on: 2019年4月2日 + * Author: fasiondog + */ + +#ifdef TEST_ALL_IN_ONE + #include +#else + #define BOOST_TEST_MODULE test_hikyuu_indicator_suite + #include +#endif + +#include +#include +#include +#include +#include + +using namespace hku; + +/** + * @defgroup test_indicator_LN test_indicator_LOG + * @ingroup test_hikyuu_indicator_suite + * @{ + */ + +/** @par 检测点 */ +BOOST_AUTO_TEST_CASE( test_LOG ) { + Indicator result; + + PriceList a; + for (int i = 0; i < 10; ++i) { + a.push_back(i); + } + a.push_back(-1); + + Indicator data = PRICELIST(a); + + result = LOG(data); + BOOST_CHECK(result.name() == "LOG"); + BOOST_CHECK(result.size() == 11); + BOOST_CHECK(result.discard() == 0); + for (int i = 0; i <10; ++i) { + BOOST_CHECK_CLOSE(result[i], std::log10(i), 0.00001); + } + BOOST_CHECK(result[10] == Null()); + + result = LOG(10); + BOOST_CHECK(result.size() == 1); + BOOST_CHECK(result.discard() == 0); + BOOST_CHECK_CLOSE(result[0], std::log10(10.0), 0.00001); +} + + +//----------------------------------------------------------------------------- +// test export +//----------------------------------------------------------------------------- +#if HKU_SUPPORT_SERIALIZATION + +/** @par 检测点 */ +BOOST_AUTO_TEST_CASE( test_LOG_export ) { + StockManager& sm = StockManager::instance(); + string filename(sm.tmpdir()); + filename += "/LOG.xml"; + + Stock stock = sm.getStock("sh000001"); + KData kdata = stock.getKData(KQuery(-20)); + Indicator x1 = LOG(CLOSE(kdata)); + { + std::ofstream ofs(filename); + boost::archive::xml_oarchive oa(ofs); + oa << BOOST_SERIALIZATION_NVP(x1); + } + + Indicator x2; + { + std::ifstream ifs(filename); + boost::archive::xml_iarchive ia(ifs); + ia >> BOOST_SERIALIZATION_NVP(x2); + } + + BOOST_CHECK(x1.size() == x2.size()); + BOOST_CHECK(x1.discard() == x2.discard()); + BOOST_CHECK(x1.getResultNumber() == x2.getResultNumber()); + for (size_t i = 0; i < x1.size(); ++i) { + BOOST_CHECK_CLOSE(x1[i], x2[i], 0.00001); + } +} +#endif /* #if HKU_SUPPORT_SERIALIZATION */ + +/** @} */ + + diff --git a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_SGN.cpp b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_SGN.cpp index 651d0be1..4f2b49ea 100644 --- a/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_SGN.cpp +++ b/hikyuu_cpp/unit_test/libs/hikyuu/indicator/test_SGN.cpp @@ -44,6 +44,21 @@ BOOST_AUTO_TEST_CASE( test_SGN ) { BOOST_CHECK(result[0] == -1); BOOST_CHECK(result[1] == 0); BOOST_CHECK(result[2] == 1); + + result = SGN(-1); + BOOST_CHECK(result.size() == 1); + BOOST_CHECK(result.discard() == 0); + BOOST_CHECK(result[0] == -1); + + result = SGN(0); + BOOST_CHECK(result.size() == 1); + BOOST_CHECK(result.discard() == 0); + BOOST_CHECK(result[0] == 0); + + result = SGN(1); + BOOST_CHECK(result.size() == 1); + BOOST_CHECK(result.discard() == 0); + BOOST_CHECK(result[0] == 1); } diff --git a/hikyuu_pywrap/indicator/_build_in.cpp b/hikyuu_pywrap/indicator/_build_in.cpp index dc15ae6b..82f54658 100644 --- a/hikyuu_pywrap/indicator/_build_in.cpp +++ b/hikyuu_pywrap/indicator/_build_in.cpp @@ -106,16 +106,19 @@ Indicator (*SUM_1)(int) = SUM; Indicator (*SUM_2)(const Indicator&, int) = SUM; Indicator (*ABS_1)() = ABS; -Indicator (*ABS_2)(const Indicator&) = ABS; +Indicator (*ABS_2)(price_t) = ABS; +Indicator (*ABS_3)(const Indicator&) = ABS; Indicator (*NOT_1)() = NOT; Indicator (*NOT_2)(const Indicator&) = NOT; Indicator (*SGN_1)() = SGN; -Indicator (*SGN_2)(const Indicator&) = SGN; +Indicator (*SGN_2)(price_t) = SGN; +Indicator (*SGN_3)(const Indicator&) = SGN; Indicator (*EXP_1)() = EXP; -Indicator (*EXP_2)(const Indicator&) = EXP; +Indicator (*EXP_2)(price_t) = EXP; +Indicator (*EXP_3)(const Indicator&) = EXP; Indicator (*MAX_1)(const Indicator&, const Indicator&) = MAX; Indicator (*MAX_2)(const Indicator&, price_t) = MAX; @@ -134,6 +137,15 @@ Indicator (*BETWEEN_6)(price_t, const Indicator&, price_t) = BETWEEN; Indicator (*BETWEEN_7)(price_t, price_t, const Indicator&) = BETWEEN; Indicator (*BETWEEN_8)(price_t, price_t, price_t) = BETWEEN; +Indicator (*LN_1)() = LN; +Indicator (*LN_2)(price_t) = LN; +Indicator (*LN_3)(const Indicator&) = LN; + +Indicator (*LOG_1)() = LOG; +Indicator (*LOG_2)(price_t) = LOG; +Indicator (*LOG_3)(const Indicator&) = LOG; + + void export_Indicator_build_in() { def("KDATA", KDATA1); def("KDATA", KDATA3); @@ -224,15 +236,18 @@ void export_Indicator_build_in() { def("ABS", ABS_1); def("ABS", ABS_2); + def("ABS", ABS_3); def("NOT", NOT_1); def("NOT", NOT_2); def("SGN", SGN_1); def("SGN", SGN_2); + def("SGN", SGN_3); def("EXP", EXP_1); def("EXP", EXP_2); + def("EXP", EXP_3); def("MAX", MAX_1); def("MAX", MAX_2); @@ -250,6 +265,14 @@ void export_Indicator_build_in() { def("BETWEEN", BETWEEN_6); def("BETWEEN", BETWEEN_7); def("BETWEEN", BETWEEN_8); + + def("LN", LN_1); + def("LN", LN_2); + def("LN", LN_3); + + def("LOG", LOG_1); + def("LOG", LOG_2); + def("LOG", LOG_3); }