cotcube-bardata 0.1.10 → 0.1.11

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: 2b80704cc4d7c8f63dc458e63d4e9c275726c1a37cf4671e0a2d57d5cf7d616f
4
- data.tar.gz: d46691cd8c9272c608c3d596f63ca449df989bfc5a6cb95ad07301a63a1acba2
3
+ metadata.gz: dc417f9b8b33204bbc1b345ec28e2c5604b2a5f59c183a6a0a1ad15a6cf223b1
4
+ data.tar.gz: f631c5507dff588e4f2e19209aca5d135514e450ddc9b311e407b9733f539191
5
5
  SHA512:
6
- metadata.gz: 2abe99e7c0f94bc26246817d1dcc3e40a52eb1bd32a8240cc54190b0c90ce56f2e4301e59d1756cf691e291dcd10cec720ee6c231e9dd23bf354082d8be25bb7
7
- data.tar.gz: 4e23f62c7b1a570d9d6a42ddcffc5d67917b53438ab3f8012687acc041a2ed511ecdddc8c0ce26cd46681f5c93d94b9540b2df35f6954771a5af8e7f94e91c43
6
+ metadata.gz: f5276bd185a561658226f65b92ce696774f1da7442bf0c10704925e4afd295566844d02bf866921575bf60cea6944555c7dd6abc28214ed5852ca8228553d2f3
7
+ data.tar.gz: c73f923b1bf4399bf6a9cea56e4adf2acc3aaeab770d4b56cc1daae7d5a4f7c4617f30baff58b03f9ced45a9987a4bf8106c709f12a1cfb17f0021cfe36a6d71
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.11 (March 07, 2021)
2
+ - daily.rb: added new technique 'caching in constants' to accelerate computation, also referring to continuous
3
+ - provide.rb: minor change, so disregarded contracts can be used in swapproximate
4
+
1
5
  ## 0.1.10 (February 11, 2021)
2
6
  - Daily.rb: Added measure parameters to continous_suite
3
7
  - cached.rb: Minor fix in comparison
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.11
@@ -73,31 +73,38 @@ module Cotcube
73
73
 
74
74
  # instead of using the provide_daily methods above, for this bulk operation a 'continuous.csv' is created
75
75
  # this boosts from 4.5sec to 0.3sec
76
- if not File.exist?(c_file) or Time.now - File.mtime(c_file) > 8.days or force_rewrite
76
+ rewriting = force_rewrite or not(File.exist?(c_file)) or (Time.now - File.mtime(c_file) > 8.days)
77
+ if rewriting
77
78
  puts "In daily+continuous: Rewriting #{c_file} #{force_rewrite ? "forcibly" : "due to fileage"}.".light_yellow
78
79
  `rm #{c_file}; find #{id_path} | xargs cat 2>/dev/null | grep -v '0,0,0,0' | sort -t, -k2 | cut -d, -f1,2,7,8 > #{c_file}`
79
80
  end
80
- data = CSV.read(c_file).map do |row|
81
- r = { contract: row[0],
82
- date: row[1],
83
- volume: row[2].to_i,
84
- oi: row[3].to_i
85
- }
86
- end
81
+ loading = lambda do
82
+ data = CSV.read(c_file).map do |row|
83
+ r = { contract: row[0],
84
+ date: row[1],
85
+ volume: row[2].to_i,
86
+ oi: row[3].to_i
87
+ }
88
+ end
87
89
 
88
- measuring.call("Finished retrieving dailies.")
89
- result = []
90
- data.group_by { |x| x[:date] }.map do |k, v|
91
- v.map { |x| x.delete(:date) }
92
- result << {
93
- date: k,
94
- volume: v.map { |x| x[:volume] }.reduce(:+),
95
- oi: v.map { |x| x[:oi] }.reduce(:+)
96
- }
97
- result.last[:contracts] = v
90
+ measuring.call("Finished retrieving dailies.")
91
+ result = []
92
+ data.group_by { |x| x[:date] }.map do |k, v|
93
+ v.map { |x| x.delete(:date) }
94
+ result << {
95
+ date: k,
96
+ volume: v.map { |x| x[:volume] }.reduce(:+),
97
+ oi: v.map { |x| x[:oi] }.reduce(:+)
98
+ }
99
+ result.last[:contracts] = v
100
+ end
101
+ end
102
+ constname = "CONTINUOUS_#{symbol}".to_sym
103
+ if rewriting or not Cotcube::Bardata.const_defined?( constname)
104
+ Cotcube::Bardata.const_set constname, loading.call
98
105
  end
99
106
  measuring.call("Finished processing")
100
- date.nil? ? result : result.select { |x| x[:date] == date }.first
107
+ date.nil? ? Cotcube::Bardata.const_get(constname) : Cotcube::Bardata.const_get(constname).find { |x| x[:date] == date }
101
108
  end
102
109
 
103
110
  def continuous_ml(symbol: nil, id: nil, base: nil)
@@ -44,7 +44,7 @@ module Cotcube
44
44
  days = provide_cached contract: contract, symbol: symbol, id: id, config: config, filter: filter,
45
45
  range: range, force_recent: force_recent
46
46
  dailies = provide_daily contract: contract, symbol: symbol, id: id, config: config, range: range
47
- if days.last[:datetime] > dailies.last[:datetime]
47
+ if ((days.last[:datetime] > dailies.last[:datetime]) rescue false)
48
48
  dailies[..-2] + days.select { |d| d[:datetime] > dailies[-2][:datetime] }
49
49
  else
50
50
  dailies
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.10
4
+ version: 0.1.11
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-02-11 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport