https://github.com/marketcalls/pyindicators
Pyindicators - Built with Claude Code
https://github.com/marketcalls/pyindicators
indicators numba python
Last synced: 3 months ago
JSON representation
Pyindicators - Built with Claude Code
- Host: GitHub
- URL: https://github.com/marketcalls/pyindicators
- Owner: marketcalls
- License: mit
- Created: 2025-05-29T16:15:58.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-05-29T17:42:20.000Z (4 months ago)
- Last Synced: 2025-05-29T17:53:53.396Z (4 months ago)
- Topics: indicators, numba, python
- Language: Python
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PyIndicators
[](https://badge.fury.io/py/pyindicators)
[](https://pypi.org/project/pyindicators/)
[](https://opensource.org/licenses/MIT)๐ **The most user-friendly technical analysis library for Python!** Combining Numba-powered performance with intelligent automation and beautiful visualizations.
> **100x easier to use than TA-Lib** - with auto-detection, one-line analysis, built-in backtesting, streaming support, and interactive widgets!
## โจ Key Features
- ๐๏ธ **Blazing Fast**: Numba JIT-compiled for C-like performance
- ๐ง **Intelligent**: Auto-detects data formats and column names
- ๐ **Complete**: 25+ indicators with built-in visualization and backtesting
- ๐ผ **Pandas Native**: Full DataFrame/Series support with named outputs
- ๐ฑ **Interactive**: Jupyter widgets and visual strategy builders
- โก **Real-time**: Streaming indicators for live trading
- ๐ง **Flexible**: From one-liners to advanced pipelines
- ๐ก๏ธ **Robust**: Smart error handling with helpful suggestions## ๐ Installation
```bash
pip install pyindicators# For interactive features
pip install pyindicators[widgets]# For development
pip install pyindicators[dev]
```## โก Quick Start - Choose Your Style
### ๐ฏ **Absolute Beginner** (1 line!)
```python
from pyindicators.easy import analyze# Auto-detects columns, adds indicators, plots, and backtests!
results = analyze('your_data.csv')
```### ๐ผ **Pandas User** (Most Popular)
```python
from pyindicators.easy import SmartDataFrame# Works with any CSV/JSON/Parquet file or DataFrame
df = SmartDataFrame('AAPL.csv') # Auto-detects OHLC columns!# Add indicators with short names
df.add_indicators('rsi', 'macd', 'bb', 'volume')# Or add everything at once
df.add_indicators('all')# Built-in visualization with signals
df.plot()# Instant backtesting
performance = df.backtest(strategy='macd_cross')
print(performance)
```### ๐ **Pipeline Enthusiast** (Advanced)
```python
from pyindicators.pipeline import IndicatorPipeline# Chain operations fluently
signals = (IndicatorPipeline(data)
.rsi()
.bollinger_bands()
.macd()
.add_signal('buy', lambda df: (df['RSI_14'] < 30) & (df['Close'] < df['BB_Lower']))
.add_signal('sell', lambda df: (df['RSI_14'] > 70) & (df['Close'] > df['BB_Upper']))
.golden_cross()
.divergence()
.get())
```### ๐ **Interactive User** (Jupyter)
```python
from pyindicators.widgets import interactive_analysis# Launch interactive explorer with sliders and real-time updates
explorer = interactive_analysis('data.csv')
```### โก **Live Trader** (Real-time)
```python
from pyindicators.streaming import LiveTradertrader = LiveTrader()
# In your trading loop
result = trader.on_tick({
'high': 105.2, 'low': 104.8,
'close': 105.0, 'volume': 1000000
})if result['action'] == 'BUY':
print(f"Buy signal at ${result['indicators']['close']}")
```### ๐ป **Command Line User**
```bash
# Quick analysis
pyindicators analyze AAPL.csv# Calculate specific indicator
pyindicators calc data.csv -i rsi -p 21# Run backtest
pyindicators backtest data.csv -s macd_cross -c 10000# Find signals
pyindicators signals data.csv --action buy
```## ๐๏ธ **All Available Interfaces**
| Interface | Best For | Example |
|-----------|----------|---------|
| **Easy Mode** | Beginners, quick analysis | `analyze('data.csv')` |
| **Pandas Wrapper** | Data scientists | `ta.rsi(df['Close'])` |
| **NumPy Core** | Performance-critical | `rsi(close_array, 14)` |
| **Pipelines** | Complex strategies | `Pipeline(data).rsi().macd()` |
| **Streaming** | Live trading | `trader.on_tick(live_data)` |
| **CLI** | Terminal users | `pyindicators analyze data.csv` |
| **Widgets** | Jupyter notebooks | `interactive_analysis(data)` |## ๐ **Available Indicators**
### ๐ **Momentum** (7 indicators)
- **RSI** (Relative Strength Index) - `rsi()`
- **Stochastic Oscillator** - `stochastic()`
- **Williams %R** - `williams_r()`
- **Rate of Change** - `roc()`
- **Momentum** - `momentum()`### ๐ **Trend** (7 indicators)
- **SMA** (Simple Moving Average) - `sma()`
- **EMA** (Exponential Moving Average) - `ema()`
- **WMA** (Weighted Moving Average) - `wma()`
- **DEMA** (Double Exponential MA) - `dema()`
- **TEMA** (Triple Exponential MA) - `tema()`
- **MACD** (Moving Average Convergence Divergence) - `macd()`
- **ADX** (Average Directional Index) - `adx()`### ๐ **Volatility** (5 indicators)
- **Bollinger Bands** - `bollinger_bands()`
- **ATR** (Average True Range) - `atr()`
- **Keltner Channels** - `keltner_channels()`
- **Donchian Channels** - `donchian_channels()`
- **Standard Deviation** - `standard_deviation()`### ๐ฆ **Volume** (5 indicators)
- **OBV** (On Balance Volume) - `obv()`
- **VWAP** (Volume Weighted Average Price) - `vwap()`
- **A/D Line** (Accumulation/Distribution) - `ad()`
- **MFI** (Money Flow Index) - `mfi()`
- **CMF** (Chaikin Money Flow) - `cmf()`## ๐ฏ **Built-in Trading Strategies**
```python
# Pre-built strategies ready to use
strategies = [
'simple', # RSI oversold/overbought
'macd_cross', # MACD crossover signals
'bb_bounce', # Bollinger Band mean reversion
'trend_follow' # Multi-indicator trend following
]# Instant backtesting
results = df.backtest(strategy='macd_cross')
```## ๐จ **Advanced Features**
### ๐ **Smart Data Detection**
```python
# Works with ANY column naming convention!
df = SmartDataFrame(data) # Auto-detects: Close, close, CLOSE, Close_Price, etc.
```### ๐ **Multi-Timeframe Analysis**
```python
from pyindicators.easy import MultiTimeframemtf = MultiTimeframe(data)
mtf.add_timeframe('daily', 'D')
mtf.add_timeframe('weekly', 'W')
confluence = mtf.find_confluence() # Find signals across timeframes
```### ๐ฏ **Signal Detection**
```python
from pyindicators.easy import find_signals# Find all trading signals automatically
signals = find_signals('AAPL.csv')
print(signals.head())
```### ๐ ๏ธ **Custom Indicators**
```python
# Create custom indicators easily
pipeline = (IndicatorPipeline(data)
.custom(lambda df: df['Close'].rolling(20).skew(), 'Skewness_20')
.transform('Volume', lambda x: np.log(x), 'Log_Volume'))
```### ๐ฎ **Interactive Visualization**
```python
from pyindicators.visual import launch_visual_tools# Interactive chart with sliders
launch_visual_tools(data, tool='interactive')# Strategy builder with drag-and-drop
launch_visual_tools(data, tool='builder')# Indicator playground
launch_visual_tools(data, tool='playground')
```## ๐จ **Smart Error Handling**
PyIndicators provides helpful error messages and suggestions:
```python
# Instead of cryptic errors, you get:
โ Column 'Close' not found in DataFrame!Available columns: ['close', 'high', 'low', 'volume']
Did you mean one of these?
โข close๐ก Tip: Check your column names are correct. Common issues:
- Case sensitivity (Close vs close)
- Extra spaces in column names
```## ๐๏ธ **Performance**
Still blazing fast with Numba optimization:
```python
import time
from pyindicators import rsi# 1 million data points
data = np.random.randn(1_000_000) + 100start = time.time()
result = rsi(data, period=14)
elapsed = time.time() - startprint(f"Calculated RSI for 1M points in {elapsed:.3f} seconds")
# Output: Calculated RSI for 1M points in 0.045 seconds
```## ๐ **Complete Examples**
### ๐ **Full Technical Analysis Workflow**
```python
from pyindicators.easy import SmartDataFrame
import yfinance as yf# Load data (or use any CSV/DataFrame)
df = yf.download('AAPL', start='2020-01-01')# Create smart dataframe with auto-detection
sdf = SmartDataFrame(df)# Add all indicators
sdf.add_indicators('all')# Create custom strategy
sdf.add_signal('custom_buy', lambda df:
(df['RSI'] < 30) &
(df['MACD'] > df['MACD_Signal']) &
(df['Close'] < df['BB_Lower'])
)# Backtest multiple strategies
strategies = ['simple', 'macd_cross', 'bb_bounce', 'trend_follow']
for strategy in strategies:
results = sdf.backtest(strategy=strategy)
print(f"{strategy}: {results['total_return']}")# Beautiful visualization
sdf.plot(show_signals=True)# Export results
sdf.df.to_csv('analysis_results.csv')
```### ๐ **Streaming Analysis**
```python
from pyindicators.streaming import LiveTrader
import yfinance as yf# Setup live trader
trader = LiveTrader()# Simulate live data feed
historical_data = yf.download('AAPL', period='1mo', interval='1m')for timestamp, row in historical_data.iterrows():
tick_data = {
'high': row['High'],
'low': row['Low'],
'close': row['Close'],
'volume': row['Volume']
}
result = trader.on_tick(tick_data)
if result['action']:
print(f"[{timestamp}] {result['action']} signal at ${tick_data['close']:.2f}")
print(f"RSI: {result['indicators'].get('rsi', 'N/A'):.1f}")# Get performance
performance = trader.get_performance()
print(f"Total PnL: {performance['total_pnl']}")
```### ๐ฏ **Strategy Comparison**
```python
from pyindicators.pipeline import StrategyPipeline# Test multiple strategy setups
strategies = {
'Conservative': StrategyPipeline(data).mean_reversion_setup(bb_period=20, rsi_period=21),
'Aggressive': StrategyPipeline(data).trend_following_setup(fast=10, slow=30),
'Breakout': StrategyPipeline(data).breakout_setup(period=15)
}results = {}
for name, strategy in strategies.items():
df_with_signals = strategy.get()
# Calculate returns for each strategy
# ... backtesting logic
results[name] = performance_metricsprint("Strategy Performance Comparison:")
print(pd.DataFrame(results).T)
```## ๐ **Documentation & Tutorials**
- **[Getting Started Guide](docs/getting_started.md)** - Complete beginner tutorial
- **[API Reference](docs/api_reference.md)** - Full function documentation
- **[Strategy Guide](docs/strategies.md)** - Trading strategy examples
- **[Performance Tips](docs/performance.md)** - Optimization techniques
- **[Jupyter Examples](examples/)** - Interactive notebook tutorials## ๐งช **Development**
### Running Tests
```bash
# Install development dependencies
pip install -e .[dev]# Run all tests
pytest# Run with coverage
pytest --cov=pyindicators --cov-report=html# Run specific test file
pytest tests/test_pandas_wrapper.py -v
```### Benchmarking
```bash
# Performance benchmarks
python examples/benchmark.py# Memory usage analysis
python examples/memory_profile.py
```### Code Quality
```bash
# Format code
black pyindicators tests# Lint code
ruff check pyindicators tests# Type checking
mypy pyindicators
```## ๐ค **Contributing**
We welcome contributions! Here's how to get started:
1. **Fork** the repository
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
3. **Add tests** for your changes
4. **Ensure** all tests pass (`pytest`)
5. **Commit** your changes (`git commit -m 'Add amazing feature'`)
6. **Push** to the branch (`git push origin feature/amazing-feature`)
7. **Open** a Pull Request### ๐ก **Ideas for Contributions**
- New technical indicators
- Additional trading strategies
- Performance optimizations
- Documentation improvements
- Integration with data providers (Alpha Vantage, Quandl, etc.)
- Additional visualization options## ๐ **License**
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ **Acknowledgments**
- **Numba Team** - For the incredible JIT compiler
- **Pandas Team** - For the amazing DataFrame functionality
- **TA-Lib** - For inspiration and reference implementations
- **Technical Analysis Community** - For indicator formulas and expertise## ๐ฌ **Support & Community**
- ๐ **Bug Reports**: [GitHub Issues](https://github.com/your-username/pyindicators/issues)
- ๐ก **Feature Requests**: [GitHub Discussions](https://github.com/your-username/pyindicators/discussions)
- ๐ง **Email**: support@pyindicators.com
- ๐ฌ **Discord**: [Join our community](https://discord.gg/pyindicators)## โญ **Star History**
If you find PyIndicators helpful, please give it a โญ๏ธ on GitHub! It helps others discover the project.
[](https://star-history.com/#your-username/pyindicators&Date)
---
**Made with โค๏ธ for the trading and data science community**
> "The best technical analysis library you'll ever use!" - Happy Users