finance_engine 0.0.2 → 0.0.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 910ed68ff0127eccd5709e5ec2df36c7968ea8fe
|
4
|
+
data.tar.gz: 343a02977675f8bacb2745c01a8b2ad75ca2215e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dc680dc8b998586a574905f5eb60c78eb3675dcf535659cc7a7df509d549681c5cac43ec8b40a1185e05f7fa6df98f1594475f25569cb694d2ee6f4a8d91642
|
7
|
+
data.tar.gz: aed0cb3ad69c71250d11a7a8e0d43c589a692ed1b682a573e4bc720e20ebb1c399c11cecfbad86c799f73fb687949eb205e725e06a4164852306335d377c3456
|
Binary file
|
@@ -25,21 +25,21 @@ module FinanceEngine
|
|
25
25
|
elsif years_to_expiration.round(3) > 0
|
26
26
|
create_tree_for_years((years_to_expiration - periods_in_year), periods_in_year, node+'u', price * @up_factor )
|
27
27
|
create_tree_for_years((years_to_expiration - periods_in_year), periods_in_year, node+'d', price * @down_factor)
|
28
|
-
get_put_value(node, periods_in_year)
|
29
|
-
get_call_value(node, periods_in_year)
|
28
|
+
get_put_value(price, node, periods_in_year)
|
29
|
+
get_call_value(price, node, periods_in_year)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def get_put_value(node, periods_in_year)
|
33
|
+
def get_put_value(price, node, periods_in_year)
|
34
34
|
up = @tree[node+'u']['put']
|
35
35
|
down = @tree[node+'d']['put']
|
36
|
-
@tree[node]['put'] = (Math::E**(-@rf* periods_in_year)*(@probability * up)+Math::E**(-@rf* periods_in_year)*((1-@probability) * down)).round(4)
|
36
|
+
@tree[node]['put'] = [put_value(price), (Math::E**(-@rf* periods_in_year)*(@probability * up)+Math::E**(-@rf* periods_in_year)*((1-@probability) * down)).round(4)].max
|
37
37
|
end
|
38
38
|
|
39
|
-
def get_call_value(node, periods_in_year)
|
39
|
+
def get_call_value(price, node, periods_in_year)
|
40
40
|
up = @tree[node+'u']['call']
|
41
41
|
down = @tree[node+'d']['call']
|
42
|
-
@tree[node]['call'] = (Math::E**(-@rf* periods_in_year)*(@probability * up)+Math::E**(-@rf* periods_in_year)*((1-@probability) * down)).round(4)
|
42
|
+
@tree[node]['call'] = [call_value(price), (Math::E**(-@rf* periods_in_year)*(@probability * up)+Math::E**(-@rf* periods_in_year)*((1-@probability) * down)).round(4)].max
|
43
43
|
end
|
44
44
|
|
45
45
|
def put_value(price)
|
@@ -37,6 +37,6 @@ describe FinanceEngine::American_Options do
|
|
37
37
|
first = FinanceEngine::American_Options.new(100,0.3,0.05,100)
|
38
38
|
first.build_american_options(1, 4)
|
39
39
|
expect(first.tree['original_']['put']).to be_within(0.0005).of(13.5240)
|
40
|
-
expect(first.tree['original_']['call']).to be_within(0.0005).of(
|
40
|
+
expect(first.tree['original_']['call']).to be_within(0.0005).of(9.535)
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finance_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey Penkar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- README.md~
|
97
97
|
- Rakefile
|
98
98
|
- finance_engine-0.0.1.gem
|
99
|
+
- finance_engine-0.0.2.gem
|
99
100
|
- finance_engine.gemspec
|
100
101
|
- lib/finance_engine.rb
|
101
102
|
- lib/finance_engine/americanoptionpricing.rb
|