Trading.Backtest.Engine (trading v0.1.0)

Event-driven backtesting engine with realistic order book simulation.

Summary

Functions

Adds a strategy to the backtest.

Returns a specification to start this module under a supervisor.

Loads historical data for backtesting.

Runs a backtest with the given configuration.

Starts the backtesting engine.

Types

t()

@type t() :: %Trading.Backtest.Engine{
  config: map(),
  current_time: integer(),
  event_queue: :queue.queue(Trading.Backtest.Event.t()),
  historical_data: map(),
  matching_engine: Trading.MatchingEngine.t(),
  portfolio: Trading.Backtest.Portfolio.t(),
  results: map(),
  strategies: [Trading.Backtest.Strategy.t()]
}

Functions

add_strategy(server, strategy_module, params)

@spec add_strategy(GenServer.server(), module(), map()) :: :ok

Adds a strategy to the backtest.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

load_historical_data(server, symbol, data)

@spec load_historical_data(GenServer.server(), String.t(), [map()]) :: :ok

Loads historical data for backtesting.

run_backtest(server, config)

@spec run_backtest(GenServer.server(), map()) :: {:ok, map()} | {:error, term()}

Runs a backtest with the given configuration.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the backtesting engine.