Skip to content

Commit 0074150

Browse files
committed
fixed OperatorSignal 多级组合
1 parent 964ac66 commit 0074150

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

hikyuu_cpp/hikyuu/trade_sys/signal/SignalBase.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ void SignalBase::reset() {
9797
void SignalBase::startCycle(const Datetime& start, const Datetime& close) {
9898
HKU_IF_RETURN(!m_ignore_cycle && !getParam<bool>("cycle"), void());
9999
HKU_INFO("m_cycle_start: {}, m_cycle_end: {}", m_cycle_start, m_cycle_end);
100-
HKU_ASSERT(start != Null<Datetime>() && close != Null<Datetime>() && start < close);
100+
HKU_CHECK(start != Null<Datetime>() && close != Null<Datetime>() && start < close, "{}",
101+
m_name);
101102
HKU_CHECK(start >= m_cycle_end || m_cycle_end == Null<Datetime>(),
102103
"curretn start: {}, pre cycle end: {}", start, m_cycle_end);
103104
m_cycle_start = start;

hikyuu_cpp/hikyuu/trade_sys/signal/SignalBase.h

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class HKU_API SignalBase : public enable_shared_from_this<SignalBase> {
107107
void startCycle(const Datetime& start, const Datetime& end);
108108
const Datetime& getCycleStart() const;
109109
const Datetime& getCycleEnd() const;
110+
bool ignoreCycle() const {
111+
return m_ignore_cycle;
112+
}
110113

111114
/** 复位操作 */
112115
void reset();

hikyuu_cpp/hikyuu/trade_sys/signal/imp/logic/OperatorSignal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void OperatorSignal::sub_sg_calculate(SignalPtr& sg, const KData& kdata) {
4747
bool cycle = sg->getParam<bool>("cycle");
4848
if (m_kdata == kdata && !cycle) {
4949
sg->_calculate(kdata);
50-
} else if (m_kdata != kdata && cycle) {
50+
} else if (m_kdata != Null<KData>() && m_kdata != kdata && cycle) {
5151
sg->startCycle(m_cycle_start, m_cycle_end);
5252
sg->_calculate(kdata);
5353
}

hikyuu_pywrap/indicator/_build_in.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -2129,4 +2129,20 @@ void export_Indicator_build_in(py::module& m) {
21292129
:param Indicator ind: 指标
21302130
:param bool ignore_discard: 忽略指标丢弃数据
21312131
:rtype: Indicator)");
2132+
2133+
m.def("JUMPUP", py::overload_cast<>(JUMPUP));
2134+
m.def("JUMPUP", py::overload_cast<const Indicator&>(JUMPUP), R"(JUMPUP([ind])
2135+
2136+
边缘跳变,从小于等于0.0,跳变到 > 0.0
2137+
2138+
:param Indicator ind: 指标
2139+
:rtype: Indicator)");
2140+
2141+
m.def("JUMPDOWN", py::overload_cast<>(JUMPDOWN));
2142+
m.def("JUMPDOWN", py::overload_cast<const Indicator&>(JUMPDOWN), R"(JUMPDOWN([ind])
2143+
2144+
边缘跳变,从大于0.0,跳变到 <= 0.0
2145+
2146+
:param Indicator ind: 指标
2147+
:rtype: Indicator)");
21322148
}

0 commit comments

Comments
 (0)