From 7e093b77ee6eac80e695272067b52b324d7d4204 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Tue, 22 Dec 2020 09:37:36 +0100 Subject: [PATCH] Update README.md --- README.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d775d97..d35adbf 100644 --- a/README.md +++ b/README.md @@ -52,11 +52,14 @@ Implementations from third parties
Switcheo - +
Liquid - + +
+OKEx +
Bitmex @@ -65,11 +68,14 @@ Implementations from third parties
HitBTC + +
+LiveCoin + Planned implementations (no timeline or specific order): -* BitMEX * Bitstamp * CoinFalcon * Binance DEX @@ -88,7 +94,7 @@ public void NonAsyncMethod() { using(var client = new BinanceClient()) { - var result = client.Ping(); + var result = client.Spot.Market.Get24HPrices(); } } @@ -96,7 +102,7 @@ public async Task AsyncMethod() { using(var client = new BinanceClient()) { - var result2 = await client.PingAsync(); + var result2 = await client.Spot.Market.Get24HPricesAsync(); } } ```` @@ -168,7 +174,7 @@ To unsubscribe use the client.Unsubscribe method and pass the UpdateSubscription ````C# // Subscribe var client = new BinanceSocketClient(); -var subResult = client.SubscribeToOrderBookUpdates("BTCUSDT", data => {}); +var subResult = client.Spot.SubscribeToOrderBookUpdates("BTCUSDT", data => {}); // Unsubscribe client.Unsubscribe(subResult.Data); @@ -202,6 +208,56 @@ The order book will automatically reconnect when the connection is lost and resy To stop synchronizing an order book use the `Stop` method. +## Shared IExchangeClient interface +Most implementations have an implementation of the `IExchangeClient` interface. It is a shared interface, which makes it easier to re-use the same code for multiple exchanges. It offers basic functionality only, for exchange specific calls use the actual client interface, for example `IBinanceClient` or `IBitfinexClient`. + +The IExchangeClient interface supports the following methods: +`string GetSymbolName(string baseAsset, string quoteAsset);` - Based on a base and quote asset return the symbol name for the exchange. +`Task>> GetSymbolsAsync();` - Get a list of supported symbols. +`Task>> GetTickersAsync();` - Get a list of tickers (High/Low/volume data for the last 24 hours) for all symbols. +`Task> GetTickerAsync(string symbol);` - Get a specific ticker. +`Task>> GetKlinesAsync(string symbol, TimeSpan timespan, DateTime? startTime = null, DateTime? endTime = null, int? limit = null);` - Get candlestick data for a symbol. +`Task> GetOrderBookAsync(string symbol);` - Get the order book for a symbol. +`Task>> GetRecentTradesAsync(string symbol);` - Get a list of the most recent trades for a symbol. +`Task> PlaceOrderAsync(string symbol, OrderSide side, OrderType type, decimal quantity, decimal? price = null, string? accountId = null);` - \[Authenticated\] Place an order. +`Task> GetOrderAsync(string orderId, string? symbol = null);` - \[Authenticated\] Get details on an order. +`Task>> GetTradesAsync(string orderId, string? symbol = null);` - \[Authenticated\] Get executed trades for an order. +`Task>> GetOpenOrdersAsync(string? symbol = null);` - \[Authenticated\] Get a list of open orders. +`Task>> GetClosedOrdersAsync(string? symbol = null);` - \[Authenticated\] Get a list of closed orders. +`Task> CancelOrderAsync(string orderId, string? symbol = null);` - \[Authenticated\] Cancel an order. +`Task>> GetBalancesAsync(string? accountId = null);` - \[Authenticated\] Get a list of balances. + +Example usage: +````C# +static async Task Main(string[] args) +{ + var clients = new List() + { + { new BinanceClient(new BinanceClientOptions(){ LogVerbosity = LogVerbosity.Debug, ApiCredentials = new ApiCredentials("BinanceKey", "BinanceSecret") }) }, + { new BitfinexClient(new BitfinexClientOptions(){ LogVerbosity = LogVerbosity.Debug, ApiCredentials = new ApiCredentials("BitfinexKey", "BitfinexSecret") }) }, + { new BittrexClientV3(new BittrexClientOptions(){ LogVerbosity = LogVerbosity.Debug, ApiCredentials = new ApiCredentials("BittrexKey", "BittrexSecret") }) }, + }; + + await Task.WhenAll(clients.Select(GetExchangeData)); + Console.WriteLine("Done"); + Console.ReadLine(); +} + +static async Task GetExchangeData(IExchangeClient client) +{ + var symbols = await client.GetSymbolsAsync(); + Console.WriteLine($"{((RestClient)client).ClientName}: {symbols.Data?.Count()} symbols returned, first = {symbols.Data?.First().CommonName}"); + + var balances = await client.GetBalancesAsync(); + var btcBalance = balances.Data?.Where(b => b.CommonAsset.ToUpperInvariant() == "BTC").FirstOrDefault(); + Console.WriteLine($"{((RestClient)client).ClientName}: {balances.Data?.Count()} balance returned, BTC balance = {btcBalance?.CommonTotal}"); + + var symbolName = client.GetSymbolName("BTC", "USDT"); + var klines = await client.GetKlinesAsync(symbolName, TimeSpan.FromHours(1)); + Console.WriteLine($"{((RestClient)client).ClientName}: {klines.Data?.Count()} klines returned, first klines @ {klines.Data?.First().CommonClose}"); +} +```` + ## Release notes * Version 3.4.0 - 21 dec 2020 * Updated IExchangeClient interface