mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 16:36:15 +00:00
Updated example
This commit is contained in:
parent
ebe332b724
commit
6b45859934
@ -5,15 +5,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Binance.Net" Version="8.0.0-alpha4" />
|
<PackageReference Include="Binance.Net" Version="8.0.0-alpha5" />
|
||||||
<PackageReference Include="Bitfinex.Net" Version="5.0.0-alpha4" />
|
<PackageReference Include="Bitfinex.Net" Version="5.0.0-alpha5" />
|
||||||
<PackageReference Include="Bittrex.Net" Version="7.0.0-alpha4" />
|
<PackageReference Include="Bittrex.Net" Version="7.0.0-alpha5" />
|
||||||
<PackageReference Include="Bybit.Net" Version="0.0.1-alpha4" />
|
<PackageReference Include="Bybit.Net" Version="0.0.1-alpha5" />
|
||||||
<PackageReference Include="CoinEx.Net" Version="5.0.0-alpha4" />
|
<PackageReference Include="CoinEx.Net" Version="5.0.0-alpha5" />
|
||||||
<PackageReference Include="FTX.Net" Version="1.0.0-alpha4" />
|
<PackageReference Include="FTX.Net" Version="1.0.0-alpha5" />
|
||||||
<PackageReference Include="Huobi.Net" Version="4.0.0-alpha5" />
|
<PackageReference Include="Huobi.Net" Version="4.0.0-alpha6" />
|
||||||
<PackageReference Include="KrakenExchange.Net" Version="3.0.0-alpha4" />
|
<PackageReference Include="KrakenExchange.Net" Version="3.0.0-alpha5" />
|
||||||
<PackageReference Include="Kucoin.Net" Version="4.0.0-alpha4" />
|
<PackageReference Include="Kucoin.Net" Version="4.0.0-alpha5" />
|
||||||
|
<PackageReference Include="Serilog.AspNetCore" Version="4.1.1-dev-00241" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
@code{
|
@code{
|
||||||
private ConcurrentDictionary<string, decimal> _prices = new ConcurrentDictionary<string, decimal>();
|
private ConcurrentDictionary<string, decimal> _prices = new ConcurrentDictionary<string, decimal>();
|
||||||
private UpdateSubscription[] _subs;
|
private UpdateSubscription[] _subs = Array.Empty<UpdateSubscription>();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
{
|
{
|
||||||
var clients = new ISpotClient[]
|
var clients = new ISpotClient[]
|
||||||
{
|
{
|
||||||
|
|
||||||
binanceClient.SpotApi.ComonSpotClient,
|
binanceClient.SpotApi.ComonSpotClient,
|
||||||
bitfinexClient.SpotApi.ComonSpotClient,
|
bitfinexClient.SpotApi.ComonSpotClient,
|
||||||
bittrexClient.SpotApi.ComonSpotClient,
|
bittrexClient.SpotApi.ComonSpotClient,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace BlazorClient
|
namespace BlazorClient
|
||||||
{
|
{
|
||||||
@ -7,6 +10,13 @@ namespace BlazorClient
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.MinimumLevel.Debug()
|
||||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
|
||||||
|
.MinimumLevel.Override("Microsoft.AspNetCore.Mvc", LogEventLevel.Error)
|
||||||
|
.WriteTo.File("log-.txt", rollingInterval: RollingInterval.Day, flushToDiskInterval: System.TimeSpan.FromSeconds(1))
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
CreateHostBuilder(args).Build().Run();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +24,8 @@ namespace BlazorClient
|
|||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup(
|
||||||
|
context => new Startup(context.Configuration, LoggerFactory.Create(config => config.AddSerilog()) ));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item px-3">
|
<li class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="ISpotClient">
|
<NavLink class="nav-link" href="SpotClient">
|
||||||
Get data ISpotClient
|
Get data ISpotClient
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1,31 +1,19 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using Binance.Net;
|
using Binance.Net;
|
||||||
using Binance.Net.Clients;
|
using Binance.Net.Clients;
|
||||||
using Binance.Net.Interfaces.Clients;
|
using Binance.Net.Interfaces.Clients;
|
||||||
using Binance.Net.Objects;
|
using Binance.Net.Objects;
|
||||||
using Bitfinex.Net;
|
using Bitfinex.Net;
|
||||||
using Bitfinex.Net.Clients;
|
|
||||||
using Bitfinex.Net.Interfaces.Clients;
|
|
||||||
using Bittrex.Net;
|
using Bittrex.Net;
|
||||||
using Bittrex.Net.Clients;
|
|
||||||
using Bittrex.Net.Interfaces.Clients;
|
|
||||||
using Bybit.Net;
|
using Bybit.Net;
|
||||||
using Bybit.Net.Clients;
|
using CoinEx.Net;
|
||||||
using Bybit.Net.Interfaces.Clients;
|
|
||||||
using CoinEx.Net.Clients;
|
using CoinEx.Net.Clients;
|
||||||
using CoinEx.Net.Interfaces.Clients;
|
using CoinEx.Net.Interfaces.Clients;
|
||||||
using CryptoExchange.Net.Authentication;
|
using CryptoExchange.Net.Authentication;
|
||||||
using FTX.Net;
|
using FTX.Net;
|
||||||
using FTX.Net.Clients;
|
|
||||||
using FTX.Net.Interfaces.Clients;
|
|
||||||
using Huobi.Net;
|
using Huobi.Net;
|
||||||
using Huobi.Net.Clients;
|
|
||||||
using Huobi.Net.Interfaces.Clients;
|
|
||||||
using Kraken.Net;
|
using Kraken.Net;
|
||||||
using Kraken.Net.Clients;
|
|
||||||
using Kraken.Net.Interfaces.Clients;
|
|
||||||
using Kucoin.Net;
|
using Kucoin.Net;
|
||||||
using Kucoin.Net.Clients;
|
|
||||||
using Kucoin.Net.Interfaces.Clients;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@ -37,9 +25,12 @@ namespace BlazorClient
|
|||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration configuration)
|
private ILoggerFactory _loggerFactory;
|
||||||
|
|
||||||
|
public Startup(IConfiguration configuration, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
|
_loggerFactory = loggerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
@ -54,22 +45,36 @@ namespace BlazorClient
|
|||||||
// Register the clients, options can be provided in the callback parameter
|
// Register the clients, options can be provided in the callback parameter
|
||||||
services.AddBinance((restClientOptions, socketClientOptions) => {
|
services.AddBinance((restClientOptions, socketClientOptions) => {
|
||||||
restClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
|
restClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
|
||||||
restClientOptions.LogLevel = LogLevel.Debug;
|
restClientOptions.LogLevel = LogLevel.Trace;
|
||||||
|
|
||||||
|
// Point the logging to use the ILogger configuration, which uses Serilog here
|
||||||
|
restClientOptions.LogWriters = new List<ILogger> { _loggerFactory.CreateLogger<IBinanceClient>() };
|
||||||
|
|
||||||
socketClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
|
socketClientOptions.ApiCredentials = new ApiCredentials("KEY", "SECRET");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
BinanceClient.SetDefaultOptions(new BinanceClientOptions
|
||||||
|
{
|
||||||
|
ApiCredentials = new ApiCredentials("KEY", "SECRET"),
|
||||||
|
LogLevel = LogLevel.Trace
|
||||||
|
});
|
||||||
|
|
||||||
|
BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions
|
||||||
|
{
|
||||||
|
ApiCredentials = new ApiCredentials("KEY", "SECRET"),
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddTransient<IBinanceClient, BinanceClient>();
|
||||||
|
services.AddScoped<IBinanceSocketClient, BinanceSocketClient>();
|
||||||
|
|
||||||
services.AddBitfinex();
|
services.AddBitfinex();
|
||||||
services.AddBittrex();
|
services.AddBittrex();
|
||||||
services.AddBybit();
|
services.AddBybit();
|
||||||
//services.AddCoinEx();
|
services.AddCoinEx();
|
||||||
services.AddFTX();
|
services.AddFTX();
|
||||||
services.AddHuobi();
|
services.AddHuobi();
|
||||||
services.AddKraken();
|
services.AddKraken();
|
||||||
services.AddKucoin();
|
services.AddKucoin();
|
||||||
|
|
||||||
// TODO remove when AddCoinEx fixed
|
|
||||||
services.AddScoped<ICoinExClient, CoinExClient>();
|
|
||||||
services.AddScoped<ICoinExSocketClient, CoinExSocketClient>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
"DetailedErrors": true,
|
"DetailedErrors": true,
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft": "Warning",
|
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user