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

Rename Namespaces, use Globals #11

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/gh-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
options: -v /home/runner/work:/__w --workdir /__w/Lean.DataSource.IQFeed/Lean.DataSource.IQFeed -e QC_JOB_USER_ID=${{ secrets.QC_JOB_USER_ID }} -e QC_API_ACCESS_TOKEN=${{ secrets.QC_API_ACCESS_TOKEN }} -e QC_JOB_ORGANIZATION_ID=${{ secrets.QC_JOB_ORGANIZATION_ID }}

- name: BuildDataSource
run: dotnet build ./QuantConnect.IQFeed/QuantConnect.IQFeed.csproj /p:Configuration=Release /v:quiet /p:WarningLevel=1
run: dotnet build ./QuantConnect.IQFeed/QuantConnect.DataSource.IQFeed.csproj /p:Configuration=Release /v:quiet /p:WarningLevel=1

- name: BuildDataSourceTests
run: dotnet build ./QuantConnect.IQFeed.Tests/QuantConnect.IQFeed.Tests.csproj /p:Configuration=Release /v:quiet /p:WarningLevel=1
run: dotnet build ./QuantConnect.IQFeed.Tests/QuantConnect.DataSource.IQFeed.Tests.csproj /p:Configuration=Release /v:quiet /p:WarningLevel=1

- name: Run Tests
run: dotnet test ./QuantConnect.IQFeed.Tests/bin/Release/QuantConnect.IQFeed.Tests.dll
run: dotnet test ./QuantConnect.IQFeed.Tests/bin/Release/QuantConnect.Lean.DataSource.IQFeed.Tests.dll
4 changes: 2 additions & 2 deletions Lean.DataSource.IQFeed.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuantConnect.IQFeed", "QuantConnect.IQFeed\QuantConnect.IQFeed.csproj", "{209C11BB-C283-4599-A04D-D96097E006E6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuantConnect.DataSource.IQFeed", "QuantConnect.IQFeed\QuantConnect.DataSource.IQFeed.csproj", "{209C11BB-C283-4599-A04D-D96097E006E6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuantConnect.Tests", "..\Lean\Tests\QuantConnect.Tests.csproj", "{AF992149-87F2-4B40-B864-E9FC8F8392A6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuantConnect.IQFeed.Tests", "QuantConnect.IQFeed.Tests\QuantConnect.IQFeed.Tests.csproj", "{E48A0E2D-97D7-4480-AE0D-EB73838D9208}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuantConnect.DataSource.IQFeed.Tests", "QuantConnect.IQFeed.Tests\QuantConnect.DataSource.IQFeed.Tests.csproj", "{E48A0E2D-97D7-4480-AE0D-EB73838D9208}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
12 changes: 6 additions & 6 deletions QuantConnect.IQFeed.Tests/IQFeedDataDownloaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using NUnit.Framework;
using System.Collections.Generic;

namespace QuantConnect.IQFeed.Tests
namespace QuantConnect.Lean.DataSource.IQFeed.Tests
{
[TestFixture, Explicit("This tests require a IQFeed credentials.")]
public class IQFeedDataDownloaderTest
Expand All @@ -35,20 +35,20 @@ public void SetUp()
private static IEnumerable<TestCaseData> HistoricalDataTestCases => IQFeedHistoryProviderTests.HistoricalTestParameters;

[TestCaseSource(nameof(HistoricalDataTestCases))]
public void DownloadsHistoricalData(Symbol symbol, Resolution resolution, TickType tickType, TimeSpan period, bool isEmptyResult)
public void DownloadsHistoricalData(Symbol symbol, Resolution resolution, TickType tickType, TimeSpan period, bool isNullResult)
{
var request = IQFeedHistoryProviderTests.CreateHistoryRequest(symbol, resolution, tickType, period);

var parameters = new DataDownloaderGetParameters(symbol, resolution, request.StartTimeUtc, request.EndTimeUtc, tickType);
var downloadResponse = _downloader.Get(parameters).ToList();
var downloadResponse = _downloader.Get(parameters)?.ToList();

if (isEmptyResult)
if (isNullResult)
{
Assert.IsEmpty(downloadResponse);
Assert.IsNull(downloadResponse);
return;
}

IQFeedHistoryProviderTests.AssertHistoricalDataResponse(resolution, downloadResponse, isEmptyResult);
IQFeedHistoryProviderTests.AssertHistoricalDataResponse(resolution, downloadResponse);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
using System.Collections.Generic;
using QuantConnect.Lean.Engine.DataFeeds.Enumerators;

namespace QuantConnect.IQFeed.Tests
namespace QuantConnect.Lean.DataSource.IQFeed.Tests
{
[TestFixture, Explicit("This tests require a IQFeed credentials.")]
public class IQFeedDataQueueHandlerTests
public class IQFeedDataProviderTests
{
private IQFeedDataQueueHandler _iqFeed;
private IQFeedDataProvider _iqFeed;

[SetUp]
public void SetUp()
{
_iqFeed = new IQFeedDataQueueHandler();
_iqFeed = new IQFeedDataProvider();
}

[TearDown]
Expand Down
20 changes: 10 additions & 10 deletions QuantConnect.IQFeed.Tests/IQFeedHistoryProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
using System.Collections.Generic;
using QuantConnect.Data.Market;

namespace QuantConnect.IQFeed.Tests
namespace QuantConnect.Lean.DataSource.IQFeed.Tests
{
[TestFixture, Explicit("This tests require a IQFeed credentials.")]
public class IQFeedHistoryProviderTests
{
private IQFeedDataQueueHandler _historyProvider;
private IQFeedDataProvider _historyProvider;

[SetUp]
public void SetUp()
{
_historyProvider = new IQFeedDataQueueHandler();
_historyProvider = new IQFeedDataProvider();
_historyProvider.Initialize(new HistoryProviderInitializeParameters(null, null, null, null, null, null, null, false, null, null));
}

Expand Down Expand Up @@ -66,27 +66,27 @@ internal static IEnumerable<TestCaseData> HistoricalTestParameters

// Not supported Security Types
yield return new TestCaseData(Symbol.Create("SPX.XO", SecurityType.Index, Market.CBOE), Resolution.Tick, TickType.Trade, TimeSpan.FromMinutes(5), true);
yield return new TestCaseData(Symbol.CreateFuture("@ESGH24", Market.CME, new DateTime(2024, 3, 21)), Resolution.Tick, TickType.Trade, TimeSpan.FromMinutes(5), true);
yield return new TestCaseData(Symbol.CreateFuture("@ESGH24", Market.CME, new DateTime(2024, 3, 21)), Resolution.Tick, TickType.Trade, TimeSpan.FromMinutes(5), true);

}
}

[TestCaseSource(nameof(HistoricalTestParameters))]
public void GetHistoricalData(Symbol symbol, Resolution resolution, TickType tickType, TimeSpan period, bool isEmptyResult)
public void GetHistoricalData(Symbol symbol, Resolution resolution, TickType tickType, TimeSpan period, bool isNullResult)
{
var historyRequests = new List<HistoryRequest> { CreateHistoryRequest(symbol, resolution, tickType, period) };

var historyResponse = _historyProvider.GetHistory(historyRequests, TimeZones.Utc).ToList();
var historyResponse = _historyProvider.GetHistory(historyRequests, TimeZones.Utc)?.ToList();

if (isEmptyResult)
if (isNullResult)
{
Assert.IsEmpty(historyResponse);
Assert.IsNull(historyResponse);
return;
}

AssertTicksHaveAppropriateTickType(resolution, tickType, historyResponse);

AssertHistoricalDataResponse(resolution, historyResponse.SelectMany(x => x.AllData).ToList(), isEmptyResult);
AssertHistoricalDataResponse(resolution, historyResponse.SelectMany(x => x.AllData).ToList());
}

internal static void AssertTicksHaveAppropriateTickType(Resolution resolution, TickType tickType, List<Slice> historyResponse)
Expand All @@ -102,7 +102,7 @@ internal static void AssertTicksHaveAppropriateTickType(Resolution resolution, T
};
}

internal static void AssertHistoricalDataResponse(Resolution resolution, List<BaseData> historyResponse, bool isEmptyResult)
internal static void AssertHistoricalDataResponse(Resolution resolution, List<BaseData> historyResponse)
{
Assert.IsNotEmpty(historyResponse);

Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed.Tests/IQFeedRealtimeDataFeedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using QuantConnect.Brokerages;
using QuantConnect.Interfaces;

namespace QuantConnect.IQFeed.Tests
namespace QuantConnect.Lean.DataSource.IQFeed.Tests
{
/// <summary>
/// Test fixture is explicit, because tests are dependent on network and are long
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using System;
using NUnit.Framework;

namespace QuantConnect.IQFeed.Tests
namespace QuantConnect.Lean.DataSource.IQFeed.Tests
{
[TestFixture]
public class IQFeedSymbolRepresentationTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<IsPackable>false</IsPackable>
<TestProjectType>UnitTest</TestProjectType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Product>QuantConnect.IQFeed.Tests</Product>
<AssemblyName>QuantConnect.IQFeed.Tests</AssemblyName>
<RootNamespace>QuantConnect.IQFeed.Tests</RootNamespace>
<AssemblyTitle>QuantConnect.IQFeed.Tests</AssemblyTitle>
<Product>QuantConnect.Lean.DataSource.IQFeed.Tests</Product>
<AssemblyName>QuantConnect.Lean.DataSource.IQFeed.Tests</AssemblyName>
<RootNamespace>QuantConnect.Lean.DataSource.IQFeed.Tests</RootNamespace>
<AssemblyTitle>QuantConnect.Lean.DataSource.IQFeed.Tests</AssemblyTitle>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
Expand All @@ -23,7 +23,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Lean\Tests\QuantConnect.Tests.csproj" />
<ProjectReference Include="..\QuantConnect.IQFeed\QuantConnect.IQFeed.csproj" />
<ProjectReference Include="..\QuantConnect.IQFeed\QuantConnect.DataSource.IQFeed.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="config.json" />
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed.Tests/TestSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using QuantConnect.Configuration;
using QuantConnect.Tests;

namespace QuantConnect.IQFeed.Tests
namespace QuantConnect.Lean.DataSource.IQFeed.Tests
{
[SetUpFixture]
public class TestSetup
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/DataStructures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
*/

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
public class Time
{
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/IQAdminSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// ToDo: When a command is given, create a default event - command applied.........

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{

public class ClientStatsEventArgs : EventArgs
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/IQConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Diagnostics;
using QuantConnect.Configuration;

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{

public class IQConnect
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/IQCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
*/

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
public class IQCredentials
{
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/IQLevel1Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Globalization;
using Timer = System.Timers.Timer;

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
public class Level1ServerDisconnectedArgs : Level1TextLineEventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using QuantConnect.Logging;
using static QuantConnect.StringExtensions;

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
// Historical stock data lookup events
public class LookupTickEventArgs : LookupEventArgs
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/IQLookupTableClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Collections.Concurrent;

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
public class LookupTableMarketEventArgs : LookupEventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/IQSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Globalization;
using QuantConnect.Configuration;

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
public enum LookupSequence
{
Expand Down
2 changes: 1 addition & 1 deletion QuantConnect.IQFeed/IQFeedAPI/SocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.Net;
using System.Net.Sockets;

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
public class TextLineEventArgs : EventArgs
{
Expand Down
18 changes: 11 additions & 7 deletions QuantConnect.IQFeed/IQFeedDataDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using QuantConnect.Configuration;
using IQFeed.CSharpApiClient.Lookup;

namespace QuantConnect.IQFeed
namespace QuantConnect.Lean.DataSource.IQFeed
{
/// <summary>
/// Represents a data downloader for retrieving historical market data using IQFeed.
Expand Down Expand Up @@ -52,7 +52,7 @@ public class IQFeedDataDownloader : IDataDownloader
public IQFeedDataDownloader()
{
_fileHistoryProviderLazy = new Lazy<IQFeedFileHistoryProvider>(() =>
{
{
// Create and connect the IQFeed lookup client
var lookupClient = LookupClientFactory.CreateNew(Config.Get("iqfeed-host", "127.0.0.1"), IQSocket.GetPort(PortType.Lookup), NumberOfClients, LookupDefault.Timeout);
// Establish connection with IQFeed Client
Expand All @@ -67,7 +67,7 @@ public IQFeedDataDownloader()
/// </summary>
/// <param name="dataDownloaderGetParameters">model class for passing in parameters for historical data</param>
/// <returns>Enumerable of base data for this symbol</returns>
public IEnumerable<BaseData> Get(DataDownloaderGetParameters dataDownloaderGetParameters)
public IEnumerable<BaseData>? Get(DataDownloaderGetParameters dataDownloaderGetParameters)
{
var symbol = dataDownloaderGetParameters.Symbol;
var resolution = dataDownloaderGetParameters.Resolution;
Expand All @@ -77,22 +77,26 @@ public IEnumerable<BaseData> Get(DataDownloaderGetParameters dataDownloaderGetPa

if (tickType == TickType.OpenInterest)
{
return Enumerable.Empty<BaseData>();
Log.Error($"{nameof(IQFeedDataDownloader)}.{nameof(Get)}: Not supported data type - {tickType}");
return null;
}

if (symbol.ID.SecurityType != SecurityType.Equity)
{
return Enumerable.Empty<BaseData>();
Log.Trace($"{nameof(IQFeedDataDownloader)}.{nameof(Get)}: Unsupported SecurityType '{symbol.SecurityType}' for symbol '{symbol}'");
return null;
}

if (tickType == TickType.Quote && resolution != Resolution.Tick)
{
Log.Trace($"{nameof(IQFeedDataDownloader)}.{nameof(Get)}: Historical data request with TickType 'Quote' is not supported for resolutions other than Tick. Requested Resolution: {resolution}");
return Enumerable.Empty<BaseData>();
return null;
}

if (endUtc < startUtc)
throw new ArgumentException("The end date must be greater or equal than the start date.");
{
return null;
}

var dataType = resolution == Resolution.Tick ? typeof(Tick) : typeof(TradeBar);

Expand Down
Loading
Loading