cotcube-helpers 0.1.8 → 0.1.9
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 +3 -0
- data/VERSION +1 -1
- data/cotcube-helpers.gemspec +4 -2
- data/lib/cotcube-helpers.rb +6 -1
- data/lib/cotcube-helpers/constants.rb +34 -0
- data/lib/cotcube-helpers/init.rb +46 -0
- data/lib/cotcube-helpers/symbols.rb +21 -0
- metadata +27 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b44c8314e88c5aca5675c78b3295f082730ddce80afc445d80228260e5c566e
|
4
|
+
data.tar.gz: 1bb545d175194aa375675b715ac63defbc1bef7101d828197d3d2aac6456cc4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bf9097c6a01afb4d68bb4bf884d7766fad12481f585ee8df9a6def9fbc82b0cef5ce0fa98eeaaad65d682406d9ac11bae8993f760a60ae390cea23aceeba791
|
7
|
+
data.tar.gz: 1f987e28e73bc9cbb66da5f8d51f7d0c4200f03c683ee36dc7f228b3684149b33aa6ed9d2d490ace172e5c8811d1f344e427324449066a2621fca55394556e67
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/cotcube-helpers.gemspec
CHANGED
@@ -26,9 +26,11 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
|
-
spec.add_dependency 'activesupport'
|
29
|
+
spec.add_dependency 'activesupport', '~> 6'
|
30
|
+
spec.add_dependency 'colorize', '~> 0.8'
|
30
31
|
|
31
|
-
|
32
|
+
|
33
|
+
spec.add_development_dependency 'rake', '~> 13'
|
32
34
|
spec.add_development_dependency 'rspec', '~>3.6'
|
33
35
|
spec.add_development_dependency 'yard', '~>0.9'
|
34
36
|
end
|
data/lib/cotcube-helpers.rb
CHANGED
@@ -19,6 +19,9 @@ require_relative 'cotcube-helpers/simple_output'
|
|
19
19
|
require_relative 'cotcube-helpers/simple_series_stats'
|
20
20
|
require_relative 'cotcube-helpers/input'
|
21
21
|
require_relative 'cotcube-helpers/reduce'
|
22
|
+
require_relative 'cotcube-helpers/constants'
|
23
|
+
require_relative 'cotcube-helpers/symbols'
|
24
|
+
require_relative 'cotcube-heleprs/init'
|
22
25
|
|
23
26
|
module Cotcube
|
24
27
|
module Helpers
|
@@ -26,7 +29,9 @@ module Cotcube
|
|
26
29
|
:parallelize,
|
27
30
|
:reduce,
|
28
31
|
:simple_series_stats,
|
29
|
-
:keystroke
|
32
|
+
:keystroke,
|
33
|
+
:symbols,
|
34
|
+
:init
|
30
35
|
|
31
36
|
# please not that module_functions of source provided in private files must be published there
|
32
37
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
zen_string_literal: true
|
3
|
+
|
4
|
+
module Cotcube
|
5
|
+
module SwapSeeker
|
6
|
+
SYMBOL_EXAMPLES = [
|
7
|
+
{ id: '13874U', symbol: 'ET', ticksize: 0.25, power: 1.25, months: 'HMUZ', bcf: 1.0, reports: 'LF', format: '8.2f', name: 'S&P 500 MICRO' },
|
8
|
+
{ id: '209747', symbol: 'NM', ticksize: 0.25, power: 0.5, monhts: 'HMUZ', bcf: 1.0, reports: 'LF', format: '8.2f', name: 'NASDAQ 100 MICRO' }
|
9
|
+
].freeze
|
10
|
+
|
11
|
+
COLORS = %i[light_red light_yellow light_green red yellow green cyan magenta blue].freeze
|
12
|
+
|
13
|
+
MONTH_COLOURS = { 'F' => :cyan, 'G' => :green, 'H' => :light_green,
|
14
|
+
'J' => :blue, 'K' => :yellow, 'M' => :light_yellow,
|
15
|
+
'N' => :cyan, 'Q' => :magenta, 'U' => :light_magenta,
|
16
|
+
'V' => :blue, 'X' => :red, 'Z' => :light_red }.freeze
|
17
|
+
|
18
|
+
MONTHS = { 'F' => 1, 'G' => 2, 'H' => 3,
|
19
|
+
'J' => 4, 'K' => 5, 'M' => 6,
|
20
|
+
'N' => 7, 'Q' => 8, 'U' => 9,
|
21
|
+
'V' => 10, 'X' => 11, 'Z' => 12,
|
22
|
+
1 => 'F', 2 => 'G', 3 => 'H',
|
23
|
+
4 => 'J', 5 => 'K', 6 => 'M',
|
24
|
+
7 => 'N', 8 => 'Q', 9 => 'U',
|
25
|
+
10 => 'V', 11 => 'X', 12 => 'Z' }.freeze
|
26
|
+
|
27
|
+
|
28
|
+
CHICAGO = Time.find_zone('America/Chicago')
|
29
|
+
|
30
|
+
DATE_FMT = '%Y-%m-%d'
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cotcube
|
4
|
+
module Helpers
|
5
|
+
|
6
|
+
def config_prefix
|
7
|
+
os = Gem::Platform.local.os
|
8
|
+
case os
|
9
|
+
when 'linux'
|
10
|
+
''
|
11
|
+
when 'freebsd'
|
12
|
+
'/usr/local'
|
13
|
+
else
|
14
|
+
raise RuntimeError, "Unsupported architecture: #{os}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def config_path
|
19
|
+
config_prefix + '/etc/cotcube'
|
20
|
+
end
|
21
|
+
|
22
|
+
def init(config_file_name: nil,
|
23
|
+
gem_name: nil,
|
24
|
+
debug: false)
|
25
|
+
gem_name ||= self.ancestors.first.to_s
|
26
|
+
config_file_name = "#{gem_name.down_case}.yml"
|
27
|
+
config_file = config_path + "/#{config_file_name}"
|
28
|
+
|
29
|
+
if File.exist?(config_file)
|
30
|
+
config = YAML.load(File.read config_file).transform_keys(&:to_sym)
|
31
|
+
else
|
32
|
+
config = {}
|
33
|
+
end
|
34
|
+
|
35
|
+
defaults = {
|
36
|
+
data_path: '/var/cotcube/' + name,
|
37
|
+
}
|
38
|
+
|
39
|
+
config = defaults.merge(config)
|
40
|
+
puts "CONFIG is '#{config}'" if debug
|
41
|
+
|
42
|
+
config
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cotcube
|
4
|
+
# Missing top level documentation
|
5
|
+
module Helpers
|
6
|
+
|
7
|
+
def symbols(config: init, type: nil, symbol: nil)
|
8
|
+
if config[:symbols_file].nil?
|
9
|
+
SYMBOL_EXAMPLES
|
10
|
+
else
|
11
|
+
CSV
|
12
|
+
.read(config[:symbols_file], headers: %i{ id symbol ticksize power months type bcf reports format name})
|
13
|
+
.map{|row| row.to_h }
|
14
|
+
.map{|row| [ :ticksize, :power, :bcf ].each {|z| row[z] = row[z].to_f}; row[:format] = "%#{row[:format]}f"; row }
|
15
|
+
.reject{|row| row[:id].nil? }
|
16
|
+
.tap{|all| all.select!{|x| x[:type] == type} unless type.nil? }
|
17
|
+
.tap { |all| all.select! { |x| x[:symbol] == symbol } unless symbol.nil? }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cotcube-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
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
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '13'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '13'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,9 +96,11 @@ files:
|
|
82
96
|
- cotcube-helpers.gemspec
|
83
97
|
- lib/cotcube-helpers.rb
|
84
98
|
- lib/cotcube-helpers/array_ext.rb
|
99
|
+
- lib/cotcube-helpers/constants.rb
|
85
100
|
- lib/cotcube-helpers/datetime_ext.rb
|
86
101
|
- lib/cotcube-helpers/enum_ext.rb
|
87
102
|
- lib/cotcube-helpers/hash_ext.rb
|
103
|
+
- lib/cotcube-helpers/init.rb
|
88
104
|
- lib/cotcube-helpers/input.rb
|
89
105
|
- lib/cotcube-helpers/parallelize.rb
|
90
106
|
- lib/cotcube-helpers/range_ext.rb
|
@@ -96,6 +112,7 @@ files:
|
|
96
112
|
- lib/cotcube-helpers/swig/date.rb
|
97
113
|
- lib/cotcube-helpers/swig/fill_x.rb
|
98
114
|
- lib/cotcube-helpers/swig/recognition.rb
|
115
|
+
- lib/cotcube-helpers/symbols.rb
|
99
116
|
homepage: https://github.com/donkeybridge/cotcube-helpers
|
100
117
|
licenses:
|
101
118
|
- BSD-4-Clause
|