hikyuu2/hikyuu_pywrap/_Stock.cpp

192 lines
6.7 KiB
C++
Raw Normal View History

2015-01-07 01:26:14 +08:00
/*
* _Stock.cpp
*
* Created on: 2011-12-4
* Author: fasiondog
*/
#include <boost/python.hpp>
#include <hikyuu/serialization/Stock_serialization.h>
#include <hikyuu/KData.h>
#include "_Parameter.h"
2015-01-07 01:26:14 +08:00
#include "pickle_support.h"
using namespace boost::python;
using namespace hku;
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getIndex_overloads, getIndex, 1, 2)
2020-10-09 01:02:52 +08:00
KRecord (Stock::*getKRecord1)(size_t pos, KQuery::KType kType) const = &Stock::getKRecord;
KRecord (Stock::*getKRecord2)(const Datetime&, KQuery::KType kType) const = &Stock::getKRecord;
2015-01-07 01:26:14 +08:00
void export_Stock() {
2020-07-09 00:18:29 +08:00
class_<Stock>("Stock", "证券对象", init<>())
2020-07-06 00:41:32 +08:00
.def(init<const string&, const string&, const string&>())
.def(init<const Stock&>())
2020-07-09 00:18:29 +08:00
2020-07-06 00:41:32 +08:00
.def("__str__", &Stock::toString)
2020-07-09 00:18:29 +08:00
.def("__repr__", &Stock::toString)
.add_property("id", &Stock::id, "内部id")
2020-07-06 00:41:32 +08:00
.add_property("market",
2020-07-09 00:18:29 +08:00
make_function(&Stock::market, return_value_policy<copy_const_reference>()),
"所属市场简称,市场简称是市场的唯一标识")
2020-07-06 00:41:32 +08:00
.add_property("code",
2020-07-09 00:18:29 +08:00
make_function(&Stock::code, return_value_policy<copy_const_reference>()),
"证券代码")
2020-07-06 00:41:32 +08:00
.add_property("market_code",
2020-07-09 00:18:29 +08:00
make_function(&Stock::market_code, return_value_policy<copy_const_reference>()),
"市场简称+证券代码,如: sh000001")
2020-07-06 00:41:32 +08:00
.add_property("name",
2020-07-09 00:18:29 +08:00
make_function(&Stock::name, return_value_policy<copy_const_reference>()),
"证券名称")
.add_property("type", &Stock::type, "证券类型参见constant")
.add_property("valid", &Stock::valid, "该证券当前是否有效")
2020-07-12 20:46:34 +08:00
.add_property("start_datetime", &Stock::startDatetime, "证券起始日期")
.add_property("last_datetime", &Stock::lastDatetime, "证券最后日期")
2020-07-09 00:18:29 +08:00
.add_property("tick", &Stock::tick, "最小跳动量")
.add_property("tick_value", &Stock::tickValue, "最小跳动量价值")
.add_property("unit", &Stock::unit, "每单位价值 = tickValue / tick")
.add_property("precision", &Stock::precision, "价格精度")
.add_property("atom", &Stock::atom, "最小交易数量同min_tradeNumber")
.add_property("min_trade_number", &Stock::minTradeNumber, "最小交易数量")
.add_property("max_trade_number", &Stock::maxTradeNumber, "最大交易数量")
.def("is_null", &Stock::isNull, R"(is_null(self)
Null
:rtype: bool)")
.def("is_buffer", &Stock::isBuffer, R"(指定类型的K线数据是否被缓存)")
.def("get_kdata", &Stock::getKData, R"(get_kdata(self, query)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
K线数据
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Query query:
:return: K线数据
:rtype: KData)")
2020-09-27 23:53:26 +08:00
.def("get_timeline_list", &Stock::getTimeLineList, R"(get_timeline_list(self, query)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
线
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Query query: K线类型
:rtype: TimeLineList)")
.def("get_trans_list", &Stock::getTransList, R"(get_trans_list(self, query)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Query query: K线类型
:rtype: TransList)")
.def("get_count", &Stock::getCount, arg("ktype") = KQuery::DAY,
R"(get_count(self, [ktype=Query.DAY])
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
K线数据量
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Query.KType ktype: K线数据类别
:return: K线记录数
:rtype: int)")
.def("get_market_value", &Stock::getMarketValue, R"(get_market_value(self, date, ktype)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Datetime date:
:param Query.KType ktype: K线数据类别
:return:
:rtype: float)")
2020-10-09 01:02:52 +08:00
.def("get_krecord", getKRecord1, (arg("pos"), arg("ktype") = KQuery::DAY),
2020-07-09 00:18:29 +08:00
R"(get_krecord(self, pos[, ktype=Query.DAY])
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
K线数据记录
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param int pos:
:param Query.KType ktype: K线数据类别
:return: K线记录
:rtype: KRecord)")
2020-10-09 01:02:52 +08:00
.def("get_krecord", getKRecord2, (arg("date"), arg("ktype") = KQuery::DAY),
R"(get_krecord(self, datetime[, ktype=Query.DAY])
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
线/线KRecord
2020-07-10 00:23:33 +08:00
2020-07-12 20:46:34 +08:00
:param Datetime datetime:
2020-07-09 00:18:29 +08:00
:param Query.KType ktype: K线数据类别
:return: K线记录
:rtype: KRecord)")
.def("get_krecord_list", &Stock::getKRecordList, R"(get_krecord_list(self, start, end, ktype)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
K线记录 [start, end)使.
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param int start:
:param int end:
:param Query.KType ktype: K线类别
:return: K线记录列表
:rtype: KRecordList)")
2020-10-03 23:58:04 +08:00
.def("get_datetime_list", &Stock::getDatetimeList, R"(get_datetime_list(self, query)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Query query:
2020-10-03 23:58:04 +08:00
:rtype: DatetimeList)")
2020-07-09 00:18:29 +08:00
.def("get_finance_info", &Stock::getFinanceInfo, R"(get_finance_info(self)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:rtype: Parameter)")
.def("get_history_finance_info", &Stock::getHistoryFinanceInfo,
R"(get_history_finance_info(self, date)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
, https://hikyuu.org/finance_fields.html
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Datetime date: 0331063009301231 Datetime(201109300000)
:rtype: PriceList)")
.def("realtime_update", &Stock::realtimeUpdate, (arg("krecord"), arg("ktype") = KQuery::DAY),
R"(realtime_update(self, krecord)
2020-07-10 00:23:33 +08:00
线
2020-07-10 00:23:33 +08:00
:param KRecord krecord: K线记录
:param KQuery.KType ktype: K 线)")
2020-07-09 00:18:29 +08:00
.def("get_weight", &Stock::getWeight,
(arg("start") = Datetime::min(), arg("end") = Datetime()),
R"(get_weight(self, [start, end])
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
[start,end)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Datetime start:
:param Datetime end:
:rtype: StockWeightList)")
.def("load_kdata_to_buffer", &Stock::loadKDataToBuffer, R"(load_kdata_to_buffer(self, ktype)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
K线数据加载至内存缓存
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Query.KType ktype: K线类型)")
.def("release_kdata_buffer", &Stock::releaseKDataBuffer, R"(release_kdata_buffer(self, ktype)
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
K线数据
2020-07-10 00:23:33 +08:00
2020-07-09 00:18:29 +08:00
:param Query.KType ktype: K线类型)")
.def(self == self)
.def(self != self)
2015-01-07 01:26:14 +08:00
#if HKU_PYTHON_SUPPORT_PICKLE
2020-07-06 00:41:32 +08:00
.def_pickle(normal_pickle_suite<Stock>())
2015-01-07 01:26:14 +08:00
#endif
2020-07-06 00:41:32 +08:00
;
2015-01-07 01:26:14 +08:00
}