From 0cba08276fc1bdd952751786ccaae632edf0de10 Mon Sep 17 00:00:00 2001 From: Steven Ewald Date: Sun, 27 Oct 2024 22:58:52 -0500 Subject: [PATCH] Fix formatting and format repo --- exchange/cmake/lint.cmake | 2 +- .../algos/normal_mode/normal_mode.cpp | 4 +-- exchange/src/exchange/bots/bot_container.cpp | 3 ++- exchange/src/exchange/matching/engine.cpp | 6 +++-- exchange/src/exchange/theo/brownian.hpp | 2 +- .../wrappers/messaging/pipe_reader.cpp | 2 +- exchange/src/linter/common.hpp | 2 +- exchange/src/linter/runtime/runtime.hpp | 2 +- .../messaging/exchange_communicator.hpp | 2 +- .../integration/test_algos/cpp/buy_eth.hpp | 25 ++++++++----------- .../test_algos/cpp/buy_market_order_1000.hpp | 3 +-- .../test_algos/cpp/buy_tsla_at_100.hpp | 25 ++++++++----------- .../test_algos/cpp/buy_tsla_on_account.hpp | 25 ++++++++----------- .../test_algos/cpp/buy_tsla_on_trade.hpp | 25 ++++++++----------- .../test_algos/cpp/cancel_limit_order.hpp | 25 ++++++++----------- .../test_algos/cpp/confirm_1000.hpp | 25 ++++++++----------- .../cpp/partial_cancel_limit_order.hpp | 25 ++++++++----------- .../test_algos/cpp/sell_market_order_1000.hpp | 25 ++++++++----------- .../test_algos/cpp/sell_tsla_on_account.hpp | 25 ++++++++----------- .../integration/test_algos/cpp/template.cpp | 1 - exchange/test/src/integration/tests/basic.cpp | 3 ++- .../matching/composite_orderbook_test.cpp | 3 +-- exchange/test/src/unit/types/decimal.cpp | 10 ++++---- 23 files changed, 122 insertions(+), 148 deletions(-) delete mode 120000 exchange/test/src/integration/test_algos/cpp/template.cpp diff --git a/exchange/cmake/lint.cmake b/exchange/cmake/lint.cmake index 26306f0b..b386799c 100644 --- a/exchange/cmake/lint.cmake +++ b/exchange/cmake/lint.cmake @@ -37,7 +37,7 @@ foreach(file IN LISTS files) if(NOT result EQUAL "0") message(FATAL_ERROR "'${file}': formatter returned with ${result}") endif() - if(NOT FIX AND output MATCHES "incomplete_format='true'") + if(NOT FIX AND output MATCHES "\n(); try { - // TODO: add back + // TODO: add back // traders.add_trader(common::RemoteAlgorithm{}, start_capital); log_i(main, "Created user"); } catch (const std::runtime_error& err) { diff --git a/exchange/src/exchange/bots/bot_container.cpp b/exchange/src/exchange/bots/bot_container.cpp index c52d2fea..bf516a90 100644 --- a/exchange/src/exchange/bots/bot_container.cpp +++ b/exchange/src/exchange/bots/bot_container.cpp @@ -23,7 +23,8 @@ BotContainer::generate_orders( for (const auto& bot : bots_) { cumulative_interest_limit += bot->get_portfolio().get_initial_capital(); - cumulative_quantity_held += bot->get_portfolio().get_holdings(bot->get_ticker()); + cumulative_quantity_held += + bot->get_portfolio().get_holdings(bot->get_ticker()); } return generate_orders( diff --git a/exchange/src/exchange/matching/engine.cpp b/exchange/src/exchange/matching/engine.cpp index 874d3ad7..a7ac9a12 100644 --- a/exchange/src/exchange/matching/engine.cpp +++ b/exchange/src/exchange/matching/engine.cpp @@ -92,10 +92,12 @@ attempt_match_(OrderPairT& orders, common::decimal_price order_fee) GenericTrader* buyer = buy_order.trader; GenericTrader* seller = sell_order.trader; - if (!buyer->can_leverage() && buyer->get_portfolio().get_capital() < total_price) [[unlikely]] + if (!buyer->can_leverage() && buyer->get_portfolio().get_capital() < total_price) + [[unlikely]] return glz::unexpected(MatchFailure::buyer_failure); if (!seller->can_leverage() - && seller->get_portfolio().get_holdings(buy_order.ticker) < match_quantity) [[unlikely]] + && seller->get_portfolio().get_holdings(buy_order.ticker) < match_quantity) + [[unlikely]] return glz::unexpected(MatchFailure::seller_failure); if (buyer == seller) [[unlikely]] { return glz::unexpected(MatchFailure::buyer_failure); diff --git a/exchange/src/exchange/theo/brownian.hpp b/exchange/src/exchange/theo/brownian.hpp index cdb4d783..f9215280 100644 --- a/exchange/src/exchange/theo/brownian.hpp +++ b/exchange/src/exchange/theo/brownian.hpp @@ -62,7 +62,7 @@ class BrownianMotion { generate_norm_(double mean, double stdev, Signedness sign = Signedness::Either); double generate_uniform_(double low, double high); bool generate_bool_(double probability_of_true); - bool market_event_ongoing_() const; + bool market_event_ongoing_() const; double generate_brownian_motion_(double mean, Signedness direction = Signedness::Either); diff --git a/exchange/src/exchange/wrappers/messaging/pipe_reader.cpp b/exchange/src/exchange/wrappers/messaging/pipe_reader.cpp index 1fea5d41..18aa9042 100644 --- a/exchange/src/exchange/wrappers/messaging/pipe_reader.cpp +++ b/exchange/src/exchange/wrappers/messaging/pipe_reader.cpp @@ -1,8 +1,8 @@ #include "pipe_reader.hpp" #include "async_pipe_runner.hpp" -#include "common/messages_wrapper_to_exchange.hpp" #include "common/logging/logging.hpp" +#include "common/messages_wrapper_to_exchange.hpp" #include #include diff --git a/exchange/src/linter/common.hpp b/exchange/src/linter/common.hpp index 95989bd0..a907ec41 100644 --- a/exchange/src/linter/common.hpp +++ b/exchange/src/linter/common.hpp @@ -2,8 +2,8 @@ // Common headers -#include "linter/config.h" #include "common/logging/logging.hpp" +#include "linter/config.h" #include #include diff --git a/exchange/src/linter/runtime/runtime.hpp b/exchange/src/linter/runtime/runtime.hpp index a3357e98..3a9bba63 100644 --- a/exchange/src/linter/runtime/runtime.hpp +++ b/exchange/src/linter/runtime/runtime.hpp @@ -61,4 +61,4 @@ class Runtime { {} }; -} // namespace nutc::lint +} // namespace nutc::linter diff --git a/exchange/src/wrapper/messaging/exchange_communicator.hpp b/exchange/src/wrapper/messaging/exchange_communicator.hpp index a6a1150e..beb5dd8b 100644 --- a/exchange/src/wrapper/messaging/exchange_communicator.hpp +++ b/exchange/src/wrapper/messaging/exchange_communicator.hpp @@ -32,7 +32,7 @@ class ExchangeCommunicator { algorithm_content consume_algorithm(); - common::tick_update consume_tick_update(); + common::tick_update consume_tick_update(); static void publish_message(const std::string& message); diff --git a/exchange/test/src/integration/test_algos/cpp/buy_eth.hpp b/exchange/test/src/integration/test_algos/cpp/buy_eth.hpp index 051c56c5..c3e4c3c5 100644 --- a/exchange/test/src/integration/test_algos/cpp/buy_eth.hpp +++ b/exchange/test/src/integration/test_algos/cpp/buy_eth.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -51,8 +49,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -65,29 +63,28 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) {} /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/buy_market_order_1000.hpp b/exchange/test/src/integration/test_algos/cpp/buy_market_order_1000.hpp index a279c4f1..7ed87d37 100644 --- a/exchange/test/src/integration/test_algos/cpp/buy_market_order_1000.hpp +++ b/exchange/test/src/integration/test_algos/cpp/buy_market_order_1000.hpp @@ -88,8 +88,7 @@ class Strategy { */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/buy_tsla_at_100.hpp b/exchange/test/src/integration/test_algos/cpp/buy_tsla_at_100.hpp index c61f934b..8b4d9a3d 100644 --- a/exchange/test/src/integration/test_algos/cpp/buy_tsla_at_100.hpp +++ b/exchange/test/src/integration/test_algos/cpp/buy_tsla_at_100.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -51,8 +49,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -65,15 +63,14 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) { if (ticker == Ticker::ETH && quantity < 101 && quantity > 99) { place_limit_order(Side::buy, Ticker::ETH, 100, 10); @@ -83,15 +80,15 @@ class Strategy { /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_account.hpp b/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_account.hpp index 02b714ab..b1ba82b1 100644 --- a/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_account.hpp +++ b/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_account.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -51,8 +49,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -65,29 +63,28 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) {} /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) { if (ticker == Ticker::ETH && quantity >= 10) diff --git a/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_trade.hpp b/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_trade.hpp index 0f88e86c..33ece543 100644 --- a/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_trade.hpp +++ b/exchange/test/src/integration/test_algos/cpp/buy_tsla_on_trade.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -51,8 +49,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -68,29 +66,28 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) {} /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/cancel_limit_order.hpp b/exchange/test/src/integration/test_algos/cpp/cancel_limit_order.hpp index be640b84..c7025839 100644 --- a/exchange/test/src/integration/test_algos/cpp/cancel_limit_order.hpp +++ b/exchange/test/src/integration/test_algos/cpp/cancel_limit_order.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -55,8 +53,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -69,29 +67,28 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) {} /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/confirm_1000.hpp b/exchange/test/src/integration/test_algos/cpp/confirm_1000.hpp index c5e6e0c3..deec19ff 100644 --- a/exchange/test/src/integration/test_algos/cpp/confirm_1000.hpp +++ b/exchange/test/src/integration/test_algos/cpp/confirm_1000.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -53,8 +51,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -67,15 +65,14 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) { if (ticker == Ticker::ETH && price >= 0.0) num_rx_ += 1; @@ -86,15 +83,15 @@ class Strategy { /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/partial_cancel_limit_order.hpp b/exchange/test/src/integration/test_algos/cpp/partial_cancel_limit_order.hpp index 53a968ad..0f655d97 100644 --- a/exchange/test/src/integration/test_algos/cpp/partial_cancel_limit_order.hpp +++ b/exchange/test/src/integration/test_algos/cpp/partial_cancel_limit_order.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -56,8 +54,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -70,29 +68,28 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) {} /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/sell_market_order_1000.hpp b/exchange/test/src/integration/test_algos/cpp/sell_market_order_1000.hpp index 29182a17..1b16e57d 100644 --- a/exchange/test/src/integration/test_algos/cpp/sell_market_order_1000.hpp +++ b/exchange/test/src/integration/test_algos/cpp/sell_market_order_1000.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -51,8 +49,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -69,29 +67,28 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) {} /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) {} }; diff --git a/exchange/test/src/integration/test_algos/cpp/sell_tsla_on_account.hpp b/exchange/test/src/integration/test_algos/cpp/sell_tsla_on_account.hpp index 4a651827..4b5be1e7 100644 --- a/exchange/test/src/integration/test_algos/cpp/sell_tsla_on_account.hpp +++ b/exchange/test/src/integration/test_algos/cpp/sell_tsla_on_account.hpp @@ -3,7 +3,7 @@ #include enum class Side { buy = 0, sell = 1 }; -enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT +enum class Ticker : std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT /** * Place a market order @@ -18,8 +18,7 @@ enum class Ticker: std::uint8_t { ETH = 0, BTC = 1, LTC = 2 }; // NOLINT * * @return true if order succeeded, false if order failed due to rate limiting */ -bool -place_market_order(Side side, Ticker ticker, float quantity); +bool place_market_order(Side side, Ticker ticker, float quantity); /** * Place a limit order @@ -37,8 +36,7 @@ place_market_order(Side side, Ticker ticker, float quantity); * @return true if order succeeded, false if order failed due to rate limiting */ std::int64_t place_limit_order( - Side side, Ticker ticker, float quantity, float price, - bool ioc = false + Side side, Ticker ticker, float quantity, float price, bool ioc = false ); bool cancel_order(Ticker ticker, std::int64_t order_id); @@ -51,8 +49,8 @@ class Strategy { * Called whenever two orders match. Could be one of your orders, or two other * people's orders. * - * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, or - * "LTC) + * @param ticker Ticker of the orders that were matched (Ticker::ETH, Ticker::BTC, + * or "LTC) * @param side Side of the orders that were matched (Side::buy or Side::sell) * @param price Price that trade was executed at * @quantity quantity Volume traded @@ -65,29 +63,28 @@ class Strategy { * Called whenever the orderbook changes. This could be because of a trade, or * because of a new order, or both. * - * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker that has an orderbook update (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Which orderbook as updated (Side::buy or Side::sell) * @param price Price of orderbook that has an update * @param quantity Volume placed into orderbook */ void - on_orderbook_update( - Ticker ticker, Side side, float quantity, float price - ) + on_orderbook_update(Ticker ticker, Side side, float quantity, float price) {} /** * Called whenever one of your orders is filled. * - * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or "LTC") + * @param ticker Ticker of order that was fulfilled (Ticker::ETH, Ticker::BTC, or + * "LTC") * @param side Side of order that was fulfilled (Side::buy or Side::sell) * @param price Price that order was fulfilled at * @param quantity Amount of capital after fulfilling order */ void on_account_update( - Ticker ticker, Side side, float price, float quantity, - float capital_remaining + Ticker ticker, Side side, float price, float quantity, float capital_remaining ) { if (ticker == Ticker::ETH && quantity >= 10) diff --git a/exchange/test/src/integration/test_algos/cpp/template.cpp b/exchange/test/src/integration/test_algos/cpp/template.cpp deleted file mode 120000 index 82124896..00000000 --- a/exchange/test/src/integration/test_algos/cpp/template.cpp +++ /dev/null @@ -1 +0,0 @@ -../../../../../template.cpp \ No newline at end of file diff --git a/exchange/test/src/integration/tests/basic.cpp b/exchange/test/src/integration/tests/basic.cpp index 72121dcb..a2e7fea5 100644 --- a/exchange/test/src/integration/tests/basic.cpp +++ b/exchange/test/src/integration/tests/basic.cpp @@ -166,7 +166,8 @@ TEST_P(IntegrationBasicAlgo, MultipleLevelOrder) cycle.wait_for_order(limit_order{Ticker::ETH, buy, 100.0, 10.0}); ASSERT_EQ( - trader1.get_portfolio().get_capital() - trader1.get_portfolio().get_initial_capital(), + trader1.get_portfolio().get_capital() + - trader1.get_portfolio().get_initial_capital(), -100.0 ); } diff --git a/exchange/test/src/unit/matching/composite_orderbook_test.cpp b/exchange/test/src/unit/matching/composite_orderbook_test.cpp index e6b8f6b9..774d8ba6 100644 --- a/exchange/test/src/unit/matching/composite_orderbook_test.cpp +++ b/exchange/test/src/unit/matching/composite_orderbook_test.cpp @@ -1,7 +1,6 @@ -#include "exchange/orders/orderbook/composite_orderbook.hpp" - #include "common/types/decimal.hpp" #include "config.h" +#include "exchange/orders/orderbook/composite_orderbook.hpp" #include "util/helpers/test_trader.hpp" #include "util/macros.hpp" diff --git a/exchange/test/src/unit/types/decimal.cpp b/exchange/test/src/unit/types/decimal.cpp index eaa1b641..64018a9a 100644 --- a/exchange/test/src/unit/types/decimal.cpp +++ b/exchange/test/src/unit/types/decimal.cpp @@ -24,11 +24,11 @@ TEST(UnitDecimalPrice, TestCommutativity) decimal_price four = 4.0; decimal_price six = 6.0; - decimal_price twelve = three*four; - EXPECT_EQ(double{twelve/six}, 2.0); + decimal_price twelve = three * four; + EXPECT_EQ(double{twelve / six}, 2.0); - decimal_price point_five = three/six; - EXPECT_EQ(double{point_five*four}, 2.0); + decimal_price point_five = three / six; + EXPECT_EQ(double{point_five * four}, 2.0); } TEST(UnitDecimalPrice, UnaryNegate) @@ -58,7 +58,7 @@ TEST(UnitDecimalPrice, DecimalDecimalDivision) { decimal_price first = 10.0; decimal_price second = 2.0; - decimal_price third = first/second; + decimal_price third = first / second; EXPECT_EQ(double{third}, 5.0); }