diff --git a/hikyuu_pywrap/convert_any.h b/hikyuu_pywrap/convert_any.h index 5d4a5238..27759a0a 100644 --- a/hikyuu_pywrap/convert_any.h +++ b/hikyuu_pywrap/convert_any.h @@ -195,6 +195,31 @@ public: std::string s(boost::any_cast(x)); return Py_BuildValue("s", s.c_str()); + } else if (x.type() == typeid(KData)) { + const KData& k = boost::any_cast(x); + std::stringstream cmd; + if (k == Null()) { + 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(x); std::stringstream cmd; @@ -210,13 +235,18 @@ public: } else if (x.type() == typeid(Block)) { const Block& blk = boost::any_cast(x); std::stringstream cmd; + object o; if (blk == Null()) { 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(); + out.add(blk.getStockList()); } - object o = eval(cmd.str()); - o.inc_ref(); return o; } else if (x.type() == typeid(KQuery)) {