ticks_to_candle 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +9 -0
- data/bin/ticks2c +19 -0
- data/lib/ticks_to_candle.rb +6 -0
- data/lib/ticks_to_candle/candle.rb +12 -0
- data/lib/ticks_to_candle/ticks.rb +16 -0
- data/lib/ticks_to_candle/version.rb +3 -0
- data/test/minitest_helper.rb +4 -0
- data/test/test_candle.rb +41 -0
- data/test/test_ticks.rb +23 -0
- data/ticks_to_candle.gemspec +24 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 036aa54adb445bedbd169d6e8ad53a16002407d8
|
4
|
+
data.tar.gz: ed9fd63f0b35590861be309c9c89d753801c8010
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5911410819adba4275a51849cb69d06904dd5e7d31c55d062f977d8f088f9a90c4eb8728dfb0e84cfd297cd7df9d26083fb6c66e41f7df9de098a3d599656193
|
7
|
+
data.tar.gz: 0de90bf0f78d61831d0b1c44208a86582e297280065d6a45ce4f18f8319599c9cd9c84503439ee38fc459517d55354b1d21a43edbac2ea212d8d4aa84ea5b085
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Shinya131
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# TicksToCandle
|
2
|
+
|
3
|
+
Generate candlestic data from ticks data.
|
4
|
+
candlestic data has opening_price, closing_price, low_price, high_price.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'ticks_to_candle'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install ticks_to_candle
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### use by ARGV
|
25
|
+
|
26
|
+
```
|
27
|
+
$ ticks2c 100.0,120.0,130.0,140.0,150.0,120.0,100.0,90.0
|
28
|
+
{:high_price=>150, :low_price=>90, :opening_price=>100, :closing_price=>90}
|
29
|
+
```
|
30
|
+
|
31
|
+
### use by STDIN
|
32
|
+
|
33
|
+
```
|
34
|
+
$ ticks2c
|
35
|
+
100
|
36
|
+
200
|
37
|
+
50
|
38
|
+
200
|
39
|
+
210
|
40
|
+
190
|
41
|
+
180
|
42
|
+
170
|
43
|
+
160
|
44
|
+
|
45
|
+
{:high_price=>210, :low_price=>50, :opening_price=>100, :closing_price=>160}
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it ( https://github.com/[my-github-username]/ticks_to_candle/fork )
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/ticks2c
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'ticks_to_candle'
|
4
|
+
|
5
|
+
if !ARGV.empty?
|
6
|
+
ticks = ARGV.first.split(",").map{|tick|tick.to_i}
|
7
|
+
else
|
8
|
+
ticks = []
|
9
|
+
|
10
|
+
while tick = $stdin.gets do
|
11
|
+
if tick == "\n"
|
12
|
+
break
|
13
|
+
end
|
14
|
+
|
15
|
+
ticks << tick.to_i
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
puts TicksToCandle::Ticks.new(*ticks).to_candle.to_hash
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class TicksToCandle::Ticks
|
2
|
+
def initialize(*ticks)
|
3
|
+
@ticks = ticks
|
4
|
+
end
|
5
|
+
|
6
|
+
def to_candle
|
7
|
+
candle = TicksToCandle::Candle.new
|
8
|
+
|
9
|
+
candle.high_price = @ticks.max
|
10
|
+
candle.low_price = @ticks.min
|
11
|
+
candle.opening_price = @ticks.first
|
12
|
+
candle.closing_price = @ticks.last
|
13
|
+
|
14
|
+
candle
|
15
|
+
end
|
16
|
+
end
|
data/test/test_candle.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe TicksToCandle::Candle do
|
4
|
+
describe '#initialize' do
|
5
|
+
before do
|
6
|
+
@ticks = [100.0, 120.0, 150.0, 90.0, 110.0]
|
7
|
+
@candle = TicksToCandle::Ticks.new(*@ticks).to_candle
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'has high_price' do
|
11
|
+
assert @candle.high_price == @ticks.max
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has low_price' do
|
15
|
+
assert @candle.low_price == @ticks.min
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'has opening_price' do
|
19
|
+
assert @candle.opening_price == @ticks.first
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has closing_price' do
|
23
|
+
assert @candle.closing_price == @ticks.last
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#to_hash' do
|
28
|
+
before do
|
29
|
+
@ticks = [100.0, 120.0, 150.0, 90.0, 110.0]
|
30
|
+
@candle = TicksToCandle::Ticks.new(*@ticks).to_candle
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'has prices' do
|
34
|
+
candle_hash = @candle.to_hash
|
35
|
+
assert candle_hash[:high_price] == @candle.high_price
|
36
|
+
assert candle_hash[:low_price] == @candle.low_price
|
37
|
+
assert candle_hash[:opening_price] == @candle.opening_price
|
38
|
+
assert candle_hash[:closing_price] == @candle.closing_price
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/test/test_ticks.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe TicksToCandle::Ticks do
|
4
|
+
describe '#initialize' do
|
5
|
+
before do
|
6
|
+
@ticks = TicksToCandle::Ticks.new(100.0, 120.0, 150.0, 90.0, 110.0)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'instance' do
|
10
|
+
assert @ticks.is_a? TicksToCandle::Ticks
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#to_candle' do
|
15
|
+
before do
|
16
|
+
@ticks = TicksToCandle::Ticks.new(100.0, 120.0, 150.0, 90.0, 110.0)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'is Candle' do
|
20
|
+
assert @ticks.to_candle.is_a? TicksToCandle::Candle
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ticks_to_candle/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ticks_to_candle"
|
8
|
+
spec.version = TicksToCandle::VERSION
|
9
|
+
spec.authors = ["Shinya131"]
|
10
|
+
spec.email = ["nagai3mt5b@gmail.com"]
|
11
|
+
spec.summary = "ticks data to candlestick data"
|
12
|
+
spec.description = "Generate candlestic data from ticks data. candlestic data has opening_price, closing_price, low_price, high_price."
|
13
|
+
spec.homepage = "https://github.com/Shinya131/ticks_to_candle"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ticks_to_candle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shinya131
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Generate candlestic data from ticks data. candlestic data has opening_price,
|
56
|
+
closing_price, low_price, high_price.
|
57
|
+
email:
|
58
|
+
- nagai3mt5b@gmail.com
|
59
|
+
executables:
|
60
|
+
- ticks2c
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/ticks2c
|
71
|
+
- lib/ticks_to_candle.rb
|
72
|
+
- lib/ticks_to_candle/candle.rb
|
73
|
+
- lib/ticks_to_candle/ticks.rb
|
74
|
+
- lib/ticks_to_candle/version.rb
|
75
|
+
- test/minitest_helper.rb
|
76
|
+
- test/test_candle.rb
|
77
|
+
- test/test_ticks.rb
|
78
|
+
- ticks_to_candle.gemspec
|
79
|
+
homepage: https://github.com/Shinya131/ticks_to_candle
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.2.0
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: ticks data to candlestick data
|
103
|
+
test_files:
|
104
|
+
- test/minitest_helper.rb
|
105
|
+
- test/test_candle.rb
|
106
|
+
- test/test_ticks.rb
|