Skip to content

Commit eabf771

Browse files
authored
Merge pull request #30 from johnnypaper/add-valid-to-price-channel
Add #valid? to PriceChannel
2 parents 02ada51 + b46c86b commit eabf771

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Ruby Technical Analysis
22

3+
## 1.0.4 (2024-02-10)
4+
- Update PriceChannel to include #valid?
5+
36
## 1.0.3 (2024-01-24)
47

58
### Breaking Changes

lib/ruby_technical_analysis/indicators/price_channel.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def call
1818
calculate_price_channel
1919
end
2020

21+
# @return [Boolean] Whether the object is valid
22+
def valid?
23+
series.length >= period
24+
end
25+
2126
private
2227

2328
def _highs

spec/ruby_technical_analysis/indicators/price_channel_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ module RubyTechnicalAnalysis
3737
expect(price_channel.call).to eq([2.974, 2.8127])
3838
end
3939
end
40+
41+
describe "#valid?" do
42+
it "returns true if the object is valid" do
43+
expect(price_channel.valid?).to eq(true)
44+
end
45+
46+
it "returns false if the object is invalid" do
47+
expect(described_class.new(series: []).valid?).to eq(false)
48+
end
49+
end
4050
end
4151

4252
describe "secondary series" do

0 commit comments

Comments
 (0)