cotcube-bardata 0.1.13 → 0.1.14
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 +4 -0
- data/VERSION +1 -1
- data/lib/cotcube-bardata.rb +7 -2
- data/lib/cotcube-bardata/cached.rb +6 -3
- data/lib/cotcube-bardata/daily.rb +4 -2
- data/lib/cotcube-bardata/provide.rb +3 -2
- data/lib/cotcube-bardata/suggest.rb +28 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f517a7bf018413f424a2eba1e1c568c4db864240f88d23fe0c722526af858b4
|
4
|
+
data.tar.gz: 7e303f08f4be6d64f1680f5107690e78525edcdf938245b22ab97a38af1523e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cbeae28346fca35de00cdc926724799f00c69ac8b023075c5dbd332327303ab457e1558eb289979ce95ef31b0cbc7e7cd1439ce550c4b2ddb415c79cffa21dd
|
7
|
+
data.tar.gz: 9fcdc6b0b14212673d1c26e9c5b6b76264a2d8baa7270d609841377ad3fd753bb1011ddad499a27412e180dcbb8bc35a831e79e79c487866634f85533440b771
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.1.14 (May 07, 2021)
|
2
|
+
- few changes in provide / cached / daily for a more straigtforward forcing of cache renewal
|
3
|
+
- suggest: new method to suggest a contract for given symbol and date
|
4
|
+
|
1
5
|
## 0.1.13 (April 07, 2021)
|
2
6
|
- daily: fixed const_caching in continuous
|
3
7
|
- trade_dates: FIXING call with HTTParty must send Agent Header
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.14
|
data/lib/cotcube-bardata.rb
CHANGED
@@ -22,6 +22,7 @@ require_relative 'cotcube-bardata/quarters'
|
|
22
22
|
require_relative 'cotcube-bardata/eods'
|
23
23
|
require_relative 'cotcube-bardata/cached'
|
24
24
|
require_relative 'cotcube-bardata/provide'
|
25
|
+
require_relative 'cotcube-bardata/suggest'
|
25
26
|
require_relative 'cotcube-bardata/range_matrix'
|
26
27
|
require_relative 'cotcube-bardata/trading_hours'
|
27
28
|
|
@@ -61,13 +62,17 @@ module Cotcube
|
|
61
62
|
# create an array of ranges based on specified source data
|
62
63
|
:trading_hours,
|
63
64
|
# receive id / symbol information on an uncertain set of parameters
|
65
|
+
# TODO: decommision sppearance of get_id_set and symbols in cotcube::bardata
|
64
66
|
:get_id_set,
|
67
|
+
:symbols,
|
68
|
+
#
|
65
69
|
:select_specific_date,
|
66
70
|
:extended_select_for_range,
|
67
71
|
:provide_cached,
|
72
|
+
:suggest_contract_for,
|
73
|
+
#
|
68
74
|
:compare,
|
69
|
-
:holidays
|
70
|
-
:symbols # reads and provides the symbols file
|
75
|
+
:holidays
|
71
76
|
|
72
77
|
# please note that module_functions of source provided in private files must be published there
|
73
78
|
end
|
@@ -12,7 +12,7 @@ module Cotcube
|
|
12
12
|
timezone: Time.find_zone('America/Chicago'),
|
13
13
|
filter: :full, # most probably either :full or :rth
|
14
14
|
force_update: false, # force reloading via provide_quarters
|
15
|
-
force_recent: false) #
|
15
|
+
force_recent: false) # provide base.last even if dayswitch hasn't happen yet
|
16
16
|
|
17
17
|
unless range.nil? ||
|
18
18
|
range.is_a?(Range) &&
|
@@ -39,6 +39,8 @@ module Cotcube
|
|
39
39
|
file = "#{dir}/#{contract}.csv"
|
40
40
|
quarters_file = "#{config[:data_path]}/quarters/#{sym[:id]}/#{contract[-3..]}.csv"
|
41
41
|
if File.exist?(file) && (not force_update)
|
42
|
+
puts "Working with existing #{file}, no update was forced" if debug
|
43
|
+
puts " Using quarters from #{quarters_file}"
|
42
44
|
base = CSV.read(file, headers: headers).map do |x|
|
43
45
|
x = x.to_h
|
44
46
|
x[:datetime] = timezone.parse(x[:datetime])
|
@@ -49,7 +51,7 @@ module Cotcube
|
|
49
51
|
end
|
50
52
|
if base.last[:high].zero?
|
51
53
|
# contract exists but is closed (has the CLOSED marker)
|
52
|
-
base.pop
|
54
|
+
base.pop
|
53
55
|
# rubocop:disable Metrics/BlockNesting
|
54
56
|
result = if range.nil?
|
55
57
|
base
|
@@ -96,8 +98,9 @@ module Cotcube
|
|
96
98
|
end
|
97
99
|
|
98
100
|
base = Cotcube::Helpers.reduce(bars: data, to: :days)
|
101
|
+
puts "Reduced base ends at #{bast.last[:datetime].strftime('%Y-%m-%d')}" if debug
|
99
102
|
|
100
|
-
# remove last day of result
|
103
|
+
# remove last day of result if suspecting incomplete last base
|
101
104
|
base.pop if base.last[:datetime].to_date == timezone.now.to_date and not force_recent
|
102
105
|
|
103
106
|
base.map do |x|
|
@@ -107,7 +107,7 @@ module Cotcube
|
|
107
107
|
Cotcube::Bardata.const_set constname, loading.call
|
108
108
|
end
|
109
109
|
measuring.call("Finished processing")
|
110
|
-
date.nil? ? Cotcube::Bardata.const_get(constname) : Cotcube::Bardata.const_get(constname).find { |x| x[:date] == date }
|
110
|
+
date.nil? ? Cotcube::Bardata.const_get(constname).map{|z| z.dup } : Cotcube::Bardata.const_get(constname).find { |x| x[:date] == date }
|
111
111
|
end
|
112
112
|
|
113
113
|
def continuous_ml(symbol: nil, id: nil, base: nil)
|
@@ -197,6 +197,7 @@ module Cotcube
|
|
197
197
|
filter: nil,
|
198
198
|
date: Date.today,
|
199
199
|
short: true,
|
200
|
+
silent: false,
|
200
201
|
measure: nil,
|
201
202
|
debuglevel: 1,
|
202
203
|
debug: false)
|
@@ -204,6 +205,7 @@ module Cotcube
|
|
204
205
|
debuglevel = debug
|
205
206
|
debug = debuglevel > 0 ? true : false
|
206
207
|
end
|
208
|
+
silent = false if debug
|
207
209
|
|
208
210
|
raise ArgumentError, ':measure, if given, must be a Time object (e.g. Time.now)' unless [NilClass, Time].include? measure.class
|
209
211
|
measuring = lambda {|c| puts "[continuous_table] Time measured until '#{c}': #{(Time.now.to_f - measure.to_f).round(2)}sec" unless measure.nil? }
|
@@ -279,7 +281,7 @@ module Cotcube
|
|
279
281
|
output_sent << "#{sym[:symbol]}#{month}" unless color == :white
|
280
282
|
end
|
281
283
|
early_year ||= output
|
282
|
-
next
|
284
|
+
next if silent or not (debug and debuglevel >= 2)
|
283
285
|
|
284
286
|
v0.each do |contract, v1|
|
285
287
|
puts "\t#{contract
|
@@ -14,6 +14,7 @@ module Cotcube
|
|
14
14
|
filter: :full,
|
15
15
|
# TODO: for future compatibility and suggestion: planning to include a function to update
|
16
16
|
# with live data from broker
|
17
|
+
force_update: false,
|
17
18
|
force_recent: false)
|
18
19
|
|
19
20
|
sym = get_id_set(symbol: symbol, id: id, contract: contract, config: config)
|
@@ -33,7 +34,7 @@ module Cotcube
|
|
33
34
|
|
34
35
|
when :days, :weeks, :months
|
35
36
|
base = provide_cached contract: contract, symbol: symbol, id: id, config: config, filter: filter,
|
36
|
-
range: range, force_recent: force_recent
|
37
|
+
range: range, force_recent: force_recent, force_update: force_update
|
37
38
|
return base if %i[day days].include? interval
|
38
39
|
|
39
40
|
# TODO: Missing implementation to reduce cached days to weeks or months
|
@@ -42,7 +43,7 @@ module Cotcube
|
|
42
43
|
provide_daily contract: contract, symbol: symbol, id: id, config: config, range: range
|
43
44
|
when :synth, :synthetic, :synthetic_days
|
44
45
|
days = provide_cached contract: contract, symbol: symbol, id: id, config: config, filter: filter,
|
45
|
-
range: range, force_recent: force_recent
|
46
|
+
range: range, force_recent: force_recent, force_update: force_update
|
46
47
|
dailies = provide_daily contract: contract, symbol: symbol, id: id, config: config, range: range
|
47
48
|
if ((days.last[:datetime] > dailies.last[:datetime]) rescue false)
|
48
49
|
dailies[..-2] + days.select { |d| d[:datetime] > dailies[-2][:datetime] }
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cotcube
|
4
|
+
# missing top level documentation
|
5
|
+
module Bardata
|
6
|
+
# based on day(of year) and symbol, suggest best fitting contract
|
7
|
+
def suggest_contract_for symbol:, date: Date.today, warnings: true
|
8
|
+
ml = Cotcube::Bardata.continuous_table symbol: symbol, date: date
|
9
|
+
if ml.size != 1
|
10
|
+
puts "WARNING: No or no unique most liquid found for #{date}. please give :contract parameter".light_yellow if warnings
|
11
|
+
if ml.size > 1
|
12
|
+
puts "\tUsing #{ml.last}. Consider breaking here, if that is not acceptable.".light_yellow if warnings
|
13
|
+
sleep 1
|
14
|
+
else
|
15
|
+
puts "\tERROR: No suggestible contract found for #{symbol} and #{date}.".light_red
|
16
|
+
return
|
17
|
+
end
|
18
|
+
end
|
19
|
+
year = date.year % 100
|
20
|
+
if ml.last[2] < "K" and date.month > 9
|
21
|
+
"#{ml.last}#{year + 1}"
|
22
|
+
else
|
23
|
+
"#{ml.last}#{year}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
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.14
|
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
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/cotcube-bardata/provide.rb
|
176
176
|
- lib/cotcube-bardata/quarters.rb
|
177
177
|
- lib/cotcube-bardata/range_matrix.rb
|
178
|
+
- lib/cotcube-bardata/suggest.rb
|
178
179
|
- lib/cotcube-bardata/trade_dates.rb
|
179
180
|
- lib/cotcube-bardata/trading_hours.rb
|
180
181
|
homepage: https://github.com/donkeybridge/cotcube-bardata
|