File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919using System . Globalization ;
2020using System . IO ;
2121using System . Linq ;
22+ using System . Text . RegularExpressions ;
2223using Newtonsoft . Json ;
2324using QuantConnect . Data . Auxiliary ;
2425using QuantConnect . DataSource ;
@@ -99,6 +100,16 @@ public bool Run(DateTime processDate)
99100 }
100101
101102 ticker = ticker . Split ( ':' ) . Last ( ) . Replace ( "\" " , string . Empty ) . ToUpperInvariant ( ) . Trim ( ) ;
103+ // Strip characters not allowed in tickers (only letters, digits, and mid-string dots are valid)
104+ ticker = Regex . Replace ( ticker , @"[^A-Z0-9.]" , string . Empty ) ;
105+ ticker = ticker . Trim ( '.' ) ;
106+
107+ // Validate: must be non-empty, only letters/digits/dots, dot not at start or end
108+ if ( ! Regex . IsMatch ( ticker , @"^[A-Z0-9][A-Z0-9.]*[A-Z0-9]$" ) && ! Regex . IsMatch ( ticker , @"^[A-Z0-9]$" ) )
109+ {
110+ Log . Trace ( $ "QuiverCNBCDataDownloader.Run(): Skipping invalid ticker '{ ticker } ' on { processDate : yyyyMMdd} ") ;
111+ continue ;
112+ }
102113
103114 if ( ! cnbcByTicker . TryGetValue ( ticker , out var _ ) )
104115 {
You can’t perform that action at this time.
0 commit comments