BcsTradeApi 2026.5.2.2

dotnet add package BcsTradeApi --version 2026.5.2.2
                    
NuGet\Install-Package BcsTradeApi -Version 2026.5.2.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BcsTradeApi" Version="2026.5.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BcsTradeApi" Version="2026.5.2.2" />
                    
Directory.Packages.props
<PackageReference Include="BcsTradeApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BcsTradeApi --version 2026.5.2.2
                    
#r "nuget: BcsTradeApi, 2026.5.2.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BcsTradeApi@2026.5.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BcsTradeApi&version=2026.5.2.2
                    
Install as a Cake Addin
#tool nuget:?package=BcsTradeApi&version=2026.5.2.2
                    
Install as a Cake Tool

BcsTradeApi

.NET 8 client library for BCS Trade API. Supports order management, portfolio, market data (REST + WebSocket) and account limits.

Installation

dotnet add package BcsTradeApi

Quick start

1. Register services

// Program.cs / Startup.cs
services.AddBcsTradeApi(options =>
{
    options.ClientId    = "your-client-id";
    options.RefreshToken = "your-refresh-token";
});

2. Inject BcsApiClient

public class MyService(BcsApiClient bcs)
{
    public async Task RunAsync()
    {
        var portfolio = await bcs.Portfolio.GetAsync();
        var limits    = await bcs.Limits.GetAsync();
    }
}

Configuration (BcsApiOptions)

Property Default Description
ClientId Client identifier
RefreshToken Refresh token for authentication
HttpTimeout 30 s HTTP request timeout
MaxRequestsPerSecond 10 Rate limit (requests/sec)
RetryCount 3 Number of HTTP retries
TokenRefreshBufferSeconds 60 Seconds before expiry to refresh token
WsPingTimeoutSeconds 90 WebSocket ping timeout
WsReconnectMaxAttempts 5 Max WebSocket reconnect attempts
WsReconnectBaseDelay 2 s Base delay for exponential reconnect backoff

Orders — bcs.Orders

Place a limit order

var order = await bcs.Orders.PlaceLimitAsync(new PlaceLimitOrderRequest
{
    Ticker        = "SBER",
    Direction     = OrderDirection.Buy,
    Quantity      = 10,
    Price         = 250.50m,
    ClientOrderId = "my-order-1"   // optional, your own ID
});

Console.WriteLine(order.OrderId);

Place a market order

var order = await bcs.Orders.PlaceMarketAsync(new PlaceMarketOrderRequest
{
    Ticker    = "SBER",
    Direction = OrderDirection.Sell,
    Quantity  = 5
});

Get order by ID

var order = await bcs.Orders.GetAsync("order-id");
Console.WriteLine(order.Status); // New, PartiallyFilled, Filled, Cancelled, Rejected

Cancel order

await bcs.Orders.CancelAsync("order-id");

Search orders

var orders = await bcs.Orders.SearchAsync(new OrdersSearchRequest
{
    Ticker   = "SBER",
    Statuses = [OrderStatus.New, OrderStatus.PartiallyFilled],
    From     = DateTime.UtcNow.AddDays(-7),
    To       = DateTime.UtcNow,
    Limit    = 50
});

Get trades (executions history)

var trades = await bcs.Orders.GetTradesAsync(new TradesSearchRequest
{
    Ticker = "SBER",
    From   = DateTime.UtcNow.AddDays(-1),
    Limit  = 100
});

Subscribe to order executions (WebSocket)

await bcs.Orders.SubscribeExecutionAsync(
    onExecution: execution =>
    {
        Console.WriteLine($"{execution.OrderId} filled {execution.FilledQuantity} @ {execution.Price}");
        return Task.CompletedTask;
    },
    onError: ex => Console.WriteLine($"Error: {ex.Message}"),
    ct: cancellationToken
);

Portfolio — bcs.Portfolio

Get current portfolio

var portfolio = await bcs.Portfolio.GetAsync();

Console.WriteLine($"Total: {portfolio.TotalValue} {portfolio.Currency}");
Console.WriteLine($"Cash:  {portfolio.Cash}");

foreach (var pos in portfolio.Positions)
{
    Console.WriteLine($"{pos.Ticker}: qty={pos.Quantity}, pnl={pos.UnrealizedPnl}");
}

Subscribe to portfolio updates (WebSocket)

await bcs.Portfolio.SubscribeAsync(
    onUpdate: portfolio =>
    {
        Console.WriteLine($"Portfolio updated: {portfolio.TotalValue}");
        return Task.CompletedTask;
    },
    onError: ex => Console.WriteLine($"Error: {ex.Message}"),
    ct: cancellationToken
);

Market Data — bcs.MarketData

Get historical candles

var candles = await bcs.MarketData.GetCandlesAsync(new CandlesRequest
{
    Ticker    = "SBER",
    Timeframe = Timeframe.H1,
    From      = DateTime.UtcNow.AddDays(-7),
    To        = DateTime.UtcNow
});

foreach (var c in candles)
    Console.WriteLine($"{c.Time}: O={c.Open} H={c.High} L={c.Low} C={c.Close} V={c.Volume}");

Available timeframes: M1 M5 M15 M30 H1 H4 D W MN

Subscribe to quotes (WebSocket)

await bcs.MarketData.SubscribeQuotesAsync(
    tickers: ["SBER", "GAZP", "LKOH"],
    onQuote: quote =>
    {
        Console.WriteLine($"{quote.Ticker}: bid={quote.Bid} ask={quote.Ask} last={quote.Last}");
        return Task.CompletedTask;
    },
    ct: cancellationToken
);

Subscribe to order book (WebSocket)

await bcs.MarketData.SubscribeOrderBookAsync(
    ticker: "SBER",
    depth: 10,
    onOrderBook: book =>
    {
        Console.WriteLine($"Best bid: {book.Bids.First().Price}");
        return Task.CompletedTask;
    },
    ct: cancellationToken
);

Subscribe to candles (WebSocket)

await bcs.MarketData.SubscribeCandlesAsync(
    ticker: "SBER",
    timeframe: Timeframe.M1,
    onCandle: candle =>
    {
        Console.WriteLine($"New candle: {candle.Close}");
        return Task.CompletedTask;
    },
    ct: cancellationToken
);

Subscribe to deals (WebSocket)

await bcs.MarketData.SubscribeDealsAsync(
    tickers: ["SBER", "GAZP"],
    onDeal: deal =>
    {
        Console.WriteLine($"{deal.Ticker}: {deal.Price} x {deal.Quantity}");
        return Task.CompletedTask;
    },
    ct: cancellationToken
);

Limits — bcs.Limits

var limits = await bcs.Limits.GetAsync();

Console.WriteLine($"Buying power:   {limits.BuyingPower} {limits.Currency}");
Console.WriteLine($"Available cash: {limits.AvailableCash}");
Console.WriteLine($"Blocked:        {limits.BlockedAmount}");

Error handling

All exceptions inherit from BcsException.

Exception When
BcsAuthException Authentication / token refresh failed
BcsApiException API returned an error HTTP status
BcsRateLimitException Rate limit exceeded (429)
BcsNetworkException Network / timeout error
BcsWebSocketException WebSocket connection error
try
{
    var order = await bcs.Orders.PlaceLimitAsync(request);
}
catch (BcsRateLimitException)
{
    // slow down
}
catch (BcsApiException ex)
{
    Console.WriteLine($"API error {ex.StatusCode}: {ex.Message} (requestId={ex.RequestId})");
}
catch (BcsAuthException ex)
{
    Console.WriteLine($"Auth failed: {ex.Message}");
}

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.5.2.2 125 5/2/2026 2026.5.2.2 is deprecated because it has critical bugs.
2026.5.2 95 5/2/2026