cotcube-bardata 0.1.15.5 → 0.1.15.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/lib/cotcube-bardata/daily.rb +49 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5798e21ced6b815404638c1f33948317338d801ea483e9e43edf21b8ad3f73ba
|
4
|
+
data.tar.gz: 8bfaf9b663d8de85f8c89b459b3f33e35ce836cad2d0153a02385aaafc4d6781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f554feb61ac91f542a9e9a24a4f9983cbfd529ace02290b531d07bb67cbe5864da1e154e023b9d00dec77b91b2243efb726d4bd005fee6cdc1af88701de583a8
|
7
|
+
data.tar.gz: 32a0446523adb94cc50426c0e03b3bd379746754d5314fe79af8ff02fe169fae95fc3a1ba894a313e5b8b7ac89a2da36d5605e0183b9e0ef8022550e00fc5449
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.15.
|
1
|
+
0.1.15.6
|
@@ -198,6 +198,55 @@ module Cotcube
|
|
198
198
|
date.nil? ? Cotcube::Bardata.const_get(constname).map{|z| z.dup } : Cotcube::Bardata.const_get(constname).find { |x| x[:date] == date }
|
199
199
|
end
|
200
200
|
|
201
|
+
# the filter series is an indicator based on the Cotcube::Bardata.continuous of the asset price.
|
202
|
+
# current default filter is the ema50
|
203
|
+
def filter_series(ema_length: 50, symbol: , print_range: nil)
|
204
|
+
ema_high_n = "ema#{ema_length}_high".to_sym
|
205
|
+
ema_low_n = "ema#{ema_length}_low".to_sym
|
206
|
+
ema_filter = "ema#{ema_length}_filter".to_sym
|
207
|
+
indicators = {
|
208
|
+
ema_high_n => Cotcube::Indicators.ema(key: :high, length: ema_length, smoothing: 2),
|
209
|
+
ema_low_n => Cotcube::Indicators.ema(key: :low, length: ema_length, smoothing: 2),
|
210
|
+
:tr => Cotcube::Indicators.true_range,
|
211
|
+
:atr5 => Cotcube::Indicators.ema(key: :tr, length: 5, smoothing: 2),
|
212
|
+
ema_filter => Cotcube::Indicators.calc(a: :high, b: :low, c: :close,
|
213
|
+
d: ema_high_n, e: ema_low_n, f: :atr5,
|
214
|
+
finalize: :to_i) do |high, low, close, ema_high, ema_low, atr5|
|
215
|
+
|
216
|
+
if close > ema_high and (low - ema_high).abs <= atr5 / 5.0; 3 # :bullish_tipped
|
217
|
+
elsif low > ema_high and (low - ema_high).abs >= atr5 * 3.0; 5 # :bullish_away
|
218
|
+
elsif low > ema_high and (low - ema_high).abs <= atr5 / 1.5; 2 # :bullish_nearby
|
219
|
+
elsif low > ema_high; 4 # :bullish
|
220
|
+
|
221
|
+
elsif close < ema_low and (high - ema_low).abs <= atr5 / 5.0; -3 # :bearish_tipped
|
222
|
+
elsif high < ema_low and (high - ema_low).abs >= atr5 * 3.0; -5 # :bearish_away
|
223
|
+
elsif high < ema_low and (high - ema_low).abs <= atr5 / 1.5; -2 # :bearish_nearby
|
224
|
+
elsif high < ema_low; -4 # :bearish
|
225
|
+
|
226
|
+
elsif close >= ema_high and (close - ema_high).abs > atr5 ; 2 # :bullish_closed
|
227
|
+
elsif close <= ema_low and (close - ema_low ).abs > atr5 ; -2 # :bearish_closed
|
228
|
+
elsif close >= ema_high; 1 # :bullish_weak
|
229
|
+
elsif close <= ema_low; -1 # :bearish_weak
|
230
|
+
elsif close > ema_low and close < ema_high; 0 # :ambigue
|
231
|
+
else
|
232
|
+
raise RuntimeError, "Unconsidered Indicator value with #{high}, #{low}, #{close}, #{ema_high}, #{ema_low}, #{atr5}"
|
233
|
+
|
234
|
+
end
|
235
|
+
end
|
236
|
+
}
|
237
|
+
filter = Cotcube::Bardata.continuous(symbol: symbol, indicators: indicators).
|
238
|
+
map{ |z| z[:datetime] = DateTime.parse(z[:date]); z[:datetime] += z[:datetime].wday == 5 ? 3 : 1; z.slice(:datetime, ema_filter) }.
|
239
|
+
group_by{ |z| z[:datetime] }.
|
240
|
+
map{ |k,v| [ k, v[0][ema_filter] ] }.
|
241
|
+
to_h.
|
242
|
+
tap{ |z| z.to_a[print_range].each { |v|
|
243
|
+
puts "#{v[0].strftime('%Y-%m-%d')
|
244
|
+
} : #{format '%2d', v[1]
|
245
|
+
}".colorize(v[1] > 3 ? :light_green : v[1] > 1 ? :green : v[1] < -3 ? :light_red : v[1] < -1 ? :red : :white )
|
246
|
+
} if print_range.is_a? Range
|
247
|
+
}
|
248
|
+
end
|
249
|
+
|
201
250
|
def continuous_ml(symbol: nil, id: nil, base: nil)
|
202
251
|
(base.nil? ? Cotcube::Bardata.continuous(symbol: symbol, id: id) : base).map do |x|
|
203
252
|
x[:ml] = x[:contracts].max_by { |z| z[:volume] }[:contract]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cotcube-bardata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.15.
|
4
|
+
version: 0.1.15.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin L. Tischendorf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|