hikyuu2/hikyuu_pywrap/_TransRecord.cpp

37 lines
1.1 KiB
C++
Raw Normal View History

2019-02-11 21:13:06 +08:00
/*
* _KRecord.cpp
*
* Created on: 2019-2-11
* Author: fasiondog
*/
#include <hikyuu/serialization/TransRecord_serialization.h>
2020-06-30 23:27:23 +08:00
#include "pybind_utils.h"
2019-02-11 21:13:06 +08:00
using namespace hku;
2023-12-27 02:16:10 +08:00
namespace py = pybind11;
2019-02-11 21:13:06 +08:00
2022-02-21 22:23:52 +08:00
#if defined(_MSC_VER)
#pragma warning(disable : 4267)
#endif
2023-12-27 02:16:10 +08:00
void export_TransRecord(py::module& m) {
py::class_<TransRecord>(m, "TransRecord")
.def(py::init<>())
.def(py::init<const Datetime&, price_t, price_t, TransRecord::DIRECT>())
2023-12-30 14:25:48 +08:00
.def("__str__", to_py_str<TransRecord>)
.def("__repr__", to_py_str<TransRecord>)
.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")
2023-12-27 02:16:10 +08:00
.def(py::self == py::self)
2019-02-11 21:13:06 +08:00
2023-12-27 02:16:10 +08:00
DEF_PICKLE(TransRecord);
py::enum_<TransRecord::DIRECT>(m, "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
}