agentskills.codes
FI

finance-guide

This document defines financial conventions, formulas, and simulation rules. The goal is to ensure consistent, correct implementation of portfolio simulation, investment strategies, and performance metrics. Domain-specific financial logic, mathematical formulas, and backtesting conventions.

Install

mkdir -p .claude/skills/finance-guide && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15046" && unzip -o skill.zip -d .claude/skills/finance-guide && rm skill.zip

Installs to .claude/skills/finance-guide

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

This document defines financial conventions, formulas, and simulation rules. The goal is to ensure consistent, correct implementation of portfolio simulation, investment strategies, and performance metrics. Domain-specific financial logic, mathematical formulas, and backtesting conventions.
291 charsno explicit “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)

About this skill

1. Financial Data Standards

When processing market data for time-series analysis, the following conventions apply:

  • Primary Pricing: The "Adjusted Close" price is the gold standard as it accounts for corporate actions (splits, dividends).
  • Time Continuity: Data must be strictly chronological (ascending). Missing data points should be handled via "Forward Fill" (Last Observation Carried Forward) to preserve the integrity of technical indicators.
  • Look-ahead Bias: Calculations at time $t$ must never access data from $t+1$. Any "future leakage" invalidates the simulation.

2. Discrete-Time Portfolio Model

The portfolio state at any time step $t$ is defined by:

  • Cash Balance ($C_t$): Non-invested capital.
  • Asset Holdings ($S_t$): Quantity of the security held.
  • Portfolio Equity ($V_t$): $V_t = C_t + (S_t \times Price_t)$
  • Order Execution: Orders generated by a signal at the close of $t$ are traditionally executed at the close of $t$ (theoretical) or the open of $t+1$ (realistic).

3. Performance & Risk Mathematics

Return Metrics

  • Arithmetic Return: $R = \frac{V_{final} - V_{initial}}{V_{initial}}$
  • Logarithmic Return: $r_t = \ln(Price_t / Price_{t-1})$
  • Compound Annual Growth Rate (CAGR): $CAGR = \left( \frac{V_{final}}{V_{initial}} \right)^{\frac{1}{\text{years}}} - 1$

Risk Analytics

  • Annualized Volatility ($\sigma$): $\sigma_{ann} = \text{std}(r_{daily}) \times \sqrt{252}$
  • Sharpe Ratio: $S = \frac{\text{mean}(r_{daily})}{\text{std}(r_{daily})} \times \sqrt{252}$ (Assuming a risk-free rate of 0).
  • Drawdown ($DD_t$): The percentage decline from the running peak: $DD_t = \frac{V_t - \text{Peak}_t}{\text{Peak}_t}$ where $\text{Peak}_t = \max(V_0 \dots V_t)$

4. Universal Strategy Logic Patterns

4.1 Passive Allocation (Buy & Hold)

  • Logic: Full capital deployment at $t_0$. No rebalancing or exit signals.

4.2 Trend Following (Moving Average Crossover)

  • Logic: Dual-window calculation.
  • Signal: A "Golden Cross" (Short-term MA crosses above Long-term MA) triggers a Buy; a "Death Cross" (Short-term MA crosses below Long-term MA) triggers a Sell/Exit.

4.3 Systematic Accumulation (Dollar-Cost Averaging)

  • Logic: Periodic capital injection ($C_{inject}$) at fixed intervals (weekly/monthly/quarterly) regardless of price.
  • Share Acquisition: $S_{new} = S_{old} + \frac{C_{inject}}{Price_t}$

4.4 Momentum / Mean Reversion (RSI)

  • Logic: Relative Strength Index calculation over $n$ periods.
  • Signal: Buy when RSI < 30 (Oversold); Sell when RSI > 70 (Overbought).

4.5 Volatility Breakout (Bollinger Bands)

  • Logic: Price relation to standard deviation bands $(\mu \pm 2\sigma)$.
  • Signal: Buy/Sell triggered by price penetration of the upper or lower boundaries.

5. Trading Statistics & Quality Control

  • Win Rate: Ratio of profitable trades to total closed trades.
  • Profit Factor: Gross profits divided by gross losses.
  • Time in Market: Percentage of the total duration where $S_t > 0$.
  • Numerical Stability: Use 64-bit float precision; handle zero-volatility cases to avoid NaN results in Sharpe calculations.

Search skills

Search the agent skills registry