rupee 0.1.8 → 0.1.9
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.
- data/.gitignore +1 -0
- data/README.rdoc +24 -2
- data/Rakefile +14 -0
- data/lib/rupee/version.rb +1 -1
- data/rupee.gemspec +3 -2
- data/spec/{c → native}/bond_spec.rb +0 -0
- data/spec/{c → native}/future_spec.rb +0 -0
- data/spec/{c → native}/option_spec.rb +0 -0
- data/spec/{c → native}/statistics_spec.rb +0 -0
- data/tasks/benchmark.rake +41 -42
- data/test_rubies +21 -0
- metadata +25 -14
- data/COPYING +0 -19
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -79,9 +79,9 @@ call option with Black-Scholes 100,000 times. You can test the same on yours
|
|
79
79
|
with rake, but in any case it makes the point that for the mathematical side
|
80
80
|
of finance a native extension has substantial benefits:
|
81
81
|
|
82
|
-
rake benchmark
|
82
|
+
rake benchmark
|
83
83
|
|
84
|
-
Results:
|
84
|
+
Results for Black-Scholes:
|
85
85
|
|
86
86
|
user system total real
|
87
87
|
Rupee (class): 0.190000 0.000000 0.190000 ( 0.194001)
|
@@ -102,3 +102,25 @@ However, if you're creating and reusing an object, I strongly recommend
|
|
102
102
|
preserving the object orientation of Ruby: the penalty for using a new instance
|
103
103
|
rather than calling the class method directly is almost entirely in the object
|
104
104
|
initialization itself.
|
105
|
+
|
106
|
+
== License
|
107
|
+
|
108
|
+
Copyright (c) 2011 Bryan McKelvey
|
109
|
+
|
110
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
111
|
+
this software and associated documentation files (the "Software"), to deal in
|
112
|
+
the Software without restriction, including without limitation the rights to
|
113
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
114
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
115
|
+
so, subject to the following conditions:
|
116
|
+
|
117
|
+
The above copyright notice and this permission notice shall be included in all
|
118
|
+
copies or substantial portions of the Software.
|
119
|
+
|
120
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
121
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
122
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
123
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
124
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
125
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
126
|
+
SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "rdoc/task"
|
3
|
+
require "sdoc"
|
2
4
|
|
3
5
|
Dir["tasks/**/*.rake"].each do |rake|
|
4
6
|
load File.expand_path(rake)
|
5
7
|
end
|
8
|
+
|
9
|
+
RDoc::Task.new do |rdoc|
|
10
|
+
rdoc.main = "README.rdoc"
|
11
|
+
rdoc.rdoc_dir = "doc"
|
12
|
+
rdoc.rdoc_files.include "README.rdoc"
|
13
|
+
rdoc.rdoc_files.include "ext/**/*.{c, h, rb}"
|
14
|
+
rdoc.rdoc_files.include "lib/**/*.rb"
|
15
|
+
rdoc.options << "-f" << "sdoc"
|
16
|
+
rdoc.options << "-c" << "utf-8"
|
17
|
+
rdoc.options << "-g"
|
18
|
+
rdoc.options << "-m" << "README.rdoc"
|
19
|
+
end
|
data/lib/rupee/version.rb
CHANGED
data/rupee.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.extensions = "ext/rupee/extconf.rb"
|
25
25
|
s.require_paths = ["lib", "ext"]
|
26
26
|
|
27
|
-
s.add_development_dependency "bundler",
|
28
|
-
s.add_development_dependency "rspec",
|
27
|
+
s.add_development_dependency "bundler", "~> 1.0"
|
28
|
+
s.add_development_dependency "rspec", "~> 2.0"
|
29
|
+
s.add_development_dependency "sdoc", "~> 0.3"
|
29
30
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/tasks/benchmark.rake
CHANGED
@@ -1,53 +1,52 @@
|
|
1
1
|
autoload :Benchmark, "benchmark"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
3
|
+
desc "Run some tests comparing native C implementations vs pure Ruby"
|
4
|
+
task :benchmark do
|
5
|
+
require "rupee"
|
6
|
+
require "rupee/benchmark"
|
7
|
+
|
8
|
+
n = 100_000
|
9
|
+
|
10
|
+
puts "Black-Scholes (#{n.to_s.gsub /(\d)(?=(\d\d\d)+(?!\d))/, "\\1,"} times)"
|
11
|
+
|
12
|
+
Benchmark.bm(19) do |x|
|
13
|
+
x.report "Rupee (class):" do
|
14
|
+
n.times do
|
15
|
+
Rupee::Option.black_scholes "c", 60, 65, 0.25, 0.08, 0, 0.3
|
17
16
|
end
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
19
|
+
x.report "Rupee (one object):" do
|
20
|
+
call = Rupee::Call.new(
|
21
|
+
:underlying => 60,
|
22
|
+
:strike => 65,
|
23
|
+
:time => 0.25,
|
24
|
+
:rate => 0.08,
|
25
|
+
:div_yield => 0.00,
|
26
|
+
:volatility => 0.3
|
27
|
+
)
|
28
|
+
|
29
|
+
n.times do
|
30
|
+
call.black_scholes
|
32
31
|
end
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
34
|
+
x.report "Rupee (new object):" do
|
35
|
+
n.times do
|
36
|
+
Rupee::Call.new(
|
37
|
+
:underlying => 60,
|
38
|
+
:strike => 65,
|
39
|
+
:time => 0.25,
|
40
|
+
:rate => 0.08,
|
41
|
+
:div_yield => 0.00,
|
42
|
+
:volatility => 0.3
|
43
|
+
).black_scholes
|
45
44
|
end
|
45
|
+
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
47
|
+
x.report("Pure Ruby:") do
|
48
|
+
n.times do
|
49
|
+
Rupee::Benchmark.black_scholes "c", 60, 65, 0.25, 0.08, 0.3
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
data/test_rubies
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
echo "Installing and running RSpec tests on all supported Rubies..."
|
3
|
+
|
4
|
+
# Save current Ruby in use under RVM
|
5
|
+
CURRENT=`rvm current`
|
6
|
+
|
7
|
+
# Prints the name of the Ruby, sets it to use under RVM, installs, tests
|
8
|
+
function test_ruby {
|
9
|
+
echo -e "\n\033[1m$1\033[0m"
|
10
|
+
rvm use $1
|
11
|
+
rake install
|
12
|
+
rspec spec
|
13
|
+
}
|
14
|
+
|
15
|
+
# Run tests on these versions
|
16
|
+
test_ruby 1.8.7
|
17
|
+
test_ruby 1.9.2
|
18
|
+
test_ruby 1.9.3
|
19
|
+
|
20
|
+
# Restore original Ruby in use
|
21
|
+
rvm use $CURRENT
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rupee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &72675190 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *72675190
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &72674810 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,18 @@ dependencies:
|
|
32
32
|
version: '2.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *72674810
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sdoc
|
38
|
+
requirement: &72674470 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.3'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *72674470
|
36
47
|
description: ! " rupee aims to provide user-friendly tools for
|
37
48
|
use in\n financial gems and applications.\n"
|
38
49
|
email:
|
@@ -45,7 +56,6 @@ files:
|
|
45
56
|
- .autotest
|
46
57
|
- .gitignore
|
47
58
|
- .rspec
|
48
|
-
- COPYING
|
49
59
|
- Gemfile
|
50
60
|
- README.rdoc
|
51
61
|
- Rakefile
|
@@ -65,13 +75,14 @@ files:
|
|
65
75
|
- lib/rupee/security.rb
|
66
76
|
- lib/rupee/version.rb
|
67
77
|
- rupee.gemspec
|
68
|
-
- spec/c/bond_spec.rb
|
69
|
-
- spec/c/future_spec.rb
|
70
|
-
- spec/c/option_spec.rb
|
71
|
-
- spec/c/statistics_spec.rb
|
72
78
|
- spec/import/quote_spec.rb
|
79
|
+
- spec/native/bond_spec.rb
|
80
|
+
- spec/native/future_spec.rb
|
81
|
+
- spec/native/option_spec.rb
|
82
|
+
- spec/native/statistics_spec.rb
|
73
83
|
- spec/spec_helper.rb
|
74
84
|
- tasks/benchmark.rake
|
85
|
+
- test_rubies
|
75
86
|
homepage: https://github.com/brymck/rupee
|
76
87
|
licenses: []
|
77
88
|
post_install_message:
|
@@ -98,8 +109,8 @@ signing_key:
|
|
98
109
|
specification_version: 3
|
99
110
|
summary: Financial tools for Ruby
|
100
111
|
test_files:
|
101
|
-
- spec/c/bond_spec.rb
|
102
|
-
- spec/c/future_spec.rb
|
103
|
-
- spec/c/option_spec.rb
|
104
|
-
- spec/c/statistics_spec.rb
|
105
112
|
- spec/import/quote_spec.rb
|
113
|
+
- spec/native/bond_spec.rb
|
114
|
+
- spec/native/future_spec.rb
|
115
|
+
- spec/native/option_spec.rb
|
116
|
+
- spec/native/statistics_spec.rb
|
data/COPYING
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Bryan McKelvey
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
-
this software and associated documentation files (the "Software"), to deal in
|
5
|
-
the Software without restriction, including without limitation the rights to
|
6
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
-
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
-
so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
11
|
-
copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
SOFTWARE.
|