public void Analyze(Broker bro, Symbol sym, string date) { #region Init Quotes q1 = null; #region Check for (int i = 0; i < bro.Symbols.Count; i++) if (bro.Symbols[i].Name == sym.Name) { for (int j = 0; j < bro.Symbols[i].Files.Count; j++) if (bro.Symbols[i].Files[j].Date == date) { q1 = new Quotes(bro.Symbols[i].Files[j].Path); i = bro.Symbols.Count; break; } } if (q1 == null || q1.pTime == null) { //Log(bro1.Name, "", sym.Name, new MegaTime(date), false); return; } #endregion #endregion bool isSos = false; MegaTime t = null; int Ticks = (int)numericUpDown1.Value; int Delta = (int)numericUpDown3.Value; int asum1 = 0, asum2 = 0; int sum1 = 0, sum2 = 0; bool fl = false; for (int i = Ticks + 1; i < q1.pTime.Count; i++) { asum1 = 0; asum2 = 0; sum1 = 0; sum2 = 0; fl = false; for (int j = 0; j < Ticks; j++) { sum1 += q1.pAsk[i - j] - q1.pAsk[i - j - 1]; sum2 += q1.pBid[i - j] - q1.pBid[i - j - 1]; asum1 += Math.Abs(sum1); asum2 += Math.Abs(sum2); if (checkBox3.Checked && asum1 / Math.Max(Math.Abs(sum1), 1) >= Delta && asum2 / Math.Max(Math.Abs(sum2), 1) >= Delta) { if (!isSos) { isSos = true; t = new MegaTime(q1.pTime[i - Ticks]); } fl = true; } else if (!checkBox3.Checked && (asum1 / Math.Max(Math.Abs(sum1), 1) >= Delta || asum2 / Math.Max(Math.Abs(sum2), 1) >= Delta)) { if (!isSos) { isSos = true; t = new MegaTime(q1.pTime[i - Ticks]); } fl = true; } } if (!fl) { if (isSos) { Log(bro.Name, sym.Name, t, true); isSos = false; } } } }
// Added to prevent duplicates to prevent key insertion errors/redundancy private static List<Quotes.QuoteProperties> DistinctQuotePropertyList( Quotes.QuoteProperties[] qps ) { var lQP = qps.ToList<Quotes.QuoteProperties>( ); var lQPDistinct = lQP.Distinct( ).ToList<Quotes.QuoteProperties>(); return lQPDistinct; }
public MarketDataItem( string input, Quotes.QuoteProperties Quote ) { _str = null; _data = null; this.Property = Quote; this.Type = Quote.Type; if ( Property.Type == Quotes.ResultType.Date ) ParseDate( input ); if ( Property.Type == Quotes.ResultType.Number ) ParseNumber( input ); if ( Property.Type == Quotes.ResultType.Pair ) ParsePair( input ); if ( Property.Type == Quotes.ResultType.Percentage ) ParsePercentage( input ); if ( Property.Type == Quotes.ResultType.Range ) ParseRange( input ); if ( Property.Type == Quotes.ResultType.RangePercentage ) ParsePercentageRange( input ); if ( Property.Type == Quotes.ResultType.Text ) ParseText( input ); if ( Property.Type == Quotes.ResultType.TruncuatedCurrency ) ParseTruncateCurrency( input ); }
// For each company, the outter dictionary key, makes a single item query for the special case quote property // The inner dictionary is expected to be the quote property name, value pair // If request is unsuccessful, returns null private static Dictionary<string, Dictionary<string, string>> SpecialCaseQuoteQuery( string baseQuery, List<string> tickers, Quotes.QuoteProperties qp ) { baseQuery += qp.ToString( ); baseQuery += endURL; var qResult = string.Empty; try{ qResult = client.DownloadString( baseQuery ); } catch{ return null; } string [] stringSeparator = new string [] { "\r\n" }; var resultLines = qResult.Split( stringSeparator, StringSplitOptions.RemoveEmptyEntries ); var result = new Dictionary<string, Dictionary<string, string>>( ); for(int i = 0; i < tickers.Count; i++) { var valuePair = new Dictionary<string, string>( ); valuePair.Add( qp.GetDesription( ), resultLines [ i ] ); result.Add( tickers [ i ], valuePair ); } return result; }