financial_maths 0.0.4 → 0.0.5

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/.DS_Store ADDED
Binary file
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem install bundler
4
+ - gem update --system
5
+ - gem --version
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source 'https://rubygems.org'
1
+ source 'http://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in financial_maths.gemspec
4
4
  gemspec
5
+ gem 'rspec'
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # FinancialMaths
2
-
2
+ [![Build Status](https://travis-ci.org/rderoldan1/financial_maths.png?branch=master)](https://travis-ci.org/rderoldan1/financial_maths)
3
3
  more functions will be added soon
4
4
 
5
5
  #### New in version 0.0.4
@@ -22,7 +22,7 @@ more functions will be added soon
22
22
 
23
23
  #### Pending
24
24
  1. include more functions
25
- 3. add some test units
25
+ 3. add some unit tests
26
26
 
27
27
  ## Installation
28
28
 
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ task :default => :spec
@@ -1,3 +1,3 @@
1
1
  module FinancialMaths
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -2,27 +2,44 @@ require "financial_maths/version"
2
2
 
3
3
  module FinancialMaths
4
4
 
5
- def variable_payment_amortization(periods, amount, rate)
6
-
7
- monthly_payments = amount/periods
5
+ def due_variable_payment_amortization(periods, amount, rate, payment)
8
6
  result = []
9
7
  result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
10
8
 
11
9
  for i in 1..periods
12
10
  interest = amount * rate
13
- month_payment = monthly_payments + interest
14
- amount -= monthly_payments
11
+ month_payment = payment + interest
12
+ amount -= payment
15
13
  #date += 1
16
14
  result << {:period=> i,
17
15
  :payment => month_payment,
18
16
  :interest => interest,
19
- :monthly_payment => monthly_payments,
17
+ :monthly_payment => payment,
20
18
  :balance => amount}
21
19
  end
22
20
  result
23
21
  end
24
22
 
25
- def fixed_payment_amortization(periods, amount, rate, payment)
23
+ def anticipated_variable_payment_amortization(periods, amount, rate, payment)
24
+ result = []
25
+ #result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
26
+
27
+ for i in 0..periods-1
28
+ interest = amount * rate
29
+ month_payment = payment + interest
30
+ amount -= payment
31
+ #date += 1
32
+ result << {:period=> i,
33
+ :payment => month_payment,
34
+ :interest => interest,
35
+ :monthly_payment => payment,
36
+ :balance => amount}
37
+ end
38
+ result
39
+ end
40
+
41
+
42
+ def due_fixed_payment_amortization(periods, amount, rate, payment)
26
43
  result = []
27
44
  result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
28
45
 
@@ -40,6 +57,24 @@ module FinancialMaths
40
57
  result
41
58
  end
42
59
 
60
+ def anticipated_fixed_payment_amortization(periods, amount, rate, payment)
61
+ result = []
62
+ #result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
63
+
64
+ for i in 0..periods-1
65
+ interest = amount * rate
66
+ month_payment = payment - interest
67
+ amount -= month_payment
68
+ #date += 1
69
+ result << {:period=> i,
70
+ :payment => payment,
71
+ :interest => interest,
72
+ :monthly_payment => month_payment,
73
+ :balance => amount}
74
+ end
75
+ result
76
+ end
77
+
43
78
  # hallar futuro dado el valor presente HFDP
44
79
  def future_given_present(present_value, interest, term)
45
80
  (present_value.to_f * (1 + interest.to_f) ** term).round(4)
@@ -74,25 +109,29 @@ module FinancialMaths
74
109
  # hallar tasa efectiva dado la tasa nominal vencida NVEF
75
110
  def efective_given_nominal_due(nominal_rate, term)
76
111
  (((1 + nominal_rate.to_f) ** term)-1).round(4)
77
- end
112
+ end
78
113
 
79
- # hallar tasa efectiva dado la tasa nominal anticipada NAEF
80
- def efective_given_nominal_antipipated(nominal_rate, term)
81
- (1 / ((1 - nominal_rate.to_f) ** term)).round(4) - 1
82
- end
114
+ # hallar tasa efectiva dado la tasa nominal anticipada NAEF
115
+ def efective_given_nominal_antipipated(nominal_rate, term)
116
+ (1 / ((1 - nominal_rate.to_f) ** term)).round(4) - 1
117
+ end
83
118
 
84
- # hallar tasa nominal anticipada dado efectiva EFNV
85
- def nominal_antipiated_given_efective(nominal_rate, term)
86
- (1 - (1 / (1 + nominal_rate.to_f) ** (1 / term))).round(4)
87
- end
119
+ # hallar tasa nominal anticipada dado efectiva EFNV
120
+ def nominal_antipiated_given_efective(nominal_rate, term)
121
+ (1 - (1 / (1 + nominal_rate.to_f) ** (1 / term))).round(4)
122
+ end
88
123
 
89
- # hallar tasa nominal anticipada dado efectiva EFNV
90
- def nominal_due_given_efective(nominal_rate, term)
91
- ((nominal_rate.to_f + 1) ** (1 / term)).round(4)
92
- end
93
- # Hallar la cuota fija anticipada HCFA
94
- def anticipated_fixed_payment(present_value, rate, term)
95
- ((present_value.to_f * rate.to_f) / ((rate.to_f + 1) - (1 / (1 + rate) ** (term - 1)))).round(4)
124
+ # hallar tasa nominal anticipada dado efectiva EFNV
125
+ def nominal_due_given_efective(nominal_rate, term)
126
+ ((nominal_rate.to_f + 1) ** (1 / term)).round(4)
127
+ end
128
+ # Hallar la cuota fija anticipada HCFA
129
+ def anticipated_fixed_payment(present_value, rate, term)
130
+ ((present_value.to_f * rate.to_f) / ((rate.to_f + 1) - (1 / (1 + rate) ** (term - 1)))).round(4)
131
+ end
132
+
133
+ def variable_payment(amount, periods)
134
+ amount.to_f / periods
96
135
  end
97
136
 
98
137
 
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'financial_maths'
4
+
5
+ include FinancialMaths
6
+ RSpec.configure do |config|
7
+
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+
4
+ describe "fixed payment test" do
5
+
6
+ it 'should be the monthly payment' do
7
+
8
+ annuity_given_present(100000000, 0.0144594763, 180).should eq(1563975.1395)
9
+
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+
4
+ describe "My behaviour" do
5
+
6
+ it 'should be the version' do
7
+ FinancialMaths::VERSION.should_not be_nil
8
+ end
9
+ end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: financial_maths
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ruben Espinosa
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -46,7 +51,10 @@ extensions: []
46
51
  extra_rdoc_files:
47
52
  - README.md
48
53
  files:
54
+ - .DS_Store
49
55
  - .gitignore
56
+ - .rspec
57
+ - .travis.yml
50
58
  - Gemfile
51
59
  - LICENSE.txt
52
60
  - README.md
@@ -54,29 +62,42 @@ files:
54
62
  - financial_maths.gemspec
55
63
  - lib/financial_maths.rb
56
64
  - lib/financial_maths/version.rb
65
+ - spec/spec_helper.rb
66
+ - spec/test_payment_spec.rb
67
+ - spec/version_spec.rb
57
68
  homepage: https://github.com/rderoldan1/financial_maths
58
69
  licenses:
59
70
  - MIT
60
- metadata: {}
61
71
  post_install_message: thanks to install financial_maths gem, I hope improve this gem
62
72
  soon!
63
73
  rdoc_options: []
64
74
  require_paths:
65
75
  - lib
66
76
  required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
67
78
  requirements:
68
79
  - - ! '>='
69
80
  - !ruby/object:Gem::Version
70
81
  version: '0'
82
+ segments:
83
+ - 0
84
+ hash: 3283559787131876594
71
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
72
87
  requirements:
73
88
  - - ! '>='
74
89
  - !ruby/object:Gem::Version
75
90
  version: '0'
91
+ segments:
92
+ - 0
93
+ hash: 3283559787131876594
76
94
  requirements: []
77
95
  rubyforge_project:
78
- rubygems_version: 2.0.0
96
+ rubygems_version: 1.8.25
79
97
  signing_key:
80
- specification_version: 4
98
+ specification_version: 3
81
99
  summary: calculate loan payments and other things
82
- test_files: []
100
+ test_files:
101
+ - spec/spec_helper.rb
102
+ - spec/test_payment_spec.rb
103
+ - spec/version_spec.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDgyOTgxM2ZiMDRkMzJlZTBkMmQwMWIwZDk1OGQyZGM4YzdkOWM3NQ==
5
- data.tar.gz: !binary |-
6
- YjcwNWJlYzRhOGRlMWVlM2I4Y2E1ODBjMWRjODUyOTZhNTM5MzAzMA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZDQ1MDE4YjNiZTFkZWQ2YTgxMWQwYTE4ZmUyZTdlY2NkOGRjY2FhY2FlYWEz
10
- ZmQ4OGJiOTljNWQ3ZGExNzI3YTE3ZWQ0OGJlNDAwMzk5NjQ3YTE1YzBhMTYy
11
- ZWQ1MzIyMWIyOTk5ZGM1MDBmNjNiZTM0NmFmMmFhOGY5YTI5OTM=
12
- data.tar.gz: !binary |-
13
- YjkzYmM1NTliMmViZGRlNWU0ZWU0MjRiYTNiNWI4ODNiMjdjODhiMTc5Mjgy
14
- NjcxZmEzMDlkNWIxOWU5ODhkNzM0MjFiMzUwODkxMzM5ZjgwZTkxNjRkZWRl
15
- MjRiZWI3NmRiOGFkNjNiZjc2NmRiOTNiOTJiODZhMTBiNDQwOWQ=