IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Simulating Stochastic Scenarios with Diffusion Models: A Guide to Using techtonique.net’s API for the purpose

    T. Moudiki发表于 2025-05-29 00:00:00
    love 0
    [This article was first published on T. Moudiki's Webpage - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
    Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

    This blog post demonstrates how to use the (work in progress) stochastic simulation API provided by techtonique.net to generate scenarios using various diffusion models. We’ll explore how to simulate paths using:

    1. Geometric Brownian Motion (GBM)
    2. Cox-Ingersoll-Ross (CIR) process
    3. Ornstein-Uhlenbeck (OU) process
    4. Gaussian Shocks scenarios

    These models are particularly useful for:

    • Financial simulation
    • Risk assessment
    • Portfolio stress testing
    • Economic scenario analysis

    We’ll walk through examples showing how to:

    • Make API calls with proper authentication
    • Generate multiple scenarios with different parameters

    The API supports (for now) various parameters including (also, read the docs):

    • Number of scenarios
    • Time horizon
    • Frequency (daily, weekly, monthly, quarterly, yearly)
    • Initial values
    • Model-specific parameters
    • Random seed for reproducibility

    Let’s get started!

    First, get a token from: https://www.techtonique.net/token.

    Now, here’s how to use the token in API requests for stochatic simulations. The JSON response contains a key “sims”. Each list is a future scenario, as envisaged by the chosen model, and based on the initial value 100.

    Note that you can use https://curlconverter.com/ to translate the following request in your favorite programming language.

    # Replace YOUR_TOKEN_HERE with your actual token
    curl -X GET "https://www.techtonique.net/scenarios/simulate/?model=GBM&n=6&horizon=5&frequency=quarterly&x0=100&theta1=0.1&theta2=0.2&theta3=0.3&seed=123" \
         -H "accept: application/json" \
         -H "Authorization: Bearer YOUR_TOKEN_HERE"
    

    Note that you can use https://curlconverter.com/ to translate the following request in your favorite programming language.

    curl -X GET "https://www.techtonique.net/scenarios/simulate/?model=CIR&n=6&horizon=5&frequency=quarterly&x0=100&theta1=0.1&theta2=0.2&theta3=0.3&seed=123" \
         -H "accept: application/json" \
         -H "Authorization: Bearer YOUR_TOKEN_HERE"
    

    Note that you can use https://curlconverter.com/ to translate the following request in your favorite programming language.

    curl -X GET "https://www.techtonique.net/scenarios/simulate/?model=OU&n=6&horizon=5&frequency=quarterly&x0=100&theta1=0.1&theta2=0.2&theta3=0.3&seed=123" \
         -H "accept: application/json" \
         -H "Authorization: Bearer YOUR_TOKEN_HERE"
    

    Note that you can use https://curlconverter.com/ to translate the following request in your favorite programming language.

    curl -X GET "https://www.techtonique.net/scenarios/simulate/?model=shocks&n=6&horizon=5&frequency=quarterly&seed=123" \
         -H "accept: application/json" \
         -H "Authorization: Bearer YOUR_TOKEN_HERE"
    

    image-title-here

    To leave a comment for the author, please follow the link and comment on their blog: T. Moudiki's Webpage - R.

    R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
    Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
    Continue reading: Simulating Stochastic Scenarios with Diffusion Models: A Guide to Using techtonique.net’s API for the purpose


沪ICP备19023445号-2号
友情链接