/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Securities;
namespace QuantConnect.ToolBox.RandomDataGenerator
{
///
/// Generates a new random object of the specified security type.
/// All returned symbols have a matching entry in the Symbol properties database.
///
///
/// A valid implementation will keep track of generated Symbol objects to ensure duplicates
/// are not generated.
///
public class DefaultSymbolGenerator : BaseSymbolGenerator
{
private readonly string _market;
private readonly SecurityType _securityType;
///
/// Creates instance
///
/// random data generation run settings
/// produces random values for use in random data generation
public DefaultSymbolGenerator(RandomDataGeneratorSettings settings, IRandomValueGenerator random)
: base(settings, random)
{
_market = settings.Market;
_securityType = settings.SecurityType;
}
///
/// Generates a single-item list at a time using base random implementation
///
///
protected override IEnumerable GenerateAsset(string ticker = null)
{
yield return NextSymbol(Settings.SecurityType, Settings.Market, ticker);
}
///
/// Returns the number of symbols with the specified parameters can be generated.
/// Returns int.MaxValue if there is no limit for the given parameters.
///
/// The number of available symbols for the given parameters, or int.MaxValue if no limit
public override int GetAvailableSymbolCount()
{
// check the Symbol properties database to determine how many symbols we can generate
// if there is a wildcard entry, we can generate as many symbols as we want
// if there is no wildcard entry, we can only generate as many symbols as there are entries
return SymbolPropertiesDatabase.ContainsKey(_market, SecurityDatabaseKey.Wildcard, _securityType)
? int.MaxValue
: SymbolPropertiesDatabase.GetSymbolPropertiesList(_market, _securityType).Count();
}
}
}