Simulatior

Check the performance of your Alpha Model

Load or Create Your Position

from finter.data import ModelData

# Load or create your position data
position = ModelData.load('your_model_name')

Setup Simulation

Define your model universe, alpha model, and simulation dates.

from finter.backtest import Simulator

# Create a simulator instance
simulator = Simulator(market_type="kr_stock")

# Run simulation with a position DataFrame
result = simulator.run(position=position)

# Access results
print(result.summary)

Key Parameters

simulator = Simulator("kr_stock")
result = simulator.run(
    position,
    start=20220101,
    end=20231231,
    buy_fee_tax=10,  # 0.1%
    sell_fee_tax=10,  # 0.1%
    slippage=5,  # 0.05%
    initial_cash=100_000_000,
    drip="reinvest",
    rebalancing_method="M",
    core_type="basic",
    debug=True
)
  • Date (date)

    • start: int (YYYYMMDD) - Simulation start date (defaults to the value set during Simulator instantiation).

    • end: int (YYYYMMDD) - Simulation end date (defaults to the value set during Simulator instantiation).

  • Data (data)

    • money_flow: pd.DataFrame - External cash inflow/outflow data (Index: date, Columns: 'money_flow').

  • Cost (cost) - Note: Input values are in Basis Points (bp, 1/10000)

    • buy_fee_tax: float - Buy fee and tax (bp).

    • sell_fee_tax: float - Sell fee and tax (bp).

    • slippage: float - Slippage (bp).

    • dividend_tax: float - Dividend tax (bp, applied if drip option is used).

  • Trade (trade)

    • initial_cash: float - Initial cash holdings.

    • volume_capacity_ratio: float (0 to 1) - Trading volume constraint ratio (0: no limit, 1: cannot exceed daily volume). Requires volume data.

    • target_volume_limit_args: Optional[Dict[str, Any]] - Settings related to target volume limits, including internal processor configurations. Example: {'processors': [{'type': 'trading_volume', 'limit_ratio': 0.1}]} (limits trading volume for a specific stock to 10% of its daily volume).

    • lot_args: Optional[Dict[str, Any]] - Settings related to trading lot sizes. Example: {'size': 100} (trade in lots of 100 shares).

  • Execution (execution)

    • resample_period: Optional[Literal[None, "W", "M", "Q"]] - Rebalancing frequency (None: daily, 'W': weekly, 'M': monthly, 'Q': quarterly).

    • rebalancing_method: Literal["by_position", "auto"] - Rebalancing method ('by_position': based on position file, 'auto': automatic).

    • core_type: AVAILABLE_CORE_TYPES - Simulation core type to use (market-specific defaults exist, e.g., 'basic', 'id_fund').

    • drip: Optional[AVAILABLE_DIVIDEND_TYPES] - Dividend handling method (None: not handled, 'reinvest': reinvest dividends). Requires dividend data.

  • Optional (optional)

    • debug: bool - Enable debug mode.

    • results: list[str] - List of result attributes to store (e.g., ['aum', 'daily_return']).

    • currency: AVAILABLE_BASE_CURRENCY - Currency for displaying results (requires exchange rate data if conversion is needed). Examples: 'KRW', 'USD'.

Last updated

Was this helpful?