cotcube-bardata 0.1.5 → 0.1.6
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 +4 -0
- data/VERSION +1 -1
- data/lib/cotcube-bardata.rb +1 -0
- data/lib/cotcube-bardata/cached.rb +2 -2
- data/lib/cotcube-bardata/daily.rb +1 -1
- data/lib/cotcube-bardata/helpers.rb +2 -2
- data/lib/cotcube-bardata/provide.rb +1 -1
- data/lib/cotcube-bardata/trading_hours.rb +12 -10
- 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: 241ac82617b49386e5ab3b2291a0d5a0e6f6f792a1184ad5956ec5eedce56d5e
|
|
4
|
+
data.tar.gz: a70bb34fe89fdc62138e2efbb8dcc7119f5e07d58672c4c9bb6923da95ab1bd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e80e2f64b55ea2df59ca62d2407ea7d534568d0bcdbd75eed6c0df233fc16f9e9c0651213f0d53401a9ac336eb4fb4e4325d874fb299ce8ba01dee53c7d25d0
|
|
7
|
+
data.tar.gz: 875c0bcca1eab089286a7ecb94979db433d15d6cb5c4a45fccc46695615da632aa48f68ae3119a908287f127cee0dd93f24319e02d45103148eb7acdad992de8
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.6
|
data/lib/cotcube-bardata.rb
CHANGED
|
@@ -52,13 +52,13 @@ module Cotcube
|
|
|
52
52
|
contract_is_marked = data.last[:high].zero?
|
|
53
53
|
data.pop if contract_is_marked
|
|
54
54
|
unless (filter == :full) || (data.size < 3)
|
|
55
|
-
requested_set = trading_hours(symbol: sym[:symbol],
|
|
55
|
+
requested_set = trading_hours(symbol: sym[:symbol], filter: filter)
|
|
56
56
|
data = data.select_within(ranges: requested_set, attr: :datetime) { |x| x.to_datetime.to_sssm }
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
base = Cotcube::Helpers.reduce(bars: data, to: :days)
|
|
60
60
|
|
|
61
|
-
# remove last day of result
|
|
61
|
+
# remove last day of result unless marked
|
|
62
62
|
base.pop unless contract_is_marked || force_recent
|
|
63
63
|
|
|
64
64
|
base.map do |x|
|
|
@@ -28,7 +28,7 @@ module Cotcube
|
|
|
28
28
|
row[k] = row[k].to_f if %i[open high low close].include? k
|
|
29
29
|
row[k] = row[k].to_i if %i[volume oi].include? k
|
|
30
30
|
end
|
|
31
|
-
row[:datetime] = timezone.parse(row[:date])
|
|
31
|
+
row[:datetime] = timezone.parse(row[:date])
|
|
32
32
|
row[:type] = :daily
|
|
33
33
|
row
|
|
34
34
|
end
|
|
@@ -83,8 +83,8 @@ module Cotcube
|
|
|
83
83
|
full = provide(contract: contract, interval: :days, filter: :full)
|
|
84
84
|
rth = provide(contract: contract, interval: :days, filter: :rth)
|
|
85
85
|
rth_dates = rth.map { |x| x[:datetime] }
|
|
86
|
-
daily.select! { |x| rth_dates.include? x[:datetime] }
|
|
87
|
-
full.select! { |x| rth_dates.include? x[:datetime] }
|
|
86
|
+
daily.select! { |x| rth_dates.include? x[:datetime].to_datetime }
|
|
87
|
+
full.select! { |x| rth_dates.include? x[:datetime].to_datetime }
|
|
88
88
|
|
|
89
89
|
printer = lambda { |z|
|
|
90
90
|
# rubocop:disable Layout/ClosingParenthesisIndentation
|
|
@@ -22,7 +22,7 @@ module Cotcube
|
|
|
22
22
|
when :quarters, :hours, :quarter, :hour
|
|
23
23
|
base = provide_quarters(contract: contract, symbol: symbol, id: id, config: config)
|
|
24
24
|
base = extended_select_for_range(range: range, base: base) if range
|
|
25
|
-
requested_set = trading_hours(symbol: sym[:symbol],
|
|
25
|
+
requested_set = trading_hours(symbol: sym[:symbol], filter: filter)
|
|
26
26
|
|
|
27
27
|
base = base.select_within(ranges: requested_set, attr: :datetime) { |x| x.to_datetime.to_sssm }
|
|
28
28
|
return base if %i[quarters quarter].include? interval
|
|
@@ -7,11 +7,13 @@ module Cotcube
|
|
|
7
7
|
# (as sunday is wday:0)
|
|
8
8
|
# according files are located in config[:data_path]/trading_hours and picked either
|
|
9
9
|
# by the symbol itself or by the assigned type
|
|
10
|
-
# commonly there are two
|
|
11
|
-
def trading_hours(symbol: nil, id: nil,
|
|
12
|
-
|
|
10
|
+
# commonly there are two filter for each symbol: :full and :rth, exceptions are e.g. meats
|
|
11
|
+
def trading_hours(symbol: nil, id: nil, # rubocop:disable Metrics/ParameterLists
|
|
12
|
+
filter: ,
|
|
13
|
+
force_filter: false, # with force_filter one would avoid falling back
|
|
14
|
+
# to the contract_type based range set
|
|
13
15
|
config: init, debug: false)
|
|
14
|
-
return (0...24 * 7 * 3600) if
|
|
16
|
+
return (0...24 * 7 * 3600) if filter.to_s =~ /24x7/
|
|
15
17
|
|
|
16
18
|
prepare = lambda do |f|
|
|
17
19
|
CSV.read(f, converters: :numeric)
|
|
@@ -22,23 +24,23 @@ module Cotcube
|
|
|
22
24
|
|
|
23
25
|
sym = get_id_set(symbol: symbol, id: id)
|
|
24
26
|
|
|
25
|
-
file = "#{config[:data_path]}/trading_hours/#{sym[:symbol]}_#{
|
|
26
|
-
puts "Trying to use #{file} for #{symbol} + #{
|
|
27
|
+
file = "#{config[:data_path]}/trading_hours/#{sym[:symbol]}_#{filter}.csv"
|
|
28
|
+
puts "Trying to use #{file} for #{symbol} + #{filter}" if debug
|
|
27
29
|
return prepare.call(file) if File.exist? file
|
|
28
30
|
|
|
29
31
|
file = "#{config[:data_path]}/trading_hours/#{sym[:symbol]}_full.csv"
|
|
30
32
|
puts "Failed. Trying to use #{file} now" if debug
|
|
31
|
-
return prepare.call(file) if File.exist?(file) && (not
|
|
33
|
+
return prepare.call(file) if File.exist?(file) && (not force_filter)
|
|
32
34
|
|
|
33
|
-
file = "#{config[:data_path]}/trading_hours/#{sym[:type]}_#{
|
|
35
|
+
file = "#{config[:data_path]}/trading_hours/#{sym[:type]}_#{filter}.csv"
|
|
34
36
|
puts "Failed. Trying to use #{file} now." if debug
|
|
35
37
|
return prepare.call(file) if File.exist? file
|
|
36
38
|
|
|
37
39
|
file = "#{config[:data_path]}/trading_hours/#{sym[:type]}_full.csv"
|
|
38
40
|
puts "Failed. Trying to use #{file} now." if debug
|
|
39
|
-
return prepare.call(file) if File.exist?(file) && (not
|
|
41
|
+
return prepare.call(file) if File.exist?(file) && (not force_filter)
|
|
40
42
|
|
|
41
|
-
puts "Finally failed to find range
|
|
43
|
+
puts "Finally failed to find range filter for #{symbol} + #{filter}, returning 24x7".colorize(:light_yellow)
|
|
42
44
|
(0...24 * 7 * 3600)
|
|
43
45
|
end
|
|
44
46
|
end
|
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.
|
|
4
|
+
version: 0.1.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-01-
|
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|