TzuTrader - A Simplified Trading Bot Library in Nim
TzuTrader is a high-performance trading bot library designed with simplicity and ease of use in mind. It provides a flat architecture with minimal nesting, making it easy to get started with algorithmic trading.
Features
- Pure Nim Implementation: No C++ dependencies
- Flat Architecture: Simple imports, intuitive API
- High Performance: Compiled speed for real-time trading
- Yahoo Finance Integration: Built-in data provider
- Backtesting: Test strategies against historical data
- Technical Indicators: Complete set reimplemented in pure Nim
- Pre-built Strategies: RSI, Moving Average Crossover, MACD, and more
Quick Start
import tzutrader # Create a strategy let strategy = newRSIStrategy(period=14, oversold=30, overbought=70) # Run a backtest let report = quickBacktest( symbols = @["AAPL"], strategy = strategy, startTime = parseTime("2023-01-01"), endTime = parseTime("2024-01-01"), initialCash = 10000.0 ) # View results echo "Total Return: ", report.totalReturn, "%"
Modules
- core: Core types and data structures
- data: Data streaming and Yahoo Finance integration
- indicators: Technical indicators (pure Nim)
- strategy: Strategy framework and pre-built strategies
- portfolio: Portfolio management
- trader: Trading engine and backtesting
- scanner: Multi-symbol scanning and ranking
- exports: Export to JSON/CSV formats
Consts
TzuTraderAuthor = "tzutrader contributors"
TzuTraderLicense = "MIT"
TzuTraderVersion = "0.7.0"
Exports
-
Position, change, isValid, fromJson, Signal, StrategyConfig, toJson, newStrategyConfig, DataError, newSignal, toJson, TzuTraderError, toJson, fromJson, OHLCV, $, changePercent, StrategyError, $, toJson, trueRange, typicalPrice, PortfolioError, newTransaction, Transaction, $, writeCSV, CSVDataStream, remaining, hasNext, getQuote, toSeconds, fetchHistoryYfnim, $, $, addToCache, latest, newDataStream, fetchQuoteYfnim, getQuotes, Int1d, Int1wk, generateMockOHLCV, reset, generateMockQuote, $, next, isCached, fetch, Interval, items, DataStream, peek, Int5m, stream, newCSVDataStream, fetch, Int1mo, len, $, getCached, Int1m, clearCache, Int30m, Quote, Int1h, Int15m, maxHistory, readCSV, fetchMultiple, roc, ema, IndicatorBase, isFull, wma, current, EMA, addValue, update, nanToZero, sma, newOBV, isNaN, newEMA, bollinger, OBV, current, newRSI, update, current, obv, rsi, newATR, update, current, newMACD, macd, MACD, stddev, update, ATR, update, RSI, atr, update, newSMA, current, SMA, roi, current, MACDStrategy, newMACDStrategy, reset, analyze, onBar, RSIStrategy, analyze, BollingerStrategy, newRSIStrategy, analyze, name, onBar, analyze, analyze, newCrossoverStrategy, reset, onBar, Strategy, reset, reset, CrossoverStrategy, reset, onBar, onBar, newBollingerStrategy, realizedPnL, PerformanceMetrics, buy, Short, totalPnL, closePosition, marketValue, marketValue, updatePrices, calculatePerformance, updatePrice, PositionInfo, unrealizedPnL, getPosition, Flat, $, Portfolio, newPortfolio, totalPnL, $, Long, PositionSide, sell, equity, hasPosition, $, calculateCommission, $, quickBacktest, newBacktester, TradeLog, formatCompact, run, quickBacktestCSV, BacktestReport, Backtester, $, summary, ScanResult, newScanner, RankBy, rankBy, topN, scanFromCSV, Scanner, filter, scan, exportJson, exportCsv, toJson, toCsvHeader, toJson, exportTradeLogCsv, exportTradeLog, toJson, exportJson, toCsvRow, exportCsv, toJson