hikyuu2/hikyuu_pywrap/trade_manage/_TradeRecord.cpp
2022-09-15 01:10:41 +08:00

74 lines
2.8 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 <boost/python.hpp>
#include <hikyuu/trade_manage/TradeRecord.h>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "../pickle_support.h"
using namespace boost::python;
using namespace hku;
#if defined(_MSC_VER)
#pragma warning(disable : 4267)
#endif
void export_TradeRecord() {
enum_<BUSINESS>("BUSINESS")
.value("INIT", BUSINESS_INIT)
.value("BUY", BUSINESS_BUY)
.value("SELL", BUSINESS_SELL)
.value("GIFT", BUSINESS_GIFT)
.value("BONUS", BUSINESS_BONUS)
.value("CHECKIN", BUSINESS_CHECKIN)
.value("CHECKOUT", BUSINESS_CHECKOUT)
.value("INVALID", BUSINESS_INVALID);
def("get_business_name", getBusinessName, R"(get_business_name(business)
:param BUSINESS business:
:return: ("INIT"|"BUY"|"SELL"|"GIFT"|"BONUS"|"CHECKIN"|"CHECKOUT"|"UNKNOWN"
:rtype: string)");
class_<TradeRecord>("TradeRecord", "交易记录", init<>())
.def(init<const Stock&, const Datetime&, BUSINESS, price_t, price_t, price_t, double,
const CostRecord&, price_t, price_t, double, 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("margin_ratio", &TradeRecord::marginRatio, "保证金比例")
.def_readwrite("part", &TradeRecord::from,
"交易指示来源,区别是交易系统哪个部件发出的指示,参见: "
":py:class:`System.Part`") // python中不能用from关键字
#if HKU_PYTHON_SUPPORT_PICKLE
.def_pickle(normal_pickle_suite<TradeRecord>())
#endif
;
class_<TradeRecordList>("TradeRecordList")
.def(vector_indexing_suite<TradeRecordList>())
#if HKU_PYTHON_SUPPORT_PICKLE
.def_pickle(normal_pickle_suite<TradeRecordList>())
#endif
;
}