cotcube-dataproxy 0.1.1 → 0.1.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: 9edcf5e59cffe3a7dbb7a03c8896da6cd98ecb288dfc648297e06c64bd0b3314
4
- data.tar.gz: 3701e4dc24d822c7349015ff4d3e5bcd28dea57d126905016706c276ee088136
3
+ metadata.gz: 82334ed8c2a2bdb18dd9a0338d24867bfb6477b648d10fd51439fcfa7503c298
4
+ data.tar.gz: 8104e6d40180b2738507abadd1422288cfd2e60220e7d10c5dbf78ede6f0387a
5
5
  SHA512:
6
- metadata.gz: cf474143f34f1d81f148f1a72986d1c575f3407a19e4494c9fa6e0e08be18b90bf5057bf4f248667a6bcbd9812e32d9cb6e75a75343e05c765dd7ab9cc5c6ddf
7
- data.tar.gz: 14599b72e780bcf9a942f70448ed1fdaf5ee9aad649b30c3701f056802fb3ea44275d6c47dee5e05da94eb8ed23620d393e14ec96c8ed347b33ad54c2f8db640
6
+ metadata.gz: b8b14427fb654780a1653348d31e9ecc3e65fe5f9d04b5508f625a77a42c7c633165a059705175b4199633887e3bb3cd8f38c2f090c698399117e32606d1692b
7
+ data.tar.gz: 0d77a939e81396c754c39a5e3d74d9bcad075c0875b20ca006f0a50388efe1e850a157830d82d9161d17270134493d34ac2f3e1250ac9a5ba0b7838fdcad5693
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.1.2 (November 28, 2021)
2
+ - subscribers/historical: returning improved values hash
3
+ - added validator for contract to sub historical
4
+ - client_response: improvied log output
5
+ - 3rd-clients: removed auto-delete (due to working GC)
6
+
1
7
  ## 0.1.1 (November 13, 2021)
2
8
  - added handy test_script in bin/test_client.rb
3
9
  - added httparty to Gem requirements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -47,8 +47,8 @@ module Cotcube
47
47
  obj[:commands] = obj[:connection].create_channel
48
48
  obj[:channel] = obj[:connection].create_channel
49
49
  obj[:request_queue] = obj[:commands].queue('', exclusive: true, auto_delete: true)
50
- obj[:request_exch] = obj[:commands].direct('dataproxy_commands', exclusive: true, auto_delete: true)
51
- obj[:replies_exch] = obj[:commands].direct('dataproxy_replies', auto_delete: true)
50
+ obj[:request_exch] = obj[:commands].direct('dataproxy_commands')
51
+ obj[:replies_exch] = obj[:commands].direct('dataproxy_replies')
52
52
  %w[ dataproxy_commands ].each do |key|
53
53
  obj[:request_queue].bind(obj[:request_exch], routing_key: key )
54
54
  end
@@ -27,11 +27,11 @@ module Cotcube
27
27
  response = { error: 1, msg: "Processing failed for '#{msg.inspect}' after '#{request}'." }
28
28
  end
29
29
  if response[:error] == 1
30
- log "CLIENT #{id} FAILIURE: #{response.inspect}.".colorize(:light_red)
30
+ log "CLIENT #{__id__} FAILIURE: #{response.inspect}.".colorize(:light_red)
31
31
  elsif response[:result].is_a?(Array)
32
- log "CLIENT #{id} SUCCESS: sent #{response[:result].size} datasets."
32
+ log "CLIENT #{__id__} SUCCESS: sent #{response[:result].size} datasets."
33
33
  else
34
- log "CLIENT #{id} SUCCESS: #{response.to_s.scan(/.{1,120}/).join(' '*30 + "\n")}"
34
+ log "CLIENT #{__id__} SUCCESS: #{response.to_s[..220].scan(/.{1,120}/).join(' '*30 + "\n")}"
35
35
  end
36
36
  mq[exchange].publish(
37
37
  response.to_json,
@@ -75,6 +75,10 @@ module Cotcube
75
75
  # the IB message 'HistoricalData' in message subscribers section
76
76
  #
77
77
  when Cotcube::Helpers.sub(minimum: 3) {'historical'}
78
+ unless request[:contract].is_a? String and request[:contract].size == 5
79
+ client_fail(request) { "IB needs complete contract information to request data, e.g. ESZ21 instead of ES, got '#{request[:contract]}' in '#{request}'." }
80
+ next
81
+ end
78
82
  con_id = request[:con_id] || Cotcube::Helpers.get_ib_contract(request[:contract])[:con_id] rescue nil
79
83
  if con_id.nil? or request[:contract].nil?
80
84
  client_fail(request) { "Cannot get :con_id for contract:'#{request[:contract]}' in '#{request}'." }
@@ -85,6 +89,8 @@ module Cotcube
85
89
  ib_contract = IB::Contract.new(con_id: con_id, exchange: sym[:exchange])
86
90
  req = {
87
91
  request_id: request[:__id__].to_i(16),
92
+ symbol: sym[:symbol],
93
+ sym: sym,
88
94
  contract: ib_contract,
89
95
  end_date_time: before,
90
96
  what_to_show: (request[:based_on] || :trades),
@@ -39,7 +39,15 @@ module Cotcube
39
39
  case msg
40
40
 
41
41
  when IB::Messages::Incoming::HistoricalData
42
- client_success(requests[__id__]) { msg.results }
42
+ client_success(requests[__id__]) {
43
+ {
44
+ symbol: requests[__id__][:contract][..1],
45
+ contract: requests[__id__][:contract],
46
+ base: msg.results.map{|z|
47
+ z.attributes.tap{|z1| z1.delete(:created_at) }
48
+ }
49
+ }
50
+ }
43
51
  req_mon.synchronize { requests.delete(__id__) }
44
52
 
45
53
  when IB::Messages::Incoming::Alert # Alert
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cotcube-dataproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.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-13 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport