Loading [MathJax]/extensions/tex2jax.js
MRFFL: MR Fortran Finance Library 2024-12-28
Computational Tools For Finance
All Namespaces Files Functions Variables
mrffl_us_markets.f90
Go to the documentation of this file.
1! -*- Mode:F90; Coding:us-ascii-unix; fill-column:129 -*-
2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.H.S.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.H.E.!!
3!>
4!! @file mrffl_us_markets.f90
5!! @author Mitch Richling http://www.mitchr.me/
6!! @date 2024-12-19
7!! @brief Annual us stock market return data and monte carlo.@EOL
8!! @keywords finance fortran monte carlo inflation cashflow time value of money tvm percentages taxes stock market
9!! @std F2023
10!! @see https://github.com/richmit/FortranFinance
11!! @copyright
12!! @parblock
13!! Copyright (c) 2024, Mitchell Jay Richling <http://www.mitchr.me/> All rights reserved.
14!!
15!! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
16!! conditions are met:
17!!
18!! 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following
19!! disclaimer.
20!!
21!! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following
22!! disclaimer in the documentation and/or other materials provided with the distribution.
23!!
24!! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
25!! derived from this software without specific prior written permission.
26!!
27!! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
28!! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29!! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30!! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
31!! USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32!! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33!! OF THE POSSIBILITY OF SUCH DAMAGE.
34!! @endparblock
35!!
36
37!----------------------------------------------------------------------------------------------------------------------------------
38!> Annual us stock market return data and monte carlo
39!!
41 use mrffl_config, only: rk=>mrfflrk, ik=>mrfflik
42 use mrffl_stats, only: resample_tail
43 implicit none
44 private
45
46 !--------------------------------------------------------------------------------------------------------------------------------
47 !> Annual S&P 500 data
48 !!
49 real(kind=rk), parameter, public :: snp_dat(1970:2023) = [ &
50 10.79, 15.63, -17.37, -29.72, 31.55, 19.15, -11.50, 1.06, 12.31, 25.77, & ! 1970-1979
51 -9.73, 14.76, 17.27, 1.40, 26.33, 14.62, 2.03, 12.40, 27.25, -6.56, & ! 1980-1989
52 26.31, 4.46, 7.06, -1.54, 34.11, 20.26, 31.01, 26.67, 19.53, -10.14, & ! 1990-1999
53 -13.04, -23.37, 26.38, 8.99, 3.00, 13.62, 3.53, -38.49, 23.45, 12.78, & ! 2000-2009
54 0.00, 13.41, 29.60, 11.39, -0.73, 9.54, 19.42, -6.24, 28.88, 16.26, & ! 2010-2019
55 26.89, -19.44, 24.23, 24.34] ! 2020-2023
56
57 !--------------------------------------------------------------------------------------------------------------------------------
58 !> Annual Russel 2000 data
59 !!
60 real(kind=rk), parameter, public :: rut_dat(1988:2023) = [ &
61 22.38, 14.21, & ! 1980-1989
62 -21.46, 43.68, 16.36, 17.00, -3.18, 26.21, 14.76, 20.52, -3.45, 19.62, & ! 1990-1999
63 -4.20, 1.03, -21.58, 45.37, 17.00, 3.32, 17.00, -2.75, -34.80, 25.22, & ! 2000-2009
64 25.31, -5.45, 14.63, 37.00, 3.53, -5.71, 19.48, 13.14, -12.18, 23.72, & ! 2010-2019
65 18.36, 13.70, -21.56, 15.09] ! 2020-2023
66
67 !--------------------------------------------------------------------------------------------------------------------------------
68 !> Nasdaq data
69 !!
70 real(kind=rk), parameter, public :: nas_dat(1974:2023) = [ &
71 -35.11, 29.76, 26.10, 7.33, 12.31, 28.11, & ! 1974-1979
72 33.88, -3.21, 18.67, 19.87, -11.22, 31.35, 7.36, -5.25, 15.40, 19.24, & ! 1980-1989
73 -17.81, 56.85, 15.47, 14.74, -3.19, 39.91, 22.71, 21.64, 39.62, 85.60, & ! 1990-1999
74 -39.29, -21.05, -31.53, 50.01, 8.59, 1.37, 9.52, 9.81, -40.54, 43.89, & ! 2000-2009
75 16.91, -1.80, 15.91, 38.32, 13.40, 5.73, 7.50, 28.24, -3.88, 35.23, & ! 2010-2019
76 43.64, 21.39, -33.10, 43.42] ! 2020-2023
77
78 !--------------------------------------------------------------------------------------------------------------------------------
79 !> Dow Jones data
80 !!
81 real(kind=rk), parameter, public :: dow_dat(1970:2023) = [ &
82 4.82, 6.11, 14.58, -16.58, -27.57, 38.32, 17.86, -17.27, -3.15, 4.19, & ! 1974-1979
83 14.93, -9.23, 19.61, 20.27, -3.74, 27.66, 22.59, 2.26, 11.85, 26.96, & ! 1980-1989
84 -4.34, 20.32, 4.17, 13.72, 2.14, 33.45, 26.01, 22.64, 16.35, 24.95, & ! 1990-1999
85 -6.17, -7.11, -16.76, 25.32, 3.15, -0.61, 16.29, 6.43, -33.84, 18.82, & ! 2000-2009
86 11.02, 5.53, 7.26, 26.50, 7.52, -2.23, 13.42, 25.08, -5.63, 22.34, & ! 2010-2019
87 7.25, 18.73, -8.78, 13.70] ! 2020-2023
88
89 !--------------------------------------------------------------------------------------------------------------------------------
90 !> DGS10 US treasury 10 year (mean by year)
91 !!
92 real(kind=rk), parameter, public :: dgs10_dat(1962:2025) = [ &
93 3.946, 4.001, 4.187, 4.283, 4.925, 5.072, 5.644, 6.672, & ! 1962-1969
94 7.354, 6.160, 6.206, 6.848, 7.562, 7.993, 7.612, 7.417, 8.408, 9.432, & ! 1970-1979
95 11.43, 13.92, 13.00, 11.10, 12.45, 10.61, 7.672, 8.392, 8.848, 8.493, & ! 1980-1989
96 8.552, 7.862, 7.008, 5.866, 7.085, 6.573, 6.443, 6.353, 5.262, 5.646, & ! 1990-1999
97 6.030, 5.020, 4.613, 4.013, 4.271, 4.288, 4.795, 4.634, 3.664, 3.264, & ! 2000-2009
98 3.215, 2.781, 1.803, 2.350, 2.539, 2.138, 1.837, 2.329, 2.911, 2.141, & ! 2010-2019
99 0.889, 1.446, 2.950, 3.959, 4.207, 4.585] ! 2020-2025
100
102
103contains
104
105 !--------------------------------------------------------------------------------------------------------------------------------
106 !> Random return from the last history_years of S&P Data.
107 !!
108 real(kind=rk) function snp_resample(history_years)
109 implicit none
110 integer(kind=ik), intent(in) :: history_years
111 snp_resample = resample_tail(snp_dat, history_years)
112 end function snp_resample
113
114 !--------------------------------------------------------------------------------------------------------------------------------
115 !> Random return from the last history_years of Russel 2000 Data.
116 !!
117 real(kind=rk) function rut_resample(history_years)
118 implicit none
119 integer(kind=ik), intent(in) :: history_years
120 rut_resample = resample_tail(rut_dat, history_years)
121 end function rut_resample
122
123 !--------------------------------------------------------------------------------------------------------------------------------
124 !> Random return from the last history_years of Nasdaq Data.
125 !!
126 real(kind=rk) function nas_resample(history_years)
127 implicit none
128 integer(kind=ik), intent(in) :: history_years
129 nas_resample = resample_tail(nas_dat, history_years)
130 end function nas_resample
131
132 !--------------------------------------------------------------------------------------------------------------------------------
133 !> Random return from the last history_years of Dow Data.
134 !!
135 real(kind=rk) function dow_resample(history_years)
136 implicit none
137 integer(kind=ik), intent(in) :: history_years
138 dow_resample = resample_tail(dow_dat, history_years)
139 end function dow_resample
140
141 !--------------------------------------------------------------------------------------------------------------------------------
142 !> Random return from the last history_years of US treasury 10 year data.
143 !!
144 real(kind=rk) function dgs10_resample(history_years)
145 implicit none
146 integer(kind=ik), intent(in) :: history_years
147 dgs10_resample = resample_tail(dgs10_dat, history_years)
148 end function dgs10_resample
149
150end module mrffl_us_markets
Configuration for MRFFL (MR Fortran Finance Library).
integer, parameter, public mrfflrk
Real kind used in interfaces.
integer, parameter, public mrfflik
Integer kinds used in interfaces.
Some statstical utilities supporting other MRFFL modules.
real(kind=rk) function, public resample_tail(data, tail_length)
Return random value from among the last tail_length elements of data.
Annual us stock market return data and monte carlo.
real(kind=rk), dimension(1970:2023), parameter, public snp_dat
Annual S&P 500 data.
real(kind=rk), dimension(1962:2025), parameter, public dgs10_dat
DGS10 US treasury 10 year (mean by year)
real(kind=rk) function, public snp_resample(history_years)
Random return from the last history_years of S&P Data.
real(kind=rk) function, public nas_resample(history_years)
Random return from the last history_years of Nasdaq Data.
real(kind=rk) function, public dgs10_resample(history_years)
Random return from the last history_years of US treasury 10 year data.
real(kind=rk), dimension(1970:2023), parameter, public dow_dat
Dow Jones data.
real(kind=rk) function, public dow_resample(history_years)
Random return from the last history_years of Dow Data.
real(kind=rk), dimension(1988:2023), parameter, public rut_dat
Annual Russel 2000 data.
real(kind=rk) function, public rut_resample(history_years)
Random return from the last history_years of Russel 2000 Data.
real(kind=rk), dimension(1974:2023), parameter, public nas_dat
Nasdaq data.