Python array of top 140 ETFs

Discussion in 'App Development' started by MoneyMatthew, Feb 17, 2020.

  1. WealthSignals

    WealthSignals Sponsor

    Nice effort MoneyMatthew. Many technical analysis software include various scanners which can be run on symbol universes. In a platform like Wealth-Lab, power users can also utilize online scanners (think black box formulas etc.)

    Just for kicks, I've created a short piece of Wealth-Lab C# code that gets and prints out the list of Top 100 ETFs by Volume dynamically. Takes just 70 lines.


    "Most Popular ETFs: Top 100 ETFs By Trading Volume" @


    using System;
    using System.Collections.Generic;
    using WealthLab;
    using System.Net;
    using System.Linq;
    using System.Globalization;
    using System.Web;
    using HtmlAgilityPack;
    using System.Linq;
    using System.Xml;
    namespace WealthLab.Strategies
       public class PrintTop100ETFs : WealthScript
         protected override void Execute()
           //Prints out the dynamic list of "Most Popular ETFs: Top 100 ETFs By Trading Volume" from
           PrintDebug("Top 100 ETFs");
           foreach (var etf in ETFDBParser.GetTop100ETFs())
       public class ETFDBParser
         static string url = "";
         static string CachedPage { get; set; }
         public static List<string> GetTop100ETFs()
           var lst = new List<string>();
           using (WebClient wc = new WebClient())
             wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0");
             wc.Headers.Add("Content-Type", "text/html, application/xhtml+xml, image/jxr, */*");
             wc.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
             wc.Headers.Add("Accept-Language", "en-US,en;q=0.5");
             wc.Headers.Add("Referer", "");
             string result = string.Empty;
             if (string.IsNullOrEmpty(CachedPage))
               result = wc.DownloadString(url);
               CachedPage = result;
             var doc = new HtmlAgilityPack.HtmlDocument();
             var table = doc.DocumentNode.SelectNodes("//table")
               .Where(tr => tr.Elements("td").Count() > 1)
               .Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList())
               .ToList().Select(n => n[0] );
             return lst;
    Last edited: Feb 22, 2020
    #11     Feb 22, 2020