2015-01-07 01:26:14 +08:00
|
|
|
/*
|
|
|
|
* _Condition.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2013-3-10
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/python.hpp>
|
2016-05-10 01:33:39 +08:00
|
|
|
#include <hikyuu/trade_sys/condition/build_in.h>
|
|
|
|
#include "../_Parameter.h"
|
|
|
|
#include "../pickle_support.h"
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
using namespace boost::python;
|
|
|
|
using namespace hku;
|
|
|
|
|
|
|
|
class ConditionWrap : public ConditionBase, public wrapper<ConditionBase> {
|
|
|
|
public:
|
2016-05-07 02:21:07 +08:00
|
|
|
ConditionWrap(): ConditionBase() {}
|
2015-01-07 01:26:14 +08:00
|
|
|
ConditionWrap(const string& name): ConditionBase(name) {}
|
|
|
|
|
2016-05-10 01:33:39 +08:00
|
|
|
void _reset() {
|
|
|
|
if (override func = get_override("_reset")) {
|
|
|
|
func();
|
2017-04-13 02:03:02 +08:00
|
|
|
} else {
|
|
|
|
ConditionBase::_reset();
|
2016-05-10 01:33:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void default_reset() {
|
|
|
|
this->ConditionBase::_reset();
|
|
|
|
}
|
|
|
|
|
2015-01-07 01:26:14 +08:00
|
|
|
void _calculate() {
|
|
|
|
this->get_override("_calculate")();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConditionPtr _clone() {
|
|
|
|
return this->get_override("_clone")();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-06-17 16:59:15 +08:00
|
|
|
string (ConditionBase::*cn_get_name)() const = &ConditionBase::name;
|
|
|
|
void (ConditionBase::*cn_set_name)(const string&) = &ConditionBase::name;
|
2016-05-10 01:33:39 +08:00
|
|
|
|
|
|
|
|
2015-01-07 01:26:14 +08:00
|
|
|
void export_Condition() {
|
2016-05-07 02:21:07 +08:00
|
|
|
class_<ConditionWrap, boost::noncopyable>("ConditionBase", init<>())
|
|
|
|
.def(init<const string&>())
|
2015-01-07 01:26:14 +08:00
|
|
|
.def(self_ns::str(self))
|
2017-06-17 16:59:15 +08:00
|
|
|
.add_property("name", cn_get_name, cn_set_name)
|
2016-05-10 01:33:39 +08:00
|
|
|
.def("getParam", &ConditionBase::getParam<boost::any>)
|
|
|
|
.def("setParam", &ConditionBase::setParam<object>)
|
2019-06-05 21:44:17 +08:00
|
|
|
.def("haveParam", &ConditionBase::haveParam)
|
2016-05-16 01:45:01 +08:00
|
|
|
.def("isValid", &ConditionBase::isValid)
|
2015-01-07 01:26:14 +08:00
|
|
|
.def("setTO", &ConditionBase::setTO)
|
2016-05-10 01:33:39 +08:00
|
|
|
.def("getTO", &ConditionBase::getTO)
|
|
|
|
.def("setTM", &ConditionBase::setTM)
|
|
|
|
.def("getTM", &ConditionBase::getTM)
|
2016-05-16 01:45:01 +08:00
|
|
|
.def("setSG", &ConditionBase::setSG)
|
|
|
|
.def("getSG", &ConditionBase::getSG)
|
2015-01-07 01:26:14 +08:00
|
|
|
.def("reset", &ConditionBase::reset)
|
|
|
|
.def("clone", &ConditionBase::clone)
|
2017-06-13 02:35:52 +08:00
|
|
|
.def("_addValid", &ConditionBase::_addValid)
|
2015-01-07 01:26:14 +08:00
|
|
|
.def("_calculate", pure_virtual(&ConditionBase::_calculate))
|
2016-05-10 01:33:39 +08:00
|
|
|
.def("_reset", &ConditionBase::_reset, &ConditionWrap::default_reset)
|
2015-01-07 01:26:14 +08:00
|
|
|
.def("_clone", pure_virtual(&ConditionBase::_clone))
|
|
|
|
;
|
|
|
|
register_ptr_to_python<ConditionPtr>();
|
2016-05-10 01:33:39 +08:00
|
|
|
|
|
|
|
def("CN_OPLine", CN_OPLine);
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|