hikyuu2/hikyuu_pywrap/trade_manage/_OrderBroker.cpp

98 lines
3.5 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.

/*
* _OrderBroker.cpp
*
* Created on: 2017年6月28日
* Author: fasiondog
*/
#include <hikyuu/trade_manage/OrderBrokerBase.h>
#include "../pybind_utils.h"
namespace py = pybind11;
using namespace hku;
class PyOrderBrokerBase : public OrderBrokerBase {
public:
using OrderBrokerBase::OrderBrokerBase;
Datetime _buy(Datetime datetime, const string& market, const string& code, price_t price,
double num) override {
PYBIND11_OVERLOAD_PURE(Datetime, OrderBrokerBase, _buy, datetime, market, code, price, num);
}
Datetime _sell(Datetime datetime, const string& market, const string& code, price_t price,
double num) override {
PYBIND11_OVERLOAD_PURE(Datetime, OrderBrokerBase, datetime, market, code, price, num);
}
};
void export_OrderBroker(py::module& m) {
py::class_<OrderBrokerBase, OrderBrokerPtr, PyOrderBrokerBase>(
m, "OrderBrokerBase",
R"(订单代理包装基类,用户可以参考自定义自己的订单代理,加入额外的处理
:param bool real:
:param float slip: slip则下单; )")
.def(py::init<>())
.def(py::init<const string&>(), R"(
:param str name: )")
.def("__str__", to_py_str<OrderBrokerBase>)
.def("__repr__", to_py_str<OrderBrokerBase>)
.def_property("name", py::overload_cast<>(&OrderBrokerBase::name, py::const_),
py::overload_cast<const string&>(&OrderBrokerBase::name),
py::return_value_policy::copy, "名称(可读写)")
.def("buy", &OrderBrokerBase::buy, R"(buy(self, datetime, market, code, price, num)
:param Datetime datetime:
:param str market:
:param str code:
:param float price:
:param float num:
:return:
:rtype: Datetime)")
.def("sell", &OrderBrokerBase::sell, R"(sell(self, datetime, market, code, price, num)
:param Datetime datetime:
:param str market:
:param str code:
:param float price:
:param float num:
:return:
"rtype: Datetime)")
.def("_buy", &OrderBrokerBase::_buy,
R"(_buy(self, datetime, market, code, price, num)
:param Datetime datetime:
:param str market:
:param str code:
:param float price:
:param float num:
:return:
:rtype: Datetime)")
.def("_sell", &OrderBrokerBase::_sell,
R"(_sell(self, datetime, market, code, price, num)
:param Datetime datetime:
:param str market:
:param str code:
:param float price:
:param float num:
:return:
"rtype: Datetime)");
}