Previously I had experimented with grabbing data from FINRA BrokerCheck and graphing output with “R”.
This time around the task was to strip data from the Canadian Securities Administrators (“CSA”) – National Registration Database (“NRD”) which lists all Canadian registrants and to create a Treemap to graphically represent the CSA registrants for a group of entities belonging to a Financial Institution.
The CSA Registrant data was collected using the following Ruby script:
require 'nokogiri' require 'rubygems' require 'watir-webdriver' browser = Watir::Browser.new :chrome browser.goto 'https://www.securities-administrators.ca/nrs/nrsearch.aspx?id=850' browser.text_field(:name => 'ctl00$bodyContent$txtFirmName').set 'BMO' browser.input(:name => 'ctl00$bodyContent$ibtnSearch').click browser.select_list(:name, 'ctl00$bodyContent$list_num_per_page').select_value("100") sleep 10 loop do table_Rows = browser.table(:id, 'ctl00_bodyContent_gvIndividuals').rows.length for i in 2..table_Rows.to_i-1 name = browser.table(:id , 'ctl00_bodyContent_gvIndividuals')[i][0].text firm = browser.table(:id, 'ctl00_bodyContent_gvIndividuals')[i][1].text if firm =~ /BMO/ && firm !~ /\(INDIVIDUAL NO LONGER REGISTERED\)/ puts "#{name}\t#{firm}" end end browser.link(:id => 'ctl00_bodyContent_lbtnNext2').click sleep 10 end