hikyuu2/hikyuu_pywrap/trade_manage/_PositionRecord.cpp
2024-08-19 02:29:22 +08:00

42 lines
1.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.

/*
* _PositionRecord.cpp
*
* Created on: 2013-2-25
* Author: fasiondog
*/
#include <hikyuu/trade_manage/PositionRecord.h>
#include "../pybind_utils.h"
using namespace hku;
namespace py = pybind11;
#if defined(_MSC_VER)
#pragma warning(disable : 4267)
#endif
void export_PositionRecord(py::module& m) {
py::class_<PositionRecord>(m, "PositionRecord", "持仓记录")
.def(py::init<>())
.def(py::init<const Stock&, const Datetime&, const Datetime&, double, price_t, price_t,
double, price_t, price_t, price_t, price_t>())
.def("__str__", &PositionRecord::str)
.def("__repr__", &PositionRecord::str)
.def_readwrite("stock", &PositionRecord::stock, "交易对象Stock")
.def_readwrite("take_datetime", &PositionRecord::takeDatetime, "初次建仓时刻Datetime")
.def_readwrite("clean_datetime", &PositionRecord::cleanDatetime,
"平仓日期,当前持仓记录中为 constant.null_datetime")
.def_readwrite("number", &PositionRecord::number, "当前持仓数量float")
.def_readwrite("stoploss", &PositionRecord::stoploss, "当前止损价float")
.def_readwrite("goal_price", &PositionRecord::goalPrice, "当前的目标价格float")
.def_readwrite("total_number", &PositionRecord::totalNumber, "累计持仓数量float")
.def_readwrite("buy_money", &PositionRecord::buyMoney, "累计买入资金float")
.def_readwrite("total_cost", &PositionRecord::totalCost, "累计交易总成本float")
.def_readwrite("total_risk", &PositionRecord::totalRisk,
"累计交易风险float = 各次 (买入价格-止损)*买入数量, 不包含交易成本")
.def_readwrite("sell_money", &PositionRecord::sellMoney, "累计卖出资金float")
DEF_PICKLE(PositionRecord);
}