Get symbol data from Morningstar.com (sector, industry, code etc.)

Modified on 2020/06/19 16:53 by Eugene — Categorized as: Community Components

Syntax


public MorningstarSymbolData

public static MorningstarSymbolData MorningstarSymbolDataExtractor.GetSymbolData(string symbol)

Parameter Description

symbolAny stock symbol valid on Morningstar website

Description

Morningstar is a well-known investment resource. Methods of the MorningstarSymbolDataExtractor class return some helpful snapshot data for U.S./international stock symbols: sector, industry, business description, NAICS/SIC/ISIC codes, stock type and style.


Example

Here's an illustration of working with Morningstar data in a Wealth-Lab strategy. It caches data requests to avoid repeated re-requests that slows script execution down:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { string symbol = Bars.Symbol; string key = string.Format("msd {0}", symbol);

if (GetGlobal(key) == null) { var msd = MorningstarSymbolDataExtractor.GetSymbolData(symbol); SetGlobal(key, (object)msd); Test(symbol, msd); } else { var msd = GetGlobal(key); Test(symbol, msd as MorningstarSymbolData); } }

void Test(string symbol, MorningstarSymbolData msd) { ClearDebug(); PrintDebug("Stock: " + symbol + "\r"); PrintDebug("Sector: " + "\t" + msd.Sector); PrintDebug("Industry: " + "\t" + msd.Industry); PrintDebug("Description: " + "\t" + msd.Description); PrintDebug("NAICS: " + "\t" + msd.NAICS); PrintDebug("SIC: " + "\t" + msd.SIC); PrintDebug("ISIC: " + "\t" + msd.ISIC); PrintDebug("Stock type: " + "\t" + msd.StockType); PrintDebug("Stock style: " + "\t" + msd.StockStyle);

} } }