hikyuu2/hikyuu_pywrap/indicator/_Indicator.cpp

233 lines
6.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* _Indicator.cpp
*
* Created on: 2012-10-18
* Author: fasiondog
*/
#include <boost/python.hpp>
#include <hikyuu/indicator/Indicator.h>
#include "../_Parameter.h"
#include "../pickle_support.h"
using namespace boost::python;
using namespace hku;
string (Indicator::*ind_read_name)() const = &Indicator::name;
void (Indicator::*ind_write_name)(const string&) = &Indicator::name;
void (Indicator::*setContext_1)(const Stock&, const KQuery&) = &Indicator::setContext;
void (Indicator::*setContext_2)(const KData&) = &Indicator::setContext;
Indicator (Indicator::*ind_call_1)(const Indicator&) = &Indicator::operator();
Indicator (Indicator::*ind_call_2)(const KData&) = &Indicator::operator();
Indicator (Indicator::*ind_call_3)() = &Indicator::operator();
void (Indicator::*setIndParam1)(const string&, const Indicator&) = &Indicator::setIndParam;
void (Indicator::*setIndParam2)(const string&, const IndParam&) = &Indicator::setIndParam;
void export_Indicator() {
class_<Indicator>("Indicator", "技术指标", init<>())
.def(init<IndicatorImpPtr>())
.def(self_ns::str(self))
.def(self_ns::repr(self))
.add_property("name", ind_read_name, ind_write_name, "指标名称")
.add_property("long_name", &Indicator::long_name, "返回形如Name(param1_val,param2_val,...)")
.add_property("discard", &Indicator::discard, "结果中需抛弃的个数")
.def("set_discard", &Indicator::setDiscard, R"(set_discard(self, discard)
discard则无效
:param int discard: 0)")
.def("get_param", &Indicator::getParam<boost::any>, R"(get_param(self, name)
:param str name:
:return:
:raises out_of_range: )")
.def("set_param", &Indicator::setParam<object>, R"(set_param(self, name, value)
:param str name:
:param value:
:type value: int | bool | float | string | Query | KData | Stock | DatetimeList
:raises logic_error: Unsupported type! )")
.def("have_param", &Indicator::haveParam, "是否存在指定参数")
.def("support_ind_param", &Indicator::supportIndParam, "是否支持动态指标参数")
.def("have_ind_param", &Indicator::haveIndParam, "是否存在指定的动态指标参数")
.def("get_ind_param", &Indicator::getIndParam, R"(get_ind_param(self, name)
:param str name:
:return:
:rtype: IndParam
:raises out_of_range: )")
.def("set_ind_param", setIndParam1)
.def("set_ind_param", setIndParam2, R"(set_param(self, name, ind)
:param str name:
:param Indicator|IndParam: Indicator IndParam )")
.def("empty", &Indicator::empty, "是否为空")
.def("clone", &Indicator::clone, "克隆操作")
.def("formula", &Indicator::formula, R"(formula(self)
:rtype: str)")
.def("get_result_num", &Indicator::getResultNumber, R"(get_result_num(self)
:rtype: int)")
.def("get", &Indicator::get, (arg("pos"), arg("result_index") = 0),
R"(get(self, pos[, result_index=0])
:param int pos:
:param int result_index:
:rtype: float)")
.def("get_pos", &Indicator::getPos, R"(get_pos(self, date):
:param Datetime date:
:rtype: int)")
.def("get_datetime", &Indicator::getDatetime, R"(get_datetime(self, pos)
:param int pos:
:rtype: float)")
.def("get_by_datetime", &Indicator::getByDate, (arg("datetime"), arg("result_index") = 0),
R"(get_by_datetime(self, date[, result_index=0])
constant.null_price
:param Datetime datetime:
:param int result_index:
:rtype: float)")
.def("get_result", &Indicator::getResult, R"(get_result(self, result_index)
:param int result_index:
:rtype: Indicator)")
.def("get_result_as_price_list", &Indicator::getResultAsPriceList,
R"(get_result_as_price_list(self, result_index)
:param int result_index:
:rtype: PriceList)")
.def("get_datetime_list", &Indicator::getDatetimeList, R"(get_datetime_list(self)
:rtype: DatetimeList)")
.def("set_context", setContext_1)
.def("set_context", setContext_2, R"(set_context(self, kdata)
:param KData kdata: K线)
set_context(self, stock, query)
:param Stock stock: Stock
:param Query query: )")
.def("get_context", &Indicator::getContext, R"(get_context(self)
:rtype: KData)")
.def("get_imp", &Indicator::getImp)
.def("__len__", &Indicator::size)
.def("__call__", ind_call_1)
.def("__call__", ind_call_2)
.def("__call__", ind_call_3)
.def(self + self)
.def(self + other<price_t>())
.def(other<price_t>() + self)
.def(self - self)
.def(self - other<price_t>())
.def(other<price_t>() - self)
.def(self * self)
.def(self * other<price_t>())
.def(other<price_t>() * self)
.def(self / self)
.def(self / other<price_t>())
.def(other<price_t>() / self)
.def(self == self)
.def(self == other<price_t>())
.def(other<price_t>() == self)
.def(self != self)
.def(self != other<price_t>())
.def(other<price_t>() != self)
.def(self >= self)
.def(self >= other<price_t>())
.def(other<price_t>() >= self)
.def(self <= self)
.def(self <= other<price_t>())
.def(other<price_t>() <= self)
.def(self > self)
.def(self > other<price_t>())
.def(other<price_t>() > self)
.def(self < self)
.def(self < other<price_t>())
.def(other<price_t>() < self)
.def(self % self)
.def(self % other<price_t>())
.def(other<price_t>() % self)
.def(self & self)
.def(self & other<price_t>())
.def(other<price_t>() & self)
.def(self | self)
.def(self | other<price_t>())
.def(other<price_t>() | self)
#if HKU_PYTHON_SUPPORT_PICKLE
.def_pickle(normal_pickle_suite<Indicator>())
#endif
;
}