Skip to content

ccxt-net/ccxt.simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CCXT.Simple

NuGet .NET License

A simplified cryptocurrency trading library for .NET that provides unified access to multiple cryptocurrency exchange APIs. Built as a simpler alternative to ccxt.net with a focus on ease of use and consistent interfaces across all supported exchanges.

🚀 Features

Unified API Interface

  • Standardized Methods: Identical API signatures across all 16 supported exchanges
  • Type Safety: Strong typing with comprehensive data models
  • Async/Await: Modern C# async patterns with ValueTask<T> for optimal performance
  • Error Handling: Consistent error reporting and exception handling

Comprehensive Exchange Support

  • 111 Total Exchanges: 15 fully implemented, 96 in development (skeleton code ready)
  • Implemented Exchanges: Binance, Bitget, Bithumb, Bittrex, ByBit, Coinbase, Coinone, Crypto.com, Gate.io, Huobi, Korbit, Kraken, KuCoin, OKX, Upbit
  • In Development: 96 additional exchanges from CCXT library (see full list below)
  • Full API Coverage: Implemented exchanges support complete trading, account, and funding operations (v1.1.6+)
  • Market Data: Real-time tickers, order books, trading pairs, volume data
  • Account Management: Balance queries, account information, deposit/withdrawal history
  • Trading Operations: Order placement, cancellation, order history, trade history
  • Funding: Deposit addresses, withdrawals, transaction history

Advanced Features

  • Multi-Currency Support: KRW, USD, USDT, BTC, and more
  • WebSocket Support: Real-time data streaming (Bitget implementation available)
  • Rate Limiting: Built-in rate limiting per exchange specifications
  • Authentication: Secure API key management with HMAC signatures

🏗️ Architecture

Core Components

// Unified interface for all exchanges
public interface IExchange
{
    // Core market data
    ValueTask<bool> GetTickers(Tickers tickers);
    ValueTask<decimal> GetPrice(string symbol);
    ValueTask<Orderbook> GetOrderbook(string symbol, int limit = 5);
    
    // Account management
    ValueTask<Dictionary<string, BalanceInfo>> GetBalance();
    ValueTask<AccountInfo> GetAccount();
    
    // Trading operations
    ValueTask<OrderInfo> PlaceOrder(string symbol, SideType side, string orderType, 
                                   decimal amount, decimal? price = null);
    ValueTask<List<OrderInfo>> GetOpenOrders(string symbol = null);
    
    // Funding operations
    ValueTask<DepositAddress> GetDepositAddress(string currency, string network = null);
    ValueTask<WithdrawalInfo> Withdraw(string currency, decimal amount, string address);
}

Data Models

// Unified ticker information
public class Ticker
{
    public string symbol { get; set; }
    public decimal lastPrice { get; set; }
    public decimal bidPrice { get; set; }
    public decimal askPrice { get; set; }
    public decimal volume24h { get; set; }
    
    // Compatibility properties
    public decimal last => lastPrice;
    public decimal bid => bidPrice;
    public decimal ask => askPrice;
}

// Account balance information
public class BalanceInfo
{
    public decimal free { get; set; }
    public decimal used { get; set; }
    public decimal total { get; set; }
}

// Order information
public class OrderInfo
{
    public string id { get; set; }
    public string symbol { get; set; }
    public SideType side { get; set; }
    public decimal amount { get; set; }
    public decimal? price { get; set; }
    public string status { get; set; }
}

📦 Installation

NuGet Package

dotnet add package CCXT.Simple

Package Manager Console

Install-Package CCXT.Simple

Clone Repository

git clone https://github.com/ccxt-net/ccxt.simple.git

🚀 Quick Start

Basic Market Data

using CCXT.Simple.Exchanges;
using CCXT.Simple.Exchanges.Binance;

// Initialize exchange
var exchange = new Exchange("KRW");
var binance = new XBinance(exchange);

// Verify available symbols
await binance.VerifySymbols();

// Get tickers
var tickers = new Tickers("binance", exchange.GetXInfors("binance").symbols);
await binance.GetTickers(tickers);

// Get specific price
var btcPrice = await binance.GetPrice("BTCUSDT");
Console.WriteLine($"BTC Price: ${btcPrice}");

// Get order book
var orderbook = await binance.GetOrderbook("BTCUSDT", 10);
Console.WriteLine($"Best Bid: ${orderbook.bids[0].price}");
Console.WriteLine($"Best Ask: ${orderbook.asks[0].price}");

Account Management & Trading

// Initialize with API credentials
var binance = new XBinance(exchange, "your_api_key", "your_secret_key");

// Get account balance
var balances = await binance.GetBalance();
foreach (var balance in balances)
{
    Console.WriteLine($"{balance.Key}: {balance.Value.free} (Free), {balance.Value.total} (Total)");
}

// Place a limit order
var order = await binance.PlaceOrder("BTCUSDT", SideType.Bid, "limit", 0.001m, 50000m);
Console.WriteLine($"Order placed: {order.id}");

// Get open orders
var openOrders = await binance.GetOpenOrders("BTCUSDT");
foreach (var openOrder in openOrders)
{
    Console.WriteLine($"Order {openOrder.id}: {openOrder.amount} at ${openOrder.price}");
}

// Cancel an order
var cancelled = await binance.CancelOrder("BTCUSDT", order.id);
Console.WriteLine($"Order cancelled: {cancelled}");

// Get order history
var history = await binance.GetOrderHistory("BTCUSDT");
Console.WriteLine($"Total orders in history: {history.Count}");

Advanced: Bitget Trading API

using CCXT.Simple.Exchanges.Bitget.RA.Trade;

// Bitget has specialized trading API
var tradeApi = new TradeAPI(exchange, "api_key", "secret_key", "pass_phrase");

// Place order with Bitget's native API
var result = await tradeApi.PlaceOrderAsync("BTCUSDT", "buy", "limit", 
                                           "normal", 50000m, 0.001m, "client_order_1");
if (result.code == "00000")
{
    Console.WriteLine($"Order successful: {result.data.orderId}");
}

🏢 Supported Exchanges

Fully Implemented Exchanges (15)

Exchange Status Market Data Trading Account Funding Special Features
Binance ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Complete API implementation
Bitget ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Advanced WS & Trading API
Bithumb ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full KRW pairs, Korean market
Bittrex ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full USD pairs, US market
ByBit ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Derivatives & spot trading
Coinbase ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full USD pairs, regulated exchange
Coinone ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full KRW pairs, Korean market
Crypto.com ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Multi-currency support
Gate.io ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Wide altcoin selection
Huobi ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Global markets, HTX rebrand
Korbit ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full KRW pairs, GraphQL API
Kraken ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Major US exchange, complete implementation
KuCoin ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Extensive altcoin support
OKX ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full Advanced trading features
Upbit ✅ Active ✅ Full ✅ Full ✅ Full ✅ Full KRW pairs, largest Korean exchange

🚧 In Development - Major Exchanges (19)

Exchange Status Priority Target Release Notes
Bitstamp 🚧 Dev High Q1 2025 European market leader
Bitfinex 🚧 Dev High Q1 2025 Advanced trading features
Poloniex 🚧 Dev Medium Q1 2025 Wide altcoin selection
Gemini 🚧 Dev High Q1 2025 US regulated exchange
Mexc 🚧 Dev Medium Q2 2025 Growing global exchange
Deribit 🚧 Dev High Q2 2025 Options & futures leader
Bitmex 🚧 Dev High Q2 2025 Derivatives pioneer
Phemex 🚧 Dev Medium Q2 2025 Derivatives trading
Bitflyer 🚧 Dev Medium Q2 2025 Japanese market
Coincheck 🚧 Dev Medium Q2 2025 Japanese exchange
Zaif 🚧 Dev Low Q3 2025 Japanese market
Luno 🚧 Dev Medium Q3 2025 Emerging markets
Bitvavo 🚧 Dev Medium Q3 2025 European exchange
Btcturk 🚧 Dev Low Q3 2025 Turkish market
Mercado 🚧 Dev Low Q3 2025 Brazilian market
Novadax 🚧 Dev Low Q3 2025 Latin American market
Indodax 🚧 Dev Low Q3 2025 Indonesian market
Woo 🚧 Dev Medium Q3 2025 Liquidity network
Vertex 🚧 Dev Medium Q4 2025 DEX with CEX features

📋 Skeleton Code Ready (77 Exchanges)

Click to expand full list of exchanges with skeleton implementation

Binance Ecosystem

  • BinanceCoinm, BinanceUs, BinanceUsdm

Major International

  • Alpaca, Apex, Ascendex, Bequant, Bigone, Bingx, Bit2c, Bitbank, Bitbns, Bitmart, Bitopro, Bitrue, Bitso, Bitteam, Bittrade, Blockchaincom, Blofin, Btcalpha, Btcbox, Btcmarkets, Cex

Coinbase Ecosystem

  • CoinbaseAdvanced, CoinbaseExchange, CoinbaseInternational

Regional Exchanges

  • Coincatch, Coinex, Coinmate, Coinmetro, Coinsph, Coinspot, Cryptocom, Cryptomus

DeFi & Derivatives

  • Defx, Delta, Derive, Digifinex, Ellipx, Hyperliquid, Paradex

Established Exchanges

  • Exmo, Fmfwio, Foxbit, Gate, Hashkey, Hibachi, Hitbtc, Hollaex, Htx, Independentreserve

Kraken Ecosystem

  • Krakenfutures

KuCoin Ecosystem

  • Kucoinfutures

Emerging Exchanges

  • Latoken, Lbank, Modetrade, Myokx, Ndax, Oceanex

OKX Ecosystem

  • Okcoin, Okx, Okxus

Specialized Exchanges

  • Onetrading, Oxfun, P2b, Paymium, Probit, Timex, Tokocrypto, Tradeogre

Next Generation

  • Wavesexchange, Whitebit, Woofipro, Xt, Yobit, Zonda

Legend:

  • Fully implemented - Complete API integration with all features
  • 🚧 In Development - Skeleton code ready, implementation in progress
  • 📋 Skeleton Ready - Interface implemented, awaiting full development

🔧 Configuration

Exchange Initialization

// Basic initialization (public data only)
var exchange = new Exchange("USD"); // or "KRW", "EUR", etc.
var binance = new XBinance(exchange);

// With API credentials (for private operations)
var binance = new XBinance(exchange, "api_key", "secret_key", "passphrase");

// Configure volume and rate limiting
exchange.Volume24hBase = 1000000;    // 24h volume threshold
exchange.Volume1mBase = 10000;       // 1min volume threshold  
exchange.ApiCallDelaySeconds = 1;    // Rate limiting delay

Event Handling

// Subscribe to events
exchange.OnMessageEvent += (exchange, message, code) => 
{
    Console.WriteLine($"[{exchange}] {message} (Code: {code})");
};

exchange.OnUsdPriceEvent += (price) => 
{
    Console.WriteLine($"BTC/USD Price Update: ${price}");
};

exchange.OnKrwPriceEvent += (price) => 
{
    Console.WriteLine($"BTC/KRW Price Update: ₩{price}");
};

🔄 Migration & Compatibility

Version 1.1.7 - Technical Improvements

  • Build System Updates: Removed netstandard2.1 support, focusing on .NET 8.0 and .NET 9.0
  • Dependency Cleanup: Replaced System.Net.Http.Json with Newtonsoft.Json for better compatibility
  • Documentation: Translated all Korean comments to English for international developers
  • Bug Fixes: Fixed CoinState.json file path issue in Bithumb exchange
  • Code Organization: Added GlobalUsings.cs for common namespace imports
  • Testing: Unified test project structure with improved test coverage
  • No Breaking Changes: Full backward compatibility maintained

Backward Compatibility

// Legacy properties still work
decimal lastPrice = ticker.last;    // Alias for ticker.lastPrice
decimal bidPrice = ticker.bid;      // Alias for ticker.bidPrice
decimal askPrice = ticker.ask;      // Alias for ticker.askPrice
decimal volume = ticker.baseVolume; // Alias for ticker.volume24h

📊 Performance & Best Practices

Async/Await Patterns

// Efficient batch operations
var tasks = new[]
{
    binance.GetTickers(tickers),
    binance.GetVolumes(tickers),
    binance.GetBookTickers(tickers)
};

await Task.WhenAll(tasks);

Rate Limiting

// Respect exchange rate limits
exchange.ApiCallDelaySeconds = 1; // Binance: 1200 requests/minute
await Task.Delay(TimeSpan.FromSeconds(exchange.ApiCallDelaySeconds));

Error Handling

try 
{
    var result = await exchange.GetTickers(tickers);
}
catch (NotImplementedException ex)
{
    Console.WriteLine($"Feature not yet implemented: {ex.Message}");
}
catch (Exception ex)
{
    Console.WriteLine($"Exchange error: {ex.Message}");
}

🛣️ Roadmap

See our detailed Development Roadmap for:

  • Quarterly development phases
  • Monthly implementation milestones
  • Priority exchange queue
  • Community involvement opportunities
  • Success metrics and goals

Current Focus: Q3 2025 - Implementing top 20 priority exchanges

🤝 Contributing

We welcome contributions! Please read our Contributing Guidelines before submitting pull requests.

📢 Request Exchange Implementation

Want a specific exchange implemented sooner?

If you need a particular exchange from our skeleton implementations (96 exchanges ready), simply create an issue with the exchange name.

We prioritize implementation based on community demand! Exchanges with more requests will be implemented first.

🚀 Request New API Functions

Need additional API functions beyond our standard interface?

We're always looking to expand our API coverage! Please create an issue for:

1. Standard API Functions (All Exchanges)

API functions that should be standardized across all exchanges:

  • GetFundingRate() - Perpetual contract funding rates
  • GetLeverageBrackets() - Margin tier information
  • GetIndexPrice() - Index price for derivatives
  • GetMarkPrice() - Mark price for futures
  • GetPositions() - Open positions for margin/futures
  • GetSubAccounts() - Sub-account management
  • TransferBetweenAccounts() - Internal transfers
  • GetTradingFees() - Current fee structure

2. Exchange-Specific API Functions

Unique APIs that certain exchanges offer:

  • CopyTrade() - Copy trading API (Bitget, ByBit)
  • GetStakingProducts() - Staking opportunities (Binance)
  • PlaceGridOrder() - Grid trading (KuCoin, Gate.io)
  • GetDualInvestment() - Dual investment products (Binance)
  • GetOptions() - Options chain data (Deribit)
  • GetInsurance() - Insurance fund data (ByBit)
  • GetLaunchpad() - IEO/Launchpad info (multiple exchanges)

When requesting API functions, please specify:

  • Whether it should be standard (all exchanges) or exchange-specific
  • The exact API endpoint from exchange documentation
  • Return data structure you expect

Your feedback helps us identify missing APIs!

Development Setup

# Clone repository
git clone https://github.com/ccxt-net/ccxt.simple.git
cd ccxt.simple

# Build solution
dotnet build

# Run tests
dotnet test

# Run samples (interactive menu)
dotnet run --project samples/CCXT.Simple.Samples.csproj

Implementation Guidelines

  • Follow existing patterns from Binance implementation
  • Use mainXchg.OnMessageEvent for error reporting
  • Implement proper rate limiting
  • Add comprehensive error handling
  • Include XML documentation

📚 Documentation

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

💖 Support

If CCXT.Simple has made your development easier and you'd like to support continued development:

NuGet Package

dotnet add package CCXT.Simple

Cryptocurrency Donations

  • Bitcoin: 15DAoUfaCanpBpTs7VQBK8dRmbQqEnF9WG
  • Ethereum: 0x556E7EdbcCd669a42f00c1Df53D550C00814B0e3

Contact & Support

👥 Team

Core Development Team


Built with ❤️ by the ODINSOFT Team

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages