diff --git a/CryptoExchange.Net.UnitTests/CryptoExchange.Net.UnitTests.csproj b/CryptoExchange.Net.UnitTests/CryptoExchange.Net.UnitTests.csproj index 592907e..3a1cfb3 100644 --- a/CryptoExchange.Net.UnitTests/CryptoExchange.Net.UnitTests.csproj +++ b/CryptoExchange.Net.UnitTests/CryptoExchange.Net.UnitTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/CryptoExchange.Net.sln b/CryptoExchange.Net.sln index a40d739..e2c2a6c 100644 --- a/CryptoExchange.Net.sln +++ b/CryptoExchange.Net.sln @@ -7,7 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CryptoExchange.Net", "Crypt EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CryptoExchange.Net.UnitTests", "CryptoExchange.Net.UnitTests\CryptoExchange.Net.UnitTests.csproj", "{FBFE1651-D43D-4D67-89B7-6C4AE9BA4496}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorClient", "Examples\BlazorClient\BlazorClient.csproj", "{AF4F5C19-162E-48F4-8B0B-BA5A2D7CE06A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorClient", "Examples\BlazorClient\BlazorClient.csproj", "{AF4F5C19-162E-48F4-8B0B-BA5A2D7CE06A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{5734C2A9-F12C-4754-A8B9-640C24DC4E02}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleClient", "Examples\ConsoleClient\ConsoleClient.csproj", "{23480C58-23BF-4EBF-A173-B7F51A043A99}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,10 +31,18 @@ Global {AF4F5C19-162E-48F4-8B0B-BA5A2D7CE06A}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF4F5C19-162E-48F4-8B0B-BA5A2D7CE06A}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF4F5C19-162E-48F4-8B0B-BA5A2D7CE06A}.Release|Any CPU.Build.0 = Release|Any CPU + {23480C58-23BF-4EBF-A173-B7F51A043A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23480C58-23BF-4EBF-A173-B7F51A043A99}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23480C58-23BF-4EBF-A173-B7F51A043A99}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23480C58-23BF-4EBF-A173-B7F51A043A99}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {AF4F5C19-162E-48F4-8B0B-BA5A2D7CE06A} = {5734C2A9-F12C-4754-A8B9-640C24DC4E02} + {23480C58-23BF-4EBF-A173-B7F51A043A99} = {5734C2A9-F12C-4754-A8B9-640C24DC4E02} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0D1B9CE9-E0B7-4B8B-88BF-6EA2CC8CA3D7} EndGlobalSection diff --git a/CryptoExchange.Net/CryptoExchange.Net.csproj b/CryptoExchange.Net/CryptoExchange.Net.csproj index 65721f2..684a980 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.csproj +++ b/CryptoExchange.Net/CryptoExchange.Net.csproj @@ -45,10 +45,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + \ No newline at end of file diff --git a/Examples/BlazorClient/BlazorClient.csproj b/Examples/BlazorClient/BlazorClient.csproj index 6779020..193f946 100644 --- a/Examples/BlazorClient/BlazorClient.csproj +++ b/Examples/BlazorClient/BlazorClient.csproj @@ -5,16 +5,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/Examples/BlazorClient/Pages/OrderBooks.razor b/Examples/BlazorClient/Pages/OrderBooks.razor index 8058d65..0a494d7 100644 --- a/Examples/BlazorClient/Pages/OrderBooks.razor +++ b/Examples/BlazorClient/Pages/OrderBooks.razor @@ -17,19 +17,21 @@ @implements IDisposable

ETH-BTC books, live updates:

-@foreach(var book in _books.OrderBy(p => p.Key)) -{ -
-

@book.Key

- @if (book.Value.AskCount >= 3 && book.Value.BidCount >= 3) - { - for (var i = 0; i < 3; i++) +
+ @foreach(var book in _books.OrderBy(p => p.Key)) + { +
+

@book.Key

+ @if (book.Value.AskCount >= 3 && book.Value.BidCount >= 3) { -
@book.Value.Bids.ElementAt(i).Price - @book.Value.Asks.ElementAt(i).Price
+ for (var i = 0; i < 3; i++) + { +
@book.Value.Bids.ElementAt(i).Price - @book.Value.Asks.ElementAt(i).Price
+ } } - } -
-} +
+ } +
@code{ private Dictionary _books = new Dictionary(); diff --git a/Examples/BlazorClient/Pages/SpotClient.razor b/Examples/BlazorClient/Pages/SpotClient.razor index 2a49758..08d05d7 100644 --- a/Examples/BlazorClient/Pages/SpotClient.razor +++ b/Examples/BlazorClient/Pages/SpotClient.razor @@ -36,12 +36,12 @@ binanceClient.SpotApi.ComonSpotClient, bitfinexClient.SpotApi.ComonSpotClient, bittrexClient.SpotApi.ComonSpotClient, - bybitClient.SpotApi.ComonSpotClient, + bybitClient.SpotApi.CommonSpotClient, coinexClient.SpotApi.ComonSpotClient, ftxClient.TradeApi.ComonSpotClient, huobiClient.SpotApi.ComonSpotClient, krakenClient.SpotApi.ComonSpotClient, - kucoinClient.SpotApi.ComonSpotClient + kucoinClient.SpotApi.CommonSpotClient }; var tasks = clients.Select(c => (c.ExchangeName, c.GetTickerAsync(c.GetSymbolName("ETH", "BTC")))); diff --git a/Examples/ConsoleClient/ConsoleClient.csproj b/Examples/ConsoleClient/ConsoleClient.csproj new file mode 100644 index 0000000..c2f71b3 --- /dev/null +++ b/Examples/ConsoleClient/ConsoleClient.csproj @@ -0,0 +1,20 @@ + + + + Exe + net5.0 + + + + + + + + + + + + + + + diff --git a/Examples/ConsoleClient/Exchanges/BinanceExchange.cs b/Examples/ConsoleClient/Exchanges/BinanceExchange.cs new file mode 100644 index 0000000..c518159 --- /dev/null +++ b/Examples/ConsoleClient/Exchanges/BinanceExchange.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Binance.Net.Clients; + +namespace ConsoleClient.Exchanges +{ + internal class BinanceExchange : IExchange + { + public async Task GetPrice(string symbol) + { + using var client = new BinanceClient(); + var result = await client.SpotApi.ExchangeData.GetPriceAsync(symbol); + // Should check result success status here + return result.Data.Price; + } + } +} diff --git a/Examples/ConsoleClient/Exchanges/IExchange.cs b/Examples/ConsoleClient/Exchanges/IExchange.cs new file mode 100644 index 0000000..a4a3277 --- /dev/null +++ b/Examples/ConsoleClient/Exchanges/IExchange.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleClient.Exchanges +{ + public interface IExchange + { + Task GetPrice(string symbol); + } +} diff --git a/Examples/ConsoleClient/Program.cs b/Examples/ConsoleClient/Program.cs new file mode 100644 index 0000000..96fe79a --- /dev/null +++ b/Examples/ConsoleClient/Program.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using ConsoleClient.Exchanges; + +namespace ConsoleClient +{ + internal class Program + { + static Dictionary _exchanges = new Dictionary + { + { "Binance", new BinanceExchange() } + }; + + static async Task Main(string[] args) + { + Console.WriteLine("> Available commands: PlaceOrder, GetOrders, GetPrice"); + while (true) + { + var input = Console.ReadLine(); + + switch (input) + { + case "PlaceOrder": + + break; + case "GetOrders": + + break; + case "GetPrice": + await ProcessGetPrice(); + break; + default: + Console.WriteLine("> Unknown command"); + break; + } + } + } + + static async Task ProcessGetPrice() + { + Console.WriteLine("> Exchange?"); + var exchange = Console.ReadLine(); + + Console.WriteLine("> Symbol?"); + var symbol = Console.ReadLine(); + + var price = await _exchanges[exchange].GetPrice(symbol); + Console.WriteLine($"> {exchange} price for {symbol}: {price}"); + } + } +}