diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 52d6ad0..be05582 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-28T03:16:09","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-29T04:41:57","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/API/Bond/index.html b/dev/API/Bond/index.html index 77b0f5a..32740bb 100644 --- a/dev/API/Bond/index.html +++ b/dev/API/Bond/index.html @@ -1,8 +1,8 @@ -Bond · FinanceModels.jl

FinanceModels.Bond API Reference

Exported API

FinanceModels.Bond.CMTYieldMethod
CMTYield(yield,maturity)
+Bond · FinanceModels.jl

FinanceModels.Bond API Reference

Exported API

FinanceModels.Bond.CMTYieldMethod
CMTYield(yield,maturity)
 CMTYield(yield::Vector)

Returns a Quote for the correpsonding bond implied by the given bond equivalent yield, and assumes that instruments <= one year maturity` pay no coupons and that the rest pay semi-annual.

Use broadcasting to create a set of quotes given a collection of FinanceModels and maturities, e.g. CMTYield.(FinanceModels,maturities).

See also FinanceCore.Quote, Bond.Fixed

Examples

julia> CMTYield(0.05,10)
-Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(2), 10))
source
FinanceModels.Bond.ParYieldMethod

ParYield(yield, maturity; frequency=Periodic(2)) ParYield(yield::Vector)

Takes bond equivalent FinanceModels, and assumes that instruments <= one year maturity pay no coupons and that the rest pay semi-annual. Alternative, you may pass a Rate as the yield and the coupon frequency will be inferred from the Rate's frequency.

Use broadcasting to create a set of quotes given a collection of FinanceModels and maturities, e.g. ParYield.(FinanceModels,maturities).

Examples

julia> ParYield(0.05,10)
-Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(2), 10))
source
FinanceModels.Bond.ZCBPriceMethod
ZCBPrice(discount,maturity)
+Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(2), 10))
source
FinanceModels.Bond.ParYieldMethod

ParYield(yield, maturity; frequency=Periodic(2)) ParYield(yield::Vector)

Takes bond equivalent FinanceModels, and assumes that instruments <= one year maturity pay no coupons and that the rest pay semi-annual. Alternative, you may pass a Rate as the yield and the coupon frequency will be inferred from the Rate's frequency.

Use broadcasting to create a set of quotes given a collection of FinanceModels and maturities, e.g. ParYield.(FinanceModels,maturities).

Examples

julia> ParYield(0.05,10)
+Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(2), 10))
source
FinanceModels.Bond.ZCBPriceMethod
ZCBPrice(discount,maturity)
 ZCBPrice(yield::Vector)

Takes spot/zero discount factors and returns a Quote for the cashflow occuring at the given maturity.

Use broadcasting to create a set of quotes given a collection of prices and maturities, e.g. ZCBPrice.(FinanceModels,maturities).

See also ZCBYield

Examples


 julia> ZCBPrice(0.5,10)
 Quote{Float64, Cashflow{Float64, Int64}}(0.5, Cashflow{Float64, Int64}(1.0, 10))
@@ -12,7 +12,7 @@
  Quote{Float64, Cashflow{Float64, Int64}}(0.9, Cashflow{Float64, Int64}(1.0, 1))
  Quote{Float64, Cashflow{Float64, Int64}}(0.8, Cashflow{Float64, Int64}(1.0, 2))
  Quote{Float64, Cashflow{Float64, Int64}}(0.75, Cashflow{Float64, Int64}(1.0, 3))
- 
source
FinanceModels.Bond.ZCBYieldMethod
ZCBYield(yield,maturity)
 ZCBYield(yield::Vector)

Returns a Quote for the cashflow occuring at the given maturity and the quoted value is derived from the given yield.

Takes zero (sometimes called "spot") rates. Assumes annual effective compounding (Periodic(1)) unless given aRate` with a different compounding frequency.

Use broadcasting to create a set of quotes given a collection of FinanceModels and maturities, e.g. ZCBYield.(FinanceModels,maturities).

See also ZCBPrice

Examples

julia> ZCBYield(0.05,30)
 Quote{Float64, Cashflow{Float64, Int64}}(0.23137744865585788, Cashflow{Float64, Int64}(1.0, 30))
 
@@ -26,7 +26,7 @@
 3-element Vector{Quote{Float64, Cashflow{Float64, Int64}}}:
  Quote{Float64, Cashflow{Float64, Int64}}(0.9615384615384615, Cashflow{Float64, Int64}(1.0, 1))
  Quote{Float64, Cashflow{Float64, Int64}}(0.9070294784580498, Cashflow{Float64, Int64}(1.0, 2))
- Quote{Float64, Cashflow{Float64, Int64}}(0.8762966040549094, Cashflow{Float64, Int64}(1.0, 3))
source

Unexported API

FinanceModels.Bond.FixedType
Bond.Fixed(coupon_rate,frequency<:FinanceCore.Frequency,maturity)

An object representing a fixed coupon bond. coupon_rate / frequency is the actual payment amount.

Note that there are a number of convienience constructors which return a Quote for a Bond.Fixed:

See also FinanceCore.Quote.

Examples

julia> Bond.Fixed(0.05,Periodic(2),3)
+ Quote{Float64, Cashflow{Float64, Int64}}(0.8762966040549094, Cashflow{Float64, Int64}(1.0, 3))
source

Unexported API

FinanceModels.Bond.FixedType
Bond.Fixed(coupon_rate,frequency<:FinanceCore.Frequency,maturity)

An object representing a fixed coupon bond. coupon_rate / frequency is the actual payment amount.

Note that there are a number of convienience constructors which return a Quote for a Bond.Fixed:

See also FinanceCore.Quote.

Examples

julia> Bond.Fixed(0.05,Periodic(2),3)
 FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(2), 3)
 
 julia> Bond.Fixed(0.05,Periodic(2),3) |> collect
@@ -40,7 +40,7 @@
 
 
 julia> ParYield(0.05,10)
-Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(2), 10))
source
FinanceModels.Bond.FloatingType
Bond.Floating(coupon_rate,frequency<:FinanceCore.Frequency,maturity,model_key)

An object representing a floating coupon bond. (coupon_rate + reference rate) / frequency is the actual payment amount, where the reference rate requires a Projection with a key/value pair where the key is the model_key argument and the value is the model which produces the reference rate.

See also FinanceCore.Quote.

Examples

julia> p = Projection(
+Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(2), 10))
source
FinanceModels.Bond.FloatingType
Bond.Floating(coupon_rate,frequency<:FinanceCore.Frequency,maturity,model_key)

An object representing a floating coupon bond. (coupon_rate + reference rate) / frequency is the actual payment amount, where the reference rate requires a Projection with a key/value pair where the key is the model_key argument and the value is the model which produces the reference rate.

See also FinanceCore.Quote.

Examples

julia> p = Projection(
         Bond.Floating(0.02, Periodic(1), 3.0, "SOFR"),
         Dict("SOFR" => Yield.Constant(0.05)),  # note the key/value store used for the model in the projection
         CashflowProjection(),
@@ -50,8 +50,8 @@
 3-element Vector{Cashflow{Float64, Float64}}:
     Cashflow{Float64, Float64}(0.07000000000000005, 1.0)
     Cashflow{Float64, Float64}(0.07000000000000005, 2.0)
-    Cashflow{Float64, Float64}(1.07, 3.0)
source
FinanceModels.Bond.ForwardYieldsFunction
ForwardYields(yields,times)

Returns a vector of Quote corresponding to the yield at the given forward times.

Examples

julia> FinanceModels.Bond.ForwardYields([0.01,0.02],[1.,3.])
+    Cashflow{Float64, Float64}(1.07, 3.0)
source
FinanceModels.Bond.ForwardYieldsFunction
ForwardYields(yields,times)

Returns a vector of Quote corresponding to the yield at the given forward times.

Examples

julia> FinanceModels.Bond.ForwardYields([0.01,0.02],[1.,3.])
 2-element Vector{Quote{Float64, Cashflow{Float64, Float64}}}:
  Quote{Float64, Cashflow{Float64, Float64}}(0.9900990099009901, Cashflow{Float64, Float64}(1.0, 1.0))
- Quote{Float64, Cashflow{Float64, Float64}}(0.9423223345470445, Cashflow{Float64, Float64}(1.0, 3.0))
source
FinanceModels.Bond.OISYieldMethod

OISYield(yield, maturity)

Returns the implied Quote for the fixed bond implied by the given yield and maturity. Assumes that maturities less than or equal to 12 months are settled once (per Hull textbook, 4.7), otherwise quarterly and that the FinanceModels given are bond equivalent.

Use broadcasting to create a set of quotes given a collection of FinanceModels and maturities, e.g. OISYield.(FinanceModels,maturities).

See also FinanceCore.Quote, Bond.Fixed

Examples

julia> OISYield(0.05,10)
-Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(4), 10))
source
FinanceModels.Bond.coupon_timesMethod
coupon_times(maturity, frequency)

Generate coupon times for a bond with the given maturity and frequency.

Arguments

  • maturity::Real: The maturity of the bond.
  • frequency::Real: The coupon frequency of the bond.

Returns

  • An array of coupon times for the bond.

Examples

julia-repl julia> Bond.coupon_times(10, 2) 0.5:0.5:10.0 julia> Bond.coupon_times(Bond.Fixed(0.05,Periodic(4),20)) 0.25:0.25:20.0`

source

Please open an issue if you encounter any issues or confusion with the package.

+ Quote{Float64, Cashflow{Float64, Float64}}(0.9423223345470445, Cashflow{Float64, Float64}(1.0, 3.0))
source
FinanceModels.Bond.OISYieldMethod

OISYield(yield, maturity)

Returns the implied Quote for the fixed bond implied by the given yield and maturity. Assumes that maturities less than or equal to 12 months are settled once (per Hull textbook, 4.7), otherwise quarterly and that the FinanceModels given are bond equivalent.

Use broadcasting to create a set of quotes given a collection of FinanceModels and maturities, e.g. OISYield.(FinanceModels,maturities).

See also FinanceCore.Quote, Bond.Fixed

Examples

julia> OISYield(0.05,10)
+Quote{Float64, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}}(1.0, FinanceModels.Bond.Fixed{Periodic, Float64, Int64}(0.05, Periodic(4), 10))
source
FinanceModels.Bond.coupon_timesMethod
coupon_times(maturity, frequency)

Generate coupon times for a bond with the given maturity and frequency.

Arguments

  • maturity::Real: The maturity of the bond.
  • frequency::Real: The coupon frequency of the bond.

Returns

  • An array of coupon times for the bond.

Examples

julia-repl julia> Bond.coupon_times(10, 2) 0.5:0.5:10.0 julia> Bond.coupon_times(Bond.Fixed(0.05,Periodic(4),20)) 0.25:0.25:20.0`

source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/API/Equity/index.html b/dev/API/Equity/index.html index b73c055..50e40e7 100644 --- a/dev/API/Equity/index.html +++ b/dev/API/Equity/index.html @@ -1,5 +1,5 @@ -Equity · FinanceModels.jl

FinanceModels.Equity API Reference

Exported API

Unexported API

FinanceModels.Equity.BlackScholesMertonType
BlackScholesMerton(r, q, σ) <: AbstractEquityModel

A struct representing the Black-Scholes-Merton model for equity prices.

Arguments

  • r: The risk-free rate.
  • q: The dividend yield.
  • σ: The volatility model of the underlying asset (see Volatility module)

Fields

  • r: The risk-free rate.
  • q: The dividend yield.
  • σ: The volatility model of the underlying asset (see Volatility module)

When fitting, the volatility will be solved-for; volatility itself is a sub-model that will be optimized with a default optimization bound of 0.0 .. 10.0

Examples

julia> model = BlackScholesMerton(0.05, 0.02, 0.2)
+Equity · FinanceModels.jl

FinanceModels.Equity API Reference

Exported API

Unexported API

FinanceModels.Equity.BlackScholesMertonType
BlackScholesMerton(r, q, σ) <: AbstractEquityModel

A struct representing the Black-Scholes-Merton model for equity prices.

Arguments

  • r: The risk-free rate.
  • q: The dividend yield.
  • σ: The volatility model of the underlying asset (see Volatility module)

Fields

  • r: The risk-free rate.
  • q: The dividend yield.
  • σ: The volatility model of the underlying asset (see Volatility module)

When fitting, the volatility will be solved-for; volatility itself is a sub-model that will be optimized with a default optimization bound of 0.0 .. 10.0

Examples

julia> model = BlackScholesMerton(0.05, 0.02, 0.2)
 BlackScholesMerton{Float64, Float64, Float64}(0.05, 0.02, 0.2)

Valuing an option:

m = Equity.BlackScholesMerton(0.01, 0.02, 0.15)
 
 a = Option.EuroCall(CommonEquity(), 1.0, 1.0)
@@ -11,4 +11,4 @@
 m = Equity.BlackScholesMerton(0.01, 0.02, Volatility.Constant())
 fit(m, qs)
 @test fit(m, qs).σ ≈ 0.15 atol = 1e-4
-
source

Please open an issue if you encounter any issues or confusion with the package.

+
source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/API/FinanceCore/index.html b/dev/API/FinanceCore/index.html index 8744ef5..6aef1c4 100644 --- a/dev/API/FinanceCore/index.html +++ b/dev/API/FinanceCore/index.html @@ -1,5 +1,5 @@ -FinanceCore · FinanceModels.jl

FinanceCore API Reference

Exported API

FinanceCore.CompositeType

Summary ≡≡≡≡≡≡≡≡≡

struct Composite{A, B}

A Composite{A,B} is a contract that is composed of two other contracts of type A and type B. The maturity of the composite is the maximum of the maturities of the two components.

It is used to assemble arbitrarily complex contracts from simpler ones.

Fields ≡≡≡≡≡≡≡≡

a :: A
+FinanceCore · FinanceModels.jl

FinanceCore API Reference

Exported API

FinanceCore.CompositeType

Summary ≡≡≡≡≡≡≡≡≡

struct Composite{A, B}

A Composite{A,B} is a contract that is composed of two other contracts of type A and type B. The maturity of the composite is the maximum of the maturities of the two components.

It is used to assemble arbitrarily complex contracts from simpler ones.

Fields ≡≡≡≡≡≡≡≡

a :: A
 b :: B

Supertype Hierarchy ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

Composite{A, B} <: FinanceCore.AbstractContract <: Any
source
FinanceCore.ContinuousType
Continuous()

A type representing continuous interest compounding frequency.

Examples

julia> Rate(0.01,Continuous())
 Rate(0.01, Continuous())

See also: Periodic

source
FinanceCore.PeriodicType
Periodic(frequency)

A type representing periodic interest compounding with the given frequency.

frequency will be converted to an Integer, and will round up to 8 decimal places (otherwise will throw an InexactError).

Examples

Creating a semi-annual bond equivalent yield:

julia> Rate(0.01,Periodic(2))
@@ -83,4 +83,4 @@
 Rate(0.010045960887181016, Periodic(1))
 
 julia> convert(Continuous(),r)
-Rate(0.009995835646701251, Continuous())
source

Please open an issue if you encounter any issues or confusion with the package.

+Rate(0.009995835646701251, Continuous())
source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/API/FinanceModels/index.html b/dev/API/FinanceModels/index.html index bfeb684..c220a39 100644 --- a/dev/API/FinanceModels/index.html +++ b/dev/API/FinanceModels/index.html @@ -1,9 +1,9 @@ -FinanceModels · FinanceModels.jl

FinanceModels API Reference

Exported API

FinanceModels.ForwardType

Forward(time,instrument)

The instrument is relative to the Forward time. e.g. if you have a Forward(1.0, Cashflow(1.0, 3.0)) then the instrument is a cashflow that pays 1.0 at time 4.0

source
FinanceModels.NullModelType
NullModel()

A singleton type representing a placeholder model for when you don't really need a model. For example: determining nominal cashflows for fixed income contract.

source
FinanceModels.ProjectionType
Projection(contract,model,kind)

The set of contracts and assumptions (model) to project the kind of output desired. Some assets require a projection in order to be valued (e.g. a floating rate bond).

If attempting to collect or otherwise reduce a contract (<:AbstractContract), by default it will get wrapped into a Projection(contract,NullModel(),CashflowProjection())

source
FinanceCore.present_valueFunction
present_value(model,contract,current_time=0.0)

Return the value of the contract as corresponding with the valuation assumptions embedded in the model.

Examples

m = Equity.BlackScholesMerton(0.01, 0.02, 0.15)
+FinanceModels · FinanceModels.jl

FinanceModels API Reference

Exported API

FinanceModels.ForwardType

Forward(time,instrument)

The instrument is relative to the Forward time. e.g. if you have a Forward(1.0, Cashflow(1.0, 3.0)) then the instrument is a cashflow that pays 1.0 at time 4.0

source
FinanceModels.NullModelType
NullModel()

A singleton type representing a placeholder model for when you don't really need a model. For example: determining nominal cashflows for fixed income contract.

source
FinanceModels.ProjectionType
Projection(contract,model,kind)

The set of contracts and assumptions (model) to project the kind of output desired. Some assets require a projection in order to be valued (e.g. a floating rate bond).

If attempting to collect or otherwise reduce a contract (<:AbstractContract), by default it will get wrapped into a Projection(contract,NullModel(),CashflowProjection())

source
FinanceCore.present_valueFunction
present_value(model,contract,current_time=0.0)

Return the value of the contract as corresponding with the valuation assumptions embedded in the model.

Examples

m = Equity.BlackScholesMerton(0.01, 0.02, 0.15)
 
 a = Option.EuroCall(CommonEquity(), 1.0, 1.0)
 
-pv(m, a) # ≈ 0.05410094201902403
source
FinanceModels.fitMethod
fit(
     model, 
     quotes, 
     method=Fit.Loss(x -> x^2);
@@ -53,11 +53,11 @@
 ]...)

In this way, fit know which arbitrary parameters in a given object may be modified. Technically, we are not modifying the immutable MyModel, but instead efficiently creating a new instance. This is enabled by AccessibleOptimization.jl.

Note that not all opitmization algorithms want a bounded interval. In that case, simply leave off the paired range. The prior example would then become:

__default_optic(m::MyModel) = OptArgs([
     @optic(_.a),
     @optic(_.b),
-]...)

```

Additional Examples

See the tutorials in the package documentation for FinanceModels.jl or the docstrings of FinanceModels.jl's avaiable model types.

source

Unexported API

FinanceModels.ProjectionKindType
abstract type ProjectionKind

An abstract type that controls what gets produced from the model.

Subtypes of ProjectionKind define the level of detail in the output of the model. For example, if you just want cashflows or you want a full amortization schedule, you might define an AmortizationSchedule kind which shows principle, interest, etc.

After defining a new ProjectionKind, you need to define the how the projection works for that new output by extending either:

function Transducers.asfoldable(p::Projection{C,M,K}) where {C<:Cashflow,M,K<:CashflowProjection}
+]...)

```

Additional Examples

See the tutorials in the package documentation for FinanceModels.jl or the docstrings of FinanceModels.jl's avaiable model types.

source

Unexported API

FinanceModels.ProjectionKindType
abstract type ProjectionKind

An abstract type that controls what gets produced from the model.

Subtypes of ProjectionKind define the level of detail in the output of the model. For example, if you just want cashflows or you want a full amortization schedule, you might define an AmortizationSchedule kind which shows principle, interest, etc.

After defining a new ProjectionKind, you need to define the how the projection works for that new output by extending either:

function Transducers.asfoldable(p::Projection{C,M,K}) where {C<:Cashflow,M,K<:CashflowProjection}
     ...
 end

or

function Transducers.__foldl__(rf, val, p::Projection{C,M,K}) where {C<:Cashflow,M,K<:CashflowProjection}
     ...
-end

There are examples of this in the documentation.

Examples

```julia julia> struct CashflowProjection <: ProjectionKind end CashflowProjection

julia> struct AmortizationSchedule <: ProjectionKind end AmortizationSchedule

source
FinanceModels.__default_opticMethod
__default_optic(model)

Returns the variables to optimize over for the given model. This is an optic/lens specifying which parameters of the modle can vary. See extended help for more. An optic argument is a singular or vector of lenses with an optional range of acceptable parameters.

Examples

We might have a model as follows where we want fit to optize parameters a and b:

struct MyModel <:FinanceModels.AbstractModel
+end

There are examples of this in the documentation.

Examples

```julia julia> struct CashflowProjection <: ProjectionKind end CashflowProjection

julia> struct AmortizationSchedule <: ProjectionKind end AmortizationSchedule

source
FinanceModels.__default_opticMethod
__default_optic(model)

Returns the variables to optimize over for the given model. This is an optic/lens specifying which parameters of the modle can vary. See extended help for more. An optic argument is a singular or vector of lenses with an optional range of acceptable parameters.

Examples

We might have a model as follows where we want fit to optize parameters a and b:

struct MyModel <:FinanceModels.AbstractModel
         a 
         b 
 end
@@ -84,6 +84,6 @@
 ]...)

In this way, fit know which arbitrary parameters in a given object may be modified. Technically, we are not modifying the immutable MyModel, but instead efficiently creating a new instance. This is enabled by AccessibleOptimization.jl.

Note that not all opitmization algorithms want a bounded interval. In that case, simply leave off the paired range. The prior example would then become:

__default_optic(m::MyModel) = OptArgs([
     @optic(_.a),
     @optic(_.b),
-]...)

```

source
FinanceModels.cashflows_timepointsMethod
cashflows_timepoints(contracts)
 cashflows_timepoints(quotes)

Create a matrix of cashflows and a vector of timepoints for a collection of quotes or contracts. Timepoints need not be spaced evenly.

This is used when constructing SmithWilson yield curves.

Arguments

  • contracts or quotes: A collection of <:AbstractContracts or Quotes.

Returns

  • A tuple (m, times) where m is a matrix of cashflows and times is a vector of timepoints.

Examples

julia> FinanceModels.cashflows_timepoints(ParYield.([0.04,0.02,0.04],[1,4,4]))
-([0.02 0.01 0.02; 1.02 0.01 0.02; … ; 0.0 0.01 0.02; 0.0 1.01 1.02], [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0])
source
FinanceModels.eurocallMethod
eurocall(;S=1.,K=1.,τ=1,r,σ,q=0.)

Calculate the Black-Scholes implied option price for a european call, where:

  • S is the current asset price
  • K is the strike or exercise price
  • τ is the time remaining to maturity (can be typed with \tau[tab])
  • r is the continuously compounded risk free rate
  • σ is the (implied) volatility (can be typed with \sigma[tab])
  • q is the continuously paid dividend rate

Rates should be input as rates (not percentages), e.g.: 0.05 instead of 5 for a rate of five percent.

!!! Experimental: this function is well-tested, but the derivatives functionality (API) may change in a future version of ActuaryUtilities.

Extended Help

This is the same as the formulation presented in the dividend extension of the BS model in Wikipedia.

Other general comments:

  • Swap/OIS curves are generally better sources for r than government debt (e.g. US Treasury) due to the collateralized nature of swap instruments.
  • (Implied) volatility is characterized by a curve that is a function of the strike price (among other things), so take care when using
  • Yields.jl can assist with converting rates to continuously compounded if you need to perform conversions.
source
FinanceModels.europutMethod
europut(;S=1.,K=1.,τ=1,r,σ,q=0.)

Calculate the Black-Scholes implied option price for a european call, where:

  • S is the current asset price
  • K is the strike or exercise price
  • τ is the time remaining to maturity (can be typed with \tau[tab])
  • r is the continuously compounded risk free rate
  • σ is the (implied) volatility (can be typed with \sigma[tab])
  • q is the continuously paid dividend rate

Rates should be input as rates (not percentages), e.g.: 0.05 instead of 5 for a rate of five percent.

!!! Experimental: this function is well-tested, but the derivatives functionality (API) may change in a future version of ActuaryUtilities.

Extended Help

This is the same as the formulation presented in the dividend extension of the BS model in Wikipedia.

Other general comments:

  • Swap/OIS curves are generally better sources for r than government debt (e.g. US Treasury) due to the collateralized nature of swap instruments.
  • (Implied) volatility is characterized by a curve that is a function of the strike price (among other things), so take care when using
  • Yields.jl can assist with converting rates to continuously compounded if you need to perform conversions.
source
FinanceModels.volatilityMethod
volatility(volatiltiy_model,strike_ratio,time_to_maturity)

Returns the volatility associated with the moneyness (strike/price ratio) and time to maturity.

source

Please open an issue if you encounter any issues or confusion with the package.

+([0.02 0.01 0.02; 1.02 0.01 0.02; … ; 0.0 0.01 0.02; 0.0 1.01 1.02], [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0])
source
FinanceModels.eurocallMethod
eurocall(;S=1.,K=1.,τ=1,r,σ,q=0.)

Calculate the Black-Scholes implied option price for a european call, where:

  • S is the current asset price
  • K is the strike or exercise price
  • τ is the time remaining to maturity (can be typed with \tau[tab])
  • r is the continuously compounded risk free rate
  • σ is the (implied) volatility (can be typed with \sigma[tab])
  • q is the continuously paid dividend rate

Rates should be input as rates (not percentages), e.g.: 0.05 instead of 5 for a rate of five percent.

!!! Experimental: this function is well-tested, but the derivatives functionality (API) may change in a future version of ActuaryUtilities.

Extended Help

This is the same as the formulation presented in the dividend extension of the BS model in Wikipedia.

Other general comments:

  • Swap/OIS curves are generally better sources for r than government debt (e.g. US Treasury) due to the collateralized nature of swap instruments.
  • (Implied) volatility is characterized by a curve that is a function of the strike price (among other things), so take care when using
  • Yields.jl can assist with converting rates to continuously compounded if you need to perform conversions.
source
FinanceModels.europutMethod
europut(;S=1.,K=1.,τ=1,r,σ,q=0.)

Calculate the Black-Scholes implied option price for a european call, where:

  • S is the current asset price
  • K is the strike or exercise price
  • τ is the time remaining to maturity (can be typed with \tau[tab])
  • r is the continuously compounded risk free rate
  • σ is the (implied) volatility (can be typed with \sigma[tab])
  • q is the continuously paid dividend rate

Rates should be input as rates (not percentages), e.g.: 0.05 instead of 5 for a rate of five percent.

!!! Experimental: this function is well-tested, but the derivatives functionality (API) may change in a future version of ActuaryUtilities.

Extended Help

This is the same as the formulation presented in the dividend extension of the BS model in Wikipedia.

Other general comments:

  • Swap/OIS curves are generally better sources for r than government debt (e.g. US Treasury) due to the collateralized nature of swap instruments.
  • (Implied) volatility is characterized by a curve that is a function of the strike price (among other things), so take care when using
  • Yields.jl can assist with converting rates to continuously compounded if you need to perform conversions.
source
FinanceModels.volatilityMethod
volatility(volatiltiy_model,strike_ratio,time_to_maturity)

Returns the volatility associated with the moneyness (strike/price ratio) and time to maturity.

source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/API/Fit/index.html b/dev/API/Fit/index.html index 621c3f0..fad858e 100644 --- a/dev/API/Fit/index.html +++ b/dev/API/Fit/index.html @@ -1,5 +1,5 @@ -Fit · FinanceModels.jl

FinanceModels.Fit API Reference

Exported API

Unexported API

FinanceModels.Fit.BootstrapType
Bootstrap()

A singleton type which is passed to fit in order to bootstrap Splines. The curves are fit such that the spline passes through the zero rates of the curve.

A subtype of FitMethod.

Examples

source
FinanceModels.Fit.LossType
Fit.Loss(function)

function should be a loss measure, such as x->x^2 or x->abs(x). This is used by the optimization algorithm in fit to determine optimal parameters as defined by this loss function.

A subtype of FitMethod.

Examples

julia> mod0 = Yield.Constant();
+Fit · FinanceModels.jl

FinanceModels.Fit API Reference

Exported API

Unexported API

FinanceModels.Fit.BootstrapType
Bootstrap()

A singleton type which is passed to fit in order to bootstrap Splines. The curves are fit such that the spline passes through the zero rates of the curve.

A subtype of FitMethod.

Examples

source
FinanceModels.Fit.LossType
Fit.Loss(function)

function should be a loss measure, such as x->x^2 or x->abs(x). This is used by the optimization algorithm in fit to determine optimal parameters as defined by this loss function.

A subtype of FitMethod.

Examples

julia> mod0 = Yield.Constant();
 
 julia> quotes = ZCBPrice([0.9, 0.8, 0.7,0.6]);
 
@@ -24,4 +24,4 @@
      0.120649 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│           
               └────────────────────────────────────────────────────────────┘           
               ⠀0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀time⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀30⠀  
-
source

Please open an issue if you encounter any issues or confusion with the package.

+
source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/API/Option/index.html b/dev/API/Option/index.html index dfba3d5..336a131 100644 --- a/dev/API/Option/index.html +++ b/dev/API/Option/index.html @@ -1,2 +1,2 @@ -Option · FinanceModels.jl

FinanceModels.Option API Reference

Exported API

Unexported API

FinanceModels.Option.EuroCallType
EuroCall(contract,strike,maturity)

A European call option on the given contract with the given strike and maturity.

Arguments

  • contract::AbstractContract - The underlying contract.
  • strike::Real - The strike price.
  • maturity::Union{Real,Date} - The maturity of the option.

Supertype Hierarchy ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

EuroCall{S,K,M} <: FinanceCore.AbstractContract <: Any
source

Please open an issue if you encounter any issues or confusion with the package.

+Option · FinanceModels.jl

FinanceModels.Option API Reference

Exported API

Unexported API

FinanceModels.Option.EuroCallType
EuroCall(contract,strike,maturity)

A European call option on the given contract with the given strike and maturity.

Arguments

  • contract::AbstractContract - The underlying contract.
  • strike::Real - The strike price.
  • maturity::Union{Real,Date} - The maturity of the option.

Supertype Hierarchy ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

EuroCall{S,K,M} <: FinanceCore.AbstractContract <: Any
source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/API/Spline/index.html b/dev/API/Spline/index.html index 19f5770..e95d820 100644 --- a/dev/API/Spline/index.html +++ b/dev/API/Spline/index.html @@ -1,5 +1,5 @@ -Spline · FinanceModels.jl

FinanceModels.Spline API Reference

Exported API

FinanceModels.SplineModule

Spline is a module which offers various degree splines used for fitting or bootstraping curves via the fit function.

Available methods:

  • Spline.BSpline(n) where n is the nth order. A spline function of order n is a piecewise polynomial function of degree n − 1. This means that, e.g., cubic polynomial is a fourth degree B-Spline.

This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

and convienience methods which create a Spline.BSpline object of the appropriate order.

  • Spline.Linear()
  • Spline.Quadratic()
  • Spline.Cubic()
source

Unexported API

FinanceModels.Spline.CubicMethod
Spline.Cubic()

Create a cubic B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

Returns

  • A BSpline object representing a cubic B-spline.

Examples

julia> Spline.Cubic()
-BSpline(4)
source
FinanceModels.Spline.LinearMethod
Spline.Linear()

Create a linear B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

Returns

  • A BSpline object representing a linear B-spline.

Examples

julia> Spline.Linear()
-BSpline(2)
source
FinanceModels.Spline.QuadraticMethod
Spline.Quadratic()

Create a quadratic B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

Returns

  • A BSpline object representing a quadratic B-spline.

Examples

julia> Spline.Quadratic()
-BSpline(3)
source

Please open an issue if you encounter any issues or confusion with the package.

+Spline · FinanceModels.jl

FinanceModels.Spline API Reference

Exported API

FinanceModels.SplineModule

Spline is a module which offers various degree splines used for fitting or bootstraping curves via the fit function.

Available methods:

  • Spline.BSpline(n) where n is the nth order. A spline function of order n is a piecewise polynomial function of degree n − 1. This means that, e.g., cubic polynomial is a fourth degree B-Spline.

This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

and convienience methods which create a Spline.BSpline object of the appropriate order.

  • Spline.Linear()
  • Spline.Quadratic()
  • Spline.Cubic()
source

Unexported API

FinanceModels.Spline.CubicMethod
Spline.Cubic()

Create a cubic B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

Returns

  • A BSpline object representing a cubic B-spline.

Examples

julia> Spline.Cubic()
+BSpline(4)
source
FinanceModels.Spline.LinearMethod
Spline.Linear()

Create a linear B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

Returns

  • A BSpline object representing a linear B-spline.

Examples

julia> Spline.Linear()
+BSpline(2)
source
FinanceModels.Spline.QuadraticMethod
Spline.Quadratic()

Create a quadratic B-spline. This object is not a fitted spline itself, rather it is a placeholder object which will be a spline representing the data only after using within fit.

Returns

  • A BSpline object representing a quadratic B-spline.

Examples

julia> Spline.Quadratic()
+BSpline(3)
source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/API/Volatility/index.html b/dev/API/Volatility/index.html index cbb5826..95ca8e5 100644 --- a/dev/API/Volatility/index.html +++ b/dev/API/Volatility/index.html @@ -1,2 +1,2 @@ -Volatility · FinanceModels.jl
+Volatility · FinanceModels.jl
diff --git a/dev/API/Yield/index.html b/dev/API/Yield/index.html index a7c266d..c2b0880 100644 --- a/dev/API/Yield/index.html +++ b/dev/API/Yield/index.html @@ -1,6 +1,6 @@ -Yield · FinanceModels.jl

FinanceModels.Yield API Reference

Exported API

Base.zeroMethod
zero(curve,time)

Return the zero rate for the curve at the given time.

source
FinanceCore.discountMethod
discount(yc, to)
-discount(yc, from,to)

The discount factor for the yield curve yc for times from through to.

source
FinanceCore.forwardMethod
forward(yc, from, to)˚

The forward Rate implied by the yield curve yc between times from and to.

source
FinanceModels.Yield.parMethod
par(curve,time;frequency=2)

Calculate the par yield for maturity time for the given curve and frequency. Returns a Rate object with periodicity corresponding to the frequency. The exception to this is if time is less than what the payments allowed by frequency (e.g. a time 0.5 but with frequency 1) will effectively assume frequency equal to 1 over time.

Examples

julia> c = Yields.Constant(0.04);
+Yield · FinanceModels.jl

FinanceModels.Yield API Reference

Exported API

Base.zeroMethod
zero(curve,time)

Return the zero rate for the curve at the given time.

source
FinanceCore.discountMethod
discount(yc, to)
+discount(yc, from,to)

The discount factor for the yield curve yc for times from through to.

source
FinanceCore.forwardMethod
forward(yc, from, to)˚

The forward Rate implied by the yield curve yc between times from and to.

source
FinanceModels.Yield.parMethod
par(curve,time;frequency=2)

Calculate the par yield for maturity time for the given curve and frequency. Returns a Rate object with periodicity corresponding to the frequency. The exception to this is if time is less than what the payments allowed by frequency (e.g. a time 0.5 but with frequency 1) will effectively assume frequency equal to 1 over time.

Examples

julia> c = Yields.Constant(0.04);
 
 julia> Yields.par(c,4)
 Yields.Rate{Float64, Yields.Periodic}(0.03960780543711406, Yields.Periodic(2))
@@ -15,7 +15,7 @@
 Yields.Rate{Float64, Yields.Periodic}(0.039374942589460726, Yields.Periodic(5))
 
 julia> Yields.par(c,2.5)
-Yields.Rate{Float64, Yields.Periodic}(0.03960780543711406, Yields.Periodic(2))
source

Unexported API

FinanceModels.Yield.CompositeYieldType
CompositeYield(curve1,curve2,operation)

Creates a datastructure that will perform the given operation after independently calculating the effects of the two curves. Can only be created via the public API by using the +, -, *, and / operatations on AbstractYield objects.

As this is double the normal operations when performing calculations, if you are using the curve in performance critical locations, you should consider transforming the inputs and constructing a single curve object ahead of time.

source
FinanceModels.Yield.ConstantType
Constant(rate)

A yield curve representing a flat term structure. rate can be a Rate object or a Real object.

If fiting with the default FinanceModels.jl settings, the solver will attempt to fit a discount rate with the range of: -1.0 .. 1.0

source
FinanceModels.Yield.ForwardStartingType
ForwardStarting(curve,forwardstart)

Rebase a curve so that discount/accumulation/etc. are re-based so that time zero from the new curves perspective is the given forwardstart time.

Examples

julia> zero = [5.0, 5.8, 6.4, 6.8] ./ 100
+Yields.Rate{Float64, Yields.Periodic}(0.03960780543711406, Yields.Periodic(2))
source

Unexported API

FinanceModels.Yield.CompositeYieldType
CompositeYield(curve1,curve2,operation)

Creates a datastructure that will perform the given operation after independently calculating the effects of the two curves. Can only be created via the public API by using the +, -, *, and / operatations on AbstractYield objects.

As this is double the normal operations when performing calculations, if you are using the curve in performance critical locations, you should consider transforming the inputs and constructing a single curve object ahead of time.

source
FinanceModels.Yield.ConstantType
Constant(rate)

A yield curve representing a flat term structure. rate can be a Rate object or a Real object.

If fiting with the default FinanceModels.jl settings, the solver will attempt to fit a discount rate with the range of: -1.0 .. 1.0

source
FinanceModels.Yield.ForwardStartingType
ForwardStarting(curve,forwardstart)

Rebase a curve so that discount/accumulation/etc. are re-based so that time zero from the new curves perspective is the given forwardstart time.

Examples

julia> zero = [5.0, 5.8, 6.4, 6.8] ./ 100
 julia> maturity = [0.5, 1.0, 1.5, 2.0]
 julia> curve = Yields.Zero(zero, maturity)
 julia> fwd = Yields.ForwardStarting(curve, 1.0)
@@ -24,7 +24,7 @@
 0.9275624570410582
 
 julia> FinanceCore.discount(fwd,1) # `curve` has effectively been reindexed to `1.0`
-0.9275624570410582

Extended Help

While ForwardStarting could be nested so that, e.g. the third period's curve is the one-period forward of the second period's curve, it will be more efficient to reuse the initial curve from a runtime and compiler perspective.

ForwardStarting is not used to construct a curve based on forward rates.

source
FinanceModels.Yield.NelsonSiegelType
NelsonSiegel(β₀, β₁, β₂, τ₁)
+0.9275624570410582

Extended Help

While ForwardStarting could be nested so that, e.g. the third period's curve is the one-period forward of the second period's curve, it will be more efficient to reuse the initial curve from a runtime and compiler perspective.

ForwardStarting is not used to construct a curve based on forward rates.

source
FinanceModels.Yield.NelsonSiegelType
NelsonSiegel(β₀, β₁, β₂, τ₁)
 NelsonSiegel(τ₁=1.0) # used in fitting

A Nelson-Siegel yield curve model Parameters of Nelson and Siegel (1987) parametric model, along with default parameter ranges used in the fitting:

  • β₀ represents a long-term interest rate: -10.0 .. 10.0
  • β₁ represents a time-decay component: -10.0 .. 10.0
  • β₂ represents a hump: -10.0 .. 10.0
  • τ₁ controls the location of the hump: 0.0 .. 100.0

Examples

julia> β₀, β₁, β₂, τ₁ = 0.6, -1.2, -1.9, 3.0
 julia> nsm = Yields.NelsonSiegel.(β₀, β₁, β₂, τ₁)
 
@@ -35,7 +35,7 @@
 ## References
 - https://onriskandreturn.com/2019/12/01/nelson-siegel-yield-curve-model/
 - https://www.bis.org/publ/bppdf/bispap25.pdf
-
source
FinanceModels.Yield.NelsonSiegelSvenssonType
NelsonSiegelSvensson(τ₁, τ₂, β₀, β₁, β₂, β₃)
 NelsonSiegelSvensson(τ₁=1.0, τ₂=1.0)

Return the NelsonSiegelSvensson yield curve. The rates should be continuous zero spot rates. If rates are not Rates, then they will be interpreted as Continuous Rates.

Parameters of Svensson (1994) parametric model, along with the default parameter bounds used in the fit routine:

  • τ₁ controls the location of the hump: 0.0 .. 100.0
  • τ₁ controls the location of the second hump: 0.0 .. 100.0
  • β₀ represents a long-term interest rate: -10.0 .. 10.0
  • β₁ represents a time-decay component: -10.0 .. 10.0
  • β₂ represents a hump: -10.0 .. 10.0
  • β₃ represents a second hump: -10.0 .. 10.0

Examples

julia> β₀, β₁, β₂, β₃, τ₁, τ₂ = 0.6, -1.2, -2.1, 3.0, 1.5
 julia> nssm = NelsonSiegelSvensson.NelsonSiegelSvensson.(β₀, β₁, β₂, β₃, τ₁, τ₂)
 
@@ -55,7 +55,7 @@
 ## References
 - https://onriskandreturn.com/2019/12/01/nelson-siegel-yield-curve-model/
 - https://www.bis.org/publ/bppdf/bispap25.pdf
-
source
FinanceModels.Yield.SmithWilsonType
Yield.SmithWilson(u, qb; ufr=ufr, α=α)
 Yield.SmithWilson(;ufr=ufr, α=α)

Create a yield curve object that implements the Smith-Wilson interpolation/extrapolation scheme.

To calibrate a curve, you generally want to construct the object without the u and qb arguments and call fit in conjunction with Quotes (fit requires no third parameter for SmithWilson curves). See Examples for what this looks like. Positional arguments to construct a curve:

  • A curve can be with u is the timepoints coming from the calibration, and qb is the internal parameterization of the curve that ensures that the calibration is correct. Users may prefer the other constructors but this mathematical constructor is also available.

Required keyword arguments:

  • ufr is the Ultimate Forward Rate, the forward interest rate to which the yield curve tends, in continuous compounding convention.
  • α is the parameter that governs the speed of convergence towards the Ultimate Forward Rate. It can be typed with \alpha[TAB]

Examples

times = [1.0, 2.5, 5.6]
 prices = [0.9, 0.7, 0.5]
 qs = ZCBPrice.(prices, times)
@@ -63,16 +63,16 @@
 ufr = 0.03
 α = 0.1
 
-model = fit(Yield.SmithWilson(ufr=ufr, α=α), qs)

Extended Help

References

source
Base.:*Method
Yields.AbstractYieldModel * Yields.AbstractYieldModel

The multiplication of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the two curves will be added together. This can be useful, for example, if you wanted to after-tax a yield.

Examples

julia> m = Yields.Constant(0.01) * 0.79;
+model = fit(Yield.SmithWilson(ufr=ufr, α=α), qs)

Extended Help

References

source
Base.:*Method
Yields.AbstractYieldModel * Yields.AbstractYieldModel

The multiplication of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the two curves will be added together. This can be useful, for example, if you wanted to after-tax a yield.

Examples

julia> m = Yields.Constant(0.01) * 0.79;
 
 julia> accumulation(m,1)
 1.0079
 
 julia> accumulation(.01*.79,1)
-1.0079
source
Base.:+Method
Yields.AbstractYieldModel + Yields.AbstractYieldModel

The addition of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the two curves will be added together.

source
Base.:-Method
Yields.AbstractYieldModel - Yields.AbstractYieldModel

The subtraction of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the second curves will be subtracted from the first.

source
Base.:/Method
Yields.AbstractYieldModel / Yields.AbstractYieldModel

The division of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the two curves will have the first divided by the second. This can be useful, for example, if you wanted to gross-up a yield to be pre-tax.

Examples

julia> m = Yields.Constant(0.01) / 0.79;
+1.0079
source
Base.:+Method
Yields.AbstractYieldModel + Yields.AbstractYieldModel

The addition of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the two curves will be added together.

source
Base.:-Method
Yields.AbstractYieldModel - Yields.AbstractYieldModel

The subtraction of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the second curves will be subtracted from the first.

source
Base.:/Method
Yields.AbstractYieldModel / Yields.AbstractYieldModel

The division of two yields will create a CompositeYield. For rate, discount, and accumulation purposes the spot rates of the two curves will have the first divided by the second. This can be useful, for example, if you wanted to gross-up a yield to be pre-tax.

Examples

julia> m = Yields.Constant(0.01) / 0.79;
 
 julia> accumulation(d,1)
 1.0126582278481013
 
 julia> accumulation(.01/.79,1)
-1.0126582278481013
source

Please open an issue if you encounter any issues or confusion with the package.

+1.0126582278481013
source

Please open an issue if you encounter any issues or confusion with the package.

diff --git a/dev/Rates/index.html b/dev/Rates/index.html index 84e435f..a9387d6 100644 --- a/dev/Rates/index.html +++ b/dev/Rates/index.html @@ -9,4 +9,4 @@ convert(Yields.Continuous(),r) # convert monthly rate to continuous

To get the scalar value out of the Rate, use FinanceModels.rate(r):

julia> r = Rate(0.01,Periodic(12));   
 julia> rate(r)
 0.01
-

Arithmetic

Adding, subtracting, multiplying, dividing, and comparing rates is supported.

+

Arithmetic

Adding, subtracting, multiplying, dividing, and comparing rates is supported.

diff --git a/dev/Updates/index.html b/dev/Updates/index.html index 9bf36a0..f463857 100644 --- a/dev/Updates/index.html +++ b/dev/Updates/index.html @@ -1,2 +1,2 @@ -FinanceModels.jl · FinanceModels.jl

FinanceModels.jl

Design

  • Contracts represent insturments that ultimately obligate a payment of cashflows, which may or may not be scenario dependant.
  • Quotes are observed or reference prices that may be used to fit models.
  • Models are the combination of assumptions and logic that can then be used to realize the assumed cashflows that arise from a contract.

Motivation

FinanceModels.jl is the evolution of Yields.jl. Yields.jl was originally designed for very nice usage of term structures of yield curves, but three aspects held it back:

  1. The design was very oriented towards interest rates, and it was awkward to stick, e.g. volatility models into a package called Yields.jl
  2. The API for contructing curves was inconsistent because there are different ways to construct a given curve and the inputs to constructing a simple bootstrapped curve with a spline through given yields vs a best-fit of a variety of instrumnets was simply a different paradigm.
  3. There was a lack of ability to even express some types of contracts that are useful for model-fitting or modeling in general.

TODOs

  • bond.frequency.frequency is awkward
  • Core contracts:
    • Composite contact (e.g. Fixed + Float -> Swap)
    • Forward contact
    • Derivatives?
    • distinguish between clean and dirty prices
  • Projections
    • Everythign is currently coerced to a F64/F64 Cashflow, but would like to be flexible with amount and timepoints
  • How to integrate Dates?
  • Core methods:
    • port Yields.jl methods
  • Ergonomics:
  • Package design:
    • promote pv to FinanceCore given it's utility here
    • promote Cashflow up to FC
+FinanceModels.jl · FinanceModels.jl

FinanceModels.jl

Design

  • Contracts represent insturments that ultimately obligate a payment of cashflows, which may or may not be scenario dependant.
  • Quotes are observed or reference prices that may be used to fit models.
  • Models are the combination of assumptions and logic that can then be used to realize the assumed cashflows that arise from a contract.

Motivation

FinanceModels.jl is the evolution of Yields.jl. Yields.jl was originally designed for very nice usage of term structures of yield curves, but three aspects held it back:

  1. The design was very oriented towards interest rates, and it was awkward to stick, e.g. volatility models into a package called Yields.jl
  2. The API for contructing curves was inconsistent because there are different ways to construct a given curve and the inputs to constructing a simple bootstrapped curve with a spline through given yields vs a best-fit of a variety of instrumnets was simply a different paradigm.
  3. There was a lack of ability to even express some types of contracts that are useful for model-fitting or modeling in general.

TODOs

  • bond.frequency.frequency is awkward
  • Core contracts:
    • Composite contact (e.g. Fixed + Float -> Swap)
    • Forward contact
    • Derivatives?
    • distinguish between clean and dirty prices
  • Projections
    • Everythign is currently coerced to a F64/F64 Cashflow, but would like to be flexible with amount and timepoints
  • How to integrate Dates?
  • Core methods:
    • port Yields.jl methods
  • Ergonomics:
  • Package design:
    • promote pv to FinanceCore given it's utility here
    • promote Cashflow up to FC
diff --git a/dev/contracts/index.html b/dev/contracts/index.html index 8934bfe..b553da3 100644 --- a/dev/contracts/index.html +++ b/dev/contracts/index.html @@ -39,4 +39,4 @@ Cashflow{Float64, Float64}(0.1, 3.5) Cashflow{Float64, Float64}(0.1, 4.0) Cashflow{Float64, Float64}(0.1, 4.5) - Cashflow{Float64, Float64}(0.1, 5.0)

Note that all contracts in FinanceModels.jl are currently unit contracts in that they assume a unit par value.

More complex Contracts

When the cashflow depends on a model. An example of this is a floating bond where the coupon paid depends on a view of forward rates. See this section in the overview on projections for how this is handled.

Available Contracts & Modules

See the Modules in the left navigation for details on available contracts/models/functions.

+ Cashflow{Float64, Float64}(0.1, 5.0)

Note that all contracts in FinanceModels.jl are currently unit contracts in that they assume a unit par value.

More complex Contracts

When the cashflow depends on a model. An example of this is a floating bond where the coupon paid depends on a view of forward rates. See this section in the overview on projections for how this is handled.

Available Contracts & Modules

See the Modules in the left navigation for details on available contracts/models/functions.

diff --git a/dev/faq/index.html b/dev/faq/index.html index b1c8ea1..4d1c379 100644 --- a/dev/faq/index.html +++ b/dev/faq/index.html @@ -1,2 +1,2 @@ -FAQs · FinanceModels.jl

Frequently Asked Questions

How can I handle Dates instead of real timepoints?

Currently, you must convert the Date into a real-valued timepoint for use within the models and contracts. Future releases may contemplate more explicit, built-in handling of dates. In the meantime, you may find these packages helpful if you need precise date-level accuracy:

Why does the package rely on using Transducers?

Transducers are a way of defining logic to be applied to a reducible collection. They can compose together efficiently and the compiler can optimize them well. In rewriting the package from v3 to v4, Transducers vastly simplified the iteration and state handling needed when projecting the contracts. The performance remains excellent and made a lot of the internals much simpler.

Transducers are a rich and powerful way to express programs and can seem somewhat unfamiliar at first encounter. For users of FinanceModels, very of transducers are needed/exposed:

  • To regular end-users who just use what is given to them here, the transducers internals are effectively completely hidden
  • To moderately advanced users who want to extend the functionality, as the examples show the only real exposure here is a weird function name ( __foldl__) with for loop with a return signature that has some extra information.

A number of examples of extending the package are given on the FinanceModels.jl Guide page and the of course the source code itself offers examples of existing Projections and Contracts.

I have another question

Ask on the discussion forum here: https://github.com/JuliaActuary/FinanceModels.jl/discussions

+FAQs · FinanceModels.jl

Frequently Asked Questions

How can I handle Dates instead of real timepoints?

Currently, you must convert the Date into a real-valued timepoint for use within the models and contracts. Future releases may contemplate more explicit, built-in handling of dates. In the meantime, you may find these packages helpful if you need precise date-level accuracy:

Why does the package rely on using Transducers?

Transducers are a way of defining logic to be applied to a reducible collection. They can compose together efficiently and the compiler can optimize them well. In rewriting the package from v3 to v4, Transducers vastly simplified the iteration and state handling needed when projecting the contracts. The performance remains excellent and made a lot of the internals much simpler.

Transducers are a rich and powerful way to express programs and can seem somewhat unfamiliar at first encounter. For users of FinanceModels, very of transducers are needed/exposed:

  • To regular end-users who just use what is given to them here, the transducers internals are effectively completely hidden
  • To moderately advanced users who want to extend the functionality, as the examples show the only real exposure here is a weird function name ( __foldl__) with for loop with a return signature that has some extra information.

A number of examples of extending the package are given on the FinanceModels.jl Guide page and the of course the source code itself offers examples of existing Projections and Contracts.

I have another question

Ask on the discussion forum here: https://github.com/JuliaActuary/FinanceModels.jl/discussions

diff --git a/dev/index.html b/dev/index.html index 285879a..94d21dd 100644 --- a/dev/index.html +++ b/dev/index.html @@ -42,4 +42,4 @@ Continuous()(0.05)

Conversion

Convert rates between different types with convert. E.g.:

r = Rate(FinanceModels.Periodic(12),0.01)             # rate that compounds 12 times per rate period (ie monthly)
 
 convert(FinanceModels.Periodic(1),r)                  # convert monthly rate to annual effective
-convert(FinanceModels.Continuous(),r)          # convert monthly rate to continuous

Arithmetic

Adding, substracting, multiplying, dividing, and comparing rates is supported.

Guide and Documentation

A guide which explains more about the components of the package and from-scratch examples of extending the package is available in the documenation

Exported vs Un-exported Functions

Generally, CamelCase methods which construct a datatype are exported as they are unlikely to conflict with other parts of code that may be written. For example, rate is un-exported (it must be called with FinanceModels.rate(...)) because rate is likely a very commonly defined variable within actuarial and financial contexts and there is a high risk of conflicting with defined variables.

Consider using import FinanceModels which would require qualifying all methods, but alleviates any namespace conflicts and has the benefit of being explicit about the calls (internally we prefer this in the package design to keep dependencies and their usage clear).

Internals

For time-variant FinanceModels (ie yield curves), the inputs are converted to spot rates and interpolated using quadratic B-splines by default (see documentation for alternatives, such as linear interpolations).

Combination Implementation

Combinations track two different curve objects and are not combined into a single underlying data structure. This means that you may achieve better performance if you combine the rates before constructing a FinanceModels representation. The exception to this is Constant curves, which do get combined into a single structure that is as performant as pre-combined rate structure.

+convert(FinanceModels.Continuous(),r) # convert monthly rate to continuous

Arithmetic

Adding, substracting, multiplying, dividing, and comparing rates is supported.

Guide and Documentation

A guide which explains more about the components of the package and from-scratch examples of extending the package is available in the documenation

Exported vs Un-exported Functions

Generally, CamelCase methods which construct a datatype are exported as they are unlikely to conflict with other parts of code that may be written. For example, rate is un-exported (it must be called with FinanceModels.rate(...)) because rate is likely a very commonly defined variable within actuarial and financial contexts and there is a high risk of conflicting with defined variables.

Consider using import FinanceModels which would require qualifying all methods, but alleviates any namespace conflicts and has the benefit of being explicit about the calls (internally we prefer this in the package design to keep dependencies and their usage clear).

Internals

For time-variant FinanceModels (ie yield curves), the inputs are converted to spot rates and interpolated using quadratic B-splines by default (see documentation for alternatives, such as linear interpolations).

Combination Implementation

Combinations track two different curve objects and are not combined into a single underlying data structure. This means that you may achieve better performance if you combine the rates before constructing a FinanceModels representation. The exception to this is Constant curves, which do get combined into a single structure that is as performant as pre-combined rate structure.

diff --git a/dev/introduction/index.html b/dev/introduction/index.html index 3d94d97..4046757 100644 --- a/dev/introduction/index.html +++ b/dev/introduction/index.html @@ -143,4 +143,4 @@ (time = 3.5, payment = 0.1, outstanding = 0.30000000000000016) (time = 4.0, payment = 0.1, outstanding = 0.20000000000000015) (time = 4.5, payment = 0.1, outstanding = 0.10000000000000014) - (time = 5.0, payment = 0.1, outstanding = 1.3877787807814457e-16) + (time = 5.0, payment = 0.1, outstanding = 1.3877787807814457e-16) diff --git a/dev/migration/index.html b/dev/migration/index.html index 02a68a0..e6f04d3 100644 --- a/dev/migration/index.html +++ b/dev/migration/index.html @@ -27,4 +27,4 @@ quotes = ZCBPrice([0.9, 0.8, 0.7,0.6]) -m = fit(ABDiscountLine(),quotes) +m = fit(ABDiscountLine(),quotes) diff --git a/dev/models/index.html b/dev/models/index.html index aacf5dd..6ccf50e 100644 --- a/dev/models/index.html +++ b/dev/models/index.html @@ -27,4 +27,4 @@ 0.8889963586709149 julia> discount(0.04,3) -0.8889963586709148

Creating New Yield Models

See the FinanceModels.jl Guide for an example of creating a model from scratch. Some additional aspects to note:

Equity and Volatility Models

Available Models - Option Valuation

Available Models - Volatility

Creating new Volatility Models

A volatility model must extend volatility(vol::Volatility.MyNewModel, strike_ratio, time_to_maturity).

+0.8889963586709148

Creating New Yield Models

See the FinanceModels.jl Guide for an example of creating a model from scratch. Some additional aspects to note:

Equity and Volatility Models

Available Models - Option Valuation

Available Models - Volatility

Creating new Volatility Models

A volatility model must extend volatility(vol::Volatility.MyNewModel, strike_ratio, time_to_maturity).