@@ -133,15 +133,32 @@ void export_Signal(py::module& m) {
133
133
134
134
.def (" _reset" , &SignalBase::_reset, " 【重载接口】子类复位接口,复位内部私有变量" )
135
135
136
+ .def (" __add__" , [](const SignalPtr& self, const SignalPtr& other) { return self + other; })
137
+ .def (" __add__" , [](const SignalPtr& self, double other) { return self + other; })
138
+ .def (" __radd__" , [](const SignalPtr& self, double other) { return other + self; })
139
+ .def (" __sub__" , [](const SignalPtr& self, const SignalPtr& other) { return self - other; })
140
+ .def (" __sub__" , [](const SignalPtr& self, double other) { return self - other; })
141
+ .def (" __rsub__" , [](const SignalPtr& self, double other) { return other - self; })
142
+ .def (" __mul__" , [](const SignalPtr& self, const SignalPtr& other) { return self * other; })
143
+ .def (" __mul__" , [](const SignalPtr& self, double other) { return self * other; })
144
+ .def (" __rmul__" , [](const SignalPtr& self, double other) { return other * self; })
145
+ .def (" __truediv__" ,
146
+ [](const SignalPtr& self, const SignalPtr& other) { return self / other; })
147
+ .def (" __truediv__" , [](const SignalPtr& self, double other) { return self / other; })
148
+ .def (" __rtruediv__" , [](const SignalPtr& self, double other) { return other / self; })
149
+ .def (" __and__" , [](const SignalPtr& self, const SignalPtr& other) { return self & other; })
150
+ .def (" __or__" , [](const SignalPtr& self, const SignalPtr& other) { return self | other; })
151
+
136
152
DEF_PICKLE (SGPtr);
137
153
138
- m.def (" SG_Bool" , SG_Bool, py::arg (" buy" ), py::arg (" sell" ),
154
+ m.def (" SG_Bool" , SG_Bool, py::arg (" buy" ), py::arg (" sell" ), py::arg ( " alternate " ) = true ,
139
155
R"( SG_Bool(buy, sell)
140
156
141
157
布尔信号指示器,使用运算结果为类似bool数组的Indicator分别作为买入、卖出指示。
142
158
143
159
:param Indicator buy: 买入指示(结果Indicator中相应位置>0则代表买入)
144
160
:param Indicator sell: 卖出指示(结果Indicator中相应位置>0则代表卖出)
161
+ :param bool alternate: 是否交替买入卖出,默认为True
145
162
:return: 信号指示器)" );
146
163
147
164
m.def (" SG_Single" , SG_Single, py::arg (" ind" ), py::arg (" filter_n" ) = 10 ,
0 commit comments