techtonique_apis.techto_simulation

 1import pandas as pd
 2from xlwings import func, arg, ret
 3from .techtonique_apis import TechtoniqueAPI
 4
 5api = TechtoniqueAPI()
 6
 7
 8@func
 9@arg("model", doc='Simulation model (default: "GBM")')
10@arg("n", doc="Number of scenarios (default: 10)")
11@arg("horizon", doc="Simulation horizon (default: 5)")
12@arg("frequency", doc='Frequency (default: "quarterly")')
13@arg("x0", doc="Initial value (default: 1.0)")
14@arg("theta1", doc="Model parameter theta1 (default: 0.0)")
15@arg("theta2", doc="Model parameter theta2 (default: 0.5)")
16@arg("theta3", doc="Model parameter theta3 (optional)")
17@arg("seed", doc="Random seed (optional)")
18@ret(index=False, doc="Simulation results as a table for Excel")
19def techto_simulation(
20    model: str = "GBM",
21    n: int = 10,
22    horizon: int = 5,
23    frequency: str = "quarterly",
24    x0: float = 1.0,
25    theta1: float = 0.0,
26    theta2: float = 0.5,
27    theta3: float = None,
28    seed: int = None,
29) -> pd.DataFrame:
30    """
31    Simulation: run scenario simulation using the Techtonique API.
32
33    Excel/xlwings custom function: Run scenario simulation from Excel using the Techtonique API.
34
35    Parameters
36    ----------
37
38    model : str, default "GBM"
39        Simulation model to use.
40
41    n : int, default 10
42        Number of scenarios.
43
44    horizon : int, default 5
45        Simulation horizon.
46
47    frequency : str, default "quarterly"
48        Frequency of simulation.
49
50    x0 : float, default 1.0
51        Initial value.
52
53    theta1 : float, default 0.0
54        Model parameter theta1.
55
56    theta2 : float, default 0.5
57        Model parameter theta2.
58
59    theta3 : float, optional
60        Model parameter theta3.
61
62    seed : int, optional
63        Random seed.
64
65    Returns
66    -------
67
68    pd.DataFrame
69        Simulation results as a DataFrame for Excel.
70
71    ---
72    xlwings lite docstring (for Excel help):
73    Run scenario simulation from Excel using the Techtonique API.
74    - model: Simulation model (default: GBM).
75    - n: Number of scenarios (default: 10).
76    - horizon: Simulation horizon (default: 5).
77    - frequency: Frequency (default: quarterly).
78    - x0: Initial value (default: 1.0).
79    - theta1: Model parameter theta1 (default: 0.0).
80    - theta2: Model parameter theta2 (default: 0.5).
81    - theta3: Model parameter theta3 (optional).
82    - seed: Random seed (optional).
83    Returns: Simulation results as a table for Excel.
84    """
85    result = api.simulate_scenario(
86        model=model,
87        n=n,
88        horizon=horizon,
89        frequency=frequency,
90        x0=x0,
91        theta1=theta1,
92        theta2=theta2,
93        theta3=theta3,
94        seed=seed,
95    )
96    # Adjust as needed based on API response structure
97    return pd.DataFrame(result["sims"])
@func
@arg('model', doc='Simulation model (default: "GBM")')
@arg('n', doc='Number of scenarios (default: 10)')
@arg('horizon', doc='Simulation horizon (default: 5)')
@arg('frequency', doc='Frequency (default: "quarterly")')
@arg('x0', doc='Initial value (default: 1.0)')
@arg('theta1', doc='Model parameter theta1 (default: 0.0)')
@arg('theta2', doc='Model parameter theta2 (default: 0.5)')
@arg('theta3', doc='Model parameter theta3 (optional)')
@arg('seed', doc='Random seed (optional)')
@ret(index=False, doc='Simulation results as a table for Excel')
def techto_simulation( model: str = 'GBM', n: int = 10, horizon: int = 5, frequency: str = 'quarterly', x0: float = 1.0, theta1: float = 0.0, theta2: float = 0.5, theta3: float = None, seed: int = None) -> pandas.core.frame.DataFrame:
 9@func
10@arg("model", doc='Simulation model (default: "GBM")')
11@arg("n", doc="Number of scenarios (default: 10)")
12@arg("horizon", doc="Simulation horizon (default: 5)")
13@arg("frequency", doc='Frequency (default: "quarterly")')
14@arg("x0", doc="Initial value (default: 1.0)")
15@arg("theta1", doc="Model parameter theta1 (default: 0.0)")
16@arg("theta2", doc="Model parameter theta2 (default: 0.5)")
17@arg("theta3", doc="Model parameter theta3 (optional)")
18@arg("seed", doc="Random seed (optional)")
19@ret(index=False, doc="Simulation results as a table for Excel")
20def techto_simulation(
21    model: str = "GBM",
22    n: int = 10,
23    horizon: int = 5,
24    frequency: str = "quarterly",
25    x0: float = 1.0,
26    theta1: float = 0.0,
27    theta2: float = 0.5,
28    theta3: float = None,
29    seed: int = None,
30) -> pd.DataFrame:
31    """
32    Simulation: run scenario simulation using the Techtonique API.
33
34    Excel/xlwings custom function: Run scenario simulation from Excel using the Techtonique API.
35
36    Parameters
37    ----------
38
39    model : str, default "GBM"
40        Simulation model to use.
41
42    n : int, default 10
43        Number of scenarios.
44
45    horizon : int, default 5
46        Simulation horizon.
47
48    frequency : str, default "quarterly"
49        Frequency of simulation.
50
51    x0 : float, default 1.0
52        Initial value.
53
54    theta1 : float, default 0.0
55        Model parameter theta1.
56
57    theta2 : float, default 0.5
58        Model parameter theta2.
59
60    theta3 : float, optional
61        Model parameter theta3.
62
63    seed : int, optional
64        Random seed.
65
66    Returns
67    -------
68
69    pd.DataFrame
70        Simulation results as a DataFrame for Excel.
71
72    ---
73    xlwings lite docstring (for Excel help):
74    Run scenario simulation from Excel using the Techtonique API.
75    - model: Simulation model (default: GBM).
76    - n: Number of scenarios (default: 10).
77    - horizon: Simulation horizon (default: 5).
78    - frequency: Frequency (default: quarterly).
79    - x0: Initial value (default: 1.0).
80    - theta1: Model parameter theta1 (default: 0.0).
81    - theta2: Model parameter theta2 (default: 0.5).
82    - theta3: Model parameter theta3 (optional).
83    - seed: Random seed (optional).
84    Returns: Simulation results as a table for Excel.
85    """
86    result = api.simulate_scenario(
87        model=model,
88        n=n,
89        horizon=horizon,
90        frequency=frequency,
91        x0=x0,
92        theta1=theta1,
93        theta2=theta2,
94        theta3=theta3,
95        seed=seed,
96    )
97    # Adjust as needed based on API response structure
98    return pd.DataFrame(result["sims"])

Simulation: run scenario simulation using the Techtonique API.

Excel/xlwings custom function: Run scenario simulation from Excel using the Techtonique API.

Parameters

model : str, default "GBM" Simulation model to use.

n : int, default 10 Number of scenarios.

horizon : int, default 5 Simulation horizon.

frequency : str, default "quarterly" Frequency of simulation.

x0 : float, default 1.0 Initial value.

theta1 : float, default 0.0 Model parameter theta1.

theta2 : float, default 0.5 Model parameter theta2.

theta3 : float, optional Model parameter theta3.

seed : int, optional Random seed.

Returns

pd.DataFrame Simulation results as a DataFrame for Excel.


xlwings lite docstring (for Excel help): Run scenario simulation from Excel using the Techtonique API.

  • model: Simulation model (default: GBM).
  • n: Number of scenarios (default: 10).
  • horizon: Simulation horizon (default: 5).
  • frequency: Frequency (default: quarterly).
  • x0: Initial value (default: 1.0).
  • theta1: Model parameter theta1 (default: 0.0).
  • theta2: Model parameter theta2 (default: 0.5).
  • theta3: Model parameter theta3 (optional).
  • seed: Random seed (optional). Returns: Simulation results as a table for Excel.