Skip to content

🔧 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

lib/sqa/market_regime.rb:26


.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

lib/sqa/market_regime.rb:61


.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

lib/sqa/market_regime.rb:109


.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

lib/sqa/market_regime.rb:136


.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

lib/sqa/market_regime.rb:145


.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

lib/sqa/market_regime.rb:170


.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

lib/sqa/market_regime.rb:179


.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

lib/sqa/market_regime.rb:211


.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

Source Location

lib/sqa/market_regime.rb:220


📝 Attributes