time-series-analysis
Scannednpx machina-cli add skill pablodiegoo/Data-Pro-Skill/time-series-analysis --openclawTime-Series Analysis Skill
This skill provides a robust framework for validating any logic applied to time-series data (financial, operational, or behavioral). It focuses on avoiding look-ahead bias and ensuring statistical robustness through walk-forward validation.
Capabilities
1. Strategy Validation Engine (time_series_backtest_engine)
Vectorized engine to simulate decisions over time.
- Supports custom entry/exit logic.
- Implements time-based and threshold-based stops.
- Handles massive datasets via streaming output.
2. Resource Allocation Simulator (resource_allocation_simulator)
Event-driven simulator to test how resources (capital, inventory, etc.) are distributed across multiple signals.
- Fixed-percentage or dynamic allocation.
- Concentration limits per signal.
- Realistic constraint modeling (leverage caps, minimum allocations).
3. Performance Metrics
Calculates standard risk-adjusted return metrics:
- Sharpe Ratio / Sortino Ratio.
- Maximum Drawdown (MDD).
- Win Rate and Expectancy.
Usage
from scripts.time_series_backtest_engine import run_backtest
from scripts.resource_allocation_simulator import simulate_allocation
# 1. Validate a strategy over historical data
results = run_backtest(
data=df,
entry_threshold=2.0,
exit_threshold=0.0,
stop_loss=3.0
)
# 2. Simulate resource distribution based on signals
sim_report = simulate_allocation(
trades=results,
initial_resource=100000,
max_per_signal=0.1
)
Best Practices
- Walk-Forward: Always separate the formation (training) window from the trading (test) window.
- Look-ahead Bias: Ensure signals at time
tonly use data available att-1. - DPI: Use
performance_curve_builderfor high-resolution result visualization.
Detailed References
- Methodology: See time_series_validation_methodology.md for backtest logic and spread calculation.
- Metrics: See financial_metrics_pairs_trading.md for financial-specific indicators (Half-Life, Sharpe).
- Validation: See walk_forward_validation.md for gold-standard validation patterns.
Dependencies
pandas, numpy, scipy.
Source
git clone https://github.com/pablodiegoo/Data-Pro-Skill/blob/main/src/datapro/data/skills/time-series-analysis/SKILL.mdView on GitHub Overview
This skill provides a robust framework for validating any logic applied to time-series data (financial, operational, or behavioral). It emphasizes avoiding look-ahead bias and ensures statistical robustness through walk-forward validation, plus an event-driven resource allocation simulator to test constraints.
How This Skill Works
Core components include a Strategy Validation Engine (time_series_backtest_engine) that simulates decisions over time with custom entry/exit logic and time-based or threshold-based stops, and a Resource Allocation Simulator that tests how resources are distributed across multiple signals under fixed-percentage or dynamic allocations and realistic constraints. It computes standard risk-adjusted metrics such as Sharpe, Sortino, Maximum Drawdown, and Win Rate, with streaming output to handle large datasets.
When to Use It
- Validating sequential logic on time-series data
- Assessing risk-adjusted performance of strategies
- Simulating resource distribution under real-world constraints
- Detecting look-ahead bias with walk-forward testing
- Benchmarking models on evolving data streams
Quick Start
- Step 1: Prepare your dataframe df with the time-series data you want to test.
- Step 2: Run backtest: results = run_backtest(data=df, entry_threshold=2.0, exit_threshold=0.0, stop_loss=3.0)
- Step 3: Run allocation: sim_report = simulate_allocation(trades=results, initial_resource=100000, max_per_signal=0.1)
Best Practices
- Always separate the formation (training) window from the trading (test) window.
- Ensure signals at time t only use data available at t-1 to avoid leakage.
- Use walk-forward validation consistently to test robustness across regimes.
- Use performance_curve_builder for high-resolution result visualization.
- Validate resource allocation under realistic constraints (leverage caps, minimum allocations).
Example Use Cases
- Backtest a trading strategy over historical price data to compare performance across regimes.
- Validate a non-trading operational rule using time-series signals (e.g., process timing or capacity checks).
- Simulate capital or inventory distribution across multiple signals under fixed-percentage allocations.
- Run walk-forward validation to detect look-ahead bias in signal generation.
- Visualize risk-adjusted performance using performance_curve_builder and reference methodology docs.