mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-11-30 02:48:57 +08:00
convert_any Parameter c++->python 支持 KData 和 Block
This commit is contained in:
parent
d9332aef40
commit
ee95cdec02
@ -195,6 +195,31 @@ public:
|
||||
std::string s(boost::any_cast<std::string>(x));
|
||||
return Py_BuildValue("s", s.c_str());
|
||||
|
||||
} else if (x.type() == typeid(KData)) {
|
||||
const KData& k = boost::any_cast<KData>(x);
|
||||
std::stringstream cmd;
|
||||
if (k == Null<KData>()) {
|
||||
cmd << "KData()";
|
||||
} else {
|
||||
auto stk = k.getStock();
|
||||
auto query = k.getQuery();
|
||||
std::stringstream q_cmd;
|
||||
if (query.queryType() == KQuery::INDEX) {
|
||||
q_cmd << "Query(" << query.start() << "," << query.end() << ", Query."
|
||||
<< KQuery::getKTypeName(query.kType()) << ", Query."
|
||||
<< KQuery::getRecoverTypeName(query.recoverType()) << ")";
|
||||
} else {
|
||||
q_cmd << "Query(Datetime(" << query.startDatetime() << "), Datetime("
|
||||
<< query.endDatetime() << "), " << "Query."
|
||||
<< KQuery::getKTypeName(query.kType()) << "Query."
|
||||
<< KQuery::getRecoverTypeName(query.recoverType()) << ")";
|
||||
}
|
||||
cmd << "KData(get_stock('" << stk.market_code() << "'), " << q_cmd.str() << ")";
|
||||
}
|
||||
object o = eval(cmd.str());
|
||||
o.inc_ref();
|
||||
return o;
|
||||
|
||||
} else if (x.type() == typeid(Stock)) {
|
||||
const Stock& stk = boost::any_cast<Stock>(x);
|
||||
std::stringstream cmd;
|
||||
@ -210,13 +235,18 @@ public:
|
||||
} else if (x.type() == typeid(Block)) {
|
||||
const Block& blk = boost::any_cast<const Block&>(x);
|
||||
std::stringstream cmd;
|
||||
object o;
|
||||
if (blk == Null<Block>()) {
|
||||
cmd << "Block()";
|
||||
o = eval(cmd.str());
|
||||
o.inc_ref();
|
||||
} else {
|
||||
cmd << "get_block('" << blk.category() << "','" << blk.name() << "')";
|
||||
cmd << "Block('" << blk.category() << "','" << blk.name() << "')";
|
||||
o = eval(cmd.str());
|
||||
o.inc_ref();
|
||||
Block out = o.cast<Block>();
|
||||
out.add(blk.getStockList());
|
||||
}
|
||||
object o = eval(cmd.str());
|
||||
o.inc_ref();
|
||||
return o;
|
||||
|
||||
} else if (x.type() == typeid(KQuery)) {
|
||||
|
Loading…
Reference in New Issue
Block a user