Skip to content

Namespaces

Namespaces are used to group common functionality in the Balsam code libraries. To begin working with the Backtester, import the Balsam namespace. Most common workflows will require the following namespaces:

using Balsam;
using Balsam.DataServers;
using Balsam.MoneyManagement;
using Balsam.Optimization;

Code examples in this documentation may omit the using statements for brevity. Many code editors, including Visual Studio, will offer to import missing namespaces when class names aren’t recognized.

  • Balsam

    The primary namespace, containing foundational data classes like TimeSeries, BarSeries, and Instrument. This is also the home of Strategy, the base class for all trading strategies.

  • Balsam.DataServers

    Includes built-in data servers AsciiBarServer for accessing text files, CsiBarServer for accessing backadjusted continuous contracts exported from CSI’s Unfair Advantage software, and BinaryBarServer for accessing data stored in a fast, binary format.

  • Balsam.MoneyManagement

    Contains Money managers responsible for position sizing and generating backtest reports. FixedFractional implements a methodology commonly used by futures trades for risk-based position sizing. FullyInvested targets a 100% notional position.

  • Balsam.Optimization

    Contains classes for automated testing of different parameter sets. Optimizer is commonly used to perform a brute-force search across the entire parameter space. WalkForwardOptimizer conducts walk-forward optimizations over moving windows of data.

  • Balsam.TransactionCosts

    Contains classes implementing TransactionCostModel for modeling slippage and transaction costs.

  • Balsam.Compression

    Contains classes for compressing or converting data to different timeframes.

  • Balsam.Data

    Contains the DataStore class, an in-memory database used to pass trade information between strategies and money managers.