enterprice 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: d8ceae7c9adf506774456b21345c7fb8a0f244f6
4
- data.tar.gz: c10118766221227fc7d30ba2809d9ae05060fe0c
3
+ metadata.gz: bb55cb6cedea5c06742f187b6c905d6610a7bf19
4
+ data.tar.gz: bc13d1c54681b5f71eb2883981da86ea90549387
5
5
  SHA512:
6
- metadata.gz: f4e24e93ba9b19a4726e43091808c4f7dcacf1e76afc8dd39865e87784d8b6c0cff030b5b189a9261db253b4fffd4a6c158003f1de02270db970a9d32ba52dd3
7
- data.tar.gz: b3dae7005ad2627453d416e7e1c5dd75d46010bcea091be28db6d376149e49a889eb81863e49143ba550d757241503030b2edf46dbe7ba1a349c8d8a829c663d
6
+ metadata.gz: 02e98c681b370c953bf79d5fadb39e8eaf7b4cd3ea9f363995ea32dfd743c3bbeb2c5c88ee5cc80d3171833af505df099c625965494d0622df35cbd6e6f9e879
7
+ data.tar.gz: 4d2c14cac62102ea4e1b4be028e2127ad679bad5077cb46f5702927a6722d2c7a9ffaa7332ed0d4cf538b1df27b980d1d629923dfe4676ee82d485690767cf45
@@ -1,5 +1,3 @@
1
- require "csv"
2
-
3
1
  module Enterprice; module IO
4
2
 
5
3
  class CandleStream
@@ -31,7 +29,7 @@ class CandleStream
31
29
  end
32
30
 
33
31
  while ts> @pivot+ @period- 1
34
- @block.call [@pivot, @prev_close, @prev_close, @prev_close, @prev_close, 0]
32
+ call_blank
35
33
  @pivot+= @period
36
34
  end
37
35
 
@@ -48,12 +46,16 @@ class CandleStream
48
46
  @block.call [@pivot, @open, @high, @low, @close, @volume]
49
47
  end
50
48
 
49
+ def call_blank
50
+ @block.call [@pivot, @prev_close, @prev_close, @prev_close, @prev_close, 0]
51
+ end
52
+
51
53
  private
52
54
  def reset_state
53
- @high= 0.0
54
- @low= 1000000.0
55
- @close= 0.0
56
- @volume= 0.0
55
+ @high= -Float::INFINITY
56
+ @low= Float::INFINITY
57
+ @close= -Float::INFINITY
58
+ @volume= 0
57
59
  end
58
60
  end # Enterprise::CandleStream
59
61
 
@@ -0,0 +1,28 @@
1
+ require_relative './named_candle_stream'
2
+
3
+ module Enterprice; module IO
4
+
5
+ class MultiCandleStream
6
+ attr_accessor :streams
7
+ attr_accessor :period
8
+ attr_accessor :block
9
+
10
+ def initialize(period, block)
11
+ @streams= {}
12
+ @period= period
13
+ @block= block
14
+ end
15
+
16
+ def << (row)
17
+ if @streams[row[0]].nil?
18
+ @streams[row[0]]= NamedCandleStream.new(@period, row[0], @block)
19
+ end
20
+ @streams[row[0]]<< row[1..-1]
21
+ end
22
+
23
+ def self.start(period, &block)
24
+ MultiCandleStream.new(period, block)
25
+ end
26
+ end
27
+
28
+ end; end
@@ -0,0 +1,22 @@
1
+ require_relative './candle_stream'
2
+
3
+ module Enterprice; module IO
4
+
5
+ class NamedCandleStream< Enterprice::IO::CandleStream
6
+ attr_accessor :name
7
+
8
+ def initialize(period, name, block)
9
+ @name= name
10
+ super(period, block)
11
+ end
12
+
13
+ def call
14
+ @block.call [@name, @pivot, @open, @high, @low, @close, @volume]
15
+ end
16
+
17
+ def call_blank
18
+ @block.call [@name, @pivot, @prev_close, @prev_close, @prev_close, @prev_close, 0]
19
+ end
20
+ end
21
+
22
+ end; end
@@ -1,3 +1,3 @@
1
1
  module Enterprice
2
- VERSION= "0.0.1"
2
+ VERSION= "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enterprice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nurettin Onur TUĞCU
@@ -19,6 +19,8 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - lib/enterprice.rb
21
21
  - lib/enterprice/io/candle_stream.rb
22
+ - lib/enterprice/io/multi_candle_stream.rb
23
+ - lib/enterprice/io/named_candle_stream.rb
22
24
  - lib/enterprice/version.rb
23
25
  - lib/version.rb
24
26
  homepage: https://github.com/nurettin/enterprice