Balsam.Backadjuster
1.1.2
dotnet add package Balsam.Backadjuster --version 1.1.2
NuGet\Install-Package Balsam.Backadjuster -Version 1.1.2
<PackageReference Include="Balsam.Backadjuster" Version="1.1.2" />
<PackageVersion Include="Balsam.Backadjuster" Version="1.1.2" />
<PackageReference Include="Balsam.Backadjuster" />
paket add Balsam.Backadjuster --version 1.1.2
#r "nuget: Balsam.Backadjuster, 1.1.2"
#:package Balsam.Backadjuster@1.1.2
#addin nuget:?package=Balsam.Backadjuster&version=1.1.2
#tool nuget:?package=Balsam.Backadjuster&version=1.1.2
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.
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 | Versions 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. |
-
.NETFramework 4.6.2
- Balsam.Backtester (>= 1.1.2)
-
.NETStandard 2.0
- Balsam.Backtester (>= 1.1.2)
-
net8.0
- Balsam.Backtester (>= 1.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.