1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-11 16:32:57 +00:00

Fixed some examples

This commit is contained in:
Jkorf
2026-05-07 14:15:50 +02:00
parent 6e4dbcf7b1
commit 8c4cf62d9f
3 changed files with 10 additions and 10 deletions
@@ -54,12 +54,12 @@ var sub2 = await okxTickerSocket.SubscribeToTickerUpdatesAsync(
Console.WriteLine("Press Enter to exit");
Console.ReadLine();
if (sub1.Success) await binanceTickerSocket.UnsubscribeAsync(sub1.Data);
if (sub2.Success) await okxTickerSocket.UnsubscribeAsync(sub2.Data);
if (sub1.Success) await sub1.Data.CloseAsync();
if (sub2.Success) await sub2.Data.CloseAsync();
// Common variations:
// Add Bybit: ITickerRestClient bybit = new BybitRestClient().V5Api.SharedClient;
// Add Kraken: ITickerRestClient kraken = new KrakenRestClient().SpotApi.SharedClient;
// Add Coinbase: ITickerRestClient cb = new CoinbaseRestClient().AdvancedTradeApi.SharedClient;
// Add Bybit: ISpotTickerRestClient bybit = new BybitRestClient().V5Api.SharedClient;
// Add Kraken: ISpotTickerRestClient kraken = new KrakenRestClient().SpotApi.SharedClient;
// Add Coinbase: ISpotTickerRestClient cb = new CoinbaseRestClient().AdvancedTradeApi.SharedClient;
// Other interfaces: ISpotOrderRestClient (place/cancel orders), IBalanceRestClient (balances),
// IFuturesOrderRestClient, IPositionRestClient, IOrderBookSocketClient, etc.
@@ -56,7 +56,7 @@ async Task<TickerSnapshot?> FetchAsync(ISpotTickerRestClient client, SharedSymbo
Exchange: client.Exchange,
Symbol: result.Data.Symbol,
LastPrice: result.Data.LastPrice ?? 0,
Volume: result.Data.Volume ?? 0);
Volume: result.Data.Volume);
}
record TickerSnapshot(string Exchange, string Symbol, decimal LastPrice, decimal Volume);
@@ -89,13 +89,13 @@ async Task ScanSymbolAsync(SharedSymbol symbol, List<IBookTickerRestClient> clie
async Task<Quote?> GetBookAsync(IBookTickerRestClient client, SharedSymbol symbol)
{
var result = await client.GetBookTickerAsync(new GetBookTickerRequest(symbol));
if (!result.Success || result.Data?.BestBidPrice == null || result.Data.BestAskPrice == null)
if (!result.Success || result.Data == null)
return null;
return new Quote(
Exchange: client.Exchange,
BidPrice: result.Data.BestBidPrice.Value,
AskPrice: result.Data.BestAskPrice.Value);
BidPrice: result.Data.BestBidPrice,
AskPrice: result.Data.BestAskPrice);
}
record Quote(string Exchange, decimal BidPrice, decimal AskPrice);
@@ -107,6 +107,6 @@ record Quote(string Exchange, decimal BidPrice, decimal AskPrice);
// ✓ Track inventory on both venues — can't sell what you don't have
// ✓ Account for withdrawal delays if rebalancing inventory
// ✓ Set hard P&L stops, position limits, maximum exposure per pair
// ✓ Use ISpotOrderRestClient with reduce-only / IOC order types for atomic execution
// ✓ Use ISpotOrderRestClient with exchange-supported IOC/fill-or-kill order options where available
// ✓ Monitor connection health and have failover logic
// ✓ Log everything — arbitrage P&L analysis requires complete audit trails