Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Futures and Future Options file-based universes #8480

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d5f0c03
Make FOPs selection universe file-based for backtesting
jhonabreul Dec 10, 2024
b7019c1
Make FOPs option chains universe file based
jhonabreul Dec 10, 2024
01c8bb2
Make Future universe selection file-based like option universe
jhonabreul Dec 17, 2024
dbb1714
Make Future universe selection file-based like option universe
jhonabreul Dec 17, 2024
0e9dc81
Abstraction cleanup
jhonabreul Dec 17, 2024
56a4a28
Add FuturesChains API to QC algorithm
jhonabreul Dec 18, 2024
b80ca60
Update regression algorithms stats
jhonabreul Dec 18, 2024
1a52344
Refactor QuantBook option and future history to use new universes
jhonabreul Dec 19, 2024
a80ad74
Fix failing tests
jhonabreul Dec 19, 2024
c871b60
Fix failing tests
jhonabreul Dec 19, 2024
cc886bc
Fix failing tests
jhonabreul Dec 20, 2024
d4afa75
Minor future chains unit test improvement
jhonabreul Dec 20, 2024
658c047
Add futures chains DataFrame property
jhonabreul Dec 20, 2024
d92dc15
Add DataFrame property to FuturesChains class
jhonabreul Dec 23, 2024
b160f6e
Add regression algorithms
jhonabreul Dec 23, 2024
06da07b
Add regression algorithms
jhonabreul Dec 24, 2024
fb76d0a
Replace QCAlgorithm.FutureChainProvider usages with new FuturesChain api
jhonabreul Dec 24, 2024
b3bec4a
Minor fixes
jhonabreul Dec 24, 2024
a13987c
Reduce number of universe files in repo
jhonabreul Dec 26, 2024
04b49c5
Minor data fixes
jhonabreul Dec 27, 2024
2db5fcb
Regression algorithms updates
jhonabreul Dec 27, 2024
993471d
Add implicit conversion from FuturesContract to Symbol
jhonabreul Dec 27, 2024
08e91cb
Improve resolution handling for history requests
jhonabreul Dec 27, 2024
69b259c
Changed _auxiliaryData field to lazily-initialized AuxiliaryData prop…
jhonabreul Dec 27, 2024
5b022ad
Refactor data handling in BaseChain and TimeSliceFactory
jhonabreul Dec 27, 2024
bc38c39
Remove specific constructors and indexers from Chain classes
jhonabreul Dec 27, 2024
a53da83
Remove chain cache logic from FuturesChainUniverse
jhonabreul Dec 27, 2024
272b8e7
Refactor class and interface names for clarity
jhonabreul Dec 27, 2024
286f6af
Add base class for options and futures contracts
jhonabreul Dec 27, 2024
1f6c7c3
Add minor fix for future options tickers parsing
jhonabreul Dec 27, 2024
a9abe80
Trigger Build
jhonabreul Dec 31, 2024
8356b01
Trigger Build
jhonabreul Jan 2, 2025
ba889a6
Trigger Build
jhonabreul Jan 2, 2025
7e635cb
Trigger Build
jhonabreul Jan 3, 2025
0b4903d
Clean chain provider classes up
jhonabreul Jan 6, 2025
d9f1516
Remove ZipEntryName other classes and unused code
jhonabreul Jan 8, 2025
68b2c25
Minor changes and cleanup
jhonabreul Jan 8, 2025
52ba16b
Trigger Build
jhonabreul Jan 8, 2025
ec1ac2b
Trigger Build
jhonabreul Jan 8, 2025
4bee3b1
Refactor FuturesContract data handling
jhonabreul Jan 8, 2025
d6520e9
Fix: use universe data for market data in FuturesContract
jhonabreul Jan 8, 2025
34d58f9
Update regression algorithms stats after rebase
jhonabreul Jan 17, 2025
040bae3
Sort configs by internal flag
jhonabreul Jan 17, 2025
60bcd30
Throw from option universe data filters for future options
jhonabreul Jan 17, 2025
2d45f26
Minor changes
jhonabreul Jan 17, 2025
0077f36
Improve some regression algorithms
jhonabreul Jan 17, 2025
0cc88be
Minor fix for failing unit tests
jhonabreul Jan 20, 2025
d75f9ad
Update FOPs universe file header
jhonabreul Jan 21, 2025
dab5aa4
Minor unit test fix
jhonabreul Jan 21, 2025
9e77d7b
Trigger Build
jhonabreul Jan 21, 2025
88c9f57
Trigger Build
jhonabreul Jan 22, 2025
163ee55
Trigger Build
jhonabreul Jan 22, 2025
bcd076e
Trigger Build
jhonabreul Jan 27, 2025
8f98f64
Trigger Build
jhonabreul Jan 27, 2025
a601f3b
Trigger Build
jhonabreul Jan 28, 2025
73b7064
Trigger Build
jhonabreul Jan 28, 2025
cd5d4f8
Trigger Build
jhonabreul Feb 3, 2025
f2ce771
Trigger Build
jhonabreul Feb 5, 2025
9892b7a
Trigger Build
jhonabreul Feb 5, 2025
3d0147b
Trigger Build
jhonabreul Feb 5, 2025
e4df4ed
Trigger Build
jhonabreul Feb 10, 2025
71caf21
Trigger Build
jhonabreul Feb 11, 2025
4c8933b
Minor fix
jhonabreul Feb 12, 2025
4fdbe60
Add history provider as constructor argument for chain providers
jhonabreul Feb 12, 2025
037ccb8
Update new regression algorithms data points count
jhonabreul Feb 12, 2025
6d654d2
Minor fix for FakeDataQueue
jhonabreul Feb 12, 2025
fbf0277
Add initialize method to chain providers classes
jhonabreul Feb 13, 2025
00c01b5
Minor changes
jhonabreul Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void Initialize()
contractDepthOffset: 0
);

_futureContract = AddFutureContract(FutureChainProvider.GetFutureContractList(_continuousContract.Symbol, Time).First());
_futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First());
}

/// <summary>
Expand Down Expand Up @@ -115,12 +115,12 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 76;
public long DataPoints => 61;

/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 0;
public int AlgorithmHistoryDataPoints => 1;

/// <summary>
/// Final status of the algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public override void OnEndOfAlgorithm()
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 0;
public int AlgorithmHistoryDataPoints => 2;

/// <summary>
/// Final status of the algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ public override void OnData(Slice slice)
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 12172;
public long DataPoints => 9922;

/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 0;
public int AlgorithmHistoryDataPoints => 2;

/// <summary>
/// Final status of the algorithm
Expand All @@ -113,7 +113,7 @@ public override void OnData(Slice slice)
{"Total Orders", "20"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "386219349.202%"},
{"Compounding Annual Return", "88398927.578%"},
{"Drawdown", "5.200%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public override void OnData(Slice slice)
return;
}

foreach (var chain in slice.OptionChains.Values)
foreach (var chain in slice.OptionChains.Values.OrderBy(x => x.Symbol.Underlying.ID.Date))
{
var futureInvested = false;
var optionInvested = false;
Expand Down Expand Up @@ -220,7 +220,7 @@ public override void OnEndOfAlgorithm()
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 608380;
public long DataPoints => 319494;

/// <summary>
/// Data Points count of the algorithm history
Expand All @@ -240,7 +240,7 @@ public override void OnEndOfAlgorithm()
{"Total Orders", "2"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "347.065%"},
{"Compounding Annual Return", "309.669%"},
{"Drawdown", "0.900%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void Initialize()
SetEndDate(2013, 10, 10);

var SP500 = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME);
_symbol = FutureChainProvider.GetFutureContractList(SP500, StartDate).First();
_symbol = FuturesChain(SP500).First();

// Test case: custom IndicatorBase<QuoteBar> indicator using Future unsubscribed symbol
var indicator1 = new CustomIndicator();
Expand Down Expand Up @@ -151,7 +151,7 @@ protected override decimal ComputeNextValue(QuoteBar input)
/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 84;
public int AlgorithmHistoryDataPoints => 85;

/// <summary>
/// Final status of the algorithm
Expand Down
5 changes: 2 additions & 3 deletions Algorithm.CSharp/BasicTemplateContinuousFutureAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using QuantConnect.Orders;
using QuantConnect.Interfaces;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Indicators;
using QuantConnect.Securities;
Expand Down Expand Up @@ -118,7 +117,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 713375;
public long DataPoints => 162575;

/// <summary>
/// Data Points count of the algorithm history
Expand Down Expand Up @@ -161,7 +160,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Estimated Strategy Capacity", "$7100000.00"},
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
{"Portfolio Turnover", "2.33%"},
{"OrderListHash", "9c524830ffc7354327638142ae62acd2"}
{"OrderListHash", "04670183a0a4c9160167415aa5102499"}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 2217330;
public long DataPoints => 504530;

/// <summary>
/// Data Points count of the algorithm history
Expand Down
6 changes: 3 additions & 3 deletions Algorithm.CSharp/BasicTemplateEurexFuturesAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ public override void OnEndOfAlgorithm()
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 133947;
public long DataPoints => 94326;

/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public int AlgorithmHistoryDataPoints => 26;
public int AlgorithmHistoryDataPoints => 0;

/// <summary>
/// Final status of the algorithm
Expand Down Expand Up @@ -233,7 +233,7 @@ public override void OnEndOfAlgorithm()
{"Estimated Strategy Capacity", "€2300000000.00"},
{"Lowest Capacity Asset", "FESX YJHOAMPYKRS5"},
{"Portfolio Turnover", "0.40%"},
{"OrderListHash", "54040d29a467becaedcf59d79323321b"}
{"OrderListHash", "ac9acc478ba1afe53993cdbb92f8ec6e"}
};
}
}
4 changes: 2 additions & 2 deletions Algorithm.CSharp/BasicTemplateFutureRolloverAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void Dispose()
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 1185;
public long DataPoints => 727;

/// <summary>
/// Data Points count of the algorithm history
Expand Down Expand Up @@ -221,5 +221,5 @@ public void Dispose()
{"Portfolio Turnover", "0.13%"},
{"OrderListHash", "7c8700a9baa24f6f76d866e7d88cc19c"}
};
}
}
}
4 changes: 2 additions & 2 deletions Algorithm.CSharp/BasicTemplateFuturesAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 75403;
public long DataPoints => 40308;

/// <summary>
/// Data Points count of the algorithm history
Expand All @@ -169,7 +169,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Total Orders", "2700"},
{"Average Win", "0.00%"},
{"Average Loss", "0.00%"},
{"Compounding Annual Return", "-99.777%"},
{"Compounding Annual Return", "-99.597%"},
{"Drawdown", "4.400%"},
{"Expectancy", "-0.724"},
{"Start Equity", "1000000"},
Expand Down
16 changes: 13 additions & 3 deletions Algorithm.CSharp/BasicTemplateFuturesDailyAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Interfaces;
using QuantConnect.Orders;
using QuantConnect.Securities;
using QuantConnect.Securities.Future;

Expand Down Expand Up @@ -104,6 +104,16 @@ select futuresContract
}
}

public override void OnSecuritiesChanged(SecurityChanges changes)
{
if (changes.RemovedSecurities.Count > 0 &&
Portfolio.Invested &&
Securities.Values.Where(x => x.Invested).All(x => x.Exchange.Hours.IsOpen(Time, true)))
{
Liquidate();
}
}

/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
Expand All @@ -117,7 +127,7 @@ select futuresContract
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public virtual long DataPoints => 12474;
public virtual long DataPoints => 5861;

/// <summary>
/// Data Points count of the algorithm history
Expand Down Expand Up @@ -160,7 +170,7 @@ select futuresContract
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
{"Portfolio Turnover", "0.92%"},
{"OrderListHash", "9507abc8348ff3cb1e2a9a5f48d128a7"}
{"OrderListHash", "c0713abdc4fb059c2be797fce36e4f36"}
};
}
}
2 changes: 1 addition & 1 deletion Algorithm.CSharp/BasicTemplateFuturesFrameworkAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public override IEnumerable<IPortfolioTarget> CreateTargets(QCAlgorithm algorith
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public virtual long DataPoints => 57759;
public virtual long DataPoints => 24883;

/// <summary>
/// Data Points count of the algorithm history
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BasicTemplateFuturesFrameworkWithExtendedMarketAlgorithm : BasicTem
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public override long DataPoints => 163416;
public override long DataPoints => 70262;

/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
Expand Down
4 changes: 2 additions & 2 deletions Algorithm.CSharp/BasicTemplateFuturesHistoryAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ public override void OnOrderEvent(OrderEvent orderEvent)
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public virtual long DataPoints => 48690;
public virtual long DataPoints => 25316;

/// <summary>
/// Data Points count of the algorithm history
/// </summary>
public virtual int AlgorithmHistoryDataPoints => 5305;
public virtual int AlgorithmHistoryDataPoints => 6075;

/// <summary>
/// Final status of the algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class BasicTemplateFuturesHistoryWithExtendedMarketHoursAlgorithm : Basic
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public override long DataPoints => 147771;
public override long DataPoints => 76063;

/// <summary>
/// Data Points count of the algorithm history
Expand Down
31 changes: 13 additions & 18 deletions Algorithm.CSharp/BasicTemplateFuturesHourlyAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
*
*/

using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Interfaces;
using QuantConnect.Securities;

namespace QuantConnect.Algorithm.CSharp
{
Expand All @@ -41,40 +36,40 @@ public class BasicTemplateFuturesHourlyAlgorithm : BasicTemplateFuturesDailyAlgo
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public override long DataPoints => 87292;
public override long DataPoints => 25312;

/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public override Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Orders", "716"},
{"Total Orders", "718"},
{"Average Win", "0.03%"},
{"Average Loss", "-0.01%"},
{"Compounding Annual Return", "-1.716%"},
{"Compounding Annual Return", "-1.720%"},
{"Drawdown", "1.700%"},
{"Expectancy", "-0.770"},
{"Start Equity", "1000000"},
{"End Equity", "982718.38"},
{"Net Profit", "-1.728%"},
{"Sharpe Ratio", "-8.845"},
{"Sortino Ratio", "-5.449"},
{"End Equity", "982676.58"},
{"Net Profit", "-1.732%"},
{"Sharpe Ratio", "-8.877"},
{"Sortino Ratio", "-5.476"},
{"Probabilistic Sharpe Ratio", "0.000%"},
{"Loss Rate", "96%"},
{"Win Rate", "4%"},
{"Profit-Loss Ratio", "4.89"},
{"Profit-Loss Ratio", "4.90"},
{"Alpha", "-0.018"},
{"Beta", "-0.002"},
{"Annual Standard Deviation", "0.002"},
{"Annual Variance", "0"},
{"Information Ratio", "-1.483"},
{"Information Ratio", "-1.484"},
{"Tracking Error", "0.089"},
{"Treynor Ratio", "9.102"},
{"Total Fees", "$1634.12"},
{"Treynor Ratio", "9.171"},
{"Total Fees", "$1638.42"},
{"Estimated Strategy Capacity", "$8000.00"},
{"Lowest Capacity Asset", "ES VP274HSU1AF5"},
{"Portfolio Turnover", "20.10%"},
{"OrderListHash", "aa7e574f86b70428ca0afae381be80ba"}
{"Portfolio Turnover", "20.14%"},
{"OrderListHash", "dedcc487d64e2f601990fc70393c89ed"}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public long DataPoints => 224662;
public long DataPoints => 117079;

/// <summary>
/// Data Points count of the algorithm history
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class BasicTemplateFuturesWithExtendedMarketDailyAlgorithm : BasicTemplat
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public override long DataPoints => 14182;
public override long DataPoints => 5965;

/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
Expand Down Expand Up @@ -69,7 +69,7 @@ public class BasicTemplateFuturesWithExtendedMarketDailyAlgorithm : BasicTemplat
{"Estimated Strategy Capacity", "$0"},
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
{"Portfolio Turnover", "0.87%"},
{"OrderListHash", "ea6fdf3133bde7063e4fc0fa809ae260"}
{"OrderListHash", "8b8b733248a21fc717079be54b2e844c"}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BasicTemplateFuturesWithExtendedMarketHourlyAlgorithm : BasicTempla
/// <summary>
/// Data Points count of all timeslices of algorithm
/// </summary>
public override long DataPoints => 228941;
public override long DataPoints => 67924;

/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
Expand Down
Loading
Loading