Skip to content

Commit 174c74d

Browse files
authored
Merge pull request #1 from pazzo83/master
merge upstream
2 parents bebb119 + f63b122 commit 174c74d

File tree

6 files changed

+275
-8
lines changed

6 files changed

+275
-8
lines changed

Manifest.toml

+200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# This file is machine-generated - editing it directly is not advised
2+
3+
[[Arpack]]
4+
deps = ["Arpack_jll", "Libdl", "LinearAlgebra"]
5+
git-tree-sha1 = "2ff92b71ba1747c5fdd541f8fc87736d82f40ec9"
6+
uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
7+
version = "0.4.0"
8+
9+
[[Arpack_jll]]
10+
deps = ["Libdl", "OpenBLAS_jll", "Pkg"]
11+
git-tree-sha1 = "68a90a692ddc0eb72d69a6993ca26e2a923bf195"
12+
uuid = "68821587-b530-5797-8361-c406ea357684"
13+
version = "3.5.0+2"
14+
15+
[[Base64]]
16+
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
17+
18+
[[BinaryProvider]]
19+
deps = ["Libdl", "SHA"]
20+
git-tree-sha1 = "5b08ed6036d9d3f0ee6369410b830f8873d4024c"
21+
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
22+
version = "0.5.8"
23+
24+
[[DataAPI]]
25+
git-tree-sha1 = "674b67f344687a88310213ddfa8a2b3c76cc4252"
26+
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
27+
version = "1.1.0"
28+
29+
[[DataStructures]]
30+
deps = ["InteractiveUtils", "OrderedCollections"]
31+
git-tree-sha1 = "b7720de347734f4716d1815b00ce5664ed6bbfd4"
32+
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
33+
version = "0.17.9"
34+
35+
[[Dates]]
36+
deps = ["Printf"]
37+
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
38+
39+
[[Dierckx]]
40+
deps = ["BinaryProvider", "Libdl", "Random", "Test"]
41+
git-tree-sha1 = "27a74763c20938a814da26f31a9e8408d16fec44"
42+
uuid = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
43+
version = "0.4.1"
44+
45+
[[Distributed]]
46+
deps = ["Random", "Serialization", "Sockets"]
47+
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
48+
49+
[[Distributions]]
50+
deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"]
51+
git-tree-sha1 = "a700a7dfde8bb3859e358b293772c56f5446e4b2"
52+
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
53+
version = "0.22.2"
54+
55+
[[FillArrays]]
56+
deps = ["LinearAlgebra", "Random", "SparseArrays"]
57+
git-tree-sha1 = "fec413d4fc547992eb62a5c544cedb6d7853c1f5"
58+
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
59+
version = "0.8.4"
60+
61+
[[InteractiveUtils]]
62+
deps = ["Markdown"]
63+
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
64+
65+
[[LibGit2]]
66+
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
67+
68+
[[Libdl]]
69+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
70+
71+
[[LinearAlgebra]]
72+
deps = ["Libdl"]
73+
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
74+
75+
[[Logging]]
76+
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
77+
78+
[[Markdown]]
79+
deps = ["Base64"]
80+
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
81+
82+
[[Missings]]
83+
deps = ["DataAPI"]
84+
git-tree-sha1 = "de0a5ce9e5289f27df672ffabef4d1e5861247d5"
85+
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
86+
version = "0.4.3"
87+
88+
[[OpenBLAS_jll]]
89+
deps = ["Libdl", "Pkg"]
90+
git-tree-sha1 = "3a6e5767e8ae022871c19162cc3ecd80748bd3dc"
91+
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
92+
version = "0.3.7+4"
93+
94+
[[OpenSpecFun_jll]]
95+
deps = ["Libdl", "Pkg"]
96+
git-tree-sha1 = "65f672edebf3f4e613ddf37db9dcbd7a407e5e90"
97+
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
98+
version = "0.5.3+1"
99+
100+
[[OrderedCollections]]
101+
deps = ["Random", "Serialization", "Test"]
102+
git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1"
103+
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
104+
version = "1.1.0"
105+
106+
[[PDMats]]
107+
deps = ["Arpack", "LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"]
108+
git-tree-sha1 = "035f8d60ba2a22cb1d2580b1e0e5ce0cb05e4563"
109+
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
110+
version = "0.9.10"
111+
112+
[[Pkg]]
113+
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"]
114+
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
115+
116+
[[Printf]]
117+
deps = ["Unicode"]
118+
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
119+
120+
[[QuadGK]]
121+
deps = ["DataStructures", "LinearAlgebra"]
122+
git-tree-sha1 = "dc84e810393cfc6294248c9032a9cdacc14a3db4"
123+
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
124+
version = "2.3.1"
125+
126+
[[REPL]]
127+
deps = ["InteractiveUtils", "Markdown", "Sockets"]
128+
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
129+
130+
[[Random]]
131+
deps = ["Serialization"]
132+
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
133+
134+
[[Rmath]]
135+
deps = ["BinaryProvider", "Libdl", "Random", "Statistics"]
136+
git-tree-sha1 = "2bbddcb984a1d08612d0c4abb5b4774883f6fa98"
137+
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
138+
version = "0.6.0"
139+
140+
[[SHA]]
141+
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
142+
143+
[[Serialization]]
144+
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
145+
146+
[[Sobol]]
147+
deps = ["Random"]
148+
git-tree-sha1 = "f8afbde90f4e2d5e579dae4b0e71f931b2e194ca"
149+
uuid = "ed01d8cd-4d21-5b2a-85b4-cc3bdc58bad4"
150+
version = "1.3.0"
151+
152+
[[Sockets]]
153+
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
154+
155+
[[SortingAlgorithms]]
156+
deps = ["DataStructures", "Random", "Test"]
157+
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
158+
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
159+
version = "0.3.1"
160+
161+
[[SparseArrays]]
162+
deps = ["LinearAlgebra", "Random"]
163+
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
164+
165+
[[SpecialFunctions]]
166+
deps = ["OpenSpecFun_jll"]
167+
git-tree-sha1 = "268052ee908b2c086cc0011f528694f02f3e2408"
168+
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
169+
version = "0.9.0"
170+
171+
[[Statistics]]
172+
deps = ["LinearAlgebra", "SparseArrays"]
173+
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
174+
175+
[[StatsBase]]
176+
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics"]
177+
git-tree-sha1 = "c53e809e63fe5cf5de13632090bc3520649c9950"
178+
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
179+
version = "0.32.0"
180+
181+
[[StatsFuns]]
182+
deps = ["Rmath", "SpecialFunctions"]
183+
git-tree-sha1 = "79982835d2ff3970685cb704500909c94189bde9"
184+
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
185+
version = "0.9.3"
186+
187+
[[SuiteSparse]]
188+
deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
189+
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
190+
191+
[[Test]]
192+
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
193+
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
194+
195+
[[UUIDs]]
196+
deps = ["Random", "SHA"]
197+
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
198+
199+
[[Unicode]]
200+
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

Project.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name = "QuantLib"
2+
uuid = "96a2b5a2-274e-5d11-8b3e-35bccd200598"
3+
author = ["Chris Alexander <[email protected]>"]
4+
version = "0.1.0"
5+
6+
[deps]
7+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
8+
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
9+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
10+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
11+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12+
Sobol = "ed01d8cd-4d21-5b2a-85b4-cc3bdc58bad4"
13+
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
14+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
15+
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
16+
17+
[compat]
18+
julia = "1"
19+
Dierckx = "0.4"
20+
Distributions = "0.22"
21+
Sobol = "1.3"
22+
SpecialFunctions = "0.10"
23+
StatsBase = "0.32"
24+
StatsFuns = "0.9"
25+
26+
[extras]
27+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
28+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
29+
30+
[targets]
31+
test = ["Dates", "Test"]

REQUIRE

-7
This file was deleted.

src/math/interpolation/linear_interpolation.jl

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ mutable struct LinearInterpolation <: Interpolation
44
s::Vector{Float64}
55
end
66

7+
"""
8+
initialize without data, e.g. for usage in curve constructors
9+
10+
Example:
11+
12+
QuantLib.InterpolatedDiscountCurve(curve_dates, curve_values, daycount,
13+
QuantLib.Math.LinearInterpolation())
14+
"""
15+
function LinearInterpolation()
16+
x_vals = Vector{Float64}()
17+
y_vals = Vector{Float64}()
18+
s = Vector{Float64}()
19+
20+
QuantLib.Math.LinearInterpolation(x_vals, y_vals, s)
21+
end
22+
723
# Linear initialize
824
function initialize!(interp::LinearInterpolation, x_vals::Vector{Float64}, y_vals::Vector{Float64})
925
interp.x_vals = x_vals

test/curves.jl

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Dates
2+
3+
effective_date = Date(2020, 01, 15)
4+
5+
days = [369, 462, 553, 735, 1100, 1465]
6+
df = [0.97678403, 0.97153083, 0.96655364, 0.95695995, 0.93829085, 0.91954718]
7+
test_date = effective_date + Day(900)
8+
9+
const dc_act_360 = QuantLib.Time.Actual360()
10+
11+
# test log-linear interpolation
12+
test_curve_loglinear = QuantLib.InterpolatedDiscountCurve(effective_date .+ Day.(days), df, dc_act_360, QuantLib.Math.LogLinear())
13+
disc_factor = QuantLib.discount(test_curve_loglinear, test_date)
14+
x1 = (test_date - test_curve_loglinear.dates[4]).value
15+
dx = (test_curve_loglinear.dates[5]-test_curve_loglinear.dates[4]).value
16+
dy = log(test_curve_loglinear.data[5]) - log(test_curve_loglinear.data[4])
17+
df_recalc = exp(log(test_curve_loglinear.data[4]) + x1*dy/dx)
18+
@test disc_factor == df_recalc
19+
20+
test_curve_linear = QuantLib.InterpolatedDiscountCurve(effective_date .+ Day.(days), df, dc_act_360, QuantLib.Math.LinearInterpolation())
21+
disc_factor = QuantLib.discount(test_curve_linear, test_date)
22+
x1 = (test_date - test_curve_linear.dates[4]).value
23+
dx = (test_curve_linear.dates[5]-test_curve_linear.dates[4]).value
24+
dy = (test_curve_linear.data[5]) - (test_curve_linear.data[4])
25+
df_recalc = ((test_curve_linear.data[4]) + x1*dy/dx)
26+
@test disc_factor == df_recalc

test/runtests.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ tests = ["cash_flows",
77
"options",
88
"swaps",
99
"swaptions",
10-
"fd_mesher"]
10+
"fd_mesher",
11+
"curves"]
1112

1213
println("Running tests:")
1314

0 commit comments

Comments
 (0)