Balsam.Backadjuster 1.1.2

dotnet add package Balsam.Backadjuster --version 1.1.2
                    
NuGet\Install-Package Balsam.Backadjuster -Version 1.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Balsam.Backadjuster" Version="1.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Balsam.Backadjuster" Version="1.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Balsam.Backadjuster" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Balsam.Backadjuster --version 1.1.2
                    
#r "nuget: Balsam.Backadjuster, 1.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Balsam.Backadjuster@1.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Balsam.Backadjuster&version=1.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Balsam.Backadjuster&version=1.1.2
                    
Install as a Cake Tool

alternate text is missing from this package README image Balsam Backadjuster

The Balsam.Backadjuster library works in conjunction with the Balsam.Backtester to link successive futures BarSeries into one continuous contract. Backadjusted contracts are commonly used to simplify testing on futures contracts while preserving the correct P&L as it rolls from one delivery to another.

Usage

The example below builds a continuous contract from 1-minute data files of individual contracts, rolling when daily volume in the next month exceeds the front month.

AsciiBarServer server = new AsciiBarServer(@"c:\data\intraday\minutebarfiles");
var symbols = server.GetSymbols("S "); //get all soybean symbols e.g. 'S N15' 'S X15'
var data = server.LoadSymbols(symbols);
Console.WriteLine($"{data.Count} individual contracts loaded.");

var rs = new RollSettings
{
    RollTrigger = RollTrigger.Volume,
    RollTime = new TimeSpan(13, 15, 0), //roll at 1:15PM CT
};

var ba = new BackAdjuster();
var continuous = ba.Build(data, rs);

Console.WriteLine($"{continuous.Count:N0} bars in {continuous.Symbol} from {continuous.FirstDate} to {continuous.LastDate}.");
continuous.Tail(10).Print();

Output

The continuous format is Date, Open, High, Low, Close, Volume, Open Interest, Unadjusted Close, and Delivery Date.

91 individual contracts loaded.
3,754,968 bars in @S from 1/3/2007 12:05:00 AM to 1/7/2025 1:20:00 PM.
@S @S Count: 10
1/7/2025 1:11:00 PM to 1/7/2025 1:20:00 PM
   0    1/7/2025 1:11:00 PM 997.25 997.50 997.00 997.25  602 0 997.25 Mar-25
   1    1/7/2025 1:12:00 PM 997.50 997.50 997.00 997.00  187 0 997.00 Mar-25
   2    1/7/2025 1:13:00 PM 997.00 997.00 996.00 996.75  588 0 996.75 Mar-25
   3    1/7/2025 1:14:00 PM 996.75 997.25 996.75 997.25  363 0 997.25 Mar-25
   4    1/7/2025 1:15:00 PM 997.25 997.50 997.00 997.50 1874 0 997.50 Mar-25
   5    1/7/2025 1:16:00 PM 997.50 997.75 997.00 997.75  663 0 997.75 Mar-25
   6    1/7/2025 1:17:00 PM 997.75 997.75 997.25 997.50  280 0 997.50 Mar-25
   7    1/7/2025 1:18:00 PM 997.75 997.75 997.25 997.25  220 0 997.25 Mar-25
   8    1/7/2025 1:19:00 PM 997.25 997.25 996.75 997.25  156 0 997.25 Mar-25
   9    1/7/2025 1:20:00 PM 997.00 997.50 997.00 997.25  280 0 997.25 Mar-25
//requires Balsam.AdvancedCharting library
var cvm = new ChartViewModel();
cvm.Plot(new PlotInstruction { Series = continuous }, new PlotInstruction { Series = continuous.UnadjustedClose, Color = Color.Blue });
new ChartWindow(cvm).ShowDialog();

In the chart below, note how the backadjusted series in green dips briefly into negative territory in its early history. The unadjusted close in blue shows the price that actually existed at that point in time, free from the effects of the cumulative roll adjustments. When working with backadjusted contracts, having the unadjusted close is critical for correct percentage calculations.

continuous

About

The Balsam.Backtester is a suite of tools designed for rapid prototyping and testing of systematic trading strategies. It can run simple event studies to quantify market "edges" all the way to full blown multi-currency, multi-timeframe, multi-strategy portfolio simulations. Check out the documentation here.

Balsam Research, LLC

Balsam Research is an independent consulting firm offering custom solutions for systematic investors. We have extensive experience automating investment processes and running real-time systematic investment programs including fully automated futures trading systems. Contact us to learn more.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.2 125 8/20/2025
1.1.1 123 8/15/2025