This file is indexed.

/usr/share/octave/packages/financial-0.5.0/heston.m is in octave-financial 0.5.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
## Copyright (C) 2016 Parsiad Azimzadeh <parsiad.azimzadeh@gmail.com>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU Lesser General Public License as published by the Free
## Software Foundation; either version 3 of the License, or (at your option) any
## later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
## for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn  {Function File} {@var{heston} =} heston (@var{Return}, @var{Speed}, @var{Level}, @var{Volatility})
## @deftypefnx {Function File} {@var{heston} =} heston (@var{Return}, @var{Speed}, @var{Level}, @var{Volatility}, @var{OptionName}, @var{OptionValue}, @dots{})
## Creates an object to represent a Heston stochastic volatility model:
##
## @center dX_1 = (@var{Return}(t) * X_1)dt + (sqrt (X_2) * X_1)dW_1;
## @center dX_2 = (@var{Speed}(t) * (@var{Level}(t) - X_2))dt + (sqrt (X_2) * @var{Volatility}(t))dW_2.
##
## See the @@sde documentation for a list of optional arguments.
##
## @seealso{sde}
## @end deftypefn

function heston = heston (Return, Speed, Level, Volatility, varargin)

  if (nargin < 4)
    print_usage ();
  endif

  if (isscalar (Return) && isreal (Return))
    ReturnFunction = @(t, X) Return;
  elseif (isa (Return, "function_handle") && nargin (Return) == 1)
    ReturnFunction = @(t, X) Return (t);
  elseif (isa (Return, "function_handle") && nargin (Return) == 2)
    ReturnFunction = Return;
  else
    error ("heston: RETURN must either be a real scalar or a function of one or two arguments returning such a scalar");
  endif

  if (isscalar (Speed) && isreal (Speed))
    SpeedFunction = @(t, X) Speed;
  elseif (isa (Speed, "function_handle") && nargin (Speed) == 1)
    SpeedFunction = @(t, X) Speed (t);
  elseif (isa (Speed, "function_handle") && nargin (Speed) == 2)
    SpeedFunction = Speed;
  else
    error ("heston: SPEED must either be a real scalar or a function of one or two arguments returning such a scalar");
  endif

  if (isscalar (Level) && isreal (Level))
    LevelFunction = @(t, X) Level;
  elseif (isa (Level, "function_handle") && nargin (Level) == 1)
    LevelFunction = @(t, X) Level (t);
  elseif (isa (Level, "function_handle") && nargin (Level) == 2)
    LevelFunction = Level;
  else
    error ("heston: LEVEL must either be a real scalar or a function of one or two arguments returning such a scalar");
  endif

  if (isscalar (Volatility) && isreal (Volatility))
    VolatilityFunction = @(t, X) Volatility;
  elseif (isa (Volatility, "function_handle") && nargin (Volatility) == 1)
    VolatilityFunction = @(t, X) Volatility (t);
  elseif (isa (Volatility, "function_handle") && nargin (Volatility) == 2)
    VolatilityFunction = Volatility;
  else
    error ("heston: VOLATILITY must either be a real scalar or a function of one or two arguments returning such a scalar");
  endif

  ## TODO: Optimize
  Drift = @(t, X) [ReturnFunction(t, X) * X(1); SpeedFunction(t, X) * (LevelFunction(t, X) - X(2))];
  Diffusion = @(t, X) [sqrt(X(2)) * X(1) 0.;0. VolatilityFunction(t, X) * sqrt(X(2))];

  heston = sde (Drift, Diffusion, varargin{:});

endfunction