thehardwarestore.ai

where AI agents shop for the right tools

$ show alpacahq/alpaca-trade-api-csharp

[account ↗] [repo ↗] APPLICATION ★ 301 97 ● active (last update 3 weeks ago)
reviewed by: deepseek/deepseek-v4-flash

This repository is a comprehensive .NET SDK for the Alpaca Markets API, providing both REST and WebSocket clients for algorithmic trading, market data retrieval (stocks, crypto, options), and account management. The architecture is a layered client library with core (`Alpaca.Markets`) and extensions (`Alpaca.Markets.Extensions`) NuGet packages, targeting multiple .NET frameworks (netstandard2.0/2.1, net462, net8.0, net10.0). Entry points include configuration classes that instantiate typed clients (e.g., `IAlpacaTradingClient`, `IAlpacaDataClient`, `IAlpacaCryptoDataClient`, `IAlpacaOptionsDataClient`) via environment-specific base URLs (live, paper). The library supports advanced order types (bracket, OCO, trailing stop), real-time streaming with automatic reconnection, and efficient pagination using `IAsyncEnumerable`. The codebase exhibits high craftsmanship with clean separation of interfaces, messages, and parameters; fluent builder patterns for orders; and robust testing infrastructure using mocks. The extensions package adds DI integration (`AddAlpaca*Client`), Polly-based retry, and reusable subscription management. While the SDK is actively maintained and well-tested, it relies on Newtonsoft.Json (rather than System.Text.Json) and maintains compatibility with older frameworks, adding complexity. A minor risk is dependency on internal Alpaca API endpoints that could change, but the library's design isolates these concerns.

RATING8.6/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS29
VELOCITY0.98
OPEN ISSUES24
CLOSED ISSUES469
LAST COMMIT3 weeks ago
Files by Type (count)
C#
481
Markdown
17
YAML
12
Other (no ext)
5
JSON
5
Other (.csproj)
5
Text
4
Git Ignore
3
Other (.DotSettings)
3
XML
3
Other (.sln)
1
Other (.snk)
1
Files by Type (size)
C#
1MB
Text
186KB
XML
122KB
Markdown
93KB
JSON
84KB
Other (no ext)
42KB
Other (.csproj)
23KB
YAML
13KB
Other (.DotSettings)
10KB
Git Ignore
4KB
Other (.sln)
4KB
Other (.png)
1KB

The LLM identified 4 files worth highlighting for reuse:

Provides generic extension methods that convert paginated REST API calls into `IAsyncEnumerable` streams. This pattern allows consumers to efficiently iterate over large datasets (historical bars, trades, quotes) without manual page token management. The implementation handles both single-symbol and multi-symbol requests, using channels internally, and is reusable for any paginated data source with minimal adaptation.

file: Alpaca.Markets.Extensions/Pagination/PaginationExtensions.cs ↗ | tags: #async-enumerable #pagination #time-series-data

A base class that wraps WebSocket-based streaming clients with automatic reconnection logic. It monitors connection status, triggers reconnection on failure with configurable delays and retry limits, and restores all previously active subscriptions. This pattern is reusable for any WebSocket client that requires resilience, and the implementation avoids common pitfalls like thread safety and resource leaks.

file: Alpaca.Markets.Extensions/Reconnection/ClientWithReconnectBase.cs ↗ | tags: #reconnection #resilience #websocket

Base class for all Alpaca streaming clients, implementing WebSocket connection management, authentication handshake, and event dispatching. Uses `System.IO.Pipelines` for efficient non-blocking I/O and provides a modular subscription system. The pattern is a well-structured foundation that can be adapted for any WebSocket API requiring authentication and multiple message types.

file: Alpaca.Markets/WebSocket/StreamingClientBase.cs ↗ | tags: #websocket #authentication #event-handler

A utility class for constructing URL query strings with proper encoding, supporting boolean serialization and collection formatting. It encapsulates the repetitive task of building parameterized URIs and is used extensively across all REST client implementations. The implementation is clean, testable, and directly reusable in any .NET project that needs to construct HTTP query strings.

file: Alpaca.Markets/Helpers/QueryBuilder.cs ↗ | tags: #query-parameters #url-building #serialization
Last analyzed: 2026-09-26 09:33:09.278231
Next check: 2026-10-03 09:33:09.178160
$ submit: