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
Implement portfolio management and conversion features in Coinbase SDK
- Added methods for listing, creating, editing, and deleting portfolios in CoinbaseRestClient.
- Implemented portfolio breakdown retrieval and fund movement between portfolios.
- Introduced conversion quote creation and trade commitment functionalities.
- Added support for futures operations including balance summary, positions, and sweeps.
- Enhanced awaitable client with corresponding asynchronous methods for portfolio and futures operations.
- Expanded test coverage for new portfolio and futures functionalities, ensuring robustness and correctness.
- Async mirrors of all the above in `CoinbaseAwaitableRestClient`, plus new data model headers (`portfolio.hpp`, `convert.hpp`, `payment_method.hpp`, `key_permissions.hpp`, `futures.hpp`, `perpetuals.hpp`) and `Amount` type in `common.hpp`
12
19
13
20
### Changed
14
21
- Change log file opening mode to append for data logging
@@ -23,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
30
24
31
### Fixed
25
32
-`unsubscribe()` now holds a reference to the `unique_ptr` instead of copying it
33
+
-`double_from_json` now handles fields the API returns as raw JSON numbers (not just stringified numbers), fixing parsing of `PortfolioPosition.allocation`/`available_to_trade_fiat`
@@ -112,6 +119,34 @@ auto response = client.create_order(
112
119
113
120
// Cancel order
114
121
auto cancel_response = client.cancel_orders({"order_id_123"});
122
+
123
+
// Portfolios
124
+
auto portfolios = client.list_portfolios();
125
+
auto breakdown = client.get_portfolio_breakdown(portfolios.front().uuid);
126
+
127
+
// Convert (quote only - commit_convert_trade executes a real conversion)
128
+
auto quote = client.create_convert_quote(from_account_uuid, to_account_uuid, 10.0);
129
+
130
+
// Futures (CFM)
131
+
auto balance_summary = client.get_futures_balance_summary();
132
+
auto positions = client.list_futures_positions();
133
+
```
134
+
135
+
#### Async REST Client
136
+
137
+
`CoinbaseAwaitableRestClient` mirrors every `CoinbaseRestClient` method as a C++20 coroutine returning `asio::awaitable<T>`, so the same endpoints (including all of the ones listed in [API Endpoints](#api-endpoints)) can be awaited from coroutine-based code:
138
+
139
+
```cpp
140
+
#include <coinbase/rest_awaitable.hpp>
141
+
142
+
coinbase::CoinbaseAwaitableRestClient client;
143
+
144
+
asio::awaitable<void> run() {
145
+
auto accounts = co_await client.list_accounts();
146
+
auto portfolios = co_await client.list_portfolios();
147
+
auto permissions = co_await client.get_api_key_permissions();
148
+
// ...
149
+
}
115
150
```
116
151
117
152
#### WebSocket Client
@@ -125,7 +160,7 @@ The SDK provides two callback mechanisms for handling WebSocket data:
##### Using UserThreadWebsocketCallbacks (User Thread)
194
229
195
230
```cpp
196
-
#include<coinbase/websocket.h>
231
+
#include <coinbase/websocket.hpp>
197
232
198
233
class MyCallbacks : public coinbase::UserThreadWebsocketCallbacks {
199
234
public:
@@ -244,8 +279,17 @@ client.stop();
244
279
-**Products**: List products, get product details
245
280
-**Orders**: Create, list, get, modify, and cancel orders
246
281
-**Fills**: List fills
282
+
-**Fees**: Get taker and maker fee rates
247
283
-**Market Data**: Get best bid/ask, price book, market trades, candles
248
284
-**Time**: Get server time
285
+
-**Portfolios**: List portfolios, create/edit/delete a portfolio, get portfolio breakdown, move funds between portfolios
286
+
-**Convert**: Create a convert quote, get a convert trade, commit a convert trade
287
+
-**Payment Methods**: List payment methods, get payment method details
288
+
-**Data API**: Get API key permissions
289
+
-**Futures (CFM)**: Get balance summary, list/get positions, schedule/list/cancel sweeps, get/set intraday margin settings, get current margin window
290
+
-**Perpetuals (INTX)**: Allocate portfolio, get portfolio summary, list/get positions, get portfolio balances, opt in/out of multi-asset collateral
291
+
292
+
All REST endpoints are available on both the synchronous `CoinbaseRestClient` and the coroutine-based `CoinbaseAwaitableRestClient` (see [Async REST Client](#async-rest-client)).
0 commit comments