cotcube-bardata 0.1.9.1 → 0.1.9.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a288595522cb8414d8db207702ccfa4f2982aee92aea7fbd9bbb69dc9bff951
4
- data.tar.gz: 05707b28f388968d3fad8cf4d5145fb0b85c5c8cd30f3cd68b722bac5d4874d1
3
+ metadata.gz: 42d2c651e2e0cc53cbd35ea0ea824e82828930bee04d1bce9a52edf9b70c54f1
4
+ data.tar.gz: 388c35d25810c30a73136e66e0e204473dd2646f2ea776c23a476b8cb769afb7
5
5
  SHA512:
6
- metadata.gz: d1a8385d8dc58b8955aa443e3dda7e66bcb2ed172518d8bf6070e6506e33bdab805a4b9d821c1aa7fc308d69bba5bfa5a80ed5fb3fca8afffeec01ff9a9e10e1
7
- data.tar.gz: 12013f03b33649879ab5f93778a9a4cf8a9586b2080b7113dac60171681dd5a158fea1d5c9695edc64f6e1ea738c33d0b82c776f0b881b38112cb2b99a76df8a
6
+ metadata.gz: 705ded304d33270f8133a5e297a807a56288b7a710ac12f6aa2896f4971c2302f6e5a3a9b229c8c513489abb32bbe3079e0f60bdf094756935f19a6d84d7d276
7
+ data.tar.gz: e36f72ffc6dbf098a86b647932f8d881016477ebb74223b8db12f75f3e9c58f4962eef7da5992838c72538d1e18545f647b4df104554e70727ba45694b55de59
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.9.2 (February 07, 2021)
2
+ - minor changes
3
+ - daily#continuous_table: introducing debuglevel
4
+
1
5
  ## 0.1.9.1 (January 29, 2021)
2
6
  - provide: added new interval 'synth', mixing available dailies with synthetic days based on quarters
3
7
  - minor change / cleanup
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9.1
1
+ 0.1.9.2
@@ -52,6 +52,8 @@ module Cotcube
52
52
  :continuous_actual_ml,
53
53
  # based on continuous, create list of when which contract was most liquid
54
54
  :continuous_overview,
55
+ # provider estimation of current ML usability
56
+ :continuous_table,
55
57
  # provide the list of quarters, possibly as hours or days.
56
58
  :provide_quarters,
57
59
  # some statistics to estimate daily volatility of specific contract
@@ -163,7 +163,13 @@ module Cotcube
163
163
  def continuous_table(symbol: nil, id: nil,
164
164
  selector: :volume,
165
165
  filter: nil,
166
+ date: Date.today,
167
+ debuglevel: 1,
166
168
  debug: false)
169
+ if debug.is_a?(Integer)
170
+ debuglevel = debug
171
+ debug = debuglevel > 0 ? true : false
172
+ end
167
173
  raise ArgumentError, 'Selector must be either :volume or :oi' unless selector.is_a?(Symbol) &&
168
174
  %i[volume oi].include?(selector)
169
175
 
@@ -173,7 +179,7 @@ module Cotcube
173
179
  return
174
180
  end
175
181
  id = sym[:id]
176
- dfm = lambda do |x, y = Date.today.year|
182
+ dfm = lambda do |x, y = date.year|
177
183
  k = Date.strptime("#{y} #{x.negative? ? x + 366 : x}", '%Y %j')
178
184
  k -= 1 while [0, 6].include?(k.wday)
179
185
  k.strftime('%a, %Y-%m-%d')
@@ -181,13 +187,14 @@ module Cotcube
181
187
  puts "#{sym[:symbol]}\t#{x}\t#{y}"
182
188
  end
183
189
 
184
- ytoday = Date.today.yday
190
+ ytoday = date.yday
185
191
  data = continuous_overview(id: id, selector: selector, filter: filter, human: false, config: init)
186
- .reject { |k, _| k[-2..].to_i == Date.today.year % 2000 }
192
+ .reject { |k, _| k[-2..].to_i == date.year % 2000 }
187
193
  .group_by { |k, _| k[2] }
188
- output_sent = 0
194
+ output_sent = []
195
+ early_year=nil
189
196
  data.keys.sort.each do |month|
190
- puts "Processing #{sym[:symbol]}#{month}" if debug
197
+ puts "Processing #{sym[:symbol]}#{month}" if debuglevel > 1
191
198
  v0 = data[month]
192
199
  ydays = v0.map { |_, v1| Date.parse(v1.last[:date]).yday }
193
200
  fdays = v0.map { |_, v1| Date.parse(v1.first[:date]).yday }.sort
@@ -207,10 +214,9 @@ module Cotcube
207
214
  else
208
215
  :white
209
216
  end
210
- if debug || (color != :white)
211
- # rubocop:disable Layout/ClosingParenthesisIndentation
212
- puts "#{sym[:symbol]
213
- }#{month
217
+ # rubocop:disable Layout/ClosingParenthesisIndentation
218
+ output = "#{sym[:symbol]
219
+ }#{month
214
220
  }\t#{format '%12s', sym[:type]
215
221
  }\t#{ytoday
216
222
  }/#{fday
@@ -220,9 +226,12 @@ module Cotcube
220
226
  }: #{dfm.call(yavg)
221
227
  }\t#{format '%5d', ydays.max
222
228
  }: #{dfm.call(ydays.max)}".colorize(color)
223
- output_sent += 1
229
+ if debug || (color != :white)
230
+ puts output
231
+ output_sent << "#{sym[:symbol]}#{month}" unless color == :white
224
232
  end
225
- next unless debug
233
+ early_year ||= output
234
+ next unless (debug and debuglevel >= 2)
226
235
 
227
236
  v0.each do |contract, v1|
228
237
  puts "\t#{contract
@@ -230,12 +239,14 @@ module Cotcube
230
239
  }\t#{Date.parse(v1.last[:date]).strftime('%a')
231
240
  }, #{v1.last[:date]
232
241
  } (#{Date.parse(v1.last[:date]).yday}"
233
- # rubocop:enable Layout/ClosingParenthesisIndentation
242
+ # rubocop:enable Layout/ClosingParenthesisIndentation
234
243
  end
235
244
  end
236
- case output_sent
245
+ case output_sent.size
237
246
  when 0
238
247
  puts "WARNING: No output was sent for symbol '#{sym[:symbol]}'.".colorize(:light_yellow)
248
+ puts " Assuming late-year-processing.".light_yellow
249
+ puts early_year.light_green
239
250
  when 1
240
251
  # all ok
241
252
  true
@@ -243,7 +254,7 @@ module Cotcube
243
254
  puts "---- #{output_sent} for #{sym[:symbol]} ---------------"
244
255
 
245
256
  end
246
- nil
257
+ output_sent
247
258
  end
248
259
  end
249
260
  end
@@ -44,7 +44,11 @@ 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
- dailies[..-2] + days.select { |d| d[:datetime] > dailies[-2][:datetime] }
47
+ if days.last[:datetime] > dailies.last[:datetime]
48
+ dailies[..-2] + days.select { |d| d[:datetime] > dailies[-2][:datetime] }
49
+ else
50
+ dailies
51
+ end
48
52
  else
49
53
  raise ArgumentError, "Unsupported or unknown interval '#{interval}' in Bardata.provide"
50
54
  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.9.1
4
+ version: 0.1.9.2
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-29 00:00:00.000000000 Z
11
+ date: 2021-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport