Quant.Infra.Net
1.5.0
See the version list below for details.
dotnet add package Quant.Infra.Net --version 1.5.0
NuGet\Install-Package Quant.Infra.Net -Version 1.5.0
<PackageReference Include="Quant.Infra.Net" Version="1.5.0" />
<PackageVersion Include="Quant.Infra.Net" Version="1.5.0" />
<PackageReference Include="Quant.Infra.Net" />
paket add Quant.Infra.Net --version 1.5.0
#r "nuget: Quant.Infra.Net, 1.5.0"
#:package Quant.Infra.Net@1.5.0
#addin nuget:?package=Quant.Infra.Net&version=1.5.0
#tool nuget:?package=Quant.Infra.Net&version=1.5.0
Quant.Infra.Net
Quant.Infra.Net is a .NET quantitative trading infrastructure library — data acquisition, statistical analysis, broker integration, portfolio analytics, and notifications in one package.
What Is This?
Quant.Infra.Net provides a unified C# API that abstracts away the complexity of connecting to multiple financial data sources, brokers, and notification channels. Instead of writing separate integrations for each platform, you get consistent interfaces and ready-to-use implementations.
Architecture Overview
| Module | Responsibility | Key Interfaces / Services |
|---|---|---|
| SourceData | Multi-source market data ingestion | ITraditionalFinanceSourceDataService, ICryptoSourceDataService — Yahoo Finance (via yfinance/pythonnet), Binance spot/futures klines, Alpaca US equity, CSV/MySQL/MongoDB readers |
| Broker | Unified broker execution layer | IBrokerService, IUSEquityBrokerService — Binance Futures (spot/order/liquidate with Testnet/Paper/Live switching), Alpaca US Equity, Charles Schwab (quotes/options/orders/positions), Interactive Brokers via InterReact (TWS/Gateway) |
| Analysis | Quantitative/statistical tooling | IAnalysisService — ADF stationarity test, OLS regression, Z-Score, Shapiro-Wilk normality test, pair-trading spread calculation, rolling statistics |
| Portfolio | Position tracking and performance | PortfolioSnapshot, StrategyPerformanceAnalyzer — CAGR, Sharpe ratio, Calmar ratio, max drawdown, equity curve charting (ScottPlot) |
| Notification | Strategy alert dispatch | IDingtalkService, IWeChatService, IEmailService — DingTalk bot, WeChat Work webhook, personal/commercial bulk email |
| Order | Order modeling and lifecycle | Unified order models across brokers, order state machine, fill tracking |
| Shared | Cross-cutting utilities | IntervalTrigger, RollingWindow<T>, resolution conversion helpers, extension methods, DataFrame I/O (Deedle) |
Why Use This Library?
Pain Points in Quant Development
When building quantitative trading systems, most developers encounter these challenges:
| Challenge | What Happens Without This Library | How Quant.Infra.Net Solves It |
|---|---|---|
| Data source fragmentation | Each API (Yahoo, Binance, Alpaca, Schwab) returns data in its own format — you write converters for every provider | Unified ITraditionalFinanceSourceDataService and ICryptoSourceDataService with standardized OHLCV models; new sources are just another implementation of the same interface |
| Broker boilerplate | Connecting to Binance futures requires handling API keys, rate limits, WebSocket reconnects; Schwab requires OAuth flow; IB needs TWS/Gateway IPC | Single IBrokerService abstraction — swap brokers by changing configuration, not code |
| Reinventing analysis math | Implementing ADF tests, regressions, Z-Score normalization from scratch every time | IAnalysisService provides 10+ statistical methods ready to call |
| No alerting pipeline | Strategies run silently — you only discover results after hours of waiting | Built-in DingTalk, WeChat Work, and email notifications fire on strategy events |
| Performance tracking is manual | Computing CAGR, Sharpe, max drawdown requires writing formulas that may contain bugs | StrategyPerformanceAnalyzer implements standard metrics with unit tests; ScottPlot integration for charting |
Who Is This For?
- Quantitative researchers and traders building strategies on the .NET platform
- Developers who want a single NuGet package to handle data, execution, and alerting
- Teams that need consistent broker abstractions across Binance, Alpaca, Schwab, and Interactive Brokers
- Anyone tired of writing the same integration code for every new project
Quick Start
Step 1: Install via NuGet
# Create a project (or use an existing one)
dotnet new console -n MyQuantApp
cd MyQuantApp
# Add the library
dotnet add package Quant.Infra.Net --version 1.5.0
# Required for Python-based data sources (Yahoo Finance via yfinance)
dotnet add package pythonnet
# Recommended for dependency injection
dotnet add package Microsoft.Extensions.DependencyInjection
Step 2: Use in Code
using Quant.Infra.Net.SourceData.Service;
using Quant.Infra.Net.Analysis.Service;
using Quant.Infra.Net.Broker.Service;
using Quant.Infra.Net.Notification.Service;
using Microsoft.Extensions.DependencyInjection;
// Register services via DI
var services = new ServiceCollection();
services.AddQuantInfraNet(); // registers all modules
// --- Data: Fetch OHLCV from multiple sources ---
var dataService = services.BuildServiceProvider()
.GetService<ITraditionalFinanceService>();
var bars = await dataService.GetOhlcvListAsync("AAPL", DateTime.Now.AddDays(-30), DateTime.Now);
// --- Analysis: Pair-trading correlation & ADF test ---
var analysis = services.BuildServiceProvider()
.GetService<IAnalysisService>();
var correlation = await analysis.CalculateCorrelationAsync(aaplPrices, msftPrices);
var isStationary = await analysis.TestStationarityAsync(spreadSeries);
// --- Broker: Place orders across platforms ---
var broker = services.BuildServiceProvider()
.GetService<IBrokerService>();
var orderResult = await broker.PlaceOrderAsync(new OrderRequest { Symbol = "AAPL", Side = Side.Buy, Quantity = 10 });
// --- Portfolio: Performance analytics ---
var portfolio = services.BuildServiceProvider()
.GetService<IPortfolioSnapshotService>();
var snapshot = await portfolio.GetSnapshotAsync(accountId);
// --- Notification: Strategy alerts ---
var dingTalk = services.BuildServiceProvider()
.GetService<IDingtalkService>();
await dingTalk.SendStrategyAlert("Mean reversion triggered for AAPL/MSFT spread");
Step 3: Configuration
// appsettings.json
{
"BinanceApi": {
"ApiKey": "your-api-key",
"SecretKey": "your-secret-key",
"Environment": "testnet" // testnet | paper | live
},
"YahooFinance": {
"PythonPath": "C:\\Users\\you\\Anaconda3\\python.exe"
}
}
Version History
| Version | Date | Description |
|---|---|---|
| 1.5.0 (current) | 2026-05-28 | Interactive Brokers (InterReact) full integration — order, market data, account management via TWS/Gateway; Charles Schwab full broker service — quotes, option chains, orders, positions; license changed to MIT; enhanced analysis service unit tests |
| 1.4.0 | 2024-05-16 | Updated API integrations to handle recent broker changes, added comprehensive documentation |
| 1.3.0 | 2024-04-05 | Enhanced notification services with email templates and improved error handling |
| 1.2.0 | 2024-03-10 | Improved Python integration stability and added new statistical analysis methods |
| 1.1.0 | 2024-02-20 | Added support for Schwab broker integration and enhanced portfolio performance metrics |
| 1.0.0 | 2024-01-15 | Initial release with core features: data acquisition, statistical analysis, trade execution, and notifications |
Code Standards
This project follows the coding standards defined in docs/Code_Standards.md:
- Bilingual (Chinese + English) XML documentation on all public members
- SOLID principles for design
- Parameter validation on all entry points
- UTC time handling and consistent enum management
Notes on Testing
⚠️ Binance Unit Tests: The Binance integration tests require a Singapore IP address to pass. They will fail when run from China or the United States due to regional access restrictions on Binance API endpoints. Run
dotnet testexcluding Binance tests for other modules:dotnet test --filter "FullyQualifiedName!~Binance"
Ecosystem
| Project | Description |
|---|---|
| Quant.Infra.Net (this repo) | Core quantitative trading library — data, analysis, execution, notifications |
| Quant.Infra.Net.Pro | Production-grade Charles Schwab web application with unattended OAuth token management and full dashboard |
License
MIT — © 2024–2026 Rong (Rex) Fan
Disclaimer: See DISCLAIMER.md for full disclaimer and limitation of liability / 详见 免责声明 了解完整免责条款与责任限制。
| Product | Versions 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. |
-
net8.0
- Accord.Statistics (>= 3.8.0)
- Alpaca.Markets (>= 7.2.0)
- Binance.Net (>= 11.9.0)
- CryptoExchange.Net (>= 9.10.0)
- CsvHelper (>= 33.0.1)
- Deedle (>= 3.0.0)
- HtmlAgilityPack (>= 1.11.67)
- MailKit (>= 4.14.1)
- MathNet.Numerics (>= 5.0.0)
- Microsoft.Data.Analysis (>= 0.21.1)
- Microsoft.Extensions.Configuration (>= 9.0.10)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.10)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 9.0.10)
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
- Microsoft.Extensions.Configuration.UserSecrets (>= 6.0.1)
- Microsoft.Extensions.DependencyInjection (>= 9.0.10)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Logging (>= 9.0.10)
- MySql.Data (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
- NodaTime (>= 3.1.11)
- Polly (>= 8.5.0)
- pythonnet (>= 3.0.5)
- RestSharp (>= 112.1.0)
- Riok.Mapperly (>= 4.1.1)
- RxSockets (>= 5.0.4)
- ScottPlot (>= 5.0.39)
- Serilog (>= 4.3.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.File (>= 6.0.0)
- Stats.NET (>= 1.0.0)
- Stringification (>= 3.2.5)
- System.Linq (>= 4.3.0)
- System.Reactive (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.5.0 - Interactive Brokers (InterReact) full integration; Charles Schwab full broker service; MIT license; enhanced analysis service unit tests