|
1 | | -# Technical Indicators Examples |
| 1 | +# Technical Analysis and Trading Strategy Examples |
2 | 2 |
|
3 | | -This directory contains simple examples showing how to use the technical indicators provided by this library. |
| 3 | +This directory contains examples showing how to use the technical indicators and trading strategies provided by this library. |
4 | 4 |
|
5 | | -## Basic Examples |
| 5 | +## Directory Structure |
6 | 6 |
|
7 | | -- `rsi_basic.rs` - Shows how to calculate and interpret the Relative Strength Index |
8 | | -- `macd_basic.rs` - Demonstrates the Moving Average Convergence Divergence indicator |
9 | | -- `bollinger_bands_basic.rs` - Example of Bollinger Bands volatility indicator |
10 | | -- `moving_averages_basic.rs` - Comparison of different moving average types (SMA, EMA, WMA) |
| 7 | +The examples are organized by category: |
11 | 8 |
|
12 | | -## CSV Reading Examples |
| 9 | +- `general/` - Basic technical indicators that apply to all markets |
| 10 | +- `stock/` - Stock market specific strategies and indicators |
| 11 | +- `options/` - Options trading strategies and volatility analysis |
| 12 | +- `csv/` - Sample CSV data files for testing |
13 | 13 |
|
14 | | -Several examples demonstrate how to load data from CSV files: |
| 14 | +## General Technical Indicators |
15 | 15 |
|
16 | | -- `compare_minute_indicator_strategies.rs` - Shows how to read minute-level OHLCV data and convert integer volume to float |
17 | | -- `compare_multi_indicator_strategies.rs` - Demonstrates proper CSV reading with column renaming |
18 | | -- `multi_indicator_strategy_for_daily_ohlcv.rs` - Shows CSV reading with a predefined schema |
19 | | -- `enhanced_minute_strategy_example.rs` - Demonstrates a multi-indicator intraday strategy for minute-level OHLCV data. Runs a full backtest, prints performance metrics, and saves all signals and indicators to `enhanced_minute_strategy_results.csv` for further analysis. |
| 16 | +Basic examples showing fundamental technical analysis concepts: |
20 | 17 |
|
21 | | -Note that when using Polars 0.46.0, CSV files should be read using the `CsvReadOptions` approach: |
| 18 | +- `general/basic_indicators.rs` - Shows how to calculate and interpret various technical indicators including moving averages, oscillators, and Bollinger Bands |
22 | 19 |
|
23 | | -```rust |
24 | | -// Read a CSV file with headers |
25 | | -let df = CsvReadOptions::default() |
26 | | - .with_has_header(true) |
27 | | - .try_into_reader_with_file_path(Some("path/to/file.csv".into()))? |
28 | | - .finish()?; |
29 | | -``` |
| 20 | +## Stock Market Strategies |
| 21 | + |
| 22 | +Stock market specific trading strategies: |
| 23 | + |
| 24 | +- `stock/trend_following.rs` - Demonstrates a trend following strategy using EMAs and RSI |
| 25 | +- `stock/mean_reversion.rs` - Shows a mean reversion strategy based on Z-score |
| 26 | +- `stock/breakout.rs` - Implements a breakout strategy with volume confirmation |
| 27 | +- `stock/volume_based.rs` - Shows volume-based strategies for stock trading |
| 28 | + |
| 29 | +## Options Trading Strategies |
| 30 | + |
| 31 | +Options market specific trading strategies: |
| 32 | + |
| 33 | +- `options/vertical_spreads.rs` - Demonstrates vertical spread strategies (bull put and bear call spreads) |
| 34 | +- `options/iron_condor.rs` - Shows how to implement iron condor strategies for range-bound markets |
| 35 | +- `options/volatility_strategies.rs` - Demonstrates volatility-based options strategies |
| 36 | +- `options/delta_neutral.rs` - Shows delta-neutral options strategies implementation |
30 | 37 |
|
31 | 38 | ## Running the Examples |
32 | 39 |
|
33 | 40 | To run any example, use the following command from the project root: |
34 | 41 |
|
35 | 42 | ```bash |
36 | | -cargo run --example <example_name> |
| 43 | +cargo run --example <folder>/<example_name> |
37 | 44 | ``` |
38 | 45 |
|
39 | 46 | For instance: |
40 | 47 |
|
41 | 48 | ```bash |
42 | | -cargo run --example rsi_basic |
| 49 | +cargo run --example general/basic_indicators |
| 50 | +cargo run --example stock/trend_following |
43 | 51 | ``` |
44 | 52 |
|
45 | | -## Notes |
| 53 | +## Notes for Real-World Application |
46 | 54 |
|
47 | | -These examples use synthetic data for demonstration purposes. In real-world applications, you would: |
| 55 | +These examples use synthetic data for demonstration purposes. In real-world applications, you should: |
48 | 56 |
|
49 | 57 | - Import actual market data (CSV files, APIs, etc.) |
50 | | -- Apply proper backtesting methodology |
51 | | -- Consider transaction costs and slippage |
52 | | -- Combine multiple indicators for confirmation |
53 | | -- Implement risk management strategies |
| 58 | +- Apply proper backtesting methodology with realistic assumptions |
| 59 | +- Consider transaction costs, slippage, and market impact |
| 60 | +- Implement proper position sizing and risk management |
| 61 | +- Test strategies across different market conditions |
| 62 | +- Consider regulatory and tax implications |
54 | 63 |
|
55 | | -The examples are designed to be simple and focus on demonstrating the basic usage of each indicator. |
| 64 | +Each example provides a simplified implementation to demonstrate the concepts. In production trading systems, more sophisticated implementations would be required. |
0 commit comments