hikyuu2/hikyuu_pywrap/trade_manage/_TradeRecord.cpp
2023-12-28 03:05:07 +08:00

73 lines
2.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* _TradeRecord.cpp
*
* Created on: 2013-2-25
* Author: fasiondog
*/
#include <hikyuu/trade_manage/TradeRecord.h>
#include "../pybind_utils.h"
using namespace hku;
namespace py = pybind11;
#if defined(_MSC_VER)
#pragma warning(disable : 4267)
#endif
PYBIND11_MAKE_OPAQUE(TradeRecordList);
void export_TradeRecord(py::module& m) {
py::enum_<BUSINESS>(m, "BUSINESS")
.value("INIT", BUSINESS_INIT)
.value("BUY", BUSINESS_BUY)
.value("SELL", BUSINESS_SELL)
.value("BUY_SHORT", BUSINESS_BUY_SHORT)
.value("SELL_SHORT", BUSINESS_SELL_SHORT)
.value("GIFT", BUSINESS_GIFT)
.value("BONUS", BUSINESS_BONUS)
.value("CHECKIN", BUSINESS_CHECKIN)
.value("CHECKOUT", BUSINESS_CHECKOUT)
.value("CHECKIN_STOCK", BUSINESS_CHECKIN_STOCK)
.value("CHECKOUT_STOCK", BUSINESS_CHECKOUT_STOCK)
.value("BORROW_CASH", BUSINESS_BORROW_CASH)
.value("RETURN_CASH", BUSINESS_RETURN_CASH)
.value("BORROW_STOCK", BUSINESS_BORROW_STOCK)
.value("RETURN_STOCK", BUSINESS_RETURN_STOCK)
.value("INVALID", BUSINESS_INVALID);
m.def("get_business_name", getBusinessName, R"(get_business_name(business)
:param BUSINESS business:
:return: ("INIT"|"BUY"|"SELL"|"GIFT"|"BONUS"|"CHECKIN"|"CHECKOUT"|"UNKNOWN"
:rtype: string)");
py::class_<TradeRecord>(m, "TradeRecord", "交易记录")
.def(py::init<>())
.def(py::init<const Stock&, const Datetime&, BUSINESS, price_t, price_t, price_t, double,
const CostRecord&, price_t, price_t, SystemPart>())
.def("__str__", &TradeRecord::toString)
.def("__repr__", &TradeRecord::toString)
.def("is_null", &TradeRecord::isNull)
.def_readwrite("stock", &TradeRecord::stock, "股票Stock")
.def_readwrite("datetime", &TradeRecord::datetime, " 交易时间Datetime")
.def_readwrite("business", &TradeRecord::business, "交易类型BUSINESS")
.def_readwrite("plan_price", &TradeRecord::planPrice, "计划交易价格float")
.def_readwrite("real_price", &TradeRecord::realPrice, "实际交易价格float")
.def_readwrite("goal_price", &TradeRecord::goalPrice,
"目标价格float如果为0表示未限定目标")
.def_readwrite("number", &TradeRecord::number, "成交数量float")
.def_readwrite("cost", &TradeRecord::cost, "交易成本")
.def_readwrite("stoploss", &TradeRecord::stoploss, "止损价float")
.def_readwrite("cash", &TradeRecord::cash, "现金余额float")
.def_readwrite("part", &TradeRecord::from,
"交易指示来源,区别是交易系统哪个部件发出的指示,参见: "
":py:class:`System.Part`") // python中不能用from关键字
DEF_PICKLE(TradeRecord);
py::bind_vector<TradeRecordList>(m, "TradeRecordList");
}