ArcCosine
systemic:core-arccosMathfunction1 crInputs
| Name | Type | Description |
|---|---|---|
| Data | floatarray | The input data series for the arccosine calculation. |
Outputs
| Name | Type | Description |
|---|---|---|
| ArcCos | floatarray | The arccosine of each input value, expressed in **radians**. |
The Arccosine module computes the inverse cosine of each value in a data series, returning the angle in radians whose cosine equals that value. This mathematical transformation has surprisingly powerful applications in finance—from analyzing correlation dynamics to building angular momentum indicators.
Mathematical Foundation
Domain and Range
flowchart LR
subgraph Domain["Input Domain"]
D["-1 ≤ x ≤ 1"]
end
subgraph Transform["ARCCOS"]
F["arccos(x)"]
end
subgraph Range["Output Range"]
R["0 to π radians<br/>(0° to 180°)"]
end
D --> F --> R
| Property | Value |
|---|---|
| Domain | |
| Range | radians (0° to 180°) |
Important: Input values must be between -1 and 1 (inclusive). Values outside this range have no defined arccosine, so those positions output null — the math is never faked with a substitute value.
Key Values Reference
| Input | Output (radians) | Output (degrees) | Interpretation |
|---|---|---|---|
| 1 | 0 | 0° | Perfect positive correlation |
| 0.5 | 1.047 | 60° | Moderate positive |
| 0 | 1.571 | 90° | Orthogonal / uncorrelated |
| -0.5 | 2.094 | 120° | Moderate negative |
| -1 | 3.142 | 180° | Perfect negative correlation |
Financial Application: Correlation Angle
One of the most elegant uses of arccosine in finance is converting correlation coefficients to angular distances. This transformation reveals the true geometric relationship between assets.
Why Convert Correlation to Angle?
Correlation coefficients are bounded and non-linear:
- The difference between 0.9 and 0.95 correlation is much more significant than between 0.1 and 0.15
- Arccos "stretches" the extremes, making small changes at high correlation visible
flowchart TD
subgraph Input["Correlation Coefficient"]
CORR["Asset A vs Asset B<br/>ρ = 0.85"]
end
subgraph Transform["ARCCOS Module"]
ARC["arccos(0.85)"]
end
subgraph Output["Angular Distance"]
ANGLE["θ = 31.8°<br/>Assets are 31.8° apart"]
end
CORR --> ARC --> ANGLE
Portfolio Diversification Insight
| Correlation | Angle | Diversification Benefit |
|---|---|---|
| 1.0 | 0° | None — assets move identically |
| 0.7 | 45° | Moderate — some diversification |
| 0.0 | 90° | Maximum — truly independent |
| -1.0 | 180° | Perfect hedge |
This angular representation is used in advanced portfolio optimization techniques like the angular distance matrix for hierarchical risk parity.
Creative Use Case: Correlation Breakdown Detector
Monitor when correlation between assets is changing rapidly by tracking the rate of change of the angular distance:
flowchart LR
subgraph System["Correlation Regime Detector"]
CORR["Rolling Correlation<br/>(20-period)"] --> ARCCOS["ARCCOS"]
ARCCOS --> ROC["Rate of Change"]
ROC --> Signal{"ROC > threshold?"}
Signal -->|Yes| Alert["⚠️ Regime Shift"]
Signal -->|No| Normal["Normal"]
end
Use case: During market stress, correlations spike toward 1.0 (angle → 0°). By monitoring the angular rate of change, you can detect regime shifts before they fully manifest in price action.
The Transformation Curve
Understanding how arccos reshapes data:
| Region | Behavior |
|---|---|
| Near | Steep — small changes in correlation → large angle changes |
| Near | Moderate — roughly linear response |
| Near | Steep — symmetric to |
This property makes arccos ideal for amplifying signals near the correlation extremes where small differences matter most.
Missing Data
When an input position is missing (null) — for example, a stock series has no bar on a weekend or holiday — the output at that same position is null. Values are never invented to fill a gap: every non-null output is the true arccosine of a real datapoint.
In live mode, the module returns exactly one datapoint — the most recent position — and it may be null when no bar exists at that moment (e.g., a weekend tick on a market-hours series). That gap is correct, not an error.
Handling Invalid Inputs
A value outside is a real datapoint whose arccosine simply does not exist — distinct from missing data, where no datapoint exists at all. Both surface as null in the output, but they mean different things:
- Missing input → null: there was no bar to compute from
- Out-of-range input → null: there was a bar, but the math is undefined for it
If out-of-range values are expected in your data, pre-filter with the CLAMP module to keep inputs inside .
Converting Radians to Degrees
The output is in radians. To convert to degrees:
Use a Multiply module with a constant of 57.2958 to convert.