Skip to content

Commit

Permalink
Dotnet 9
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero committed Dec 13, 2024
1 parent 8febb9a commit de360a7
Show file tree
Hide file tree
Showing 43 changed files with 120 additions and 76 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
# Only run on push events (not on pull_request) for security reasons in order to be able to use secrets
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free space
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: false
- name: Run API Tests
uses: addnab/docker-run-action@v3
with:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/gh-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free space
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h

- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: false

- uses: addnab/docker-run-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rebase-org-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
with:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free space
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: false

- uses: addnab/docker-run-action@v3
with:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/report-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free space
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: false

- uses: addnab/docker-run-action@v3
with:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/research-regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free space
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: false

- uses: addnab/docker-run-action@v3
with:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/virtual-environments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Free space
run: df -h && rm -rf /usr/share/dotnet && sudo rm -rf /usr/local/lib/android && sudo rm -rf /opt/ghc && rm -rf /opt/hostedtoolcache* && df -h
- name: Liberate disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
docker-images: false
swap-storage: false

- uses: addnab/docker-run-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Algorithm.CSharp</RootNamespace>
<AssemblyName>QuantConnect.Algorithm.CSharp</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Algorithm.Framework</RootNamespace>
<AssemblyName>QuantConnect.Algorithm.Framework</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Expand Down
6 changes: 3 additions & 3 deletions Algorithm.Python/CallbackCommandRegressionAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def initialize(self):
bool_command.something_else = { "Property": 10 }
bool_command.array_test = [ "SPY", "BTCUSD" ]
link = self.link(bool_command)
if "&command[array_test][0]=SPY&command[array_test][1]=BTCUSD&command[result]=True&command[something_else][Property]=10&command[$type]=BoolCommand" not in link:
if "&command%5barray_test%5d%5b0%5d=SPY&command%5barray_test%5d%5b1%5d=BTCUSD&command%5bresult%5d=True&command%5bsomething_else%5d%5bProperty%5d=10&command%5b%24type%5d=BoolCommand" not in link:
raise ValueError(f'Invalid link was generated! {link}')

potential_command = VoidCommand()
Expand All @@ -85,12 +85,12 @@ def initialize(self):
potential_command.parameters = { "tag": "Signal X" }

command_link = self.link(potential_command)
if "command[target][0]=BAC&command[quantity]=10&command[parameters][tag]=Signal+X&command[$type]=VoidCommand" not in command_link:
if "&command%5btarget%5d%5b0%5d=BAC&command%5bquantity%5d=10&command%5bparameters%5d%5btag%5d=Signal+X&command%5b%24type%5d=VoidCommand" not in command_link:
raise ValueError(f'Invalid link was generated! {command_link}')
self.notify.email("email@address", "Trade Command Event", f"Signal X trade\nFollow link to trigger: {command_link}")

untyped_command_link = self.link({ "symbol": "SPY", "parameters": { "quantity": 10 } })
if "&command[symbol]=SPY&command[parameters][quantity]=10" not in untyped_command_link:
if "&command%5bsymbol%5d=SPY&command%5bparameters%5d%5bquantity%5d=10" not in untyped_command_link:
raise ValueError(f'Invalid link was generated! {untyped_command_link}')
self.notify.email("email@address", "Untyped Command Event", f"Signal Y trade\nFollow link to trigger: {untyped_command_link}")

Expand Down
2 changes: 1 addition & 1 deletion Algorithm.Python/QuantConnect.Algorithm.Python.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Algorithm.Python</RootNamespace>
<AssemblyName>QuantConnect.Algorithm.Python</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<OutputPath>bin\$(Configuration)\</OutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
2 changes: 1 addition & 1 deletion Algorithm/QuantConnect.Algorithm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Algorithm</RootNamespace>
<AssemblyName>QuantConnect.Algorithm</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Expand Down
2 changes: 1 addition & 1 deletion AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.AlgorithmFactory</RootNamespace>
<AssemblyName>QuantConnect.AlgorithmFactory</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Expand Down
2 changes: 1 addition & 1 deletion Api/QuantConnect.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Api</RootNamespace>
<AssemblyName>QuantConnect.Api</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Expand Down
2 changes: 1 addition & 1 deletion Brokerages/QuantConnect.Brokerages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Brokerages</RootNamespace>
<AssemblyName>QuantConnect.Brokerages</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
Expand Down
1 change: 1 addition & 0 deletions Common/Brokerages/BybitBrokerageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Benchmarks;
using QuantConnect.Orders;
using QuantConnect.Orders.Fees;
Expand Down
7 changes: 6 additions & 1 deletion Common/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4376,9 +4376,14 @@ public static decimal SafeDivision(this decimal numerator, decimal denominator,
}
}

/// <summary>
/// Retrieve a common custom data types from the given symbols if any
/// </summary>
/// <param name="symbols">The target symbols to search</param>
/// <returns>The custom data type or null</returns>
public static Type GetCustomDataTypeFromSymbols(Symbol[] symbols)
{
if (symbols.Any())
if (symbols.Length != 0)
{
if (!SecurityIdentifier.TryGetCustomDataTypeInstance(symbols[0].ID.Symbol, out var dataType)
|| symbols.Any(x => !SecurityIdentifier.TryGetCustomDataTypeInstance(x.ID.Symbol, out var customDataType) || customDataType != dataType))
Expand Down
2 changes: 1 addition & 1 deletion Common/QuantConnect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>QuantConnect.Common</AssemblyName>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
Expand Down
12 changes: 0 additions & 12 deletions Common/Util/LinqExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ namespace QuantConnect.Util
/// </summary>
public static class LinqExtensions
{
/// <summary>
/// Creates a dictionary enumerable of key value pairs
/// </summary>
/// <typeparam name="K">The key type</typeparam>
/// <typeparam name="V">The value type</typeparam>
/// <param name="enumerable">The IEnumerable of KeyValuePair instances to convert to a dictionary</param>
/// <returns>A dictionary holding the same data as the enumerable</returns>
public static Dictionary<K, V> ToDictionary<K, V>(this IEnumerable<KeyValuePair<K, V>> enumerable)
{
return enumerable.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}

/// <summary>
/// Creates a new read-only dictionary from the key value pairs
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Compression/QuantConnect.Compression.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Compression</RootNamespace>
<AssemblyName>QuantConnect.Compression</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion Configuration/QuantConnect.Configuration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>QuantConnect.Configuration</RootNamespace>
<AssemblyName>QuantConnect.Configuration</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Expand Down
3 changes: 0 additions & 3 deletions DockerfileJupyter
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ ENV PYTHONPATH=${WORK}:${PYTHONPATH}
RUN mkdir -p /root/.ipython/profile_default/startup/ && \
ln -s /Lean/Launcher/bin/Debug/start.py /root/.ipython/profile_default/startup/start.py

# conda libc is old and causes issues in research we want to use the hosts version which is updated
RUN mkdir -p /opt/miniconda3/lib/ && ln -vsf /lib/x86_64-linux-gnu/libstdc++.so.6 /opt/miniconda3/lib/libstdc++.so.6

RUN find ${WORK} -type f -not -name '*.py*' -not -name '*.xml' -not -name '*.exe.config' -not -name '*.exe' -not -name '*.so' -not -name '*.dll' -not -name '*.ipynb' -not -name '*.csx' -not -name 'QuantConnect.Lean.Launcher.runtimeconfig.json' -not -name 'decimal.py' -delete

# Create initialize script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>QuantConnect.DownloaderDataProvider.Launcher</RootNamespace>
<AssemblyName>QuantConnect.DownloaderDataProvider.Launcher</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
Expand Down
17 changes: 11 additions & 6 deletions Engine/DataFeeds/DataQueueHandlerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace QuantConnect.Lean.Engine.DataFeeds
/// </summary>
public class DataQueueHandlerManager : IDataQueueHandler, IDataQueueUniverseProvider
{
private ITimeProvider _frontierTimeProvider;
private readonly IAlgorithmSettings _algorithmSettings;
private readonly Dictionary<SubscriptionDataConfig, Queue<IDataQueueHandler>> _dataConfigAndDataHandler = new();

Expand All @@ -44,6 +43,12 @@ public DataQueueHandlerManager(IAlgorithmSettings settings)
_algorithmSettings = settings;
}

/// <summary>
/// Frontier time provider to use
/// </summary>
/// <remarks>Protected for testing purposes</remarks>
protected ITimeProvider FrontierTimeProvider { get; set; }

/// <summary>
/// Collection of data queue handles being used
/// </summary>
Expand Down Expand Up @@ -73,7 +78,7 @@ public IEnumerator<BaseData> Subscribe(SubscriptionDataConfig dataConfig, EventH
{
// Emit ticks & custom data as soon as we get them, they don't need any kind of batching behavior applied to them
// only use the frontier time provider if we need to
var immediateEmission = dataConfig.Resolution == Resolution.Tick || dataConfig.IsCustomData || _frontierTimeProvider == null;
var immediateEmission = dataConfig.Resolution == Resolution.Tick || dataConfig.IsCustomData || FrontierTimeProvider == null;
var exchangeTimeZone = dataConfig.ExchangeTimeZone;

IEnumerator<BaseData> enumerator;
Expand All @@ -84,7 +89,7 @@ public IEnumerator<BaseData> Subscribe(SubscriptionDataConfig dataConfig, EventH
// let's only wake up the main thread if the data point is allowed to be emitted, else we could fill forward previous bar and not let this one through
var dataAvailable = eventArgs as NewDataAvailableEventArgs;
if (dataAvailable == null || dataAvailable.DataPoint == null
|| dataAvailable.DataPoint.EndTime.ConvertToUtc(exchangeTimeZone) <= _frontierTimeProvider.GetUtcNow())
|| dataAvailable.DataPoint.EndTime.ConvertToUtc(exchangeTimeZone) <= FrontierTimeProvider.GetUtcNow())
{
newDataAvailableHandler?.Invoke(sender, eventArgs);
}
Expand Down Expand Up @@ -113,7 +118,7 @@ public IEnumerator<BaseData> Subscribe(SubscriptionDataConfig dataConfig, EventH
return enumerator;
}

var utcStartTime = _frontierTimeProvider.GetUtcNow();
var utcStartTime = FrontierTimeProvider.GetUtcNow();

var exchangeHours = MarketHoursDatabase.FromDataFolder().GetExchangeHours(dataConfig.Symbol.ID.Market, dataConfig.Symbol, dataConfig.Symbol.SecurityType);
if (LeanData.UseStrictEndTime(_algorithmSettings.DailyPreciseEndTime, dataConfig.Symbol, dataConfig.Increment, exchangeHours))
Expand All @@ -122,7 +127,7 @@ public IEnumerator<BaseData> Subscribe(SubscriptionDataConfig dataConfig, EventH
enumerator = new StrictDailyEndTimesEnumerator(enumerator, exchangeHours, utcStartTime.ConvertFromUtc(exchangeTimeZone));
}

return new FrontierAwareEnumerator(enumerator, _frontierTimeProvider,
return new FrontierAwareEnumerator(enumerator, FrontierTimeProvider,
new TimeZoneOffsetProvider(exchangeTimeZone, utcStartTime, Time.EndOfTime)
);
}
Expand Down Expand Up @@ -178,7 +183,7 @@ public void SetJob(LiveNodePacket job)
DataHandlers.Add(dataHandler);
}

_frontierTimeProvider = InitializeFrontierTimeProvider();
FrontierTimeProvider = InitializeFrontierTimeProvider();
}

/// <summary>
Expand Down
9 changes: 8 additions & 1 deletion Engine/DataFeeds/Enumerators/LiveSubscriptionEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ public bool MoveNext()
}

var result = _underlyingEnumerator.MoveNext();
_current = _underlyingEnumerator.Current;
if (result)
{
_current = _underlyingEnumerator.Current;
}
else
{
_current = null;
}

if (_current != null && _current.Symbol != _requestedSymbol)
{
Expand Down
Loading

0 comments on commit de360a7

Please sign in to comment.