Skip to content

Commit afcfb73

Browse files
committed
Align clang-format rules with project style
1 parent da910c5 commit afcfb73

18 files changed

Lines changed: 145 additions & 176 deletions

.clang-format

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ UseTab: Never
77
AccessModifierOffset: -4
88
ContinuationIndentWidth: 4
99
ConstructorInitializerIndentWidth: 4
10-
ColumnLimit: 0
10+
ColumnLimit: 120
1111
PointerAlignment: Left
1212
ReferenceAlignment: Left
1313
SortIncludes: false
14+
IndentCaseLabels: true
15+
AlignTrailingComments: Never
1416
AllowShortBlocksOnASingleLine: Empty
1517
AllowShortCaseLabelsOnASingleLine: true
1618
AllowShortFunctionsOnASingleLine: All

benchmarks/bench_latency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void BM_LatencyHistogram_Record(benchmark::State& state) {
6767
DefaultLatencyHistogram histogram;
6868

6969
for (auto _ : state) {
70-
histogram.record(1000); // 1 microsecond
70+
histogram.record(1000); // 1 microsecond
7171
}
7272
state.SetItemsProcessed(state.iterations());
7373
}

benchmarks/bench_orderbook.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ static void BM_OrderBook_DeepBook_Add(benchmark::State& state) {
133133

134134
// Add orders across multiple price levels
135135
for (int64_t i = 0; i < numLevels; ++i) {
136-
(void)book.addOrder(orderId++, Side::Buy,
137-
priceFromDouble(50000.0 - static_cast<double>(i)), 100);
136+
(void)book.addOrder(orderId++, Side::Buy, priceFromDouble(50000.0 - static_cast<double>(i)), 100);
138137
}
139138
}
140139

benchmarks/bench_spsc_queue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static void BM_SPSCQueue_PushPop_SingleThread(benchmark::State& state) {
2929
benchmark::DoNotOptimize(value);
3030
}
3131

32-
state.SetItemsProcessed(state.iterations() * 2); // 2 ops per iteration
32+
state.SetItemsProcessed(state.iterations() * 2); // 2 ops per iteration
3333
}
3434
BENCHMARK(BM_SPSCQueue_PushPop_SingleThread);
3535

@@ -156,7 +156,7 @@ static void BM_SPSCQueue_ElementSize(benchmark::State& state) {
156156
state.SetBytesProcessed(static_cast<int64_t>(state.iterations()) * 2 * static_cast<int64_t>(ElementSize));
157157
}
158158
BENCHMARK_TEMPLATE(BM_SPSCQueue_ElementSize, 8);
159-
BENCHMARK_TEMPLATE(BM_SPSCQueue_ElementSize, 64); // Cache line
159+
BENCHMARK_TEMPLATE(BM_SPSCQueue_ElementSize, 64); // Cache line
160160
BENCHMARK_TEMPLATE(BM_SPSCQueue_ElementSize, 128);
161161
BENCHMARK_TEMPLATE(BM_SPSCQueue_ElementSize, 256);
162162

@@ -224,7 +224,7 @@ BENCHMARK(BM_SPSCQueue_FrontPeek);
224224
// Empty check benchmark
225225
static void BM_SPSCQueue_EmptyCheck(benchmark::State& state) {
226226
SPSCQueue<int, 1024> queue;
227-
(void)queue.tryPush(42); // Not empty
227+
(void)queue.tryPush(42); // Not empty
228228

229229
for (auto _ : state) {
230230
bool empty = queue.empty();

include/core/SPSCQueue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class alignas(CACHE_LINE_SIZE) SPSCQueue {
228228
* @return Maximum number of elements (Capacity - 1 usable).
229229
*/
230230
[[nodiscard]] static constexpr std::size_t capacity() noexcept {
231-
return Capacity - 1; // One slot always empty to distinguish full/empty
231+
return Capacity - 1; // One slot always empty to distinguish full/empty
232232
}
233233

234234
/**
@@ -323,7 +323,7 @@ class SPSCQueueBlocking : public SPSCQueue<T, Capacity> {
323323
static void spinWait(std::size_t& spins) noexcept {
324324
if (++spins < MaxSpins) {
325325
#if defined(__x86_64__) || defined(_M_X64)
326-
_mm_pause(); // CPU hint for spin-wait
326+
_mm_pause(); // CPU hint for spin-wait
327327
#elif defined(__aarch64__)
328328
asm volatile("yield");
329329
#endif

include/core/Timestamp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class TscCalibrator {
208208
m_nanosPerCycle = 1.0 / m_cyclesPerNano;
209209
}
210210

211-
double m_cyclesPerNano{3.0}; // Default ~3GHz
211+
double m_cyclesPerNano{3.0}; // Default ~3GHz
212212
double m_nanosPerCycle{0.333};
213213
};
214214

include/core/Types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ enum class Side : std::uint8_t {
124124
enum class OrderType : std::uint8_t {
125125
Limit = 0,
126126
Market = 1,
127-
IOC = 2, // Immediate or Cancel
128-
FOK = 3 // Fill or Kill
127+
IOC = 2, // Immediate or Cancel
128+
FOK = 3 // Fill or Kill
129129
};
130130

131131
/**

include/gateway/OrderEntryGateway.hpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ struct GatewayConfig {
5757
std::size_t maxOpenOrders{1000};
5858

5959
/// Order timeout in nanoseconds
60-
Timestamp orderTimeoutNanos{5'000'000'000}; // 5 seconds
60+
Timestamp orderTimeoutNanos{5'000'000'000}; // 5 seconds
6161

6262
/// Enable pre-trade risk checks
6363
bool enableRiskChecks{true};
6464

6565
/// Maximum order value (price * quantity)
66-
std::int64_t maxOrderValue{1'000'000'000'000}; // $10,000 at 8 decimals
66+
std::int64_t maxOrderValue{1'000'000'000'000}; // $10,000 at 8 decimals
6767

6868
/// Maximum position per symbol
6969
Quantity maxPositionPerSymbol{100'000};
@@ -83,20 +83,20 @@ struct GatewayConfig {
8383
* @brief Internal order representation with full state tracking.
8484
*/
8585
struct alignas(CACHE_LINE_SIZE) InternalOrder {
86-
OrderId clientOrderId; ///< Client-assigned order ID
87-
OrderId exchangeOrderId; ///< Exchange-assigned order ID
88-
SymbolId symbolId; ///< Instrument
89-
std::string symbol; ///< Symbol string
90-
Side side; ///< Buy/Sell
91-
Price price; ///< Limit price
92-
Quantity orderQty; ///< Original quantity
93-
Quantity filledQty; ///< Cumulative filled quantity
94-
Quantity remainingQty; ///< Remaining quantity
95-
OrderStatus status; ///< Current status
96-
OrderType orderType; ///< Order type
97-
Timestamp submitTime; ///< When order was submitted
98-
Timestamp lastUpdateTime; ///< Last status change
99-
std::uint64_t strategyId; ///< Originating strategy
86+
OrderId clientOrderId; ///< Client-assigned order ID
87+
OrderId exchangeOrderId; ///< Exchange-assigned order ID
88+
SymbolId symbolId; ///< Instrument
89+
std::string symbol; ///< Symbol string
90+
Side side; ///< Buy/Sell
91+
Price price; ///< Limit price
92+
Quantity orderQty; ///< Original quantity
93+
Quantity filledQty; ///< Cumulative filled quantity
94+
Quantity remainingQty; ///< Remaining quantity
95+
OrderStatus status; ///< Current status
96+
OrderType orderType; ///< Order type
97+
Timestamp submitTime; ///< When order was submitted
98+
Timestamp lastUpdateTime; ///< Last status change
99+
std::uint64_t strategyId; ///< Originating strategy
100100

101101
InternalOrder() noexcept = default;
102102

@@ -125,13 +125,13 @@ struct ExecutionReport {
125125
OrderId clientOrderId;
126126
OrderId exchangeOrderId;
127127
OrderStatus status;
128-
Price lastPrice; ///< Last fill price
129-
Quantity lastQty; ///< Last fill quantity
130-
Quantity cumulativeQty; ///< Total filled quantity
131-
Quantity leavesQty; ///< Remaining quantity
132-
Timestamp transactTime; ///< Exchange timestamp
133-
int rejectReason; ///< Reason code if rejected
134-
std::string text; ///< Reject reason text
128+
Price lastPrice; ///< Last fill price
129+
Quantity lastQty; ///< Last fill quantity
130+
Quantity cumulativeQty; ///< Total filled quantity
131+
Quantity leavesQty; ///< Remaining quantity
132+
Timestamp transactTime; ///< Exchange timestamp
133+
int rejectReason; ///< Reason code if rejected
134+
std::string text; ///< Reject reason text
135135
};
136136

137137
//==============================================================================
@@ -650,7 +650,7 @@ class OrderEntryGateway {
650650

651651
private:
652652
[[nodiscard]] bool checkRateLimit(Timestamp now) noexcept {
653-
constexpr Timestamp WINDOW_NANOS = 1'000'000'000; // 1 second
653+
constexpr Timestamp WINDOW_NANOS = 1'000'000'000; // 1 second
654654

655655
while (m_orderTimeCount > 0 &&
656656
(now - m_orderTimes[m_orderTimeHead]) > WINDOW_NANOS) {

include/market_data/MarketDataHandler.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ struct MarketDataConfig {
7272
* the wire protocol (FIX, binary, etc.).
7373
*/
7474
struct alignas(CACHE_LINE_SIZE) MarketDataMessage {
75-
SymbolId symbolId; ///< Instrument symbol
76-
SeqNum seqNum; ///< Exchange sequence number
77-
Timestamp sendingTime; ///< Exchange timestamp (SendingTime)
78-
Timestamp receiveTime; ///< Local receive timestamp
79-
MdMsgType msgType; ///< Message type
80-
Side side; ///< Bid/Ask for book updates
81-
Price price; ///< Price
82-
Quantity quantity; ///< Quantity
83-
OrderId orderId; ///< Order ID (for order-level books)
75+
SymbolId symbolId; ///< Instrument symbol
76+
SeqNum seqNum; ///< Exchange sequence number
77+
Timestamp sendingTime; ///< Exchange timestamp (SendingTime)
78+
Timestamp receiveTime; ///< Local receive timestamp
79+
MdMsgType msgType; ///< Message type
80+
Side side; ///< Bid/Ask for book updates
81+
Price price; ///< Price
82+
Quantity quantity; ///< Quantity
83+
OrderId orderId; ///< Order ID (for order-level books)
8484

8585
MarketDataMessage() noexcept = default;
8686

@@ -407,7 +407,7 @@ class MarketDataHandler {
407407
MarketDataMessage msg;
408408
msg.symbolId = symbolId;
409409
msg.receiveTime = entry.receiveTime;
410-
msg.sendingTime = entry.receiveTime; // Use receive time as proxy
410+
msg.sendingTime = entry.receiveTime; // Use receive time as proxy
411411
msg.price = entry.price;
412412
msg.quantity = entry.size;
413413

include/market_data/QuickFixApplication.hpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ inline constexpr char EXEC_TYPE_REJECTED = '8';
8585
* @brief Normalized market data entry extracted from QuickFIX message.
8686
*/
8787
struct QuickFixMdEntry {
88-
char entryType; ///< '0'=Bid, '1'=Ask, '2'=Trade
89-
char updateAction; ///< '0'=New, '1'=Change, '2'=Delete
90-
Price price; ///< Price
91-
Quantity size; ///< Size
92-
std::string entryId; ///< Entry ID (if provided)
93-
Timestamp receiveTime; ///< Local receive timestamp
88+
char entryType; ///< '0'=Bid, '1'=Ask, '2'=Trade
89+
char updateAction; ///< '0'=New, '1'=Change, '2'=Delete
90+
Price price; ///< Price
91+
Quantity size; ///< Size
92+
std::string entryId; ///< Entry ID (if provided)
93+
Timestamp receiveTime; ///< Local receive timestamp
9494
};
9595

9696
//==============================================================================
@@ -101,16 +101,16 @@ struct QuickFixMdEntry {
101101
* @brief Normalized execution report extracted from QuickFIX message.
102102
*/
103103
struct QuickFixExecReport {
104-
OrderId clOrdId; ///< Client order ID
105-
OrderId orderId; ///< Exchange order ID
106-
char execType; ///< Execution type
107-
OrderStatus status; ///< Order status
108-
Price lastPx; ///< Last fill price
109-
Quantity lastQty; ///< Last fill quantity
110-
Quantity cumQty; ///< Cumulative filled quantity
111-
Quantity leavesQty; ///< Remaining quantity
112-
std::string text; ///< Reject reason text
113-
Timestamp receiveTime; ///< Local receive timestamp
104+
OrderId clOrdId; ///< Client order ID
105+
OrderId orderId; ///< Exchange order ID
106+
char execType; ///< Execution type
107+
OrderStatus status; ///< Order status
108+
Price lastPx; ///< Last fill price
109+
Quantity lastQty; ///< Last fill quantity
110+
Quantity cumQty; ///< Cumulative filled quantity
111+
Quantity leavesQty; ///< Remaining quantity
112+
std::string text; ///< Reject reason text
113+
Timestamp receiveTime; ///< Local receive timestamp
114114
};
115115

116116
//==============================================================================
@@ -332,7 +332,7 @@ class QuickFixApplication : public FIX::Application, public FIX::MessageCracker
332332

333333
request.set(FIX::MDReqID(mdReqId));
334334
request.set(FIX::SubscriptionRequestType(subscriptionType));
335-
request.set(FIX::MarketDepth(0)); // Full book
335+
request.set(FIX::MarketDepth(0)); // Full book
336336

337337
// Add MD entry types
338338
FIX44::MarketDataRequest::NoMDEntryTypes entryTypesGroup;
@@ -436,7 +436,7 @@ class QuickFixApplication : public FIX::Application, public FIX::MessageCracker
436436

437437
QuickFixMdEntry entry;
438438
entry.receiveTime = receiveTime;
439-
entry.updateAction = qfix::MD_ACTION_NEW; // Snapshot implies new
439+
entry.updateAction = qfix::MD_ACTION_NEW; // Snapshot implies new
440440

441441
FIX::MDEntryType entryType;
442442
group.get(entryType);
@@ -590,14 +590,14 @@ class QuickFixApplication : public FIX::Application, public FIX::MessageCracker
590590
if (m_mdCallback) {
591591
m_mdCallback(entry);
592592
}
593-
m_mdQueue.tryPush(entry); // Best effort
593+
m_mdQueue.tryPush(entry); // Best effort
594594
}
595595

596596
void enqueueExecutionReport(const QuickFixExecReport& report) {
597597
if (m_execCallback) {
598598
m_execCallback(report);
599599
}
600-
m_execQueue.tryPush(report); // Best effort
600+
m_execQueue.tryPush(report); // Best effort
601601
}
602602

603603
bool sendMessage(FIX::Message& message) {

0 commit comments

Comments
 (0)