Engine API
The Engine module provides the core execution framework for Planar strategies. It handles data management, order execution, and coordinates between different execution modes (simulation, paper trading, and live trading).
Overview
The Engine serves as the central coordinator that:
- Manages strategy execution across different modes
- Handles data loading and OHLCV management
- Coordinates with exchanges and executors
- Provides unified interfaces for backtesting and live trading
Data Structures and Types
Core Types
The Engine module works with several key types.
Complete API Reference
Planar.Engine.load_universe! — Method
load_universe! all the instances with given timeframes data...
load_universe!(
ac::PlanarCore.Collections.InstrumentCollection,
tfs...;
kwargs...
) -> DataFrames.DataFrame
Planar.Engine.purge_data! — Method
purge_data!(s::Strategy, sym::AbstractString; purge=true)Explicitly purge cached OHLCV/Zarr data for sym after removeasset!. No-op by default on remove; call this when audit retention is not needed.
Planar.Engine.stub_universe! — Method
Replaces the data of the asset instances with src which should be a mapping. Used for backtesting.
stub_universe!(
ac::PlanarCore.Collections.InstrumentCollection,
src;
fromfiat
)
The stub_universe! function takes the following parameters:
ac: an InstrumentCollection object which encapsulates a collection of assets.src: The mapping, should be a pairTimeFrame => Dict{String, PairData}.fromfiat(optional, default is true): a boolean that indicates whether the assets are priced in fiat currency. If true, the assets are priced in fiat currency.
The function replaces the OHLCV data of the assets in the ac collection with the data from the src mapping. This is useful for backtesting trading strategies.
Example:
using PlanarDownloadTool.BinanceData as bn
using Strategies
using Exchanges
setexchange!(:binanceusdm)
cfg = Config(Symbol(exc.id))
strat = strategy!(:Example, cfg)
data = bn.binanceload()
stub_universe!(strat.universe, data)See Also
- Strategies API - Strategy base classes and interfaces
- Data API - Data structures and management
- Executors API - Order execution and management
- Execution Modes Guide - Understanding sim, paper, and live modes
- Data Management Guide - Working with market data