Skip to content

Commit

Permalink
Fix order of arguments in wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenewald committed Oct 13, 2024
1 parent e2781c2 commit f5e7f7e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
8 changes: 4 additions & 4 deletions exchange/src/wrapper/runtime/cpp/cpp_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ CppRuntime::~CppRuntime()

void
CppRuntime::fire_on_trade_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const
{
on_trade_update_func_(
Expand All @@ -111,7 +111,7 @@ CppRuntime::fire_on_trade_update(

void
CppRuntime::fire_on_orderbook_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const
{
on_orderbook_update_func_(
Expand All @@ -127,8 +127,8 @@ CppRuntime::fire_on_account_update(
) const
{
on_account_update_func_(
strategy_object_, ticker, side, static_cast<float>(quantity),
static_cast<float>(price), static_cast<float>(capital)
strategy_object_, ticker, side, static_cast<float>(price),
static_cast<float>(quantity), static_cast<float>(capital)
);
}

Expand Down
4 changes: 2 additions & 2 deletions exchange/src/wrapper/runtime/cpp/cpp_runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class CppRuntime : public Runtime {

private:
void fire_on_trade_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const override;

void fire_on_orderbook_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const override;

void fire_on_account_update(
Expand Down
8 changes: 3 additions & 5 deletions exchange/src/wrapper/runtime/python/python_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
#include <pybind11/embed.h>
#include <pybind11/pybind11.h>

#include <iostream>

namespace nutc::wrapper {

namespace py = pybind11;

void
PyRuntime::fire_on_trade_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const
{
try {
Expand All @@ -28,7 +26,7 @@ PyRuntime::fire_on_trade_update(

void
PyRuntime::fire_on_orderbook_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const
{
try {
Expand All @@ -49,7 +47,7 @@ PyRuntime::fire_on_account_update(
{
try {
py::globals()["strategy"].attr("on_account_update")(
ticker, side, static_cast<float>(quantity), static_cast<float>(price),
ticker, side, static_cast<float>(price), static_cast<float>(quantity),
static_cast<float>(capital)
);
} catch (const py::error_already_set& err) {
Expand Down
4 changes: 2 additions & 2 deletions exchange/src/wrapper/runtime/python/python_runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class PyRuntime : public Runtime {
pybind11::scoped_interpreter guard_;

void fire_on_trade_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const override;

void fire_on_orderbook_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const override;

void fire_on_account_update(
Expand Down
8 changes: 4 additions & 4 deletions exchange/src/wrapper/runtime/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ void
Runtime::process_message(tick_update&& tick_update)
{
std::ranges::for_each(tick_update.ob_updates, [&](const position& u) {
fire_on_orderbook_update(u.ticker, u.side, u.price, u.quantity);
fire_on_orderbook_update(u.ticker, u.side, u.quantity, u.price);
});
std::ranges::for_each(tick_update.matches, [&](const match& m) {
const auto& p = m.position;
fire_on_trade_update(p.ticker, p.side, p.price, p.quantity);
fire_on_trade_update(p.ticker, p.side, p.quantity, p.price);

if (m.buyer_id == trader_id_) {
if (m.buyer_id == trader_id_) [[unlikely]] {
fire_on_account_update(
p.ticker, p.side, p.price, p.quantity, m.buyer_capital
);
}
if (m.seller_id == trader_id_) {
if (m.seller_id == trader_id_) [[unlikely]] {
fire_on_account_update(
p.ticker, p.side, p.price, p.quantity, m.seller_capital
);
Expand Down
4 changes: 2 additions & 2 deletions exchange/src/wrapper/runtime/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class Runtime {
{}

virtual void fire_on_trade_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const = 0;
virtual void fire_on_orderbook_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity
Ticker ticker, Side side, decimal_quantity quantity, decimal_price price
) const = 0;
virtual void fire_on_account_update(
Ticker ticker, Side side, decimal_price price, decimal_quantity quantity,
Expand Down

0 comments on commit f5e7f7e

Please sign in to comment.