fix: Fire reject report if order ack has errors

Rejects are ONLY observable in the order ack, not the execution report
stream from which all other updates are observed. While the pybit sdk
does expose ack callbacks, it doesn't invoke them on rejects/errors.
This commit is contained in:
John Colvin committed 2025-06-20 16:37:47 +00:00
1 parent 02626ce35c
commit 27cbd51b1c
8 files changed
+231 -50

No files matched your search

@@ -74,6 +74,9 @@ class PyExecutionReport {
std::int64_t transact_time() const;
void set_transact_time(std::int64_t value);
const std::string &error_msg() const;
void set_error_msg(std::string value);
/**
* Sets all data at once (more performant than setting props one at a time
* when calling from python).
@@ -127,6 +130,7 @@ class PyExecutionReport {
double avg_filled_price_;
std::string transact_id_;
std::int64_t transact_time_;
std::string error_msg_;
friend void from_json(const nlohmann::json &j, PyExecutionReport &req);
};
@@ -263,6 +267,13 @@ inline void PyExecutionReport::set_transact_time(std::int64_t value) {
transact_time_ = value;
}
inline const std::string &PyExecutionReport::error_msg() const {
return error_msg_;
}
inline void PyExecutionReport::set_error_msg(std::string value) {
error_msg_ = std::move(value);
}
inline std::string PyExecutionReport::to_string() const {
return fmt::format("{}", *this);
}
@@ -261,6 +261,7 @@ PYBIND11_MODULE(python_interop_module, m) {
.PROP(PyExecutionReport, avg_filled_price)
.PROP(PyExecutionReport, order_type)
.PROP(PyExecutionReport, transact_time)
.PROP(PyExecutionReport, error_msg)
.def(
"set_data", &PyExecutionReport::set_data, py::arg("key"),
py::arg("account"), py::arg("exchange_order_id"),