Skip to content

Commit da900ef

Browse files
initial commit
0 parents  commit da900ef

17 files changed

+549
-0
lines changed

.codecov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comment: false

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: julia
2+
os:
3+
- linux
4+
- osx
5+
julia:
6+
- 1.0
7+
notifications:
8+
email: false
9+
git:
10+
depth: 99999999
11+
matrix:
12+
allow_failures:
13+
- julia: nightly
14+
15+
after_success:
16+
- julia -e 'cd(Pkg.dir("FinancialDerivatives")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
17+
- julia -e 'cd(Pkg.dir("FinancialDerivatives")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'

LICENSE.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The FinancialDerivatives.jl package is licensed under the MIT "Expat" License:
2+
3+
> Copyright (c) 2018: Alexandre Brilhante.
4+
>
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in all
13+
> copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
> SOFTWARE.
22+
>

Manifest.toml

+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
[[Arpack]]
2+
deps = ["BinaryProvider", "Libdl", "LinearAlgebra", "Random", "SparseArrays", "Test"]
3+
git-tree-sha1 = "5b046410fb617d9cf2f8bc0edd5da05a2e5a2ad4"
4+
uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
5+
version = "0.2.3"
6+
7+
[[Base64]]
8+
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
9+
10+
[[BinDeps]]
11+
deps = ["Compat", "Libdl", "SHA", "URIParser"]
12+
git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9"
13+
uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
14+
version = "0.8.10"
15+
16+
[[BinaryProvider]]
17+
deps = ["Libdl", "Pkg", "SHA", "Test"]
18+
git-tree-sha1 = "38be61810f280c3c478f5c38aaf387f8f9199275"
19+
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
20+
version = "0.5.1"
21+
22+
[[Compat]]
23+
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
24+
git-tree-sha1 = "ff2595695fc4f14427358ce2593f867085c45dcb"
25+
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
26+
version = "1.2.0"
27+
28+
[[DataStructures]]
29+
deps = ["InteractiveUtils", "OrderedCollections", "REPL", "Random", "Serialization", "Test"]
30+
git-tree-sha1 = "8fc6e166e24fda04b2b648d4260cdad241788c54"
31+
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
32+
version = "0.14.0"
33+
34+
[[Dates]]
35+
deps = ["Printf"]
36+
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
37+
38+
[[DelimitedFiles]]
39+
deps = ["Mmap"]
40+
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
41+
42+
[[Distributed]]
43+
deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"]
44+
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
45+
46+
[[Distributions]]
47+
deps = ["Distributed", "LinearAlgebra", "PDMats", "Pkg", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "Test"]
48+
git-tree-sha1 = "c24e9b6500c037673f0241a2783472b8c3d080c7"
49+
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
50+
version = "0.16.4"
51+
52+
[[InteractiveUtils]]
53+
deps = ["LinearAlgebra", "Markdown"]
54+
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
55+
56+
[[LibGit2]]
57+
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
58+
59+
[[Libdl]]
60+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
61+
62+
[[LinearAlgebra]]
63+
deps = ["Libdl"]
64+
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
65+
66+
[[Logging]]
67+
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
68+
69+
[[Markdown]]
70+
deps = ["Base64"]
71+
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
72+
73+
[[Missings]]
74+
deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"]
75+
git-tree-sha1 = "adc26d2ee85a49c413464110d922cf21efc9d233"
76+
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
77+
version = "0.3.1"
78+
79+
[[Mmap]]
80+
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
81+
82+
[[OrderedCollections]]
83+
deps = ["Pkg", "Random", "Serialization", "Test"]
84+
git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b"
85+
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
86+
version = "1.0.2"
87+
88+
[[PDMats]]
89+
deps = ["Arpack", "LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"]
90+
git-tree-sha1 = "9e3e7a5c9b8cfdba8c01a1bcae38fe0144936fda"
91+
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
92+
version = "0.9.5"
93+
94+
[[Pkg]]
95+
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
96+
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
97+
98+
[[Printf]]
99+
deps = ["Unicode"]
100+
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
101+
102+
[[QuadGK]]
103+
deps = ["DataStructures", "LinearAlgebra", "Test"]
104+
git-tree-sha1 = "7e8dff9c205f36eceaf6e62a43ff851637ca45fc"
105+
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
106+
version = "2.0.2"
107+
108+
[[REPL]]
109+
deps = ["InteractiveUtils", "Markdown", "Sockets"]
110+
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
111+
112+
[[Random]]
113+
deps = ["Serialization"]
114+
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
115+
116+
[[Rmath]]
117+
deps = ["BinaryProvider", "Libdl", "Pkg", "Random", "Statistics", "Test"]
118+
git-tree-sha1 = "9a6c758cdf73036c3239b0afbea790def1dabff9"
119+
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
120+
version = "0.5.0"
121+
122+
[[SHA]]
123+
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
124+
125+
[[Serialization]]
126+
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
127+
128+
[[SharedArrays]]
129+
deps = ["Distributed", "Mmap", "Random", "Serialization"]
130+
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
131+
132+
[[Sockets]]
133+
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
134+
135+
[[SortingAlgorithms]]
136+
deps = ["DataStructures", "Random", "Test"]
137+
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
138+
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
139+
version = "0.3.1"
140+
141+
[[SparseArrays]]
142+
deps = ["LinearAlgebra", "Random"]
143+
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
144+
145+
[[SpecialFunctions]]
146+
deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"]
147+
git-tree-sha1 = "c35c9c76008babf4d658060fc64aeb369a41e7bd"
148+
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
149+
version = "0.7.1"
150+
151+
[[Statistics]]
152+
deps = ["LinearAlgebra", "SparseArrays"]
153+
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
154+
155+
[[StatsBase]]
156+
deps = ["DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "Test"]
157+
git-tree-sha1 = "723193a13e8078cec6dcd0b8fe245c8bfd81690e"
158+
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
159+
version = "0.25.0"
160+
161+
[[StatsFuns]]
162+
deps = ["Pkg", "Rmath", "SpecialFunctions", "Test"]
163+
git-tree-sha1 = "d14bb7b03defd2deaa5675646f6783089e0556f0"
164+
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
165+
version = "0.7.0"
166+
167+
[[SuiteSparse]]
168+
deps = ["Libdl", "LinearAlgebra", "SparseArrays"]
169+
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
170+
171+
[[Test]]
172+
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
173+
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
174+
175+
[[URIParser]]
176+
deps = ["Test", "Unicode"]
177+
git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69"
178+
uuid = "30578b45-9adc-5946-b283-645ec420af67"
179+
version = "0.4.0"
180+
181+
[[UUIDs]]
182+
deps = ["Random"]
183+
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
184+
185+
[[Unicode]]
186+
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

Project.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name = "FinancialDerivatives"
2+
uuid = "b21666fa-ca8c-11e8-3cc4-33811bd3fa24"
3+
license = "MIT"
4+
authors = "Alexandre Brilhante"
5+
version = "0.1.0"
6+
7+
[deps]
8+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
9+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
10+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
11+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# FinancialDerivatives.jl
2+
3+
[![Build Status](https://travis-ci.org/brilhana/FinancialDerivatives.jl.svg?branch=master)](https://travis-ci.org/brilhana/FinancialDerivatives.jl)
4+
[![Coverage Status](https://coveralls.io/repos/brilhana/FinancialDerivatives.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/brilhana/FinancialDerivatives.jl?branch=master)
5+
[![codecov.io](http://codecov.io/github/brilhana/FinancialDerivatives.jl/coverage.svg?branch=master)](http://codecov.io/github/brilhana/FinancialDerivatives.jl?branch=master)
6+
7+
Financial derivatives modeling and pricing in Julia.
8+
9+
## Models
10+
11+
* Black-Scholes.
12+
* Brennan-Schwartz.
13+
* Cox-Ross-Rubinstein.
14+
* Garman-Kohlhagen.
15+
* Longstaff-Schwartz.
16+
* Rendlemen-Bartter.
17+
* Vasicek.
18+
19+
## Installation
20+
21+
```julia
22+
(v1.0) pkg> add https://github.com/brilhana/FinancialDerivatives.jl
23+
```
24+
25+
## Usage
26+
27+
```julia
28+
using FinancialDerivatives
29+
30+
american_put = Option(100.0, 90.0, 0.05, 0.3, 180/365, -1)
31+
32+
evaluate(american_put, BlackScholes())
33+
```

appveyor.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
environment:
2+
matrix:
3+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/1.0/julia-1.0-latest-win32.exe"
4+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/1.0/julia-1.0-latest-win64.exe"
5+
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6+
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
7+
8+
branches:
9+
only:
10+
- master
11+
- /release-.*/
12+
13+
notifications:
14+
- provider: Email
15+
on_build_success: false
16+
on_build_failure: false
17+
on_build_status_changed: false
18+
19+
install:
20+
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
21+
# If there's a newer build queued for the same PR, cancel this one
22+
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
23+
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
24+
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
25+
throw "There are newer queued builds for this pull request, failing early." }
26+
# Download most recent Julia Windows binary
27+
- ps: (new-object net.webclient).DownloadFile(
28+
$env:JULIA_URL,
29+
"C:\projects\julia-binary.exe")
30+
# Run installer silently, output to C:\projects\julia
31+
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
32+
33+
build_script:
34+
# Need to convert from shallow to complete for Pkg.clone to work
35+
- IF EXIST .git\shallow (git fetch --unshallow)
36+
- C:\projects\julia\bin\julia -e "versioninfo();
37+
Pkg.clone(pwd(), \"FinancialDerivatives\"); Pkg.build(\"FinancialDerivatives\")"
38+
39+
test_script:
40+
- C:\projects\julia\bin\julia -e "Pkg.test(\"FinancialDerivatives\")"

src/FinancialDerivatives.jl

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module FinancialDerivatives
2+
3+
import Distributions: cdf, Normal
4+
import Statistics: mean
5+
6+
export InterestRateDerivative,
7+
Option,
8+
FXOption
9+
10+
export BlackScholes,
11+
BrennanSchwartz,
12+
CoxRossRubinstein,
13+
GarmanKohlhagen,
14+
LongstaffSchwartz,
15+
RendlemanBartter,
16+
Vasicek
17+
18+
export evaluate
19+
20+
abstract type Model end
21+
22+
include("derivatives.jl")
23+
24+
include("models/black_scholes.jl")
25+
include("models/brennan_schwartz.jl")
26+
include("models/cox_ross_rubinstein.jl")
27+
include("models/garman_kohlhagen.jl")
28+
include("models/longstaff_schwartz.jl")
29+
include("models/rendleman_bartter.jl")
30+
include("models/vasicek.jl")
31+
32+
end # module

src/derivatives.jl

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
abstract type Derivative end
2+
3+
abstract type Forward <: Derivative end
4+
5+
abstract type Future <: Derivative end
6+
7+
abstract type Swap <: Derivative end
8+
9+
abstract type Swaption <: Derivative end
10+
11+
struct InterestRateDerivative{T<:Number}
12+
k::T
13+
r::T
14+
σ::T
15+
θ::T
16+
t::T
17+
end
18+
19+
struct Option{T<:Number}
20+
s::T
21+
k::T
22+
r::T
23+
σ::T
24+
t::T
25+
call::Int64
26+
end
27+
28+
struct FXOption{T<:Number}
29+
s::T
30+
k::T
31+
r_d::T
32+
r_f::T
33+
σ::T
34+
t::T
35+
call::Int64
36+
end

0 commit comments

Comments
 (0)