Quick Start Guide
Get started with Trade Geometry Analyzer in 5 minutes.
Installation
Minimal Example
import pandas as pd
from signal_analyzer import analyze, AnalysisConfig
# Your OHLC data with signals
df = pd.DataFrame({
'Open': [...],
'High': [...],
'Low': [...],
'Close': [...],
'sig': [1, -1, 0, 1, ...], # +1=long, -1=short, 0=neutral
})
# Configure analysis
config = AnalysisConfig(
H=20, # 20-bar forward horizon
sections=['A', 'B', 'C', 'D'], # Run these sections
store_paths=True, # Required for Section D
)
# Run analysis
result = analyze(df, sig_col='sig', config=config)
# Access results
print(result.section_a['long']['metrics'])
print(result.section_d['long']['best_zones'][:5])
# Show plots
import matplotlib.pyplot as plt
plt.show()
With ATR Normalization
For volatility-adjusted analysis:
# Add ATR column to your data
df['atr'] = calculate_atr(df) # Your ATR calculation
config = AnalysisConfig(
H=20,
sections=['A', 'B', 'C', 'D', 'E'], # Include Section E
vol_col='atr', # Enable vol normalization
store_paths=True,
)
result = analyze(df, sig_col='sig', config=config)
Understanding the Output
AnalysisResult Structure
The analyze() function returns an AnalysisResult object with:
# Trade sets
result.long_trades # TradeSet for long entries
result.short_trades # TradeSet for short entries
# Section results (dicts with 'long' and 'short' keys)
result.section_a # Geometry metrics
result.section_b # Frontier analysis
result.section_c # Ordering analysis
result.section_d # TP/SL feasibility
result.section_e # Vol normalization
result.section_f # Cluster analysis
# All plots
result.plots # Dict of matplotlib figures
Accessing Metrics
# Geometry metrics (Section A)
metrics = result.section_a['long']['metrics']
print(f"Median MFE: {metrics['median_mfe']:.2f}%")
print(f"Win Rate: {metrics['win_rate']*100:.1f}%")
# Best TP/SL zones (Section D)
best_zones = result.section_d['long']['best_zones']
for zone in best_zones[:3]:
print(f"TP={zone['tp']:.2f}%, SL={zone['sl']:.2f}%, EV={zone['ev']:.2f}%")
# Ordering proportions (Section C)
props = result.section_c['long']['proportions']
print(f"MFE-first: {props['mfe_first']*100:.1f}%")
print(f"MAE-first: {props['mae_first']*100:.1f}%")
Viewing Plots
# Show all plots
import matplotlib.pyplot as plt
plt.show()
# Show specific plot
result.plots['scatter'].show()
# Save plot
result.plots['heatmap_prob'].savefig('tp_sl_heatmap.png', dpi=150)
Configuration Options
Key AnalysisConfig parameters:
| Parameter | Default | Description |
|---|---|---|
H |
10 | Forward horizon in bars |
sections |
All | List of sections to run: ['A','B','C','D','E','F'] |
trim_method |
'iqr' | Outlier removal: 'iqr', 'percentile', or None |
trim_k |
1.5 | IQR multiplier (3.0 = very permissive) |
store_paths |
True | Store full paths (required for Section D) |
vol_col |
None | Volatility column name (for Section E) |
n_clusters |
None | Number of clusters (auto if None) |
Example Configurations
Fast analysis (just geometry and frontiers):
Full analysis with custom settings:
config = AnalysisConfig(
H=30, # 30-bar horizon
sections=['A', 'B', 'C', 'D', 'E', 'F'], # All sections
trim_k=3.0, # More permissive outlier removal
store_paths=True,
vol_col='atr_14', # Use 14-period ATR
n_regimes=3, # Split into 3 volatility regimes
)
Next Steps
Now that you've run your first analysis:
- Understand the concepts: Core Concepts
- Explore each section: User Guide
- See real examples: Examples
- Dive into the API: API Reference