2015-01-07 01:26:14 +08:00
|
|
|
/*
|
|
|
|
* _Environment.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2013-3-2
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _TradeRecord.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2013-2-25
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <boost/python.hpp>
|
|
|
|
#include <hikyuu/trade_sys/environment/EnvironmentBase.h>
|
2016-05-19 01:06:00 +08:00
|
|
|
#include <hikyuu/trade_sys/environment/build_in.h>
|
2017-07-21 01:13:51 +08:00
|
|
|
#include "../_Parameter.h"
|
|
|
|
#include "../pickle_support.h"
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
using namespace boost::python;
|
|
|
|
using namespace hku;
|
|
|
|
|
|
|
|
class EnvironmentWrap: public EnvironmentBase, public wrapper<EnvironmentBase>{
|
|
|
|
public:
|
2017-07-21 01:13:51 +08:00
|
|
|
EnvironmentWrap() : EnvironmentBase() {}
|
|
|
|
EnvironmentWrap(const string& name): EnvironmentBase(name) {}
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2016-05-18 02:03:29 +08:00
|
|
|
void _reset() {
|
|
|
|
if (override func = get_override("_reset")) {
|
|
|
|
func();
|
2017-04-13 02:03:02 +08:00
|
|
|
} else {
|
|
|
|
EnvironmentBase::_reset();
|
2016-05-18 02:03:29 +08:00
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
2016-05-18 02:03:29 +08:00
|
|
|
void default_reset() {
|
|
|
|
this->EnvironmentBase::_reset();
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EnvironmentPtr _clone() {
|
|
|
|
return this->get_override("_clone")();
|
|
|
|
}
|
|
|
|
|
2016-05-18 02:03:29 +08:00
|
|
|
void _calculate() {
|
|
|
|
this->get_override("_calculate")();
|
|
|
|
}
|
2015-01-07 01:26:14 +08:00
|
|
|
};
|
|
|
|
|
2017-06-17 16:59:15 +08:00
|
|
|
string (EnvironmentBase::*ev_get_name)() const = &EnvironmentBase::name;
|
|
|
|
void (EnvironmentBase::*ev_set_name)(const string&) = &EnvironmentBase::name;
|
2016-05-16 01:45:01 +08:00
|
|
|
|
2015-01-07 01:26:14 +08:00
|
|
|
void export_Environment() {
|
2017-07-21 01:13:51 +08:00
|
|
|
class_<EnvironmentWrap, boost::noncopyable>("EnvironmentBase", 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", ev_get_name, ev_set_name)
|
2016-05-16 01:45:01 +08:00
|
|
|
.def("getParam", &EnvironmentBase::getParam<boost::any>)
|
|
|
|
.def("setParam", &EnvironmentBase::setParam<object>)
|
2019-06-05 21:44:17 +08:00
|
|
|
.def("haveParam", &EnvironmentBase::haveParam)
|
2016-05-18 02:03:29 +08:00
|
|
|
.def("setQuery", &EnvironmentBase::setQuery)
|
|
|
|
.def("getQuery", &EnvironmentBase::getQuery)
|
|
|
|
.def("isValid", &EnvironmentBase::isValid)
|
|
|
|
.def("_addValid", &EnvironmentBase::_addValid)
|
2015-01-07 01:26:14 +08:00
|
|
|
.def("reset", &EnvironmentBase::reset)
|
|
|
|
.def("clone", &EnvironmentBase::clone)
|
2016-05-18 02:03:29 +08:00
|
|
|
.def("_reset", &EnvironmentBase::_reset, &EnvironmentWrap::default_reset)
|
2015-01-07 01:26:14 +08:00
|
|
|
.def("_clone", pure_virtual(&EnvironmentBase::_clone))
|
2016-05-18 02:03:29 +08:00
|
|
|
.def("_calculate", pure_virtual(&EnvironmentBase::_calculate))
|
2015-01-07 01:26:14 +08:00
|
|
|
;
|
|
|
|
register_ptr_to_python<EnvironmentPtr>();
|
2016-05-19 01:06:00 +08:00
|
|
|
|
|
|
|
def("EV_TwoLine", EV_TwoLine, (arg("fast"), arg("slow"), arg("market") = "SH"));
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|