hikyuu2/hikyuu_pywrap/_TransRecord.cpp

48 lines
1.3 KiB
C++
Raw Normal View History

2019-02-11 21:13:06 +08:00
/*
* _KRecord.cpp
*
* Created on: 2019-2-11
* Author: fasiondog
*/
#include <boost/python.hpp>
#include <hikyuu/serialization/TransRecord_serialization.h>
2022-02-21 22:23:52 +08:00
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
2020-06-30 23:27:23 +08:00
#include "pybind_utils.h"
2019-02-11 21:13:06 +08:00
#include "pickle_support.h"
using namespace boost::python;
using namespace hku;
2022-02-21 22:23:52 +08:00
#if defined(_MSC_VER)
#pragma warning(disable : 4267)
#endif
2019-02-11 21:13:06 +08:00
void export_TransRecord() {
class_<TransRecord>("TransRecord", init<>())
2020-06-30 23:27:23 +08:00
.def(init<const Datetime&, price_t, price_t, TransRecord::DIRECT>())
.def(self_ns::str(self))
2023-12-03 02:09:51 +08:00
.def(self_ns::repr(self))
.def_readwrite("date", &TransRecord::datetime, "时间")
2020-07-10 00:23:33 +08:00
.def_readwrite("price", &TransRecord::price, "价格")
.def_readwrite("vol", &TransRecord::vol, "成交量")
.def_readwrite("direct", &TransRecord::direct, "买卖盘性质, 参见: TransRecord.DIRECT")
.def(self == self)
2019-02-11 21:13:06 +08:00
#if HKU_PYTHON_SUPPORT_PICKLE
2020-06-30 23:27:23 +08:00
.def_pickle(normal_pickle_suite<TransRecord>())
2019-02-11 21:13:06 +08:00
#endif
2020-06-30 23:27:23 +08:00
;
2019-02-11 21:13:06 +08:00
enum_<TransRecord::DIRECT>("DIRECT")
2020-06-30 23:27:23 +08:00
.value("BUY", TransRecord::BUY)
.value("SELL", TransRecord::SELL)
.value("AUCTION", TransRecord::AUCTION);
2019-02-11 21:13:06 +08:00
2020-07-03 00:16:00 +08:00
class_<TransList>("TransList")
2022-02-21 22:23:52 +08:00
.def(vector_indexing_suite<TransList>())
2020-07-03 00:16:00 +08:00
#if HKU_PYTHON_SUPPORT_PICKLE
.def_pickle(normal_pickle_suite<TransList>())
#endif
;
2019-02-11 21:13:06 +08:00
}