You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor REST API tests and enhance WebSocket tests
- Updated REST API tests to improve order handling and logging.
- Introduced a new `order_` member variable to store order details for reuse.
- Enhanced error logging for order creation, modification, and cancellation.
- Adjusted order quantities for better precision in tests.
- Refactored WebSocket tests to include connection and disconnection tracking.
- Added a new test for repeated connect/disconnect scenarios to validate stability.
- Improved logging for market data and user data events.
Copy file name to clipboardExpand all lines: README.md
+97-7Lines changed: 97 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,14 @@ A modern C++ SDK for interacting with the Coinbase Advanced API, providing both
12
12
13
13
-**REST API Support**: Complete implementation of Coinbase Advanced API endpoints for accounts, orders, products, trades, and more
14
14
-**WebSocket Support**: Real-time market data streaming with level2, ticker, market trades, and user data channels
15
+
- Connection lifecycle callbacks for connect/disconnect events
16
+
- Per-client sequence number tracking for multiple concurrent connections
17
+
- Explicit shutdown control with `stop()` method
15
18
-**Comprehensive Order Types**: Support for market, limit, stop limit, bracket, and TWAP orders
16
19
-**Type Safety**: Full C++ type definitions for all API responses with JSON serialization/deserialization
17
20
-**Modern C++**: Uses C++20 features, RAII, smart pointers, and modern C++ best practices
18
21
-**Async/Await Support**: Built-in async support using C++ coroutines
19
-
-**Thread-Safe**: Designed for multi-threaded applications
22
+
-**Thread-Safe**: Designed for multi-threaded applications with lock-free data structures
20
23
21
24
## Architecture
22
25
@@ -111,23 +114,61 @@ auto cancel_response = client.cancel_orders({"order_id_123"});
111
114
112
115
#### WebSocket Client
113
116
117
+
The SDK provides two callback mechanisms for handling WebSocket data:
118
+
119
+
1. **`WebsocketCallbacks`**: Callbacks are invoked directly on the WebSocket thread. Use this for simple applications or when you want immediate processing.
120
+
121
+
2. **`UserThreadWebsocketCallbacks`**: Callbacks are invoked on your own thread. The WebSocket data is queued in a lock-free queue, and you control when to process it by calling `processData()`. Use this for better control over threading and to avoid blocking the WebSocket thread.
122
+
123
+
##### Using WebsocketCallbacks (WebSocket Thread)
124
+
114
125
```cpp
115
126
#include <coinbase/websocket.h>
116
127
117
128
class MyCallbacks : public coinbase::WebsocketCallbacks {
- **`WebsocketCallbacks`**: Immediate processing on WebSocket I/O thread. Simple but can block WebSocket operations if callbacks are slow.
235
+
- **`UserThreadWebsocketCallbacks`**: Deferred processing on your thread. Better performance and control, but requires calling `processData()` regularly. Uses lock-free queues for efficient data transfer between threads.
0 commit comments