|
| 1 | +--- |
| 2 | +description: Conventions for using DeepCoin.Net library when working with the DeepCoin cryptocurrency exchange in C#/.NET. Apply when generating code that interacts with the DeepCoin API. |
| 3 | +globs: |
| 4 | + - "**/*.cs" |
| 5 | + - "**/*.csproj" |
| 6 | +alwaysApply: false |
| 7 | +--- |
| 8 | + |
| 9 | +# DeepCoin.Net Conventions |
| 10 | + |
| 11 | +This codebase uses **DeepCoin.Net** for DeepCoin cryptocurrency exchange access. Do not write raw `HttpClient` calls to DeepCoin endpoints. |
| 12 | + |
| 13 | +## Client setup pattern |
| 14 | + |
| 15 | +```csharp |
| 16 | +using DeepCoin.Net; |
| 17 | +using DeepCoin.Net.Clients; |
| 18 | + |
| 19 | +var restClient = new DeepCoinRestClient(options => |
| 20 | +{ |
| 21 | + options.ApiCredentials = new DeepCoinCredentials("API_KEY", "API_SECRET", "API_PASS"); |
| 22 | +}); |
| 23 | +``` |
| 24 | + |
| 25 | +For public market data only, no credentials are needed: `new DeepCoinRestClient()`. |
| 26 | + |
| 27 | +## Result pattern |
| 28 | + |
| 29 | +All methods return `WebCallResult<T>` (REST) or `CallResult<T>` (WebSocket). Always check `.Success` before reading `.Data`: |
| 30 | + |
| 31 | +```csharp |
| 32 | +var tickers = await restClient.ExchangeApi.ExchangeData.GetTickersAsync(SymbolType.Spot); |
| 33 | +if (!tickers.Success) { /* tickers.Error */ return; } |
| 34 | +var eth = tickers.Data.FirstOrDefault(x => x.Symbol == "ETH-USDT"); |
| 35 | +``` |
| 36 | + |
| 37 | +## API surface |
| 38 | + |
| 39 | +- `restClient.ExchangeApi.ExchangeData` for tickers, symbols, klines, order books, and funding rates |
| 40 | +- `restClient.ExchangeApi.Account` for balances, bills, leverage, deposit/withdraw history, and listen keys |
| 41 | +- `restClient.ExchangeApi.Trading` for positions, orders, user trades, order history, and TP/SL |
| 42 | +- `restClient.ExchangeApi.SharedClient` for shared REST interfaces |
| 43 | +- `socketClient.ExchangeApi` for public and private WebSocket subscriptions |
| 44 | +- `socketClient.ExchangeApi.SharedClient` for shared socket interfaces |
| 45 | + |
| 46 | +## Native symbols and account modes |
| 47 | + |
| 48 | +Use DeepCoin's native hyphenated symbols: |
| 49 | + |
| 50 | +```csharp |
| 51 | +"ETH-USDT" // spot |
| 52 | +"ETH-USDT-SWAP" // swap/futures |
| 53 | +``` |
| 54 | + |
| 55 | +Use `SymbolType.Spot` for spot data and account balances, `SymbolType.Swap` for swap/futures data and positions. Use `TradeMode.Spot` for spot orders; use `TradeMode.Cross` or `TradeMode.Isolated` for swap/futures orders. |
| 56 | + |
| 57 | +## Order placement |
| 58 | + |
| 59 | +```csharp |
| 60 | +var order = await restClient.ExchangeApi.Trading.PlaceOrderAsync( |
| 61 | + "ETH-USDT", |
| 62 | + OrderSide.Buy, |
| 63 | + OrderType.Limit, |
| 64 | + quantity: 0.1m, |
| 65 | + price: 2000m, |
| 66 | + tradeMode: TradeMode.Spot); |
| 67 | +``` |
| 68 | + |
| 69 | +For swap/futures orders include `positionSide: PositionSide.Long` or `PositionSide.Short` when the request is directional. |
| 70 | + |
| 71 | +## WebSocket pattern |
| 72 | + |
| 73 | +```csharp |
| 74 | +var socketClient = new DeepCoinSocketClient(); |
| 75 | +var sub = await socketClient.ExchangeApi.SubscribeToSymbolUpdatesAsync( |
| 76 | + "ETH-USDT", |
| 77 | + update => { /* update.Data.LastPrice */ }); |
| 78 | +if (!sub.Success) { /* sub.Error */ return; } |
| 79 | + |
| 80 | +await socketClient.UnsubscribeAsync(sub.Data); |
| 81 | +``` |
| 82 | + |
| 83 | +Private streams require a listen key: |
| 84 | + |
| 85 | +```csharp |
| 86 | +var listenKey = await restClient.ExchangeApi.Account.StartUserStreamAsync(); |
| 87 | +if (!listenKey.Success) { return; } |
| 88 | + |
| 89 | +await socketClient.ExchangeApi.SubscribeToUserDataUpdatesAsync(listenKey.Data.ListenKey); |
| 90 | +``` |
| 91 | + |
| 92 | +## Multi-exchange code |
| 93 | + |
| 94 | +For exchange-agnostic code, use `CryptoExchange.Net.SharedApis`: |
| 95 | + |
| 96 | +```csharp |
| 97 | +using CryptoExchange.Net.SharedApis; |
| 98 | + |
| 99 | +var shared = new DeepCoinRestClient().ExchangeApi.SharedClient; |
| 100 | +var ticker = await shared.GetSpotTickerAsync( |
| 101 | + new GetTickerRequest(new SharedSymbol(TradingMode.Spot, "ETH", "USDT"))); |
| 102 | +``` |
| 103 | + |
| 104 | +## Hard rules |
| 105 | + |
| 106 | +- Never write raw `HttpClient` to DeepCoin endpoints |
| 107 | +- Never use `.Result` or `.Wait()` |
| 108 | +- Never instantiate clients per request |
| 109 | +- Never skip checking `WebCallResult.Success` |
| 110 | +- Never use `DeepCoinClient`; use `DeepCoinRestClient` |
| 111 | +- Never use generic `ApiCredentials`; use `DeepCoinCredentials` |
| 112 | +- Never use Binance-style API branches such as `SpotApi` or `UsdFuturesApi` |
| 113 | +- Use DeepCoin native symbols with hyphens in native methods |
| 114 | +- Always store WebSocket subscriptions and unsubscribe on shutdown |
| 115 | + |
| 116 | +## Reference |
| 117 | + |
| 118 | +- `CLAUDE.md` in repo root has fuller examples |
| 119 | +- `llms.txt` and `llms-full.txt` in repo root for AI context |
| 120 | +- `Examples/ai-friendly/` contains compilable examples |
0 commit comments