-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path04-shared-client.cs
More file actions
31 lines (24 loc) · 1.43 KB
/
Copy path04-shared-client.cs
File metadata and controls
31 lines (24 loc) · 1.43 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
// 04-shared-client.cs
//
// Demonstrates: accessing CryptoExchange.Net shared clients from Coinbase.Net
// while keeping native Coinbase endpoints available.
//
// Setup: dotnet add package Coinbase.Net
using Coinbase.Net.Clients;
var restClient = new CoinbaseRestClient();
var sharedRest = restClient.AdvancedTradeApi.SharedClient;
Console.WriteLine($"Shared exchange: {sharedRest.Exchange}");
Console.WriteLine($"Supported trading modes: {string.Join(", ", sharedRest.SupportedTradingModes)}");
var info = sharedRest.Discover();
var supportedFeatures = info.Features.Where(x => x.Supported).Select(x => x.EndpointName);
Console.WriteLine($"{info.Exchange} {info.TypeName}: {string.Join(", ", supportedFeatures)}");
var socketClient = new CoinbaseSocketClient();
Console.WriteLine($"Shared socket exchange: {socketClient.AdvancedTradeApi.SharedClient.Exchange}");
// Native Coinbase endpoints are still best when you need product metadata,
// portfolios, Coinbase App deposits/withdrawals, or Advanced Trade order fields.
var nativeProduct = await restClient.AdvancedTradeApi.ExchangeData.GetSymbolAsync("ETH-USD");
if (nativeProduct.Success)
Console.WriteLine($"Native Coinbase product: {nativeProduct.Data.Symbol} last={nativeProduct.Data.LastPrice}");
var exchangeProducts = await restClient.ExchangeApi.ExchangeData.GetSymbolsAsync();
if (exchangeProducts.Success)
Console.WriteLine($"Exchange API product count: {exchangeProducts.Data.Length}");