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 +4 -4
- data/lib/enterprice/io/candle_stream.rb +9 -7
- data/lib/enterprice/io/multi_candle_stream.rb +28 -0
- data/lib/enterprice/io/named_candle_stream.rb +22 -0
- data/lib/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb55cb6cedea5c06742f187b6c905d6610a7bf19
|
4
|
+
data.tar.gz: bc13d1c54681b5f71eb2883981da86ea90549387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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=
|
54
|
-
@low=
|
55
|
-
@close=
|
56
|
-
@volume= 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
|
data/lib/version.rb
CHANGED
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.
|
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
|