enterprice 0.0.1
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 +7 -0
- data/lib/enterprice.rb +3 -0
- data/lib/enterprice/io/candle_stream.rb +62 -0
- data/lib/enterprice/version.rb +4 -0
- data/lib/version.rb +3 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8ceae7c9adf506774456b21345c7fb8a0f244f6
|
4
|
+
data.tar.gz: c10118766221227fc7d30ba2809d9ae05060fe0c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4e24e93ba9b19a4726e43091808c4f7dcacf1e76afc8dd39865e87784d8b6c0cff030b5b189a9261db253b4fffd4a6c158003f1de02270db970a9d32ba52dd3
|
7
|
+
data.tar.gz: b3dae7005ad2627453d416e7e1c5dd75d46010bcea091be28db6d376149e49a889eb81863e49143ba550d757241503030b2edf46dbe7ba1a349c8d8a829c663d
|
data/lib/enterprice.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
3
|
+
module Enterprice; module IO
|
4
|
+
|
5
|
+
class CandleStream
|
6
|
+
attr_accessor :period
|
7
|
+
|
8
|
+
def self.start(period, &block)
|
9
|
+
CandleStream.new(period, block)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(period, block)
|
13
|
+
@pivot= nil
|
14
|
+
@open= nil
|
15
|
+
@period= period
|
16
|
+
@prev_close= 0.0
|
17
|
+
@block= block
|
18
|
+
reset_state
|
19
|
+
end
|
20
|
+
|
21
|
+
def << (row)
|
22
|
+
ts, price, amount= row
|
23
|
+
@pivot||= ts
|
24
|
+
@open||= price
|
25
|
+
|
26
|
+
if ts> @pivot+ @period- 1
|
27
|
+
call
|
28
|
+
@prev_close= @close
|
29
|
+
reset_state
|
30
|
+
@pivot+= @period
|
31
|
+
end
|
32
|
+
|
33
|
+
while ts> @pivot+ @period- 1
|
34
|
+
@block.call [@pivot, @prev_close, @prev_close, @prev_close, @prev_close, 0]
|
35
|
+
@pivot+= @period
|
36
|
+
end
|
37
|
+
|
38
|
+
if ts< @pivot+ @period
|
39
|
+
@open= @prev_close if @prev_close!= 0.0
|
40
|
+
@high= price if price> @high
|
41
|
+
@low= price if price< @low
|
42
|
+
@close= price
|
43
|
+
@volume+= amount
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def call
|
48
|
+
@block.call [@pivot, @open, @high, @low, @close, @volume]
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def reset_state
|
53
|
+
@high= 0.0
|
54
|
+
@low= 1000000.0
|
55
|
+
@close= 0.0
|
56
|
+
@volume= 0.0
|
57
|
+
end
|
58
|
+
end # Enterprise::CandleStream
|
59
|
+
|
60
|
+
end # IO
|
61
|
+
end # Enterprise
|
62
|
+
|
data/lib/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: enterprice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nurettin Onur TUĞCU
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This gem provides utilities and methods I use when inspecting time series
|
14
|
+
on remote machines.
|
15
|
+
email: onur.tugcu@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/enterprice.rb
|
21
|
+
- lib/enterprice/io/candle_stream.rb
|
22
|
+
- lib/enterprice/version.rb
|
23
|
+
- lib/version.rb
|
24
|
+
homepage: https://github.com/nurettin/enterprice
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.2.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Programming utilities for quantitative trading
|
48
|
+
test_files: []
|