From 50eefc65d4eb52efad95db1692dfdb82f3486d66 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 16 Jun 2025 14:16:57 +0000 Subject: [PATCH] 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. --- .../python_interop/execution/py_module.cpp | 153 ------------------ .../python_interop/md/py_module.cpp | 97 ----------- 2 files changed, 250 deletions(-) delete mode 100644 src/lib_python_interop/python_interop/execution/py_module.cpp delete mode 100644 src/lib_python_interop/python_interop/md/py_module.cpp diff --git a/src/lib_python_interop/python_interop/execution/py_module.cpp b/src/lib_python_interop/python_interop/execution/py_module.cpp deleted file mode 100644 index 8cef1cbf9..000000000 --- a/src/lib_python_interop/python_interop/execution/py_module.cpp +++ /dev/null @@ -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 -#include -#include -#include - -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) - -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 -// Binds a pseudo property with getter/setter methods. -// Binds getter -> , and setter -> set_. -#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_>( - 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_>( - 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>( - 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_>( - 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_>(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_(m, "ExecutionGatewayBridge") - .def(py::init<>()) - .DEF(ExecutionGatewayBridge, on_execution_report) - .DEF(ExecutionGatewayBridge, on_position_info) - .DEF(ExecutionGatewayBridge, on_is_ready); - py::class_(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); -} diff --git a/src/lib_python_interop/python_interop/md/py_module.cpp b/src/lib_python_interop/python_interop/md/py_module.cpp deleted file mode 100644 index 4d2614e67..000000000 --- a/src/lib_python_interop/python_interop/md/py_module.cpp +++ /dev/null @@ -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 -#include -#include - -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) - -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 -// Binds a pseudo property with getter/setter methods. -// Binds getter -> , and setter -> set_. -#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_(m, "PyBookLevel") - .def(py::init<>()) - .PROP(PyBookLevel, price) - .PROP(PyBookLevel, quantity); - py::class_(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_>(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>>(m, "PyBookList"); - // trade - py::class_>(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>>(m, "PyTradeList"); - // md bridge - py::class_(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_(m, "MdProvider") - .def(py::init<>()) - .DEF_ARGS(MdProvider, start, py::arg("bridge")) - .DEF(MdProvider, stop); -} - -#undef PROP -#undef EXPLICIT_DEF -#undef DEF -#undef _STR