Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

369 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

TaLibStandard banner

TaLibStandard

Sparkline

A modern and robust C# Technical Analysis library based on the original open-source TA-Lib by Mario Fortier, using Generic Math and supporting Double, Float, and Decimal data types.


phmatray - TaLibStandard License: GPL-3.0-or-later stars - TaLibStandard forks - TaLibStandard

GitHub tag issues - TaLibStandard GitHub pull requests GitHub contributors GitHub last commit CI/CD codecov Codacy Badge


πŸ“ Table of Contents

πŸ“š Introduction

TaLibStandard is a modern interpretation of the widely used TA-Lib, reimagined in C# 14. It is designed to be reliable, efficient, and user-friendly for developers performing financial market analysis. The addition of .NET's Generic Math feature allows for a richer, more flexible library that can handle a variety of number types.

🎯 Goal

The primary objective of TaLibStandard is to provide a comprehensive, feature-rich and accessible library for conducting technical analysis on financial market data.

🏁 Getting started

To get started with TaLibStandard, read the getting started guide β€” it covers installation, your first indicator, and the output-alignment rule that everything else depends on. Then clone the repository and explore the runnable projects in the samples directory (see Samples). For a comprehensive overview of the library's capabilities, refer to the indicator catalog or the flat list of available functions.

πŸ“Œ Features

  • Support for Double, Float, and Decimal data types, with the help of .NET's Generic Math
  • With some basic tests (coverage: >= 80%)
  • .NET Exception handling (BREAKING CHANGE)

Roadmap (next features)

  • Comprehensive API documentation that is easy to understand
  • High-Level API for common use cases
  • Support for more data types
  • Support for more functions
  • More tests
  • More examples β€” see Samples
  • Add a Benchmark project β€” see Benchmarks
  • Create a gRPC server to expose the library as a service

πŸ“„ Documentation

TaLibStandard provides a COMPLETE DOCUMENTATION of the library.

All summaries are written in English. If you want to help us translate the documentation, please open an issue to discuss it.

Note: The documentation is generated using Doraku/DefaultDocumentation tool. It is generated automatically when the project is built.

πŸ“– Guides

Hand-written guides live in docs/guides, and every public entry point is catalogued in docs/indicators.

Guide What it covers
🏁 Getting started Installation, your first indicator, and the three things that trip everyone up: RetCode, BegIdx/NBElement output alignment, and the double / float / decimal story. Start here.
πŸ“‹ Indicator catalog Every TAMath and TACandle entry point, grouped by category, with signatures, defaults, outputs and links to the generated API pages.
πŸ“‘ Real-time streaming Ticks β†’ bars β†’ indicators over SignalR and raw WebSocket: architecture, message contracts, warm-up semantics and production notes.
πŸ“‰ Backtesting The engine model, the structurally enforced no-look-ahead guarantee, the cost model, every metric with its formula, and how to write your own strategy.
πŸ“ˆ TradingView integration Pine Script ta.* β†’ TAMath mapping, parity caveats, UDF datafeed and Lightweight Charts wiring, alert-webhook security.
⚑ Benchmarks What the benchmark suite measures, how to run it, how to read BenchmarkDotNet output, and the measured results.

⚠️ Three indicators currently return wrong numbers, quietly and with RetCode.Success: Atr diverges to +∞, the EMA family (Ema, Macd, Dema, Tema, T3, Apo, Ppo, Trix, …) seeds itself low, and Rsi returns NaN for a perfectly flat series. See Known library defects before building on any of them; the indicator catalog marks every affected entry point.

πŸ“₯ Installation

πŸ“‹ Prerequisites

  • .NET 10.0 (supported versions: 10.x)
  • A C# IDE (Visual Studio, JetBrains Rider, etc.)
  • A C# compiler (dotnet CLI, etc.)

πŸš€ We use the latest C# features

This library targets .NET 10.0 and uses the latest C# features. It is written in C# 14.0 and uses the new init properties, record types, switch expressions, using declarations and more.

I invite you to read the C# 14.0 documentation to learn more about these features.

πŸ“¦ NuGet Packages

Package Name NuGet Version Badge NuGet Downloads Badge Package Explorer
Atypical.TechnicalAnalysis.Candles NuGet NuGet Explore
Atypical.TechnicalAnalysis.Functions NuGet NuGet Explore
Atypical.TechnicalAnalysis.Core NuGet NuGet Explore

This table is automatically updated regularly the latest developments and releases in the Atypical Technical Analysis suite.

πŸ§ͺ Tests Specifications

  • Target framework : .NET 10
  • Language version : C# 14
  • xUnit and Shouldly

πŸ’Ύ Installation

To install TaLibStandard, you can use the NuGet package manager. Run the following command in your terminal:

dotnet add package Atypical.TechnicalAnalysis.Candles
dotnet add package Atypical.TechnicalAnalysis.Functions

πŸ§‘β€πŸ’» Usage

TaLibStandard exposes two APIs on the same indicator: a low-level TAFunc API that mirrors the original TA-Lib C signature (ref/in parameters, pre-allocated output arrays), and a higher-level TAMath API that wraps it and returns a strongly-typed result record.

High-level API (TAMath)

using TechnicalAnalysis.Functions;

double[] closingPrices = [.. /* your OHLCV data */];

// RsiResult exposes RetCode, BegIdx, NBElement and the Real[] output array
RsiResult rsi = TAMath.Rsi(0, closingPrices.Length - 1, closingPrices, timePeriod: 14);

if (rsi.RetCode == RetCode.Success)
{
    double latestRsi = rsi.Real[^1]; // most recent RSI value
}

Low-level API (TAFunc) β€” original TA-Lib signature

using TechnicalAnalysis.Functions;

double[] closes = [.. data.Select(d => (double)d.Close)];
double[] outReal = new double[closes.Length];
int outBegIdx = 0;
int outNbElement = 0;
int period = 14;

RetCode result = TAFunc.Rsi(
    0, closes.Length - 1,
    in closes,
    in period,
    ref outBegIdx,
    ref outNbElement,
    ref outReal);

double[] rsiValues = outReal.Take(outNbElement).ToArray();

Candlestick pattern recognition

using TechnicalAnalysis.Candles;

// Detects the "Short Line" candle pattern over the given OHLC arrays
CandleIndicatorResult pattern = TACandle.CdlShortLine(
    0, closes.Length - 1, opens, highs, lows, closes);

Both TAFunc and TAMath overloads are generic-math friendly and accept double[] or float[] inputs. See the full function list for every available indicator and candlestick pattern, and the Demo.BlazorWasm project for a working end-to-end example that charts these indicators.

One rule to internalise before anything else. TAMath fills its output array from index 0, not from the input index it corresponds to. Output element k describes input index BegIdx + k, for k in [0, NBElement); everything from NBElement onwards is a meaningless zero. Getting this wrong shifts every signal in time, silently. The getting started guide works through it with a hand-checkable example.

🧩 Samples

Runnable projects, all completely offline β€” no market data provider, no API key, no network calls.

Sample Run it Guide
Real-time streaming
ASP.NET Core server: synthetic tick feed β†’ OHLCV bars β†’ seven indicators (eleven series) per closed bar, published over a SignalR hub and a raw WebSocket, plus a zero-dependency browser dashboard.
dotnet run --project samples/TechnicalAnalysis.Samples.RealTime -c Release
then open http://localhost:5199
πŸ“‘ Real-time streaming
Real-time console client
SignalR client for the server above; exercises both the group-push and the server-streaming paths.
dotnet run --project samples/TechnicalAnalysis.Samples.RealTime.Client -c Release -- --symbol GLOBEX πŸ“‘ Real-time streaming
Backtesting
Bar-by-bar engine with a structurally enforced no-look-ahead guarantee, a commission/slippage cost model, a full metrics suite and five strategies compared side by side.
dotnet run --project samples/TechnicalAnalysis.Samples.Backtesting -c Release πŸ“‰ Backtesting
Blazor WebAssembly demo
Interactive browser demo charting the indicators.
dotnet run --project Demo.BlazorWasm β€”

⚑ Benchmarks

benchmarks/TechnicalAnalysis.Benchmarks is a BenchmarkDotNet suite of 119 benchmarks over deterministic synthetic market data at three series lengths (1 000 / 10 000 / 100 000), all with [MemoryDiagnoser]. Every indicator in the overlap, momentum and volatility/volume suites is measured twice β€” once through the allocation-free TAFunc API and once through the ergonomic TAMath API β€” so the cost of convenience is a number rather than a guess. Candlestick patterns are measured on double, float and decimal to price the generic-math design.

# see what is there, without running anything
dotnet run --project benchmarks/TechnicalAnalysis.Benchmarks -c Release -- --list flat

# prove every benchmark computes something valid (fast; not a measurement)
dotnet run --project benchmarks/TechnicalAnalysis.Benchmarks -c Release -- --selfcheck

# one suite
dotnet run --project benchmarks/TechnicalAnalysis.Benchmarks -c Release -- --anyCategories Momentum

An optional sixth suite compares the managed port head to head against the original TA-Lib C library through P/Invoke, with an equivalence assertion that runs before anything is timed. It is enabled automatically when the native library is found and silently skipped when it is not, so the suite has no native dependency.

See the benchmarks guide for the full switch reference, the native install instructions per platform, how to read every output column, the measured results and the methodology caveats.

πŸ“Š Code Quality

We strive for the highest code quality in TaLibStandard, leveraging Codacyβ€”an automated code analysis/quality tool. Codacy provides static analysis, cyclomatic complexity measures, duplication identification, and code unit test coverage changes for every commit and pull request.

View our Codacy metrics here.

❓ Issues and Feature Requests

For reporting bugs or suggesting new features, kindly submit these as an issue to the TaLibStandard Repository. We value your contributions, but before submitting an issue, please ensure it is not a duplicate of an existing one.

Tech Stack

  • .NET 10
  • Microsoft.AspNetCore.Components.WebAssembly
  • Microsoft.AspNetCore.Components.WebAssembly.DevServer
  • Microsoft.DotNet.HotReload.WebAssembly.Browser
  • MudBlazor
  • PublishSPAforGitHubPages.Build
  • DefaultDocumentation

🀝 Contributing

We welcome contributions from the community! If you'd like to contribute to TaLibStandard, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

🌟 Contributors

Contributors

βœ‰οΈ Contact

You can contact us by opening an issue on this repository.

πŸ“ Release notes

v3.0.0 (January 2026) - .NET 10 LTS Release πŸŽ‰

Breaking Changes:

  • Upgraded to .NET 10 LTS - Framework support extended until November 2028
  • C# 14 Language Features - Utilizing the latest C# capabilities
  • Updated Dependencies - All major packages updated to .NET 10 compatible versions
  • Minimum .NET Version: Now requires .NET 10.0 SDK

Major Improvements:

  • Code Quality: Extensive refactoring eliminated ~1,200 lines of duplicated code
  • Validation Consolidation: Unified validation patterns across 99 indicators
  • Result Classes: Consolidated result types with inheritance hierarchy
  • Mathematical Functions: Template-based approach for 60+ math indicators
  • Lookback Validation: Standardized lookback calculations for 87 indicators
  • Code Cleanup: Removed unused code and consolidated common patterns

Performance:

  • All 898 tests passing
  • No performance degradation
  • Maintained backward compatibility in algorithms

Documentation:

  • Auto-generated API documentation updated
  • All function and candle pattern docs regenerated

For migration guide from v2.x to v3.0, see Migration from v2 to v3.

Previous Releases

  • v2.0.0 (June 2025) - Major release with .NET Exception handling
  • v1.0.0 (June 2025) - First stable release
  • v0.4.0 (June 2025) - Generic Math support
  • v0.3.1 (June 2025) - Bug fixes and improvements
  • v0.3.0 (June 2025) - Enhanced functionality
  • v0.2.0 (June 2025) - Additional indicators
  • v0.1.0 (November 2023) - Initial release

Migration from v2 to v3

Prerequisites

  • Update to .NET 10 SDK: Download from dotnet.microsoft.com
  • Update project target framework:
    <TargetFramework>net10.0</TargetFramework>

Breaking Changes

  1. Framework Requirement

    • Minimum version: .NET 10.0
    • Projects targeting .NET 9 or earlier must upgrade
  2. Package Dependencies

    • If you reference TaLibStandard packages, ensure your project can target .NET 10.0
    • Update any conflicting package versions

API Compatibility

  • No API breaking changes - All public method signatures remain the same
  • No behavioral changes - All algorithms produce identical results
  • Code that worked with v2.x will work with v3.0 after framework upgrade

Testing Your Migration

// No code changes needed - same API as v2.x
var rsiResult = TAFunc.Rsi(0, closePrices.Length - 1, closePrices, 14,
    ref outBegIdx, ref outNBElement, ref rsiValues);

πŸ“œ License

GNU General Public License v3.0 or later.

About

Modern C# port of TA-Lib: 200+ technical analysis indicators supporting Double, Float, and Decimal via Generic Math

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages