Skip to content

Vasicek example #55

Closed
Closed

Description

Hi,

I have a question regarding the Vasicek example in the documentation.

The REPL help shows:

julia> m = Vasicek(0.136,0.0168,0.0119,Yields.Continuous(0.01))

However, when I tried this example, I received an error.

May I know if Yields.Continuous(0.01) should be Continuous(0.01) by using FinanceCore? I tried and it worked but would like to confirm this is the correct usage.

Apologies if I have misunderstood the documentation.

Thank you.

Activity

  1. alecloudenback commented on Jul 18, 2026

    @alecloudenback
    Member

    Hi — yes, that’s correct. Yields.Continuous(0.01) belongs to an older API, so the documentation example you encountered was stale.

    With EconomicScenarioGenerators.jl, the corrected usage is:

    using EconomicScenarioGenerators
    using FinanceCore
    
    m = Vasicek(
        0.136,
        0.0168,
        0.0119,
        FinanceCore.Continuous(0.01),
    )

    Alternatively, FinanceModels re-exports Continuous, so this also works:

    using EconomicScenarioGenerators
    using FinanceModels
    
    m = Vasicek(0.136, 0.0168, 0.0119, Continuous(0.01))

    For new single-model interest-rate simulations, however, we recommend using the maintained successor in FinanceModels.jl v6 or later. Here is the equivalent complete example:

    using FinanceModels
    using Random
    
    model = ShortRate.Vasicek(
        0.136,            # speed of mean reversion
        0.0168,           # long-term mean rate
        0.0119,           # volatility
        Continuous(0.01), # initial short rate
    )
    
    # Generate one reproducible scenario at half-year intervals for 30 years.
    scenarios = simulate(
        model;
        n_scenarios = 1,
        timestep = 0.5,
        horizon = 30.0,
        rng = Xoshiro(1),
    )
    
    path = only(scenarios)
    
    # Extract the simulated short rates.
    times = 0.0:0.5:30.0
    rates = short_rate.(Ref(path), times)
    
    collect(zip(times, rates))

    The initial rate may also be passed directly as a scalar, which is interpreted as continuously compounded:

    model = ShortRate.Vasicek(0.136, 0.0168, 0.0119, 0.01)

    FinanceModels.jl now provides the maintained single-model short-rate implementations and simulation functionality. EconomicScenarioGenerators.jl remains the home of Correlated, which supports copula-correlated simulation across multiple models.

    Thank you for reporting this—and no need to apologize. Your understanding is correct.

  2. alecloudenback commented on Jul 18, 2026

    @alecloudenback
    Member

    Also, @momoxaxa I see that you are creating a Julia life model repository - I'd love to connect and chat to learn more about your background and other repository work. Feel free to reach out on LinkedIn or the Julia slack if you are interested in connecting.

  3. ghost closed this as completedon Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions