/// <summary> /// Returns the number of symbols with the specified parameters can be generated. /// Returns int.MaxValue if there is no limit for the given parameters. /// </summary> /// <returns>The number of available symbols for the given parameters, or int.MaxValue if no limit</returns> 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()); }
public virtual Symbol NextSymbol(SecurityType securityType, string market) { if (securityType == SecurityType.Option || securityType == SecurityType.Future) { throw new ArgumentException("Please use NextOption or NextFuture for SecurityType.Option and SecurityType.Future respectively."); } string ticker; // we must return a symbol matching an entry in the symbol properties database // if there is a wildcard entry, we can generate a truly random symbol // if there is no wildcard entry, the symbols we can generate are limited by the entries in the database if (_symbolPropertiesDatabase.ContainsKey(market, SecurityDatabaseKey.Wildcard, securityType)) { // let's make symbols all have 3 chars as it's acceptable for all security types with wildcard entries ticker = NextUpperCaseString(3, 3); } else { ticker = NextTickerFromSymbolPropertiesDatabase(securityType, market); } // by chance we may generate a ticker that actually exists, and if map files exist that match this // ticker then we'll end up resolving the first trading date for use in the SID, otherwise, all // generated symbol will have a date equal to SecurityIdentifier.DefaultDate var symbol = Symbol.Create(ticker, securityType, market); if (_symbols.Add(symbol)) { return(symbol); } // lo' and behold, we created a duplicate --recurse to find a unique value // this is purposefully done as the last statement to enable the compiler to // unroll this method into a tail-recursion loop :) return(NextSymbol(securityType, market)); }