hikyuu2/hikyuu_cpp/hikyuu/indicator/imp/IExp.cpp
2019-04-05 13:17:38 +08:00

55 lines
810 B
C++

/*
* IExp.cpp
*
* Created on: 2019年4月3日
* Author: fasiondog
*/
#include "IExp.h"
#if HKU_SUPPORT_SERIALIZATION
BOOST_CLASS_EXPORT(hku::IExp)
#endif
namespace hku {
IExp::IExp() : IndicatorImp("EXP", 1) {
}
IExp::~IExp() {
}
bool IExp::check() {
return true;
}
void IExp::_calculate(const Indicator& data) {
size_t total = data.size();
m_discard = data.discard();
if (m_discard >= total) {
m_discard = total;
return;
}
for (size_t i = m_discard; i < total; ++i) {
price_t x = std::exp(data[i]);
if (std::isinf(x)) {
_set(Null<price_t>(), i);
} else {
_set(std::exp(data[i]), i);
}
}
}
Indicator HKU_API EXP() {
return Indicator(make_shared<IExp>());
}
} /* namespace hku */