Skip to content

BlitzTrader .NET Strategy Development Guide

Welcome to the .NET programmer’s guide for Blitz Trading Strategy development using C#.


Introduction

BlitzTrader empowers developers with a comprehensive framework to build trading strategies effortlessly, ranging from simple to highly complex systems.

Built on the BlitzTrader .NET framework, developers can efficiently design, develop, and deploy trading strategies that run within the BlitzTrader server application container.

Note

The BlitzTrader API is built using Microsoft® .NET Framework 4.7.1.
Its event-driven architecture decouples strategy logic from the trading platform, ensuring real-time delivery of critical events for informed decision-making.


The Blitz SDK is available for .NET Framework 4.7.1 and above.

It supports:

  • Individual trading
  • Proprietary trading firms
  • Institutional trading systems

BlitzTrader improves:

  • Development efficiency
  • Code consistency
  • Reusability

Architecture Overview

Architecture

As shown in the illustration, the programmable strategy is loaded in Blitz Server Strategy container and communicates with OMS, RMS, Market Data Feed server, and Trading Dashboard.


Project Setup

  1. Open Visual Studio
  2. Go to File → New → Project
  3. Select Class Library (.NET Framework)
  4. Enter project name and click OK

Required DLLs

INSTALL_DIR\Bin\QX.Blitz\..
Assembly Description
QX.Base.Common.dll Common structures
QX.Base.Core.dll Strategy base
QX.Base.Data.dll Data
QX.Base.Financial.dll Greeks
QX.Common.Lib.dll Helpers
QX.Common.Helper.dll Utilities

Optional:

Assembly Description
QX.FinLib.dll Indicators

Strategy Implementation

Click to view full strategy code
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Timers;
using System.Data;

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;
using QX.Common.Lib;

using QX.FinLib;
using QX.FinLib.Data;
using QX.FinLib.Common.Util;
using QX.FinLibDB;
using QX.Blitz.Core.InstrumentInfo;

namespace QX.Blitz.Strategy.PaitTrading
{
    [StrategyAttribute("{AD672C4A-3BB9-4070-A605-B9AD63F677F6}", "QX.PairTradeAlphaX1", "PairTradeAlphaX1", "X1","QXT")]
    public class MainStrategy : StrategyBase
    {
        private IVObject _ivInstrumentPair1 = new IVObject("Pair1", "Pair1 Tradable Instrument", true, InstrumentType.Equity | InstrumentType.Futures | InstrumentType.Options, MarketDataType.All, OrderEventType.All);

        private IVObject _ivInstrumentPair2 = new IVObject("Pair2", "Pair2 Tradable Instrument", true, InstrumentType.Equity | InstrumentType.Futures | InstrumentType.Options, MarketDataType.All, OrderEventType.All);

        private IVInfo _ivInfoPair1 = null;
        private IVInfo _ivInfoPair2 = null;

        #region Input Parameters
        [StrategyParameterAttribute("ClientID", 1, "ClientID")]
        private string Input_ClientID = "1";

        [StrategyParameterAttribute("BarSize", 1, "Minute Bar Size")]
        private int Input_MinBarSize = 1;

        [StrategyParameterAttribute("OrderQtyLots", 1, "Order Quantity in Lots")]
        private int Input_OrderQtyLots = 1;

        [StrategyParameterAttribute("SLPercentage", 2, "Stop Loss")]
        private double Input_SLPercentage = 2;

        [StrategyParameterAttribute("PTPercentage", 5, "Profit Target")]
        private double Input_PTLPercentage = 5;

        [StrategyParameterAttribute("SquareOffTime", "15:20", "SquareOffTime")]
        private string Input_SquareOffTime = "15:20";
        #endregion

        #region Published Parameters
        [StrategyPublishParameter("LastState", DefaultValue = "", Description = "Last State", DisplayName = "Last State")]
        private string Output_LastState = "X";

        [StrategyPublishParameter("MarketSpread", DefaultValue = 0, Description = "Market Spread", DisplayName = "Market Spread")]
        private double Output_MarketSpread = 0;

        [StrategyPublishParameter("MTM", DefaultValue = 0, Description = "MTM")]
        private double Output_MTM = 0;

        [StrategyPublishParameter("TransactionCount", DefaultValue = 0, Description = "TransactionCount")]
        private int Output_TransactionCount = 0;
        #endregion

        private Dictionary<long, IOrderCommandEx> _orderExecutionMAP = new Dictionary<long, IOrderCommandEx>();

        protected override void OnInitialize()
        {
            _ivInfoPair1 = GetIVInfo(_ivInstrumentPair1);
            _ivInfoPair2 = GetIVInfo(_ivInstrumentPair2);
            TraceLogInfo("Strategy Initialize Successfully");
        }

        protected override bool OnStart(out string errorString)
        {
            errorString = string.Empty;
            return true;
        }

        protected override void OnMarketDataEvent(StrategyMarketDataEventArgs eventArgs)
        {
        }
    }
}

Next Step

Proceed to SDK Architecture.