GoFlux is a modern technical analysis library for Go, forked from techan by sdcoffey. This project aims to revitalize and expand the library with modern Go best practices, comprehensive testing, and additional technical analysis indicators.
- 35+ technical analysis indicators (trend, momentum, volume, moving averages)
- Performance metrics (Sharpe, Sortino, Calmar, CAGR, drawdown, and more)
- Candlestick pattern detection (20+ patterns)
- Rule-based strategy engine (AND/OR/NOT, trailing stops, time-based exits)
- Backtesting engine with trade & equity analytics
- Time series utilities (resampling, Heikin Ashi, Renko)
$ go get github.com/irfndi/goflux@latestpackage main
import (
"fmt"
"log"
"strconv"
"time"
"github.com/irfndi/goflux/pkg"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
series := goflux.NewTimeSeries()
// fetch this from your preferred exchange
dataset := [][]string{
// Timestamp, Open, Close, High, Low, volume
{"1234567", "1", "2", "3", "5", "6"},
}
for _, datum := range dataset {
start, _ := strconv.ParseInt(datum[0], 10, 64)
period := goflux.NewTimePeriod(time.Unix(start, 0), time.Hour*24)
candle := goflux.NewCandle(period)
open, err := goflux.NewDecimalFromStringWithError(datum[1])
if err != nil {
return err
}
closePrice, err := goflux.NewDecimalFromStringWithError(datum[2])
if err != nil {
return err
}
maxPrice, err := goflux.NewDecimalFromStringWithError(datum[3])
if err != nil {
return err
}
minPrice, err := goflux.NewDecimalFromStringWithError(datum[4])
if err != nil {
return err
}
volume, err := goflux.NewDecimalFromStringWithError(datum[5])
if err != nil {
return err
}
candle.OpenPrice = open
candle.ClosePrice = closePrice
candle.MaxPrice = maxPrice
candle.MinPrice = minPrice
candle.Volume = volume
series.AddCandle(candle)
}
closePrices := goflux.NewClosePriceIndicator(series)
movingAverage := goflux.NewEMAIndicator(closePrices, 10)
fmt.Println(movingAverage.Calculate(0).FormattedString(2))
return nil
}indicator := goflux.NewClosePriceIndicator(series)
// record trades on this object
record := goflux.NewTradingRecord()
entryConstant := goflux.NewConstantIndicator(30)
exitConstant := goflux.NewConstantIndicator(10)
// Is satisfied when the price ema moves above 30 and the current position is new
entryRule := goflux.And(
goflux.NewCrossUpIndicatorRule(entryConstant, indicator),
goflux.PositionNewRule{})
// Is satisfied when the price ema moves below 10 and the current position is open
exitRule := goflux.And(
goflux.NewCrossDownIndicatorRule(indicator, exitConstant),
goflux.PositionOpenRule{})
strategy := goflux.RuleStrategy{
UnstablePeriod: 10, // Index at or below which ShouldEnter and ShouldExit return false
EntryRule: entryRule,
ExitRule: exitRule,
}
strategy.ShouldEnter(0, record) // returns falseThis project uses Beads for issue tracking - a modern, AI-native tool designed for live directly in your codebase alongside your code.
Learn more: github.com/steveyegge/beads
# Find available work
bd ready
# View issue details
bd show <issue-id>
# Claim work
bd update <issue-id> --status in_progress
# Complete work
bd close <issue-id>
# Sync with git
bd syncThis project uses Protected Branch Mode for team collaboration:
- Issues are automatically committed to
beads-syncbranch mainbranch stays protected- Team members review and merge metadata via PR
- See
CONTRIBUTING.mdfor setup instructions
# Install Beads
curl -sSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash
# Initialize in this repo (already configured)
bd readyRun bd ready or bd list to see current planned improvements and tasks in progress.
Past work includes:
- Modern project structure
- Additional indicators and utilities
- Expanded trading and risk-management rules
- Comprehensive testing suite
- Improved documentation
- CI/CD pipeline with GitHub Actions
GoFlux maintains backward compatibility with the original techan API. Simply update your imports:
// Old
import "github.com/sdcoffey/techan"
// New
import "github.com/irfndi/goflux/pkg"The package name is goflux, so you can use it directly:
import "github.com/irfndi/goflux/pkg"
// Usage
series := goflux.NewTimeSeries()Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute.
To contribute:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Submit a pull request
GoFlux builds on the pioneering work of the technical analysis community:
- techan (sdcoffey) – the original Go technical analysis library and direct foundation of this project.
- ta4j – a mature Java TA framework whose strategy composition and indicator design patterns heavily influenced GoFlux's architecture.
- TA‑Lib – the long-standing C/C++ technical analysis library (200+ indicators and candlestick patterns) that serves as a reference standard for indicator behavior and naming.
- Pandas TA (Python) – for ideas around indicator catalogs, composition patterns, and declarative strategy definitions.
- YATA (Rust) – for performance-oriented designs and trait-based indicator patterns.
- Backtrader – the Python backtesting framework that inspired GoFlux's analyzer and observer patterns.
- VectorBT – for vectorized operations and portfolio simulation approaches.
GoFlux aims to bring these proven ideas into a modern, idiomatic Go library focused on concurrent, cloud-native trading systems.
GoFlux is released under the MIT license. See LICENSE for details.