2015-01-07 01:26:14 +08:00
|
|
|
/*
|
|
|
|
* _Parameter.cpp
|
|
|
|
*
|
|
|
|
* Created on: 2013-2-28
|
|
|
|
* Author: fasiondog
|
|
|
|
*/
|
|
|
|
|
2023-12-27 02:16:10 +08:00
|
|
|
#include <hikyuu/utilities/Parameter.h>
|
|
|
|
#include "pybind_utils.h"
|
2015-01-07 01:26:14 +08:00
|
|
|
|
|
|
|
using namespace hku;
|
2023-12-27 02:16:10 +08:00
|
|
|
namespace py = pybind11;
|
2015-01-07 01:26:14 +08:00
|
|
|
|
2017-10-12 01:58:08 +08:00
|
|
|
bool (*parameter_eq)(const Parameter&, const Parameter&) = &operator==;
|
2017-10-26 02:02:32 +08:00
|
|
|
bool (*parameter_ne)(const Parameter&, const Parameter&) = &operator!=;
|
2017-10-12 01:58:08 +08:00
|
|
|
bool (*parameter_lt)(const Parameter&, const Parameter&) = &operator<;
|
|
|
|
|
2023-12-27 02:16:10 +08:00
|
|
|
void export_Parameter(py::module& m) {
|
|
|
|
py::class_<Parameter>(m, "Parameter", "参数类,供需要命名参数设定的类使用,类似于 dict")
|
2023-12-28 02:21:36 +08:00
|
|
|
.def(py::init<>())
|
2023-12-30 14:25:48 +08:00
|
|
|
.def("__str__", to_py_str<Parameter>)
|
|
|
|
.def("__repr__", to_py_str<Parameter>)
|
2020-07-09 00:18:29 +08:00
|
|
|
|
|
|
|
.def("__contains__", &Parameter::have)
|
2023-12-27 02:16:10 +08:00
|
|
|
.def("__setitem__", &Parameter::set<boost::any>)
|
|
|
|
.def("__getitem__", &Parameter::get<boost::any>)
|
|
|
|
.def("have", &Parameter::have, "Return True if there is a parameter for the specified name.")
|
|
|
|
.def("set", &Parameter::set<boost::any>)
|
|
|
|
.def("get", &Parameter::get<boost::any>)
|
|
|
|
.def("type", &Parameter::type,
|
|
|
|
"Get the type name of the specified parameter, return 'string' | 'int' | 'double' | "
|
|
|
|
"'bool' | 'Stock' | 'KQuery' | 'KData' | 'PriceList' | 'DatetimeList'")
|
|
|
|
.def("get_name_list", &Parameter::getNameList, "Get all the parameter names list")
|
|
|
|
.def("get_name_value_list", &Parameter::getNameValueList,
|
|
|
|
"Return a string, like 'name1=val1,name2=val2,...'")
|
|
|
|
|
|
|
|
.def(py::self == py::self)
|
|
|
|
.def(py::self != py::self)
|
|
|
|
.def(py::self < py::self)
|
|
|
|
|
|
|
|
DEF_PICKLE(Parameter);
|
2015-01-07 01:26:14 +08:00
|
|
|
}
|