Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Algorithm.CSharp/QuantConnect.Algorithm.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.42" />
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.44" />
<PackageReference Include="Accord" Version="3.6.0" />
<PackageReference Include="Accord.Fuzzy" Version="3.6.0" />
<PackageReference Include="Accord.MachineLearning" Version="3.6.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void OnData(Slice slice)
}
catch (Exception exception)
{
if (exception.Message.Contains("This asset symbol (PEPE 0) was not found in your security list") && !Portfolio.Invested)
if (exception.Message.Contains("PEPE was not found", StringComparison.InvariantCultureIgnoreCase) && !Portfolio.Invested)
{
SetHoldings("SPY", 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.42" />
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.44" />
<PackageReference Include="Accord" Version="3.6.0" />
<PackageReference Include="Accord.Math" Version="3.6.0" />
<PackageReference Include="Accord.Statistics" Version="3.6.0" />
Expand Down
15 changes: 7 additions & 8 deletions Algorithm.Python/DynamicSecurityDataRegressionAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# limitations under the License.

from AlgorithmImports import *
from System.Collections.Generic import List
from QuantConnect.Data.Custom.IconicTypes import *

### <summary>
Expand All @@ -28,24 +27,24 @@ def initialize(self):
self._equity = self.add_equity(ticker, Resolution.DAILY)

custom_linked_equity = self.add_data(LinkedData, ticker, Resolution.DAILY)

first_linked_data = LinkedData()
first_linked_data.count = 100
first_linked_data.symbol = custom_linked_equity.symbol
first_linked_data.end_time = self.start_date

second_linked_data = LinkedData()
second_linked_data.count = 100
second_linked_data.symbol = custom_linked_equity.symbol
second_linked_data.end_time = self.start_date

# Adding linked data manually to cache for example purposes, since
# LinkedData is a type used for testing and doesn't point to any real data.
custom_linked_equity_type = list(custom_linked_equity.subscriptions)[0].type
custom_linked_data = List[LinkedData]()
custom_linked_data.add(first_linked_data)
custom_linked_data.add(second_linked_data)
self._equity.cache.add_data_list(custom_linked_data, custom_linked_equity_type, False)
custom_linked_data = list[LinkedData]()
custom_linked_data.append(first_linked_data)
custom_linked_data.append(second_linked_data)
self._equity.cache.add_data_list(custom_linked_data, custom_linked_equity_type, False)

def on_data(self, data):
# The Security object's Data property provides convenient access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# limitations under the License.

from AlgorithmImports import *
from System import *

### <summary>
### Regression algorithm illustrating how to request history data for different data mapping modes.
Expand All @@ -25,13 +24,12 @@ def initialize(self):
self._continuous_contract_symbol = self.add_future(Futures.Indices.SP_500_E_MINI, Resolution.DAILY).symbol

def on_end_of_algorithm(self):
data_mapping_modes = [DataMappingMode(x) for x in Enum.get_values(DataMappingMode)]
history_results = [
self.history([self._continuous_contract_symbol], self.start_date, self.end_date, Resolution.DAILY, data_mapping_mode=data_mapping_mode)
.droplevel(0, axis=0)
.loc[self._continuous_contract_symbol]
.close
for data_mapping_mode in data_mapping_modes
for data_mapping_mode in DataMappingMode
]

if any(x.size != history_results[0].size for x in history_results):
Expand All @@ -40,5 +38,5 @@ def on_end_of_algorithm(self):
# Check that close prices at each time are different for different data mapping modes
for j in range(history_results[0].size):
close_prices = set(history_results[i][j] for i in range(len(history_results)))
if len(close_prices) != len(data_mapping_modes):
if len(close_prices) != len(DataMappingMode):
raise AssertionError("History results close prices should have been different for each data mapping mode at each time")
2 changes: 1 addition & 1 deletion Algorithm.Python/QuantConnect.Algorithm.Python.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<Compile Include="..\Common\Properties\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.42" />
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.44" />
</ItemGroup>
<ItemGroup>
<Content Include="OptionUniverseFilterGreeksShortcutsRegressionAlgorithm.py" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ def on_data(self, data):
try:
self.market_order("PEPE", 1)
except Exception as exception:
if "This asset symbol (PEPE 0) was not found in your security list" in str(exception) and not self.portfolio.invested:
if "PEPE was not found" in str(exception) and not self.portfolio.invested:
self.set_holdings("SPY", 1)
2 changes: 1 addition & 1 deletion Algorithm/QuantConnect.Algorithm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.42" />
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.44" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NodaTime" Version="3.0.5" />
Expand Down
2 changes: 1 addition & 1 deletion AlgorithmFactory/QuantConnect.AlgorithmFactory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.42" />
<PackageReference Include="QuantConnect.pythonnet" Version="2.0.44" />
<PackageReference Include="NodaTime" Version="3.0.5" />
</ItemGroup>
<ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions Common/Data/Market/BaseChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ public HashSet<Symbol> FilteredContracts
[PandasIgnore]
public PyObject DataFrame => _dataframe.Value;

/// <summary>
/// The number of contracts in this chain
/// </summary>
public int Count => Contracts.Count;

/// <summary>
/// Checks if the chain contains a contract with the specified symbol
/// </summary>
/// <param name="key">The symbol of the contract to check for</param>
/// <returns>True if the chain contains a contract with the specified symbol; otherwise, false.</returns>
public bool ContainsKey(Symbol key)
{
return Contracts.ContainsKey(key);
}

/// <summary>
/// Initializes a new default instance of the <see cref="BaseChain{T, TContractsCollection}"/> class
/// </summary>
Expand Down
13 changes: 10 additions & 3 deletions Common/Data/Market/DataDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace QuantConnect.Data.Market
/// Provides a base class for types holding base data instances keyed by symbol
/// </summary>
[PandasNonExpandable]
public class DataDictionary<T> : ExtendedDictionary<T>, IDictionary<Symbol, T>
public class DataDictionary<T> : ExtendedDictionary<Symbol, T>, IDictionary<Symbol, T>
{
// storage for the data
private readonly IDictionary<Symbol, T> _data = new Dictionary<Symbol, T>();
Expand Down Expand Up @@ -146,7 +146,7 @@ public bool Remove(KeyValuePair<Symbol, T> item)
/// <returns>
/// The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.
/// </returns>
public int Count
public override int Count
{
get { return _data.Count; }
}
Expand All @@ -169,11 +169,17 @@ public override bool IsReadOnly
/// true if the <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/> contains an element with the key; otherwise, false.
/// </returns>
/// <param name="key">The key to locate in the <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/>.</param><exception cref="System.ArgumentNullException"><paramref name="key"/> is null.</exception>
public bool ContainsKey(Symbol key)
public override bool ContainsKey(Symbol key)
{
return _data.ContainsKey(key);
}

/// <summary>
/// Gets all the items in the dictionary
/// </summary>
/// <returns>All the items in the dictionary</returns>
public override IEnumerable<KeyValuePair<Symbol, T>> GetItems() => _data;

/// <summary>
/// Adds an element with the provided key and value to the <see cref="System.Collections.Generic.IDictionary{TKey, TValue}"/>.
/// </summary>
Expand Down Expand Up @@ -226,6 +232,7 @@ public override T this[Symbol symbol]
{
return data;
}
CheckForImplicitlyCreatedSymbol(symbol);
throw new KeyNotFoundException($"'{symbol}' wasn't found in the {GetType().GetBetterTypeName()} object, likely because there was no-data at this moment in time and it wasn't possible to fillforward historical data. Please check the data exists before accessing it with data.ContainsKey(\"{symbol}\")");
}
set
Expand Down
22 changes: 1 addition & 21 deletions Common/Data/Market/Delistings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
Expand Down Expand Up @@ -38,25 +38,5 @@ public Delistings(DateTime frontier)
: base(frontier)
{
}

/// <summary>
/// Gets or sets the Delisting with the specified ticker.
/// </summary>
/// <returns>
/// The Delisting with the specified ticker.
/// </returns>
/// <param name="ticker">The ticker of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new Delisting this[string ticker] { get { return base[ticker]; } set { base[ticker] = value; } }

/// <summary>
/// Gets or sets the Delisting with the specified Symbol.
/// </summary>
/// <returns>
/// The Delisting with the specified Symbol.
/// </returns>
/// <param name="symbol">The Symbol of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new Delisting this[Symbol symbol] { get { return base[symbol]; } set { base[symbol] = value; } }
}
}
22 changes: 1 addition & 21 deletions Common/Data/Market/Dividends.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
Expand Down Expand Up @@ -38,25 +38,5 @@ public Dividends(DateTime frontier)
: base(frontier)
{
}

/// <summary>
/// Gets or sets the Dividend with the specified ticker.
/// </summary>
/// <returns>
/// The Dividend with the specified ticker.
/// </returns>
/// <param name="ticker">The ticker of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new Dividend this[string ticker] { get { return base[ticker]; } set { base[ticker] = value; } }

/// <summary>
/// Gets or sets the Dividend with the specified Symbol.
/// </summary>
/// <returns>
/// The Dividend with the specified Symbol.
/// </returns>
/// <param name="symbol">The Symbol of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new Dividend this[Symbol symbol] { get { return base[symbol]; } set { base[symbol] = value; } }
}
}
22 changes: 1 addition & 21 deletions Common/Data/Market/FuturesContracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,5 @@ public FuturesContracts(DateTime time)
: base(time)
{
}

/// <summary>
/// Gets or sets the FuturesContract with the specified ticker.
/// </summary>
/// <returns>
/// The FuturesContract with the specified ticker.
/// </returns>
/// <param name="ticker">The ticker of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new FuturesContract this[string ticker] { get { return base[ticker]; } set { base[ticker] = value; } }

/// <summary>
/// Gets or sets the FuturesContract with the specified Symbol.
/// </summary>
/// <returns>
/// The FuturesContract with the specified Symbol.
/// </returns>
/// <param name="symbol">The Symbol of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new FuturesContract this[Symbol symbol] { get { return base[symbol]; } set { base[symbol] = value; } }
}
}
}
20 changes: 0 additions & 20 deletions Common/Data/Market/MarginInterestRates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,5 @@ public MarginInterestRates(DateTime frontier)
: base(frontier)
{
}

/// <summary>
/// Gets or sets the Dividend with the specified ticker.
/// </summary>
/// <returns>
/// The Dividend with the specified ticker.
/// </returns>
/// <param name="ticker">The ticker of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new MarginInterestRate this[string ticker] { get { return base[ticker]; } set { base[ticker] = value; } }

/// <summary>
/// Gets or sets the Dividend with the specified Symbol.
/// </summary>
/// <returns>
/// The Dividend with the specified Symbol.
/// </returns>
/// <param name="symbol">The Symbol of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new MarginInterestRate this[Symbol symbol] { get { return base[symbol]; } set { base[symbol] = value; } }
}
}
22 changes: 1 addition & 21 deletions Common/Data/Market/OptionContracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,5 @@ public OptionContracts(DateTime time)
: base(time)
{
}

/// <summary>
/// Gets or sets the OptionContract with the specified ticker.
/// </summary>
/// <returns>
/// The OptionContract with the specified ticker.
/// </returns>
/// <param name="ticker">The ticker of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new OptionContract this[string ticker] { get { return base[ticker]; } set { base[ticker] = value; } }

/// <summary>
/// Gets or sets the OptionContract with the specified Symbol.
/// </summary>
/// <returns>
/// The OptionContract with the specified Symbol.
/// </returns>
/// <param name="symbol">The Symbol of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new OptionContract this[Symbol symbol] { get { return base[symbol]; } set { base[symbol] = value; } }
}
}
}
22 changes: 1 addition & 21 deletions Common/Data/Market/QuoteBars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,5 @@ public QuoteBars(DateTime time)
: base(time)
{
}

/// <summary>
/// Gets or sets the QuoteBar with the specified ticker.
/// </summary>
/// <returns>
/// The QuoteBar with the specified ticker.
/// </returns>
/// <param name="ticker">The ticker of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new QuoteBar this[string ticker] { get { return base[ticker]; } set { base[ticker] = value; } }

/// <summary>
/// Gets or sets the QuoteBar with the specified Symbol.
/// </summary>
/// <returns>
/// The QuoteBar with the specified Symbol.
/// </returns>
/// <param name="symbol">The Symbol of the element to get or set.</param>
/// <remarks>Wraps the base implementation to enable indexing in python algorithms due to pythonnet limitations</remarks>
public new QuoteBar this[Symbol symbol] { get { return base[symbol]; } set { base[symbol] = value; } }
}
}
}
Loading
Loading