cotcube-bardata 0.1.9.1 → 0.1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/VERSION +1 -1
- data/lib/cotcube-bardata.rb +2 -0
- data/lib/cotcube-bardata/daily.rb +25 -14
- data/lib/cotcube-bardata/provide.rb +5 -1
- 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: 42d2c651e2e0cc53cbd35ea0ea824e82828930bee04d1bce9a52edf9b70c54f1
|
4
|
+
data.tar.gz: 388c35d25810c30a73136e66e0e204473dd2646f2ea776c23a476b8cb769afb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 705ded304d33270f8133a5e297a807a56288b7a710ac12f6aa2896f4971c2302f6e5a3a9b229c8c513489abb32bbe3079e0f60bdf094756935f19a6d84d7d276
|
7
|
+
data.tar.gz: e36f72ffc6dbf098a86b647932f8d881016477ebb74223b8db12f75f3e9c58f4962eef7da5992838c72538d1e18545f647b4df104554e70727ba45694b55de59
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.9.
|
1
|
+
0.1.9.2
|
data/lib/cotcube-bardata.rb
CHANGED
@@ -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 =
|
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 =
|
190
|
+
ytoday = date.yday
|
185
191
|
data = continuous_overview(id: id, selector: selector, filter: filter, human: false, config: init)
|
186
|
-
|
192
|
+
.reject { |k, _| k[-2..].to_i == date.year % 2000 }
|
187
193
|
.group_by { |k, _| k[2] }
|
188
|
-
output_sent =
|
194
|
+
output_sent = []
|
195
|
+
early_year=nil
|
189
196
|
data.keys.sort.each do |month|
|
190
|
-
puts "Processing #{sym[:symbol]}#{month}" if
|
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
|
-
|
211
|
-
|
212
|
-
|
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
|
-
|
229
|
+
if debug || (color != :white)
|
230
|
+
puts output
|
231
|
+
output_sent << "#{sym[:symbol]}#{month}" unless color == :white
|
224
232
|
end
|
225
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2021-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|