Strategy Examples
Learn from complete, production-ready strategy implementations organized by complexity. All examples use wisp's event-driven architecture with Start(), run(), and Emit() patterns.
Architecture Pattern
Every example follows this proven pattern:
Start(ctx) → launches run() goroutine → ticker ticks → analyze market → Emit(signal)
Each strategy:
- Launches non-blocking via
Start() - Owns its execution loop in
run() - Emits signals asynchronously via
wisp.Emit() - Shuts down cleanly via
Stop()
Basic Strategies
Perfect for getting started with wisp. These strategies use 1-2 indicators and simple logic.
- RSI Strategy - Classic momentum with oversold/overbought levels. Ticks hourly, emits buy/sell signals.
- Moving Average Crossover - Golden/death cross trend following. Simple, reliable trend detection.
- Bollinger Bands Mean Reversion - Fade extremes, target the middle. Reverting to the mean.
Intermediate Strategies
Add sophistication with multiple indicators, filters, and risk management.
- Multi-Indicator Confirmation - Require 3/4 signals to agree before trading
- MACD with Trend Filter - Only trade with prevailing trend using MACD crossovers
- ATR Risk Management - Dynamic stops and position sizing based on volatility
Advanced Strategies
Complex strategies for experienced traders: portfolios, arbitrage, and multi-asset.
- Portfolio Strategy - Trade multiple assets with individual analysis and allocation
- Cross-Exchange Arbitrage - Exploit price differences across exchanges
Using These Examples
Copy and Customize
- Copy the complete code from any example
- Save as
strategy.goin your project - Adjust parameters to your preferences
- Run backtest:
wisp backtest
Common Modifications
- Adjust indicator parameters (RSI 14 → 20)
- Change ticker interval (1 hour → 4 hours)
- Modify position sizes
- Add stop losses with ATR
- Combine multiple strategies
- Add volatility filters
What Each Example Includes
- Strategy Overview - Type, indicators, risk level, asset count
- Complete Code - Copy-paste ready, fully functional
- How It Works - Step-by-step execution flow
- Key Concepts - Important principles and rationale
- Backtesting - Expected characteristics and trade frequency
- Improvements - Ideas for enhancement and customization
Learning Progression
Start with basic strategies, then advance:
- Basic RSI - Simplest: one indicator, one asset
- Basic MA Crossover - Trend following, price confirmation
- Basic Bollinger Bands - Multiple confirmations
- Intermediate MACD - Add trend filters
- Intermediate ATR Risk - Add dynamic sizing
- Intermediate Multi-Indicator - Consensus approach
- Advanced Portfolio - Multiple assets
- Advanced Arbitrage - Cross-exchange operations
Next Steps
- Writing Strategies - Deep dive into strategy patterns and best practices
- Quick Reference - API cheat sheet
- API Reference - Full indicator documentation
- Configuration - Set up for production