cleanup: Remove unnecessary py_module.cpp files

We used to have separate modules for md and execution. I forgot
to remove these after unifying them to a single module.
This commit is contained in:
John Colvin committed 2025-06-16 14:31:28 +00:00
1 parent c098b5e442
commit 0cb46fd8ab
2 files changed
-250

No files matched your search

@@ -1,153 +0,0 @@
#include "py_cancel_order_request.h"
#include "py_cancel_replace_order_request.h"
#include "py_create_order_request.h"
#include "python_interop/execution/execution_gateway.h"
#include "python_interop/execution/execution_gateway_bridge.h"
#include "python_interop/execution/py_execution_gateway.h"
#include "python_interop/execution/py_execution_report.h"
#include "python_interop/execution/py_position_info.h"
#include "python_interop/md/md_bridge.h"
#include "python_interop/md/md_provider.h"
#include "python_interop/md/py_book.h"
#include "python_interop/md/py_book_level.h"
#include "python_interop/md/py_book_side.h"
#include "python_interop/md/py_md_provider.h"
#include "python_interop/md/py_trade.h"
#include <memory>
#include <pybind11/detail/common.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl_bind.h>
using bts::md::py_interop::MdBridge;
using bts::md::py_interop::MdProvider;
using bts::md::py_interop::PyBook;
using bts::md::py_interop::PyBookLevel;
using bts::md::py_interop::PyBookSide;
using bts::md::py_interop::PyMdProvider;
using bts::md::py_interop::PyTrade;
using python_execution::ExecutionGateway;
using python_execution::ExecutionGatewayBridge;
using python_execution::PyCancelOrderRequest;
using python_execution::PyCancelReplaceOrderRequest;
using python_execution::PyCreateOrderRequest;
using python_execution::PyExecutionGateway;
using python_execution::PyExecutionReport;
using python_execution::PyPositionInfo;
using std::shared_ptr;
using std::shared_ptr;
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
namespace py = pybind11;
#define PY_ARG(arg) pybind11::arg(#arg)
#define _STR(x) #x
// In general, we bind c++ methods to python methods with the same name verbatim.
// The DEF macro avoids typos in the python method name for this common case.
#define DEF(type, member) def(_STR(member), &type::member)
#define DEF_ARGS(type, member, ...) \
def(_STR(member), &type::member, __VA_ARGS__)
#define EXPLICIT_DEF(type, member, member_type) \
def(_STR(member), (member_type) & type::member)
// The PROP macro defines getter and setter methods according to <name>
// Binds a pseudo property with getter/setter methods.
// Binds getter -> <name>, and setter -> set_<name>.
#define PROP(type, name) \
def(_STR(name), &type::name) \
.def(_STR(set_##name), &type::set_##name, py::arg(#name))
PYBIND11_MODULE(python_execution_module, m) {
py::class_<PyCreateOrderRequest, shared_ptr<PyCreateOrderRequest>>(
m, "PyCreateOrderRequest")
.def(py::init<>())
.PROP(PyCreateOrderRequest, key)
.PROP(PyCreateOrderRequest, exchange_security_id)
.PROP(PyCreateOrderRequest, venue)
.PROP(PyCreateOrderRequest, is_buy)
.PROP(PyCreateOrderRequest, price)
.PROP(PyCreateOrderRequest, quantity)
.PROP(PyCreateOrderRequest, order_type)
.PROP(PyCreateOrderRequest, time_in_force)
.def("__str__", &PyCreateOrderRequest::to_string);
py::class_<PyCancelOrderRequest, shared_ptr<PyCancelOrderRequest>>(
m, "PyCancelOrderRequest")
.def(py::init<>())
.PROP(PyCancelOrderRequest, key)
.PROP(PyCancelOrderRequest, exchange_order_id)
.PROP(PyCancelOrderRequest, exchange_security_id)
.PROP(PyCancelOrderRequest, venue)
.PROP(PyCancelOrderRequest, is_buy)
.def("__str__", &PyCancelOrderRequest::to_string);
py::class_<
PyCancelReplaceOrderRequest, shared_ptr<PyCancelReplaceOrderRequest>>(
m, "PyCancelReplaceOrderRequest")
.def(py::init<>())
.PROP(PyCancelReplaceOrderRequest, key)
.PROP(PyCancelReplaceOrderRequest, exchange_order_id)
.PROP(PyCancelReplaceOrderRequest, exchange_security_id)
.PROP(PyCancelReplaceOrderRequest, venue)
.PROP(PyCancelReplaceOrderRequest, is_buy)
.PROP(PyCancelReplaceOrderRequest, price)
.PROP(PyCancelReplaceOrderRequest, quantity)
.def("__str__", &PyCancelReplaceOrderRequest::to_string);
py::class_<PyExecutionReport, shared_ptr<PyExecutionReport>>(
m, "PyExecutionReport")
.def(py::init<>())
.PROP(PyExecutionReport, key)
.PROP(PyExecutionReport, account)
.PROP(PyExecutionReport, exchange_order_id)
.PROP(PyExecutionReport, exchange_security_id)
.PROP(PyExecutionReport, order_status)
.PROP(PyExecutionReport, time_in_force)
.PROP(PyExecutionReport, exec_type)
.PROP(PyExecutionReport, venue)
.PROP(PyExecutionReport, security_type)
.PROP(PyExecutionReport, is_buy)
.PROP(PyExecutionReport, price)
.PROP(PyExecutionReport, quantity)
.PROP(PyExecutionReport, filled_quantity)
.PROP(PyExecutionReport, last_filled_quantity)
.PROP(PyExecutionReport, last_filled_price)
.PROP(PyExecutionReport, avg_filled_price)
.PROP(PyExecutionReport, order_type)
.PROP(PyExecutionReport, transact_time)
.def(
"set_data", &PyExecutionReport::set_data, py::arg("key"),
py::arg("account"), py::arg("exchange_order_id"),
py::arg("exchange_security_id"), py::arg("venue"),
py::arg("security_type"), py::arg("order_type"),
py::arg("order_status"), py::arg("time_in_force"),
py::arg("exec_type"), py::arg("is_buy"), py::arg("price"),
py::arg("quantity"), py::arg("filled_quantity"),
py::arg("last_filled_quantity"), py::arg("last_filled_price"),
py::arg("avg_filled_price"), py::arg("transact_id"),
py::arg("transact_time"))
.def("__str__", &PyExecutionReport::to_string);
py::class_<PyPositionInfo, shared_ptr<PyPositionInfo>>(m, "PyPositionInfo")
.def(py::init<>())
.PROP(PyPositionInfo, account)
.PROP(PyPositionInfo, exchange_security_id)
.PROP(PyPositionInfo, venue)
.PROP(PyPositionInfo, security_type)
.PROP(PyPositionInfo, long_quantity)
.PROP(PyPositionInfo, long_avg_cost)
.PROP(PyPositionInfo, short_quantity)
.PROP(PyPositionInfo, short_avg_cost)
.PROP(PyPositionInfo, transact_time)
.def("__str__", &PyPositionInfo::to_string);
py::class_<ExecutionGatewayBridge>(m, "ExecutionGatewayBridge")
.def(py::init<>())
.DEF(ExecutionGatewayBridge, on_execution_report)
.DEF(ExecutionGatewayBridge, on_position_info)
.DEF(ExecutionGatewayBridge, on_is_ready);
py::class_<ExecutionGateway, PyExecutionGateway>(m, "ExecutionGateway")
.def(py::init<>())
.DEF_ARGS(ExecutionGateway, start, py::arg("bridge"))
.DEF_ARGS(ExecutionGateway, create_order, py::arg("req"))
.DEF_ARGS(ExecutionGateway, cancel_order, py::arg("req"))
.DEF_ARGS(ExecutionGateway, cancel_replace_order, py::arg("req"))
.DEF(ExecutionGateway, stop);
}
@@ -1,97 +0,0 @@
#include "md_provider.h"
#include "python_interop/md/py_book_level.h"
#include "python_interop/md/py_book_side.h"
#include "python_interop/md/py_md_provider.h"
#include "python_interop/md/py_trade.h"
#include <pybind11/detail/common.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl_bind.h>
using bts::md::py_interop::MdBridge;
using bts::md::py_interop::MdProvider;
using bts::md::py_interop::PyBook;
using bts::md::py_interop::PyBookLevel;
using bts::md::py_interop::PyBookSide;
using bts::md::py_interop::PyMdProvider;
using bts::md::py_interop::PyTrade;
using std::shared_ptr;
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
namespace py = pybind11;
#define _STR(x) #x
// In general, we bind c++ methods to python methods with the same name verbatim.
// The DEF macro avoids typos in the python method name for this common case.
#define DEF(type, member) def(_STR(member), &type::member)
#define DEF_ARGS(type, member, ...) \
def(_STR(member), &type::member, __VA_ARGS__)
#define EXPLICIT_DEF(type, member, member_type) \
def(_STR(member), (member_type) & type::member)
// The PROP macro defines getter and setter methods according to <name>
// Binds a pseudo property with getter/setter methods.
// Binds getter -> <name>, and setter -> set_<name>.
#define PROP(type, name) \
def(_STR(name), &type::name) \
.def(_STR(set_##name), &type::set_##name, py::arg(#name))
// Define python module with c++ classes.
PYBIND11_MODULE(python_md_module, m) {
using BookSideGetter = PyBookSide &(PyBook::*)();
using BookLevelGetter = PyBookLevel (PyBookSide::*)(int) const;
// book
py::class_<PyBookLevel>(m, "PyBookLevel")
.def(py::init<>())
.PROP(PyBookLevel, price)
.PROP(PyBookLevel, quantity);
py::class_<PyBookSide>(m, "PyBookSide")
.def(py::init<>())
.EXPLICIT_DEF(PyBookSide, get_level, BookLevelGetter)
.DEF(PyBookSide, set_level)
.PROP(PyBookSide, is_ascending)
.def("__len__", &PyBookSide::size)
.def("__str__", &PyBookSide::to_string);
py::class_<PyBook, shared_ptr<PyBook>>(m, "PyBook")
.def(py::init<>())
.PROP(PyBook, venue)
.PROP(PyBook, security_type)
.PROP(PyBook, exchange_security_id)
.EXPLICIT_DEF(PyBook, bids, BookSideGetter)
.DEF(PyBook, set_bids)
.EXPLICIT_DEF(PyBook, asks, BookSideGetter)
.DEF(PyBook, set_asks)
.def(
"set_data", &PyBook::set_data, py::arg("exch_sec_id"),
py::arg("venue"), py::arg("sec_type"), py::arg("bids"),
py::arg("asks"))
.def("__len__", &PyBook::size)
.def("__str__", &PyBook::to_string);
py::bind_vector<std::vector<shared_ptr<PyBook>>>(m, "PyBookList");
// trade
py::class_<PyTrade, shared_ptr<PyTrade>>(m, "PyTrade")
.def(py::init<>())
.PROP(PyTrade, venue)
.PROP(PyTrade, security_type)
.PROP(PyTrade, exchange_security_id)
.PROP(PyTrade, price)
.PROP(PyTrade, quantity)
.PROP(PyTrade, aggressor_side)
.PROP(PyTrade, timestamp);
py::bind_vector<std::vector<shared_ptr<PyTrade>>>(m, "PyTradeList");
// md bridge
py::class_<MdBridge>(m, "MdBridge")
.DEF_ARGS(MdBridge, on_securities, py::arg("securities"))
.DEF_ARGS(MdBridge, on_books, py::arg("books"))
.DEF_ARGS(MdBridge, on_trades, py::arg("trades"));
// md provider
py::class_<MdProvider, PyMdProvider>(m, "MdProvider")
.def(py::init<>())
.DEF_ARGS(MdProvider, start, py::arg("bridge"))
.DEF(MdProvider, stop);
}
#undef PROP
#undef EXPLICIT_DEF
#undef DEF
#undef _STR