Skip to content

Strategy Class Template

Strategy Class Structure

A BlitzTrader strategy is a standard C# class in your project, implemented as a .NET class that inherits from the framework base class:

QX.Blitz.Core.StrategyBase


Basic Strategy Definition

Click to view basic strategy class
[StrategyAttribute("{611A7560-1353-4852-A916-1F5FC19277F2}", "XT.PairTradingX1", "Pair TradingStrategy", "X1", "QXT")]
public class MainStrategy : StrategyBase
{
}

Your strategy class MainStrategy implements key override methods from the base class, such as:

  • OnInitialize()
  • OnStart()
  • OnStop()
  • OnMarketDataEvent()
  • OnTrade()

These methods define how your strategy interacts with the BlitzTrader platform.

You should customize these methods with your trading logic.


Save this class in a file named: MainStrategy.cs

Strategy Attribute

The strategy class is decorated with the StrategyAttribute, which provides metadata to the BlitzTrader platform.

This metadata includes:

  • Unique Identifier (GUID)
  • Strategy Name
  • Description
  • Version
  • Owner

This information is used by the platform to identify and manage the strategy.

You should modify these parameters based on your strategy requirements.

Project Structure Guidelines

Your strategy development project may contain:

  • Multiple classes
  • External dependencies
  • Third-party integrations

However, it must include one primary strategy class that:

  • Inherits from StrategyBase
  • Acts as the entry point of your strategy

This class defines how your strategy interacts with the BlitzTrader system.

Strategy Code Structure

Click to view full strategy structure template
using QX.Base.Common;
using QX.Base.Common.InstrumentInfo;
using QX.Base.Common.Message;
using QX.Base.Core;
using QX.Base.Data;
using QX.Blitz.Core;
using QX.Blitz.Core.Series;
using QX.Common.Helper;

[StrategyAttribute("{611A7560-1353-4852-A916-1F5FC19277F2}", "XT.PairTradingX1", "Pair TradingStrategy", "X1", "QXT")]
public class MainStrategy : StrategyBase
{
    // 1. Define IVObject variables (static or dynamic)

    // 2. Define strategy input and output variables

    // 3. Define local variables

    // 4. Implement override methods

    // 5. Use framework utilities for order execution and logic
}

Implementation Notes

Within the main strategy class, you can define:

  • IVObject variables
  • Input and output parameters
  • Local variables
  • Override methods

The BlitzTrader framework provides built-in functionalities for:

  • Order execution
  • Market data handling
  • Order event processing

These tools should be used to implement:

  • Strategy logic (alpha generation)
  • Execution logic

This allows you to build robust and scalable trading strategies within the BlitzTrader ecosystem.