🔧 SQA::MarketRegime¶
Source Information
Defined in: lib/sqa/market_regime.rb:17
🏭 Class Methods¶
.detect(stock, lookback: = nil, window: = nil)¶
Detect current market regime for a stock
Parameters
| Name | Type | Description |
|---|---|---|
stock |
SQA::Stock |
Stock to analyze |
lookback |
Integer |
Days to look back for regime detection |
window |
Integer |
Alias for lookback (for backward compatibility) |
Returns
Type: Hash
Regime metadata with both symbolic and numeric values
Source Location
.detect_history(stock, window: = 60)¶
Detect market regimes across entire history
Splits historical data into regime periods
Parameters
| Name | Type | Description |
|---|---|---|
stock |
SQA::Stock |
Stock to analyze |
window |
Integer |
Rolling window for regime detection |
Returns
Type: Array<Hash>
Array of regime periods
Source Location
.detect_trend_with_score(prices)¶
Classify regime type based on trend with numeric score
Parameters
| Name | Type | Description |
|---|---|---|
prices |
Array<Float> |
Price array |
Returns
Type: Hash
{ type: Symbol, score: Float }
Source Location
.detect_trend(prices)¶
Classify regime type based on trend (backward compatibility)
Parameters
| Name | Type | Description |
|---|---|---|
prices |
Array<Float> |
Price array |
Returns
Type: Symbol
:bull, :bear, or :sideways
Source Location
.detect_volatility_with_score(prices)¶
Detect volatility regime with numeric score
Parameters
| Name | Type | Description |
|---|---|---|
prices |
Array<Float> |
Price array |
Returns
Type: Hash
{ type: Symbol, score: Float }
Source Location
.detect_volatility(prices)¶
Detect volatility regime (backward compatibility)
Parameters
| Name | Type | Description |
|---|---|---|
prices |
Array<Float> |
Price array |
Returns
Type: Symbol
:low, :medium, or :high
Source Location
.detect_strength_with_score(prices)¶
Detect trend strength with numeric score
Parameters
| Name | Type | Description |
|---|---|---|
prices |
Array<Float> |
Price array |
Returns
Type: Hash
{ type: Symbol, score: Float }
Source Location
.detect_strength(prices)¶
Detect trend strength (backward compatibility)
Parameters
| Name | Type | Description |
|---|---|---|
prices |
Array<Float> |
Price array |
Returns
Type: Symbol
:weak, :moderate, or :strong
Source Location
.split_by_regime(stock)¶
Split data by regime
Parameters
| Name | Type | Description |
|---|---|---|
stock |
SQA::Stock |
Stock to analyze |
Returns
Type: Hash
Data grouped by regime type