cotcube-bardata 0.1.12 → 0.1.13
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 +5 -0
- data/VERSION +1 -1
- data/lib/cotcube-bardata/daily.rb +36 -26
- data/lib/cotcube-bardata/helpers.rb +4 -0
- data/lib/cotcube-bardata/range_matrix.rb +0 -1
- data/lib/cotcube-bardata/trade_dates.rb +1 -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: 6b1f66885f510fbe8be92a8e543f7206220db76940825862115c60be6892d5d4
|
4
|
+
data.tar.gz: a12e509a14c41cc17e31d95fca73d09ab09c342b029e973baf30377ebe8f1d6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc53284daf85e21387ba1d7b24b3e2518be8dae3d49f6b2893e6aa6442e082516be12f76f23001ad3f04aee3e3ae5601ae7e747fd8451d5d9a437c7ac2b45976
|
7
|
+
data.tar.gz: 3b496b4e75e73feee1dbc08fd355572471ba78eb1b692c91e81dd3b1f515eab510cab0d22bc712cabab84cfe621a536e91a81e0925ce897e8d48c05770b0b015
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.1.13 (April 07, 2021)
|
2
|
+
- daily: fixed const_caching in continuous
|
3
|
+
- trade_dates: FIXING call with HTTParty must send Agent Header
|
4
|
+
- helpers/get_id_set: added support for params given as Symbols (:NG instead of 'NG')
|
5
|
+
|
1
6
|
## 0.1.12 (March 13, 2021)
|
2
7
|
- range_matrix: adapted to accept block for range provision; added params :days_only and :last_n
|
3
8
|
- minor fix on previous patch
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.13
|
@@ -8,6 +8,7 @@ module Cotcube
|
|
8
8
|
symbol: nil, id: nil,
|
9
9
|
range: nil,
|
10
10
|
timezone: Time.find_zone('America/Chicago'),
|
11
|
+
keep_last: false,
|
11
12
|
config: init)
|
12
13
|
contract = contract.to_s.upcase
|
13
14
|
unless contract.is_a?(String) && [3, 5].include?(contract.size)
|
@@ -48,7 +49,7 @@ module Cotcube
|
|
48
49
|
row[:type] = :daily
|
49
50
|
row
|
50
51
|
end
|
51
|
-
data.pop if data.last[:high].zero?
|
52
|
+
data.pop if data.last[:high].zero? and not keep_last
|
52
53
|
if range.nil?
|
53
54
|
data
|
54
55
|
else
|
@@ -68,6 +69,7 @@ module Cotcube
|
|
68
69
|
measuring.call("Starting")
|
69
70
|
sym = get_id_set(symbol: symbol, id: id)
|
70
71
|
id = sym[:id]
|
72
|
+
symbol = sym[:symbol]
|
71
73
|
id_path = "#{config[:data_path]}/daily/#{id}"
|
72
74
|
c_file = "#{id_path}/continuous.csv"
|
73
75
|
|
@@ -158,7 +160,7 @@ module Cotcube
|
|
158
160
|
oi: x[:contracts].sort_by { |z| - z[:oi] }[0..4].compact.reject { |z| z[:oi].zero? }
|
159
161
|
}
|
160
162
|
end
|
161
|
-
measuring.call("Retrieved continuous")
|
163
|
+
measuring.call("Retrieved continuous for #{sym[:symbol]}")
|
162
164
|
data.reject! { |x| x[selector].empty? }
|
163
165
|
result = data.group_by { |x| x[selector].first[:contract] }
|
164
166
|
result.each_key do |key|
|
@@ -194,6 +196,7 @@ module Cotcube
|
|
194
196
|
selector: :volume,
|
195
197
|
filter: nil,
|
196
198
|
date: Date.today,
|
199
|
+
short: true,
|
197
200
|
measure: nil,
|
198
201
|
debuglevel: 1,
|
199
202
|
debug: false)
|
@@ -230,39 +233,47 @@ module Cotcube
|
|
230
233
|
measuring.call("Retrieved continous_overview")
|
231
234
|
output_sent = []
|
232
235
|
early_year=nil
|
236
|
+
long_output = []
|
233
237
|
data.keys.sort.each do |month|
|
238
|
+
current_long = { month: month }
|
234
239
|
puts "Processing #{sym[:symbol]}#{month}" if debuglevel > 1
|
235
240
|
v0 = data[month]
|
236
|
-
|
241
|
+
ldays = v0.map { |_, v1| Date.parse(v1.last[:date]).yday }
|
237
242
|
fdays = v0.map { |_, v1| Date.parse(v1.first[:date]).yday }.sort
|
238
243
|
# if the last ml day nears the end of the year, we must fix
|
239
|
-
|
244
|
+
ldays.map! { |x| x > 350 ? x - 366 : x } if ldays.min < 50
|
240
245
|
fday = fdays[fdays.size / 2]
|
241
|
-
|
242
|
-
# a contract is proposed to use after fday - 1, but before
|
243
|
-
# it is warned to user after fday - 1 but before
|
244
|
-
# it is warned red >=
|
245
|
-
color = if (ytoday >=
|
246
|
+
lavg = ldays.reduce(:+) / ldays.size
|
247
|
+
# a contract is proposed to use after fday - 1, but before ldays.min (green)
|
248
|
+
# it is warned to user after fday - 1 but before lavg - 1 (red)
|
249
|
+
# it is warned red >= lavg - 1 and <= lavg + 1
|
250
|
+
color = if (ytoday >= lavg - 1) && (ytoday <= lavg + 1)
|
246
251
|
:light_red
|
247
|
-
elsif (ytoday >
|
252
|
+
elsif (ytoday > ldays.min) && (ytoday < lavg - 1)
|
248
253
|
:light_yellow
|
249
|
-
elsif (ytoday >= (fday >
|
254
|
+
elsif (ytoday >= (fday > lavg ? 0 : fday - 5)) && (ytoday <= ldays.min)
|
250
255
|
:light_green
|
251
256
|
else
|
252
257
|
:white
|
253
258
|
end
|
254
259
|
# rubocop:disable Layout/ClosingParenthesisIndentation
|
260
|
+
long_output << {
|
261
|
+
month: month,
|
262
|
+
first_ml: fday,
|
263
|
+
last_min: ldays.min,
|
264
|
+
last_avg: lavg,
|
265
|
+
last_max: ldays.max }
|
255
266
|
output = "#{sym[:symbol]
|
256
267
|
}#{month
|
257
268
|
}\t#{format '%12s', sym[:type]
|
258
|
-
}\
|
259
|
-
|
260
|
-
}\
|
261
|
-
}: #{dfm.call(
|
262
|
-
}\t#{format '%5d',
|
263
|
-
}: #{dfm.call(
|
264
|
-
}\
|
265
|
-
}: #{dfm.call(
|
269
|
+
}\ttoday is #{ytoday
|
270
|
+
} -- median of first is #{fday
|
271
|
+
}\tlast ranges from #{format '%5d', ldays.min
|
272
|
+
}: #{dfm.call(ldays.min)
|
273
|
+
}\t#{format '%5d', lavg
|
274
|
+
}: #{dfm.call(lavg)
|
275
|
+
}\tto #{format '%5d', ldays.max
|
276
|
+
}: #{dfm.call(ldays.max)}".colorize(color)
|
266
277
|
if debug || (color != :white)
|
267
278
|
puts output
|
268
279
|
output_sent << "#{sym[:symbol]}#{month}" unless color == :white
|
@@ -273,12 +284,12 @@ module Cotcube
|
|
273
284
|
v0.each do |contract, v1|
|
274
285
|
puts "\t#{contract
|
275
286
|
}\t#{v1.first[:date]
|
276
|
-
}
|
277
|
-
|
278
|
-
} (#{Date.parse(v1.last[:date]).yday}"
|
287
|
+
} (#{format '%3d', Date.parse(v1.first[:date]).yday
|
288
|
+
})\t#{Date.parse(v1.last[:date]).strftime('%a, %Y-%m-%d')
|
289
|
+
} (#{Date.parse(v1.last[:date]).yday})"
|
279
290
|
# rubocop:enable Layout/ClosingParenthesisIndentation
|
280
291
|
end
|
281
|
-
|
292
|
+
end
|
282
293
|
case output_sent.size
|
283
294
|
when 0
|
284
295
|
puts "WARNING: No output was sent for symbol '#{sym[:symbol]}'.".colorize(:light_yellow)
|
@@ -288,11 +299,10 @@ module Cotcube
|
|
288
299
|
# all ok
|
289
300
|
true
|
290
301
|
else
|
291
|
-
puts "
|
292
|
-
|
302
|
+
puts "Continuous table show #{output_sent.size} active contracts ( #{output_sent} ) for #{sym[:symbol]} ---------------"
|
293
303
|
end
|
294
304
|
measuring.call("Finished processing")
|
295
|
-
output_sent
|
305
|
+
short ? output_sent : long_output
|
296
306
|
end
|
297
307
|
end
|
298
308
|
end
|
@@ -46,6 +46,10 @@ module Cotcube
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def get_id_set(symbol: nil, id: nil, contract: nil, config: init)
|
49
|
+
contract = contract.to_s.upcase if contract.is_a? Symbol
|
50
|
+
id = id.to_s.upcase if id.is_a? Symbol
|
51
|
+
symbol = symbol.to_s.upcase if symbol.is_a? Symbol
|
52
|
+
|
49
53
|
if contract.is_a?(String) && (contract.length == 5)
|
50
54
|
c_symbol = contract[0..1]
|
51
55
|
if (not symbol.nil?) && (symbol != c_symbol)
|
@@ -38,7 +38,6 @@ module Cotcube
|
|
38
38
|
|
39
39
|
%i[days weeks months].each do |period|
|
40
40
|
next if days_only and %i[weeks months].include? period
|
41
|
-
p yield(source[period].first)
|
42
41
|
source[period].map! do |x|
|
43
42
|
x[:range] = block_given? ? yield(x) : (((x[:high] - x[:low]) / sym[:ticksize]).round)
|
44
43
|
x
|
@@ -8,7 +8,7 @@ module Cotcube
|
|
8
8
|
def last_trade_date
|
9
9
|
uri = 'https://www.cmegroup.com/CmeWS/mvc/Volume/TradeDates?exchange=CME'
|
10
10
|
begin
|
11
|
-
HTTParty.get(uri)
|
11
|
+
HTTParty.get(uri, headers: { "User-Agent" => "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"})
|
12
12
|
.parsed_response
|
13
13
|
.map do |x|
|
14
14
|
a = x['tradeDate'].chars.each_slice(2).map(&:join)
|
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.
|
4
|
+
version: 0.1.13
|
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-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|