FindSymbols

Modified on 2013/05/11 11:24 by Eugene — Categorized as: Community Components

Syntax

public static Dictionary<string, List<string>> FindSymbols(this string symbols)

public Dictionary<string, List<string>> FindSymbols(string symbols)

Parameter Description

symbolsSymbol name (or a list of symbols) to find

Description

Sometimes, you need to know which DataSet(s) contain some particular symbol name(s). This function lets you find DataSets which include a given symbol. Passing a list of symbols is also supported.

When passing multiple symbol names, separate them with one of these characters: comma (','), semicolon (';'), or space (' '). (Consequently, space couldn't be a part of the symbol name.)

A Dictionary is returned, where the Key collection contains symbol name(s), and the Value collection contains the list of DataSet names where a corresponding symbol name was found.

Example

Check out this example which makes the function's usage easy:

Example using C# extension methods:


using System;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;

namespace WealthLab.Strategies { public class SearchForClickedSymbol : WealthScript { protected override void Execute() { ClearDebug();

// Dialog to manually input some symbol(s) string symbols = this.Input(); // FindSymbols output Dictionary<string, List<string>> result = symbols.FindSymbols(); foreach( KeyValuePair<string, List<string>> kvp in result ) { //Looping by each symbol... PrintDebug("Symbol: " + kvp.Key); // ...display every DataSet found foreach( string ds in kvp.Value ) PrintDebug("DataSet name: " + ds); } } } }

Legacy syntax example:


using System;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using Community.Components; /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/

namespace WealthLab.Strategies { public class SearchForClickedSymbol : WealthScript { protected override void Execute() { Utility u = new Utility(this); ClearDebug();

// Dialog to manually input some symbol(s) string symbols = Utility.Input(); // FindSymbols output Dictionary<string, List<string>> result = new Dictionary<string, List<string>>(); result = u.FindSymbols(symbols); foreach( KeyValuePair<string, List<string>> kvp in result ) { //Looping by each symbol... PrintDebug("Symbol: " + kvp.Key); // ...display every DataSet found foreach( string ds in kvp.Value ) PrintDebug("DataSet name: " + ds); } } } }