Skip to content

Commit c634b88

Browse files
committed
Ai docs
1 parent a846bc6 commit c634b88

14 files changed

Lines changed: 1951 additions & 0 deletions

File tree

.cursor/rules/deepcoin-net.mdc

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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

.github/copilot-instructions.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copilot Instructions for DeepCoin.Net
2+
3+
This repository is **DeepCoin.Net** - a strongly typed C#/.NET client library for the DeepCoin REST and WebSocket APIs. It is part of the CryptoExchange.Net ecosystem.
4+
5+
When generating code that consumes DeepCoin.Net, follow these conventions:
6+
7+
## Use DeepCoin.Net, not raw HTTP
8+
9+
Never generate `HttpClient` calls to DeepCoin endpoints. Always use `DeepCoinRestClient` or `DeepCoinSocketClient`. This keeps request signing, rate limiting, result handling, and WebSocket reconnect behavior in the library.
10+
11+
## Client setup
12+
13+
```csharp
14+
using DeepCoin.Net;
15+
using DeepCoin.Net.Clients;
16+
17+
var restClient = new DeepCoinRestClient(options =>
18+
{
19+
options.ApiCredentials = new DeepCoinCredentials("API_KEY", "API_SECRET", "API_PASS");
20+
});
21+
```
22+
23+
For public market data only, no credentials are needed: `new DeepCoinRestClient()`.
24+
25+
## Result handling
26+
27+
Methods return `WebCallResult<T>` (REST) or `CallResult<T>` (WebSocket). Always check `.Success` before reading `.Data`. The error is on `.Error`.
28+
29+
## API structure
30+
31+
- `restClient.ExchangeApi.ExchangeData` - public market data: tickers, symbols, klines, order book, funding rates
32+
- `restClient.ExchangeApi.Account` - balances, bills, leverage, deposit/withdraw history, listen keys
33+
- `restClient.ExchangeApi.Trading` - positions, orders, user trades, order history, TP/SL
34+
- `restClient.ExchangeApi.SharedClient` - CryptoExchange.Net shared REST interfaces
35+
- `socketClient.ExchangeApi` - public and private WebSocket subscriptions
36+
- `socketClient.ExchangeApi.SharedClient` - CryptoExchange.Net shared socket interfaces
37+
38+
## DeepCoin symbol shape
39+
40+
DeepCoin spot symbols use hyphenated names such as `ETH-USDT`. Swap symbols use names such as `ETH-USDT-SWAP`. Use `SymbolType.Spot` for spot and `SymbolType.Swap` for swaps/futures.
41+
42+
## Order placement
43+
44+
Use `DeepCoinCredentials`, not generic `ApiCredentials`. For spot orders use `tradeMode: TradeMode.Spot`. For swap/futures orders use `TradeMode.Cross` or `TradeMode.Isolated` and include `positionSide` when opening or closing a directional position.
45+
46+
## WebSocket pattern
47+
48+
Store the returned `UpdateSubscription` and unsubscribe on shutdown via `socketClient.UnsubscribeAsync(sub.Data)`. Authenticated streams require a listen key from `restClient.ExchangeApi.Account.StartUserStreamAsync()`.
49+
50+
## Cross-exchange
51+
52+
For code that needs to work across multiple exchanges, use `CryptoExchange.Net.SharedApis` interfaces accessed via `.ExchangeApi.SharedClient`.
53+
54+
## Avoid
55+
56+
- Legacy or imagined `DeepCoinClient` class; use `DeepCoinRestClient`
57+
- Generic `ApiCredentials`; use `DeepCoinCredentials("key", "secret", "pass")`
58+
- Binance-style branches such as `SpotApi`, `UsdFuturesApi`, or `CoinFuturesApi`
59+
- Non-hyphenated symbols like `ETHUSDT` in native DeepCoin methods
60+
- Synchronous `.Result` / `.Wait()`; use `await`
61+
- Reading `.Data` before checking `.Success`
62+
- Instantiating clients per request; use DI or reuse clients
63+
64+
## Reference
65+
66+
For detailed patterns and pitfalls see `CLAUDE.md`, `llms.txt`, and `llms-full.txt` in the repository root, and `Examples/ai-friendly/` for compilable examples.

0 commit comments

Comments
 (0)