mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 02:48:57 +08:00
continue
This commit is contained in:
parent
d4aee26be2
commit
f9173dc212
@ -76,8 +76,8 @@ if sys.platform == 'win32':
|
||||
# 读取配置信息,并初始化
|
||||
#
|
||||
# ==============================================================================
|
||||
#config_file = './test_data/hikyuu_win.ini'
|
||||
config_file = os.path.expanduser('~') + "/.hikyuu/hikyuu.ini"
|
||||
config_file = './test_data/hikyuu_win.ini'
|
||||
#config_file = os.path.expanduser('~') + "/.hikyuu/hikyuu.ini"
|
||||
if not os.path.exists(config_file):
|
||||
# 检查老版本配置是否存在,如果存在可继续使用,否则异常终止
|
||||
data_config_file = os.path.expanduser('~') + "/.hikyuu/data_dir.ini"
|
||||
|
@ -18,34 +18,6 @@
|
||||
namespace hku {
|
||||
|
||||
double HKU_API roundEx(double number, int ndigits) {
|
||||
/*double f;
|
||||
int i;
|
||||
f = 1.0;
|
||||
i = abs(ndigits);
|
||||
while (--i >= 0){
|
||||
f = f*10.0;
|
||||
}
|
||||
|
||||
if (ndigits < 0){
|
||||
number /= f;
|
||||
}else{
|
||||
number *= f;
|
||||
}
|
||||
|
||||
if (number >= 0.0){
|
||||
number = std::floor(number + 0.5);
|
||||
}else{
|
||||
number = std::ceil(number - 0.5);
|
||||
}
|
||||
|
||||
if (ndigits < 0){
|
||||
number *= f;
|
||||
}else{
|
||||
number /= f;
|
||||
}
|
||||
|
||||
return number;*/
|
||||
|
||||
//切换至:ROUND_HALF_EVEN 银行家舍入法
|
||||
double pow1, pow2, y, z;
|
||||
double x = number;
|
||||
|
@ -14,41 +14,38 @@ using namespace boost::python;
|
||||
using namespace hku;
|
||||
|
||||
void export_KData() {
|
||||
|
||||
class_<KData>("KData", init<>())
|
||||
.def(init<const KData&>())
|
||||
.def(init<const Stock&, const KQuery&>())
|
||||
//.def(self_ns::str(self))
|
||||
.def("__str__", &KData::toString)
|
||||
.add_property("startPos", &KData::startPos)
|
||||
.add_property("endPos", &KData::endPos)
|
||||
.add_property("lastPos", &KData::lastPos)
|
||||
.add_property("open", &KData::open)
|
||||
.add_property("close", &KData::close)
|
||||
.add_property("high", &KData::high)
|
||||
.add_property("low", &KData::low)
|
||||
.add_property("amo", &KData::amo)
|
||||
.add_property("vol", &KData::vol)
|
||||
.def(init<const KData&>())
|
||||
.def(init<const Stock&, const KQuery&>())
|
||||
//.def(self_ns::str(self))
|
||||
.def("__str__", &KData::toString)
|
||||
.def("__repr__", &KData::toString)
|
||||
.add_property("startPos", &KData::startPos)
|
||||
.add_property("endPos", &KData::endPos)
|
||||
.add_property("lastPos", &KData::lastPos)
|
||||
.add_property("open", &KData::open)
|
||||
.add_property("close", &KData::close)
|
||||
.add_property("high", &KData::high)
|
||||
.add_property("low", &KData::low)
|
||||
.add_property("amo", &KData::amo)
|
||||
.add_property("vol", &KData::vol)
|
||||
|
||||
.def("getDatetimeList", &KData::getDatetimeList)
|
||||
.def("getKRecord", &KData::getKRecord)
|
||||
.def("get", &KData::getKRecord)
|
||||
.def("getKRecordByDate", &KData::getKRecordByDate)
|
||||
.def("getByDate", &KData::getKRecordByDate)
|
||||
.def("_getPos", &KData::getPos) //python中需要将Null的情况改写为None
|
||||
.def("getDatetimeList", &KData::getDatetimeList)
|
||||
.def("getKRecord", &KData::getKRecord)
|
||||
.def("get", &KData::getKRecord)
|
||||
.def("getKRecordByDate", &KData::getKRecordByDate)
|
||||
.def("getByDate", &KData::getKRecordByDate)
|
||||
.def("_getPos", &KData::getPos) // python中需要将Null的情况改写为None
|
||||
|
||||
.def("size", &KData::size)
|
||||
.def("empty", &KData::empty)
|
||||
.def("getQuery", &KData::getQuery)
|
||||
.def("getStock", &KData::getStock)
|
||||
.def("tocsv", &KData::tocsv)
|
||||
.def("size", &KData::size)
|
||||
.def("empty", &KData::empty)
|
||||
.def("getQuery", &KData::getQuery)
|
||||
.def("getStock", &KData::getStock)
|
||||
.def("tocsv", &KData::tocsv)
|
||||
|
||||
.def("__len__", &KData::size)
|
||||
.def("__len__", &KData::size)
|
||||
#if HKU_PYTHON_SUPPORT_PICKLE
|
||||
.def_pickle(normal_pickle_suite<KData>())
|
||||
.def_pickle(normal_pickle_suite<KData>())
|
||||
#endif
|
||||
;
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,32 +16,32 @@ bool (*krecord_eq)(const KRecord&, const KRecord&) = operator==;
|
||||
|
||||
void export_KReord() {
|
||||
class_<KRecord>("KRecord", init<>())
|
||||
.def(init<const Datetime&>())
|
||||
.def(init<const Datetime&, price_t, price_t, price_t, price_t, price_t, price_t>())
|
||||
.def(self_ns::str(self))
|
||||
.def_readwrite("datetime", &KRecord::datetime)
|
||||
.def_readwrite("openPrice", &KRecord::openPrice)
|
||||
.def_readwrite("highPrice", &KRecord::highPrice)
|
||||
.def_readwrite("lowPrice", &KRecord::lowPrice)
|
||||
.def_readwrite("closePrice", &KRecord::closePrice)
|
||||
.def_readwrite("transAmount", &KRecord::transAmount)
|
||||
.def_readwrite("transCount", &KRecord::transCount)
|
||||
.def("__eq__", krecord_eq)
|
||||
.def(init<const Datetime&>())
|
||||
.def(init<const Datetime&, price_t, price_t, price_t, price_t, price_t, price_t>())
|
||||
.def(self_ns::str(self))
|
||||
.def(self_ns::repr(self))
|
||||
.def_readwrite("datetime", &KRecord::datetime, "时间")
|
||||
.def_readwrite("openPrice", &KRecord::openPrice)
|
||||
.def_readwrite("highPrice", &KRecord::highPrice)
|
||||
.def_readwrite("lowPrice", &KRecord::lowPrice)
|
||||
.def_readwrite("closePrice", &KRecord::closePrice)
|
||||
.def_readwrite("transAmount", &KRecord::transAmount)
|
||||
.def_readwrite("transCount", &KRecord::transCount)
|
||||
.def("__eq__", krecord_eq)
|
||||
#if HKU_PYTHON_SUPPORT_PICKLE
|
||||
.def_pickle(normal_pickle_suite<KRecord>())
|
||||
.def_pickle(normal_pickle_suite<KRecord>())
|
||||
#endif
|
||||
;
|
||||
;
|
||||
|
||||
KRecordList::const_reference (KRecordList::*KRecordList_at)(KRecordList::size_type) const = &KRecordList::at;
|
||||
KRecordList::const_reference (KRecordList::*KRecordList_at)(KRecordList::size_type) const =
|
||||
&KRecordList::at;
|
||||
void (KRecordList::*append)(const KRecord&) = &KRecordList::push_back;
|
||||
class_<KRecordList>("KRecordList")
|
||||
.def("__iter__", iterator<KRecordList>())
|
||||
.def("size", &KRecordList::size)
|
||||
.def("__len__", &KRecordList::size)
|
||||
.def("__getitem__", KRecordList_at, return_value_policy<copy_const_reference>())
|
||||
.def("append", append)
|
||||
;
|
||||
.def("__iter__", iterator<KRecordList>())
|
||||
.def("size", &KRecordList::size)
|
||||
.def("__len__", &KRecordList::size)
|
||||
.def("__getitem__", KRecordList_at, return_value_policy<copy_const_reference>())
|
||||
.def("append", append);
|
||||
|
||||
register_ptr_to_python<KRecordListPtr>();
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ void export_TransRecord() {
|
||||
void (TransList::*append)(const TransRecord&) = &TransList::push_back;
|
||||
class_<TransList>("TransList")
|
||||
.def(self_ns::str(self))
|
||||
.def(self_ns::repr(self))
|
||||
.def("__iter__", iterator<TransList>())
|
||||
.def("size", &TransList::size)
|
||||
.def("__len__", &TransList::size)
|
||||
|
@ -11,12 +11,30 @@
|
||||
using namespace boost::python;
|
||||
using namespace hku;
|
||||
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(roundEx_overload, roundEx, 1, 2);
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(roundUp_overload, roundUp, 1, 2);
|
||||
BOOST_PYTHON_FUNCTION_OVERLOADS(roundDown_overload, roundDown, 1, 2);
|
||||
|
||||
void export_util() {
|
||||
def("roundEx", roundEx, roundEx_overload());
|
||||
def("roundUp", roundUp, roundUp_overload());
|
||||
def("roundDown", roundDown, roundDown_overload());
|
||||
def("roundEx", roundEx, (arg("number"), arg("ndigits") = 0),
|
||||
R"(roundEx(number[, ndigits=0])
|
||||
|
||||
四舍五入,ROUND_HALF_EVEN 银行家舍入法
|
||||
|
||||
:param float number 待四舍五入的数据
|
||||
:param int ndigits 保留小数位数
|
||||
:rype: float)");
|
||||
|
||||
def("roundUp", roundUp, (arg("number"), arg("ndigits") = 0), R"(roundUp(number[, ndigits=0])
|
||||
|
||||
向上截取,如10.1截取后为11
|
||||
|
||||
:param float number 待处理数据
|
||||
:param int ndigits 保留小数位数
|
||||
:rtype: float)");
|
||||
|
||||
def("roundDown", roundDown, (arg("number"), arg("ndigits") = 0),
|
||||
R"(roundDown(number[, ndigits=0])
|
||||
|
||||
向下截取,如10.1截取后为10
|
||||
|
||||
:param float number 待处理数据
|
||||
:param int ndigits 保留小数位数
|
||||
:rtype: float)");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user