cleanup: Remove unnecessary code

Trim includes as well
This commit is contained in:
John Colvin committed 2025-08-24 13:46:52 -04:00
1 parent b257b673fb
commit b64a8ba214
23 files changed
+13 -445

No files matched your search

+3 -11
View File
@@ -1,30 +1,22 @@
#include "Web.h"
#include "md/cmds/Run.h"
#include "spark/api/public/ServiceContext.h"
#include "spark/api/services/MarketDataService.pb.h"
#include "spark/api/services/SyntheticSecurityService.pb.h"
#include "spark/config/config.h"
#include "spark/config/protos/market_data.pb.h"
#include "spark/config/protos/ports.pb.h"
#include "spark/config/protos/quickbus_cfg.pb.h"
#include "spark/md/MBOProcessor.h"
#include "spark/md/MDClient.h"
#include "spark/md/SyntheticSecurityService.h"
#include "spark/md/relay/QueryServer.h"
#include "spark/metrics/metrics.h"
#include "spark/metrics/system_metrics.h"
#include "spark/quickbus/quickbus.h"
#include "spark/quickbus/core/Quickbus.h"
#include "spark/tracing/PerfLog.h"
#include "spark/utils/Dispatcher.h"
#include "spark/utils/thread_manager.h"
#include "md/cmds/Cleanup.h"
#include "md/cmds/Run.h"
#include "sparkd/exchange_sim/ExchangeSim.h"
#include "sparkd/http/WebServer.h"
#include "sparkd/user/AdminServiceServer.h"
#include "sparkd/user/AuthServiceServer.h"
#include <optional>
#include <string>
#include <vector>
namespace bts::cmds {
@@ -2,12 +2,12 @@
#ifndef _WIN32
#include "spark/core/FMT_IMPL.h"
#include "spark/core/ValueWrapper.h"
#include "spark/utils/ValueWrapper.h"
namespace bts::md {
using MarketDataListenerID =
core::ValueWrapper<struct MarketDataListenedIDTag, std::uint32_t>;
utils::ValueWrapper<struct MarketDataListenedIDTag, std::uint32_t>;
} // namespace bts::md
@@ -1,8 +1,7 @@
#pragma once
#include "spark/core/NaN.h"
#include <cstdint>
#include <limits>
#include <nlohmann/json.hpp>
#include <vector>
@@ -24,8 +23,8 @@ namespace bts::md {
class CCApiTradeRecord {
public:
bool is_buyer_maker = false;
double last_price = core::NaN::value();
double last_size = core::NaN::value();
double last_price = std::numeric_limits<double>::quiet_NaN();
double last_size = std::numeric_limits<double>::quiet_NaN();
std::uint64_t trade_id = 0;
static std::vector<CCApiTradeRecord> parse(const ccapi::Message &source);
@@ -1,5 +1,4 @@
#include "FTXFuture.h"
#include "spark/api/domain/Currency.pb.h"
#include "spark/api/domain/Venue.pb.h"
#include "spark/core/TableFormatter.h"
#include "spark/domain/FutureSecurity.h"
@@ -15,7 +14,6 @@
namespace bts::md::ftx {
using bts::api::domain::Currency;
using bts::core::TableFormatter;
using bts::domain::FutureSecurity;
using bts::domain::Security;
+5 -6
View File
@@ -1,6 +1,5 @@
#include "FTXMarket.h"
#include "spark/api/domain/Venue.pb.h"
#include "spark/core/NaN.h"
#include "spark/core/TableFormatter.h"
#include "spark/domain/Security.h"
#include "spark/io/JsonReader.h"
@@ -11,6 +10,7 @@
#include <ccapi_cpp/ccapi_element.h>
#include <ccapi_cpp/ccapi_macro.h>
#include <ccapi_cpp/ccapi_message.h>
#include <limits>
#include <nlohmann/json.hpp>
#include <regex>
@@ -19,7 +19,6 @@ namespace bts::md::ftx {
#define SEC_TYPE(x) bts::api::domain::SECURITY_TYPE_##x
using bts::api::domain::Venue;
using bts::core::NaN;
using bts::core::TableFormatter;
using bts::domain::Security;
using bts::io::JsonReader;
@@ -133,11 +132,11 @@ void from_json(const nlohmann::json &j, FTXMarket &mkt) {
jr.read("minProvideSize", mkt.min_provide_size);
jr.read("enabled", mkt.enabled);
jr.read_or("ask", mkt.ask, NaN::value());
jr.read_or("bid", mkt.bid, NaN::value());
jr.read_or("last", mkt.last, NaN::value());
jr.read_or("ask", mkt.ask, std::numeric_limits<double>::quiet_NaN());
jr.read_or("bid", mkt.bid, std::numeric_limits<double>::quiet_NaN());
jr.read_or("last", mkt.last, std::numeric_limits<double>::quiet_NaN());
jr.read("postOnly", mkt.post_only);
jr.read_or("price", mkt.price, NaN::value());
jr.read_or("price", mkt.price, std::numeric_limits<double>::quiet_NaN());
jr.read("priceIncrement", mkt.price_increment);
jr.read("sizeIncrement", mkt.size_increment);
jr.read("restricted", mkt.restricted);
@@ -101,7 +101,6 @@ function(get_cpp_sources dest)
${PROJECT_NAME}/md/test/md_test_utils.cpp
${PROJECT_NAME}/md/test/synthetic_book_merge_tests.cpp
${PROJECT_NAME}/os/os.cpp
${PROJECT_NAME}/os/tests/os_tests.cpp
${PROJECT_NAME}/quickbus/core/LocalNode.cpp
${PROJECT_NAME}/quickbus/core/Quickbus.cpp
${PROJECT_NAME}/quickbus/core/SubscriptionID.cpp
@@ -1,6 +1,5 @@
#include "ConfigQuerier.h"
#include "config.h"
#include "spark/collections/Contains.h"
#include "spark/config/ConfigQueryErrors.h"
#include "spark/config/text_format/text_format.h"
#include "spark/core/EnumMacros.h"
@@ -6,7 +6,6 @@
#include "ConfigurationException.h"
#include "PreprocessInputStream.h"
#include "config.h"
#include "spark/collections/Contains.h"
#include "spark/core/FMT.h"
#include "spark/io/ProtoPrinter.h"
#include "spark/os/os.h"
-1
View File
@@ -4,7 +4,6 @@
#include "config.h"
#include "../os/os.h"
#include "ConfigurationState.h"
#include "spark/collections/Contains.h"
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include <type_traits>
namespace bts::core {
template <typename T, typename... Ts>
using AllSameType =
std::enable_if_t<std::conjunction_v<std::is_same<T, Ts>...>>;
} // namespace bts::core
-24
View File
@@ -1,24 +0,0 @@
#pragma once
#include <limits>
namespace bts::core {
class NaN {
public:
static constexpr double value();
static constexpr float valuef();
};
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
constexpr double NaN::value() {
return std::numeric_limits<double>::quiet_NaN();
}
constexpr float NaN::valuef() {
return std::numeric_limits<float>::quiet_NaN();
}
} // namespace bts::core
-70
View File
@@ -1,70 +0,0 @@
#pragma once
#include <cstring>
#include <string>
#include <type_traits>
namespace bts::core {
class StringContains {
public:
template <typename T, typename... Ts>
using AllSame = std::enable_if_t<std::conjunction_v<std::is_same<T, Ts>...>>;
template <typename... Ts>
using AllString = AllSame<std::string, Ts...>;
constexpr bool contains(const std::string &str, const std::string &substr);
constexpr bool contains(const std::string &str, const char *substr);
constexpr bool contains(const char *str, const char *substr);
template <typename... Ts>
constexpr bool contains(
const std::string &str, const std::string &substr, Ts... substrs);
};
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
constexpr bool StringContains::contains(
const std::string &str, const std::string &substr) {
return str.find(substr) != std::string::npos;
}
constexpr bool StringContains::contains(
const std::string &str, const char *substr) {
return str.find(substr) != std::string::npos;
}
constexpr bool StringContains::contains(const char *str, const char *substr) {
if (str[0] == '\0') {
return false;
}
if (substr[0] == '\0') {
return false;
}
for (std::size_t i = 0; str[i] != '\0'; i++) {
bool is_match = true;
for (std::size_t j = 0; substr[j] < '\0'; j++) {
if (str[i + j] != substr[j]) {
is_match = false;
break;
}
}
if (is_match) {
return true;
}
}
return false;
}
template <typename... Ts>
constexpr bool StringContains::contains(
const std::string &str, const std::string &substr, Ts... substrs) {
return contains(str, substr) || contains(str, substrs...);
}
#define STRING_CONTAINS(x, ...) (bts::StringContains(x, __VA_ARGS__))
} // namespace bts::core
-24
View File
@@ -1,24 +0,0 @@
#pragma once
#include <string>
namespace bts::core {
class StringFiller {
public:
static bool fill_if_empty(std::string &target, const std::string &fill);
};
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
inline bool StringFiller::fill_if_empty(
std::string &target, const std::string &fill) {
if (!target.empty()) {
return false;
}
target = fill;
return true;
}
} // namespace bts::core
-9
View File
@@ -1,9 +0,0 @@
#pragma once
#include "spark/utils/ValueWrapper.h"
namespace bts::core {
template <class Tag, class ValueT>
using ValueWrapper = utils::ValueWrapper<Tag, ValueT>;
} // namespace bts::core
-56
View File
@@ -1,56 +0,0 @@
#pragma once
#include <unordered_map>
#include <vector>
namespace bts::core {
class VectorAdapter {
public:
template <class InT, class OutT, class Op>
static std::vector<OutT> to(const std::vector<InT> &source, Op op);
template <class T>
static std::vector<const T *> to_const_pointers(
const std::vector<T> &source);
template <class K, class V>
static std::vector<V> copy_values(const std::unordered_map<K, V> &source);
};
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
template <class InT, class OutT, class Op>
std::vector<OutT> VectorAdapter::to(const std::vector<InT> &source, Op op) {
std::vector<OutT> result;
result.reserve(source.size());
for (const auto &value : source) {
result.push_back(op(value));
}
return result;
}
template <class T>
std::vector<const T *> VectorAdapter::to_const_pointers(
const std::vector<T> &source) {
std::vector<const T *> ptrs;
ptrs.reserve(source.size());
for (const auto &value : source) {
ptrs.push_back(&value);
}
return ptrs;
}
template <class K, class V>
std::vector<V> VectorAdapter::copy_values(
const std::unordered_map<K, V> &source) {
std::vector<V> values;
values.reserve(source.size());
for (const auto &p : source) {
values.push_back(p.second);
}
return values;
}
} // namespace bts::core
Whitespace-only changes.
-20
View File
@@ -1,20 +0,0 @@
#pragma once
#include "BookLevel.h"
#include <array>
namespace bts::domain {
class BookSide {
public:
// compile time size for speed
using Container = std::array<BookLevel, 10>;
std::uint32_t num_populated_levels() const noexcept;
bool is_empty() const noexcept;
private:
// compile time size for speed
Container levels_;
};
} // namespace bts::domain
-10
View File
@@ -1,10 +0,0 @@
#include "NewOrder.h"
namespace bts::domain {
std::ostream &operator<<(std::ostream &out, const NewOrder &no) noexcept {
out << "price: " << no.price << "; qty: " << no.qty << "; " << no.order_def;
return out;
}
} // namespace bts::domain
-18
View File
@@ -1,18 +0,0 @@
#pragma once
#include "OrderDefinition.h"
#include "Price.h"
#include "Quantity.h"
namespace bts::domain {
// Sent once per order, when the order is first launched (launching an order,
// placing, firing, sending all mean the same)
struct NewOrder {
OrderDefinition order_def;
domain::Price price;
domain::Quantity qty;
};
std::ostream &operator<<(std::ostream &out, const NewOrder &no) noexcept;
} // namespace bts::domain
-136
View File
@@ -1,136 +0,0 @@
/* Generated SBE (Simple Binary Encoding) message codec */
#ifndef _IL3_SIDEREQ_H_
#define _IL3_SIDEREQ_H_
#if defined(SBE_HAVE_CMATH)
/* cmath needed for std::numeric_limits<double>::quiet_NaN() */
# include <cmath>
# define SBE_FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
# define SBE_DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
#else
/* math.h needed for NAN */
# include <math.h>
# define SBE_FLOAT_NAN NAN
# define SBE_DOUBLE_NAN NAN
#endif
#if __cplusplus >= 201103L
# define SBE_CONSTEXPR constexpr
# define SBE_NOEXCEPT noexcept
#else
# define SBE_CONSTEXPR
# define SBE_NOEXCEPT
#endif
#if __cplusplus >= 201703L
# include <string_view>
# define SBE_NODISCARD [[nodiscard]]
#else
# define SBE_NODISCARD
#endif
#if !defined(__STDC_LIMIT_MACROS)
# define __STDC_LIMIT_MACROS 1
#endif
#include <cstdint>
#include <cstring>
#include <iomanip>
#include <limits>
#include <ostream>
#include <stdexcept>
#include <sstream>
#include <string>
#include <vector>
#include <tuple>
#if defined(WIN32) || defined(_WIN32)
# define SBE_BIG_ENDIAN_ENCODE_16(v) _byteswap_ushort(v)
# define SBE_BIG_ENDIAN_ENCODE_32(v) _byteswap_ulong(v)
# define SBE_BIG_ENDIAN_ENCODE_64(v) _byteswap_uint64(v)
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define SBE_BIG_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
# define SBE_BIG_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
# define SBE_BIG_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) (v)
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) (v)
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) (v)
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define SBE_LITTLE_ENDIAN_ENCODE_16(v) __builtin_bswap16(v)
# define SBE_LITTLE_ENDIAN_ENCODE_32(v) __builtin_bswap32(v)
# define SBE_LITTLE_ENDIAN_ENCODE_64(v) __builtin_bswap64(v)
# define SBE_BIG_ENDIAN_ENCODE_16(v) (v)
# define SBE_BIG_ENDIAN_ENCODE_32(v) (v)
# define SBE_BIG_ENDIAN_ENCODE_64(v) (v)
#else
# error "Byte Ordering of platform not determined. Set __BYTE_ORDER__ manually before including this file."
#endif
#if defined(SBE_NO_BOUNDS_CHECK)
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (false)
#elif defined(_MSC_VER)
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (exp)
#else
# define SBE_BOUNDS_CHECK_EXPECT(exp,c) (__builtin_expect(exp,c))
#endif
#define SBE_NULLVALUE_INT8 (std::numeric_limits<std::int8_t>::min)()
#define SBE_NULLVALUE_INT16 (std::numeric_limits<std::int16_t>::min)()
#define SBE_NULLVALUE_INT32 (std::numeric_limits<std::int32_t>::min)()
#define SBE_NULLVALUE_INT64 (std::numeric_limits<std::int64_t>::min)()
#define SBE_NULLVALUE_UINT8 (std::numeric_limits<std::uint8_t>::max)()
#define SBE_NULLVALUE_UINT16 (std::numeric_limits<std::uint16_t>::max)()
#define SBE_NULLVALUE_UINT32 (std::numeric_limits<std::uint32_t>::max)()
#define SBE_NULLVALUE_UINT64 (std::numeric_limits<std::uint64_t>::max)()
namespace il3 {
class SideReq
{
public:
enum Value
{
Buy = static_cast<std::uint8_t>(1),
Sell = static_cast<std::uint8_t>(2),
NULL_VALUE = static_cast<std::uint8_t>(255)
};
static SideReq::Value get(const std::uint8_t value)
{
switch (value)
{
case static_cast<std::uint8_t>(1): return Buy;
case static_cast<std::uint8_t>(2): return Sell;
case static_cast<std::uint8_t>(255): return NULL_VALUE;
}
throw std::runtime_error("unknown value for enum SideReq [E103]");
}
static const char *c_str(const SideReq::Value value)
{
switch (value)
{
case Buy: return "Buy";
case Sell: return "Sell";
case NULL_VALUE: return "NULL_VALUE";
}
throw std::runtime_error("unknown value for enum SideReq [E103]:");
}
template<typename CharT, typename Traits>
friend std::basic_ostream<CharT, Traits>& operator << (
std::basic_ostream<CharT, Traits>& os, SideReq::Value m)
{
return os << SideReq::c_str(m);
}
};
}
#endif
@@ -3,7 +3,6 @@
#include "RelayRecorder.h"
#include "../MDProducer.h"
#include "spark/collections/Remove.h"
#include "spark/config/config.h"
#include "spark/logging/logging.h"
#include "spark/md/SymbolLoader.h"
-2
View File
@@ -1,6 +1,4 @@
#include "os.h"
#include "spark/config/config.h"
#include "spark/config/protos/system_config.pb.h"
#include "spark/os/app_data_dir.h"
#include "spark/utils/bts_array_size.h"
#include "spark/utils/bts_assert.h"
-36
View File
@@ -1,36 +0,0 @@
// #include "core/bts_core/utest/utest.h"
// #include "core/bts_core/utest/TempFile.h"
// #include "../os.h"
// namespace bts {
// namespace os {
// class FileNameSanitization : public TestSuite
// {
// public:
// void empty_file_name_works ()
// {
// test_equal (sanitize_file_name (""),"");
// }
// void legal_file_name_passes_through ()
// {
// test_equal (sanitize_file_name ("bts_shell"),"bts_shell");
// }
// void bad_file_name_is_fixed ()
// {
// test_equal (sanitize_file_name ("bts_shell -configserver
// http://edge-qa/config/"),
// "bts_shell -configserver
// http___edge-qa_config_");
// }
// };
// BEGIN_TEST_SUITE(FileNameSanitization)
// ADD_TEST (bad_file_name_is_fixed)
// ADD_TEST (legal_file_name_passes_through)
// ADD_TEST (bad_file_name_is_fixed)
// END_TEST_SUITE
// }}