-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathorderbook_processor.cpp
More file actions
49 lines (40 loc) · 1.87 KB
/
orderbook_processor.cpp
File metadata and controls
49 lines (40 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "orderbook_processor.h"
#include <QDebug>
OrderbookProcessor::OrderbookProcessor(Orderbook *engine, QObject *parent)
: QObject(parent),
engine_(engine)
{
// Create two separate timers for different update frequencies
tradingTimer_ = new QTimer(this);
guiTimer_ = new QTimer(this);
// Connect timers to their respective processing slots
connect(tradingTimer_, &QTimer::timeout, this, &OrderbookProcessor::processTrading);
connect(guiTimer_, &QTimer::timeout, this, &OrderbookProcessor::processGuiUpdate);
}
// Start both timers with different intervals
// Trading timer: Fast updates for responsive order processing (10ms)
// GUI timer: Slower updates for smooth visual experience (250ms = 4 FPS)
void OrderbookProcessor::startUpdates(int tradingIntervalMs, int guiIntervalMs)
{
qDebug() << "OrderbookProcessor::startUpdates called with trading interval:" << tradingIntervalMs
<< "ms, GUI interval:" << guiIntervalMs << "ms";
tradingTimer_->start(tradingIntervalMs);
guiTimer_->start(guiIntervalMs);
}
// Fast processing for trading engine - handles order matching and execution
void OrderbookProcessor::processTrading()
{
// This can be used for any fast trading-related processing
// For now, the orderbook handles its own matching, so this is a placeholder
// In a more complex system, this might handle order queue processing, etc.
}
// Slower processing for GUI updates - emits snapshots for display
void OrderbookProcessor::processGuiUpdate()
{
qDebug() << "OrderbookProcessor::processGuiUpdate called";
// 1. Get the data snapshot from the engine
OrderbookLevelInfos snapshot = engine_->GetOrderInfos();
qDebug() << "GUI Update - Bids:" << snapshot.GetBids().size() << "Asks:" << snapshot.GetAsks().size();
// 2. Emit the signal to notify any connected GUI models
emit snapshotReady(snapshot);
}