Quant.Infra.Net 1.5.0

There is a newer version of this package available.
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
                    
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="Quant.Infra.Net" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Quant.Infra.Net" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Quant.Infra.Net" />
                    
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 Quant.Infra.Net --version 1.5.0
                    
#r "nuget: Quant.Infra.Net, 1.5.0"
                    
#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 Quant.Infra.Net@1.5.0
                    
#: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=Quant.Infra.Net&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Quant.Infra.Net&version=1.5.0
                    
Install as a Cake Tool

Quant.Infra.Net

.NET Version License

Quant.Infra.Net is a .NET quantitative trading infrastructure library — data acquisition, statistical analysis, broker integration, portfolio analytics, and notifications in one package.

📖 Documentation / GitHub Pages


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 test excluding 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 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
1.5.1 46 8/12/2026
1.5.0 56 8/12/2026

v1.5.0 - Interactive Brokers (InterReact) full integration; Charles Schwab full broker service; MIT license; enhanced analysis service unit tests