hikyuu2/hikyuu_cpp/hikyuu/indicator/crt/MOD.h
2019-05-01 21:26:50 +08:00

49 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* MOD.h
*
* Created on: 2019-5-1
* Author: fasiondog
*/
#ifndef INDICATOR_IMP_MOD_H_
#define INDICATOR_IMP_MOD_H_
#include "CVAL.h"
namespace hku {
/**
* 取整后求模
* @details
* <pre>
* 该函数仅为兼容通达信。实际上,指标求模可直接使用 % 操作符
* </pre>
* @param ind1 指标1将取整
* @param ind2 指标2将取整
* @ingroup Indicator
*/
Indicator MOD(const Indicator& ind1, const Indicator& ind2);
Indicator MOD(const Indicator& ind1, price_t ind2);
Indicator MOD(price_t ind1, const Indicator& ind2);
Indicator MOD(price_t ind1, price_t ind2);
inline Indicator MOD(const Indicator& ind1, const Indicator& ind2) {
return (ind1 % ind2);
}
inline Indicator MOD(const Indicator& ind1, price_t ind2) {
return ind1 % CVAL(ind1, ind2);
}
inline Indicator MOD(price_t ind1, const Indicator& ind2) {
return CVAL(ind2, ind1) % ind2;
}
inline Indicator MOD(price_t ind1, price_t ind2) {
return CVAL(ind1) % CVAL(ind2);
}
} /* namespace */
#endif /* INDICATOR_IMP_MOD_H_ */