cotcube-bardata 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6685b99ba2fcbd933356ebefad21f83c3ec641101b8772419c030b3d197f0de
4
- data.tar.gz: 825d415ff9c9f3a5ffe072ff1cec47e8238ce63399c9c7519e7a496392aef4f8
3
+ metadata.gz: 241ac82617b49386e5ab3b2291a0d5a0e6f6f792a1184ad5956ec5eedce56d5e
4
+ data.tar.gz: a70bb34fe89fdc62138e2efbb8dcc7119f5e07d58672c4c9bb6923da95ab1bd1
5
5
  SHA512:
6
- metadata.gz: dff1e21c1076d0d566a088a0e8af2955abaf4d9d3c26ddfa33685f4b8fa660744dfbd3210ede01badf71bd85398cb064d292f0ec6998f7784d3db4f06bac2b88
7
- data.tar.gz: ed811a9909dc7c08b08030c07b8c4ee811c13e1313a7481d8747f4ca4107b0597f5abde1e2eb8f78ac907e15f37aa494398144df565e354b00042b41bc00265e
6
+ metadata.gz: 5e80e2f64b55ea2df59ca62d2407ea7d534568d0bcdbd75eed6c0df233fc16f9e9c0651213f0d53401a9ac336eb4fb4e4325d874fb299ce8ba01dee53c7d25d0
7
+ data.tar.gz: 875c0bcca1eab089286a7ecb94979db433d15d6cb5c4a45fccc46695615da632aa48f68ae3119a908287f127cee0dd93f24319e02d45103148eb7acdad992de8
@@ -1,3 +1,7 @@
1
+ ## 0.1.6 (January 07, 2021)
2
+ - prefering datetime instead date (in helpers and daily)
3
+ - changed keyword :set to :filter in cached, provide and trading_hours
4
+
1
5
  ## 0.1.5 (January 02, 2021)
2
6
  - applied some still missing cops
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -60,6 +60,7 @@ module Cotcube
60
60
  :trading_hours,
61
61
  # receive id / symbol information on an uncertain set of parameters
62
62
  :get_id_set,
63
+ :provide_cached,
63
64
  :compare,
64
65
  :holidays,
65
66
  :symbols # reads and provides the symbols file
@@ -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], set: filter)
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 if not marked
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]).to_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], set: filter)
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 sets for each symbol: :full and :rth, exceptions are e.g. meats
11
- def trading_hours(symbol: nil, id: nil, # rubocop:disable Metrics/ParameterLists
12
- set: :full, force_set: false,
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 set.to_s =~ /24x7/
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]}_#{set}.csv"
26
- puts "Trying to use #{file} for #{symbol} + #{set}" if debug
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 force_set)
33
+ return prepare.call(file) if File.exist?(file) && (not force_filter)
32
34
 
33
- file = "#{config[:data_path]}/trading_hours/#{sym[:type]}_#{set}.csv"
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 force_set)
41
+ return prepare.call(file) if File.exist?(file) && (not force_filter)
40
42
 
41
- puts "Finally failed to find range set for #{symbol} + #{set}, returning 24x7"..colorize(:light_yellow)
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.5
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-02 00:00:00.000000000 Z
11
+ date: 2021-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport