sqa 0.0.32 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +92 -1
- data/README.md +4 -0
- data/Rakefile +52 -10
- data/docs/IMPROVEMENT_PLAN.md +531 -0
- data/docs/advanced/index.md +1 -13
- data/docs/api/index.md +547 -61
- data/docs/api-reference/alphavantageapi.md +1057 -0
- data/docs/api-reference/apierror.md +31 -0
- data/docs/api-reference/index.md +221 -0
- data/docs/api-reference/notimplemented.md +27 -0
- data/docs/api-reference/sqa.md +267 -0
- data/docs/api-reference/sqa_backtest.md +137 -0
- data/docs/api-reference/sqa_backtest_results.md +530 -0
- data/docs/api-reference/sqa_badparametererror.md +13 -0
- data/docs/api-reference/sqa_config.md +538 -0
- data/docs/api-reference/sqa_configurationerror.md +13 -0
- data/docs/api-reference/sqa_datafetcherror.md +56 -0
- data/docs/api-reference/sqa_dataframe.md +752 -0
- data/docs/api-reference/sqa_dataframe_alphavantage.md +30 -0
- data/docs/api-reference/sqa_dataframe_data.md +325 -0
- data/docs/api-reference/sqa_dataframe_yahoofinance.md +25 -0
- data/docs/api-reference/sqa_ensemble.md +413 -0
- data/docs/api-reference/sqa_fpop.md +211 -0
- data/docs/api-reference/sqa_geneticprogram.md +325 -0
- data/docs/api-reference/sqa_geneticprogram_individual.md +114 -0
- data/docs/api-reference/sqa_marketregime.md +212 -0
- data/docs/api-reference/sqa_multitimeframe.md +227 -0
- data/docs/api-reference/sqa_patternmatcher.md +195 -0
- data/docs/api-reference/sqa_pluginmanager.md +55 -0
- data/docs/api-reference/sqa_portfolio.md +455 -0
- data/docs/api-reference/sqa_portfolio_position.md +220 -0
- data/docs/api-reference/sqa_portfolio_trade.md +332 -0
- data/docs/api-reference/sqa_portfoliooptimizer.md +248 -0
- data/docs/api-reference/sqa_riskmanager.md +388 -0
- data/docs/api-reference/sqa_seasonalanalyzer.md +121 -0
- data/docs/api-reference/sqa_sectoranalyzer.md +163 -0
- data/docs/api-reference/sqa_stock.md +649 -0
- data/docs/api-reference/sqa_strategy.md +178 -0
- data/docs/api-reference/sqa_strategy_bollingerbands.md +26 -0
- data/docs/api-reference/sqa_strategy_common.md +29 -0
- data/docs/api-reference/sqa_strategy_consensus.md +129 -0
- data/docs/api-reference/sqa_strategy_ema.md +41 -0
- data/docs/api-reference/sqa_strategy_kbs.md +154 -0
- data/docs/api-reference/sqa_strategy_macd.md +26 -0
- data/docs/api-reference/sqa_strategy_mp.md +41 -0
- data/docs/api-reference/sqa_strategy_mr.md +41 -0
- data/docs/api-reference/sqa_strategy_random.md +41 -0
- data/docs/api-reference/sqa_strategy_rsi.md +41 -0
- data/docs/api-reference/sqa_strategy_sma.md +41 -0
- data/docs/api-reference/sqa_strategy_stochastic.md +26 -0
- data/docs/api-reference/sqa_strategy_volumebreakout.md +26 -0
- data/docs/api-reference/sqa_strategygenerator.md +298 -0
- data/docs/api-reference/sqa_strategygenerator_pattern.md +264 -0
- data/docs/api-reference/sqa_strategygenerator_patterncontext.md +326 -0
- data/docs/api-reference/sqa_strategygenerator_profitablepoint.md +424 -0
- data/docs/api-reference/sqa_stream.md +256 -0
- data/docs/api-reference/sqa_ticker.md +175 -0
- data/docs/api-reference/string.md +135 -0
- data/docs/assets/images/advanced-workflow.svg +89 -0
- data/docs/assets/images/architecture.svg +107 -0
- data/docs/assets/images/data-flow.svg +138 -0
- data/docs/assets/images/getting-started-workflow.svg +88 -0
- data/docs/assets/images/strategy-flow.svg +78 -0
- data/docs/assets/images/system-architecture.svg +150 -0
- data/docs/concepts/index.md +292 -19
- data/docs/getting-started/index.md +1 -14
- data/docs/index.md +26 -23
- data/docs/llms.txt +109 -0
- data/docs/strategies/kbs.md +15 -14
- data/docs/strategy.md +381 -3
- data/docs/terms_of_use.md +1 -1
- data/examples/README.md +10 -0
- data/lib/api/alpha_vantage_api.rb +3 -7
- data/lib/sqa/config.rb +109 -28
- data/lib/sqa/data_frame/data.rb +13 -1
- data/lib/sqa/data_frame.rb +168 -26
- data/lib/sqa/errors.rb +79 -17
- data/lib/sqa/init.rb +70 -15
- data/lib/sqa/pattern_matcher.rb +4 -4
- data/lib/sqa/portfolio.rb +1 -1
- data/lib/sqa/sector_analyzer.rb +3 -11
- data/lib/sqa/stock.rb +169 -15
- data/lib/sqa/strategy.rb +62 -4
- data/lib/sqa/ticker.rb +106 -48
- data/lib/sqa/version.rb +1 -1
- data/lib/sqa.rb +4 -4
- data/mkdocs.yml +68 -81
- metadata +89 -21
- data/docs/README.md +0 -43
- data/examples/sinatra_app/Gemfile +0 -42
- data/examples/sinatra_app/Gemfile.lock +0 -268
- data/examples/sinatra_app/QUICKSTART.md +0 -169
- data/examples/sinatra_app/README.md +0 -471
- data/examples/sinatra_app/RUNNING_WITHOUT_TALIB.md +0 -90
- data/examples/sinatra_app/TROUBLESHOOTING.md +0 -95
- data/examples/sinatra_app/app.rb +0 -404
- data/examples/sinatra_app/config.ru +0 -5
- data/examples/sinatra_app/public/css/style.css +0 -723
- data/examples/sinatra_app/public/debug_macd.html +0 -82
- data/examples/sinatra_app/public/js/app.js +0 -107
- data/examples/sinatra_app/start.sh +0 -53
- data/examples/sinatra_app/views/analyze.erb +0 -306
- data/examples/sinatra_app/views/backtest.erb +0 -325
- data/examples/sinatra_app/views/dashboard.erb +0 -831
- data/examples/sinatra_app/views/error.erb +0 -58
- data/examples/sinatra_app/views/index.erb +0 -118
- data/examples/sinatra_app/views/layout.erb +0 -61
- data/examples/sinatra_app/views/portfolio.erb +0 -43
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# 📦 SQA::Strategy
|
|
2
|
+
|
|
3
|
+
!!! note "Description"
|
|
4
|
+
This module needs to be extend'ed within
|
|
5
|
+
a strategy class so that these common class
|
|
6
|
+
methods are available in every trading strategy.
|
|
7
|
+
|
|
8
|
+
!!! abstract "Source Information"
|
|
9
|
+
**Defined in:** `lib/sqa/strategy.rb:16`
|
|
10
|
+
|
|
11
|
+
**Inherits from:** `Object`
|
|
12
|
+
|
|
13
|
+
## 🔨 Instance Methods
|
|
14
|
+
|
|
15
|
+
### `#strategies()`
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
!!! success "Returns"
|
|
19
|
+
|
|
20
|
+
**Type:** `Array<Method>`
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Collection of strategy trade methods
|
|
25
|
+
|
|
26
|
+
??? info "Source Location"
|
|
27
|
+
`lib/sqa/strategy.rb:19`
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### `#strategies=(value)`
|
|
32
|
+
|
|
33
|
+
Sets the attribute strategies
|
|
34
|
+
|
|
35
|
+
!!! info "Parameters"
|
|
36
|
+
|
|
37
|
+
| Name | Type | Description |
|
|
38
|
+
|------|------|-------------|
|
|
39
|
+
| `value` | `Any` | the value to set the attribute strategies to. |
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
??? info "Source Location"
|
|
43
|
+
`lib/sqa/strategy.rb:19`
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### `#initialize()`
|
|
48
|
+
|
|
49
|
+
Creates a new Strategy instance with an empty strategies collection.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
!!! success "Returns"
|
|
53
|
+
|
|
54
|
+
**Type:** `Strategy`
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
a new instance of Strategy
|
|
59
|
+
|
|
60
|
+
??? info "Source Location"
|
|
61
|
+
`lib/sqa/strategy.rb:22`
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### `#add(a_strategy)`
|
|
66
|
+
|
|
67
|
+
Adds a trading strategy to the collection.
|
|
68
|
+
Strategies must be either a Class with a .trade method or a Method object.
|
|
69
|
+
|
|
70
|
+
!!! info "Parameters"
|
|
71
|
+
|
|
72
|
+
| Name | Type | Description |
|
|
73
|
+
|------|------|-------------|
|
|
74
|
+
| `a_strategy` | `Class, Method` | Strategy to add |
|
|
75
|
+
!!! success "Returns"
|
|
76
|
+
|
|
77
|
+
**Type:** `Array<Method>`
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Updated strategies collection
|
|
82
|
+
!!! example "Usage Examples"
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
strategy.add(SQA::Strategy::RSI)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
strategy.add(MyModule.method(:custom_trade))
|
|
90
|
+
```
|
|
91
|
+
??? info "Source Location"
|
|
92
|
+
`lib/sqa/strategy.rb:39`
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### `#execute(v)`
|
|
97
|
+
|
|
98
|
+
Executes all registered strategies with the given data vector.
|
|
99
|
+
|
|
100
|
+
!!! info "Parameters"
|
|
101
|
+
|
|
102
|
+
| Name | Type | Description |
|
|
103
|
+
|------|------|-------------|
|
|
104
|
+
| `v` | `OpenStruct` | Data vector containing indicator values and prices |
|
|
105
|
+
!!! success "Returns"
|
|
106
|
+
|
|
107
|
+
**Type:** `Array<Symbol>`
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
Array of signals (:buy, :sell, or :hold) from each strategy
|
|
112
|
+
!!! example "Usage Examples"
|
|
113
|
+
|
|
114
|
+
```ruby
|
|
115
|
+
vector = OpenStruct.new(rsi: 25, prices: prices_array)
|
|
116
|
+
signals = strategy.execute(vector) # => [:buy, :hold, :sell]
|
|
117
|
+
```
|
|
118
|
+
??? info "Source Location"
|
|
119
|
+
`lib/sqa/strategy.rb:60`
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### `#auto_load(except: = [:common], only: = [])`
|
|
124
|
+
|
|
125
|
+
Auto-loads strategy files from the strategy directory.
|
|
126
|
+
|
|
127
|
+
!!! info "Parameters"
|
|
128
|
+
|
|
129
|
+
| Name | Type | Description |
|
|
130
|
+
|------|------|-------------|
|
|
131
|
+
| `except` | `Array<Symbol>` | Strategy names to exclude (default: [:common]) |
|
|
132
|
+
| `only` | `Array<Symbol>` | If provided, only load these strategies |
|
|
133
|
+
!!! success "Returns"
|
|
134
|
+
|
|
135
|
+
**Type:** `nil`
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
!!! example "Usage Examples"
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
strategy.auto_load(except: [:common, :random])
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
```ruby
|
|
145
|
+
strategy.auto_load(only: [:rsi, :macd])
|
|
146
|
+
```
|
|
147
|
+
??? info "Source Location"
|
|
148
|
+
`lib/sqa/strategy.rb:79`
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### `#available()`
|
|
153
|
+
|
|
154
|
+
Returns all available strategy classes in the SQA::Strategy namespace.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
!!! success "Returns"
|
|
158
|
+
|
|
159
|
+
**Type:** `Array<Class>`
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
Array of strategy classes
|
|
164
|
+
!!! example "Usage Examples"
|
|
165
|
+
|
|
166
|
+
```ruby
|
|
167
|
+
SQA::Strategy.new.available
|
|
168
|
+
# => [SQA::Strategy::RSI, SQA::Strategy::MACD, ...]
|
|
169
|
+
```
|
|
170
|
+
??? info "Source Location"
|
|
171
|
+
`lib/sqa/strategy.rb:108`
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 📝 Attributes
|
|
176
|
+
|
|
177
|
+
### 🔄 `strategies` <small>read/write</small>
|
|
178
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::BollingerBands
|
|
2
|
+
|
|
3
|
+
!!! note "Description"
|
|
4
|
+
Bollinger Bands trading strategy
|
|
5
|
+
Buy when price touches lower band (oversold)
|
|
6
|
+
Sell when price touches upper band (overbought)
|
|
7
|
+
|
|
8
|
+
!!! abstract "Source Information"
|
|
9
|
+
**Defined in:** `lib/sqa/strategy/bollinger_bands.rb:8`
|
|
10
|
+
|
|
11
|
+
**Inherits from:** `Object`
|
|
12
|
+
|
|
13
|
+
## 🏭 Class Methods
|
|
14
|
+
|
|
15
|
+
### `.trade(vector)`
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
??? info "Source Location"
|
|
21
|
+
`lib/sqa/strategy/bollinger_bands.rb:9`
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 📝 Attributes
|
|
26
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 🔧 SQA::Strategy::Common
|
|
2
|
+
|
|
3
|
+
!!! abstract "Source Information"
|
|
4
|
+
**Defined in:** `lib/sqa/strategy/common.rb:8`
|
|
5
|
+
|
|
6
|
+
## 🔨 Instance Methods
|
|
7
|
+
|
|
8
|
+
### `#trade_against(vector)`
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
??? info "Source Location"
|
|
14
|
+
`lib/sqa/strategy/common.rb:9`
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
### `#desc()`
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
??? info "Source Location"
|
|
24
|
+
`lib/sqa/strategy/common.rb:23`
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📝 Attributes
|
|
29
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::Consensus
|
|
2
|
+
|
|
3
|
+
!!! abstract "Source Information"
|
|
4
|
+
**Defined in:** `lib/sqa/strategy/consensus.rb:5`
|
|
5
|
+
|
|
6
|
+
**Inherits from:** `Object`
|
|
7
|
+
|
|
8
|
+
## 🏭 Class Methods
|
|
9
|
+
|
|
10
|
+
### `.trade(vector)`
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
??? info "Source Location"
|
|
16
|
+
`lib/sqa/strategy/consensus.rb:8`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
### `.trade_against(vector)`
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
??? info "Source Location"
|
|
26
|
+
`lib/sqa/strategy/common.rb:9`
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### `.desc()`
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
??? info "Source Location"
|
|
36
|
+
`lib/sqa/strategy/common.rb:23`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 🔨 Instance Methods
|
|
41
|
+
|
|
42
|
+
### `#initialize(vector)`
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
!!! success "Returns"
|
|
46
|
+
|
|
47
|
+
**Type:** `Consensus`
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
a new instance of Consensus
|
|
52
|
+
|
|
53
|
+
??? info "Source Location"
|
|
54
|
+
`lib/sqa/strategy/consensus.rb:12`
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### `#my_fancy_trader()`
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
??? info "Source Location"
|
|
64
|
+
`lib/sqa/strategy/consensus.rb:17`
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### `#consensus()`
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
??? info "Source Location"
|
|
74
|
+
`lib/sqa/strategy/consensus.rb:26`
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### `#strat_one()`
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
??? info "Source Location"
|
|
84
|
+
`lib/sqa/strategy/consensus.rb:41`
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### `#strat_two()`
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
??? info "Source Location"
|
|
94
|
+
`lib/sqa/strategy/consensus.rb:42`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### `#strat_three()`
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
??? info "Source Location"
|
|
104
|
+
`lib/sqa/strategy/consensus.rb:43`
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### `#strat_four()`
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
??? info "Source Location"
|
|
114
|
+
`lib/sqa/strategy/consensus.rb:44`
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### `#strat_five()`
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
??? info "Source Location"
|
|
124
|
+
`lib/sqa/strategy/consensus.rb:45`
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 📝 Attributes
|
|
129
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::EMA
|
|
2
|
+
|
|
3
|
+
!!! abstract "Source Information"
|
|
4
|
+
**Defined in:** `lib/sqa/strategy/ema.rb:5`
|
|
5
|
+
|
|
6
|
+
**Inherits from:** `Object`
|
|
7
|
+
|
|
8
|
+
## 🏭 Class Methods
|
|
9
|
+
|
|
10
|
+
### `.trade(vector)`
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
??? info "Source Location"
|
|
16
|
+
`lib/sqa/strategy/ema.rb:8`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
### `.trade_against(vector)`
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
??? info "Source Location"
|
|
26
|
+
`lib/sqa/strategy/common.rb:9`
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### `.desc()`
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
??? info "Source Location"
|
|
36
|
+
`lib/sqa/strategy/common.rb:23`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📝 Attributes
|
|
41
|
+
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::KBS
|
|
2
|
+
|
|
3
|
+
!!! abstract "Source Information"
|
|
4
|
+
**Defined in:** `lib/sqa/strategy/kbs_strategy.rb:50`
|
|
5
|
+
|
|
6
|
+
**Inherits from:** `Object`
|
|
7
|
+
|
|
8
|
+
## 🏭 Class Methods
|
|
9
|
+
|
|
10
|
+
### `.trade(vector)`
|
|
11
|
+
|
|
12
|
+
Main strategy interface - compatible with SQA::Strategy framework
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
??? info "Source Location"
|
|
18
|
+
`lib/sqa/strategy/kbs_strategy.rb:62`
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 🔨 Instance Methods
|
|
23
|
+
|
|
24
|
+
### `#kb()`
|
|
25
|
+
|
|
26
|
+
Returns the value of attribute kb.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
??? info "Source Location"
|
|
32
|
+
`lib/sqa/strategy/kbs_strategy.rb:51`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### `#default_rules_loaded()`
|
|
37
|
+
|
|
38
|
+
Returns the value of attribute default_rules_loaded.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
??? info "Source Location"
|
|
44
|
+
`lib/sqa/strategy/kbs_strategy.rb:51`
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### `#initialize(load_defaults: = true)`
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
!!! success "Returns"
|
|
52
|
+
|
|
53
|
+
**Type:** `KBS`
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
a new instance of KBS
|
|
58
|
+
|
|
59
|
+
??? info "Source Location"
|
|
60
|
+
`lib/sqa/strategy/kbs_strategy.rb:53`
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### `#execute(vector)`
|
|
65
|
+
|
|
66
|
+
Execute strategy with given market data
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
??? info "Source Location"
|
|
72
|
+
`lib/sqa/strategy/kbs_strategy.rb:68`
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### `#add_rule(name, &block)`
|
|
77
|
+
|
|
78
|
+
Add a custom trading rule
|
|
79
|
+
|
|
80
|
+
Example:
|
|
81
|
+
add_rule :buy_dip do
|
|
82
|
+
on :rsi, { value: ->(v) { v < 30 } }
|
|
83
|
+
on :macd, { signal: :bullish }
|
|
84
|
+
perform { kb.assert(:signal, { action: :buy, confidence: :high }) }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
Note: Use `kb.assert` in perform blocks, not just `assert`
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
??? info "Source Location"
|
|
93
|
+
`lib/sqa/strategy/kbs_strategy.rb:92`
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### `#assert_fact(type, attributes = {})`
|
|
98
|
+
|
|
99
|
+
Assert a fact into working memory
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
??? info "Source Location"
|
|
105
|
+
`lib/sqa/strategy/kbs_strategy.rb:105`
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### `#query_facts(type, pattern = {})`
|
|
110
|
+
|
|
111
|
+
Query facts from working memory
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
??? info "Source Location"
|
|
117
|
+
`lib/sqa/strategy/kbs_strategy.rb:110`
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### `#print_facts()`
|
|
122
|
+
|
|
123
|
+
Print current working memory (for debugging)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
??? info "Source Location"
|
|
129
|
+
`lib/sqa/strategy/kbs_strategy.rb:115`
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### `#print_rules()`
|
|
134
|
+
|
|
135
|
+
Print all rules (for debugging)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
??? info "Source Location"
|
|
141
|
+
`lib/sqa/strategy/kbs_strategy.rb:120`
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 📝 Attributes
|
|
146
|
+
|
|
147
|
+
### 👁️ `kb` <small>read-only</small>
|
|
148
|
+
|
|
149
|
+
Returns the value of attribute kb.
|
|
150
|
+
|
|
151
|
+
### 👁️ `default_rules_loaded` <small>read-only</small>
|
|
152
|
+
|
|
153
|
+
Returns the value of attribute default_rules_loaded.
|
|
154
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::MACD
|
|
2
|
+
|
|
3
|
+
!!! note "Description"
|
|
4
|
+
MACD (Moving Average Convergence Divergence) crossover strategy
|
|
5
|
+
Buy when MACD line crosses above signal line (bullish)
|
|
6
|
+
Sell when MACD line crosses below signal line (bearish)
|
|
7
|
+
|
|
8
|
+
!!! abstract "Source Information"
|
|
9
|
+
**Defined in:** `lib/sqa/strategy/macd.rb:8`
|
|
10
|
+
|
|
11
|
+
**Inherits from:** `Object`
|
|
12
|
+
|
|
13
|
+
## 🏭 Class Methods
|
|
14
|
+
|
|
15
|
+
### `.trade(vector)`
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
??? info "Source Location"
|
|
21
|
+
`lib/sqa/strategy/macd.rb:9`
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 📝 Attributes
|
|
26
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::MP
|
|
2
|
+
|
|
3
|
+
!!! abstract "Source Information"
|
|
4
|
+
**Defined in:** `lib/sqa/strategy/mp.rb:5`
|
|
5
|
+
|
|
6
|
+
**Inherits from:** `Object`
|
|
7
|
+
|
|
8
|
+
## 🏭 Class Methods
|
|
9
|
+
|
|
10
|
+
### `.trade(vector)`
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
??? info "Source Location"
|
|
16
|
+
`lib/sqa/strategy/mp.rb:8`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
### `.trade_against(vector)`
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
??? info "Source Location"
|
|
26
|
+
`lib/sqa/strategy/common.rb:9`
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### `.desc()`
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
??? info "Source Location"
|
|
36
|
+
`lib/sqa/strategy/common.rb:23`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📝 Attributes
|
|
41
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::MR
|
|
2
|
+
|
|
3
|
+
!!! abstract "Source Information"
|
|
4
|
+
**Defined in:** `lib/sqa/strategy/mr.rb:5`
|
|
5
|
+
|
|
6
|
+
**Inherits from:** `Object`
|
|
7
|
+
|
|
8
|
+
## 🏭 Class Methods
|
|
9
|
+
|
|
10
|
+
### `.trade(vector)`
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
??? info "Source Location"
|
|
16
|
+
`lib/sqa/strategy/mr.rb:8`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
### `.trade_against(vector)`
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
??? info "Source Location"
|
|
26
|
+
`lib/sqa/strategy/common.rb:9`
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### `.desc()`
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
??? info "Source Location"
|
|
36
|
+
`lib/sqa/strategy/common.rb:23`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📝 Attributes
|
|
41
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 📦 SQA::Strategy::Random
|
|
2
|
+
|
|
3
|
+
!!! abstract "Source Information"
|
|
4
|
+
**Defined in:** `lib/sqa/strategy/random.rb:5`
|
|
5
|
+
|
|
6
|
+
**Inherits from:** `Object`
|
|
7
|
+
|
|
8
|
+
## 🏭 Class Methods
|
|
9
|
+
|
|
10
|
+
### `.trade(vector)`
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
??? info "Source Location"
|
|
16
|
+
`lib/sqa/strategy/random.rb:8`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
### `.trade_against(vector)`
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
??? info "Source Location"
|
|
26
|
+
`lib/sqa/strategy/common.rb:9`
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### `.desc()`
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
??? info "Source Location"
|
|
36
|
+
`lib/sqa/strategy/common.rb:23`
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📝 Attributes
|
|
41
|
+
|