📦 SQA::Strategy¶
Description
This module needs to be extend'ed within a strategy class so that these common class methods are available in every trading strategy.
🔨 Instance Methods¶
#strategies()¶
Returns
Type: Array<Method>
Collection of strategy trade methods
Source Location
#strategies=(value)¶
Sets the attribute strategies
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
the value to set the attribute strategies to. |
Source Location
#initialize()¶
Creates a new Strategy instance with an empty strategies collection.
Returns
Type: Strategy
a new instance of Strategy
Source Location
#add(a_strategy)¶
Adds a trading strategy to the collection. Strategies must be either a Class with a .trade method or a Method object.
Parameters
| Name | Type | Description |
|---|---|---|
a_strategy |
Class, Method |
Strategy to add |
Returns
Type: Array<Method>
Updated strategies collection
Source Location
#execute(v)¶
Executes all registered strategies with the given data vector.
Parameters
| Name | Type | Description |
|---|---|---|
v |
OpenStruct |
Data vector containing indicator values and prices |
Returns
Type: Array<Symbol>
Array of signals (:buy, :sell, or :hold) from each strategy
Usage Examples
Source Location
#auto_load(except: = [:common], only: = [])¶
Auto-loads strategy files from the strategy directory.
Parameters
| Name | Type | Description |
|---|---|---|
except |
Array<Symbol> |
Strategy names to exclude (default: [:common]) |
only |
Array<Symbol> |
If provided, only load these strategies |
Returns
Type: nil
Usage Examples
Source Location
#available()¶
Returns all available strategy classes in the SQA::Strategy namespace.
Returns
Type: Array<Class>
Array of strategy classes