Search Framework:
EventDataPoint
Namespace: WealthLab.Data
Parent: Object

The EventDataPoint class represents a single piece of event data, such as a fundamental data item (dividend, split, earnings), analyst rating, or chart pattern. WealthLab supports several Event Data Providers, both included out of the box and available via extensions. Each provider supplies its own set of historical event data. You can access event data using the EventDataPoints property or the GetEventDataPoints method of the BarHistory class.

Constructors
EventDataPoint
public EventDataPoint()
public EventDataPoint(string name, DateTime dt, double value = 0)

EventDataPoint supports both a parameterless constructor and a constructor that assigns the Name, Date, and optionally Value properties. The second constructor also initializes Data to an empty string.



Members
Data
public string Data

Contains optional string data populated by the Event Data Provider that generated the event. Each provider can use this property differently, so consult the provider's documentation for details.


Date
public DateTime Date

The date/time associated with the event.


DedupText
public virtual string DedupText

Returns a string used to identify duplicate event data points. The default implementation combines the event's Date, Text, and ProviderName, separated by semicolons. Derived EventDataPoint classes can override this property to provide their own deduplication logic.


DedupTextDaily
public string DedupTextDaily

Returns a string used for daily deduplication of events such as dividends during backtesting. The value combines the date portion of Date and the Name of the event, separated by a semicolon.


Details
public Dictionary<string, string> Details

Contains item-specific information associated with the event, represented as string values keyed by string names. The Dictionary is created on first access if it has not already been assigned.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using WealthLab.Data;
namespace WealthScript1
{
    public class MyStrategy1 : UserStrategyBase
    {
        public override void Initialize(BarHistory bars)
        {
            foreach (EventDataPoint edp in bars.EventDataPoints)
            {
                string data = $"{edp.ProviderName}\t{edp.Date.ToShortDateString()}\t{edp.Value}";
                if (edp.HasDetailItems)
                {
                    foreach (var item in edp.Details)
                        data += $"\t{item.Key}:{item.Value}";
                }
                else
                    data += "\t(No Details)";
                WriteToDebugLog(data);
            }
        }
        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

EndDate
public DateTime EndDate

The ending date/time associated with the event. If an ending date has not been explicitly assigned, this property returns the value of Date.


HasDetailItems
public bool HasDetailItems

Returns true if the Details Dictionary has been created and contains one or more items.


InCurrentRange
public bool InCurrentRange(BarHistory bh)

Returns true if the event's Date falls between the StartDate and EndDate of the BarHistory specified in bh, inclusive.


ItemName
public string ItemName

Returns a display-friendly version of the event's Name. If Name contains a prefix ending in a closing bracket (]), the prefix is removed and the remaining text is trimmed.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using WealthLab.Data;
namespace WealthLab
{
    public class MyStrategy1 : UserStrategyBase
    {
        public override void Initialize(BarHistory bars)
        {
            if (bars.EventDataPoints.Count > 0)
            {
                EventDataPoint edp = bars.EventDataPoints[bars.EventDataPoints.Count - 1];
                DrawHeaderText("The most recent event item is a " + edp.ItemName + " reported on " + edp.Date.ToShortDateString(), WLColor.Green, 18);
            }
        }
        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

Name
public string Name

The name of the event. Examples include "Split", "Dividend", or "Analyst Rating".


ProviderName
public string ProviderName

Contains the name of the Event Data Provider that generated this event.


Text
public virtual string Text

Returns descriptive text for the event. The default implementation combines Name and Value, with Value formatted to two decimal places. Derived EventDataPoint classes can override this property to provide a more appropriate description.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using WealthLab.Data;
namespace WealthLab
{
    public class MyStrategy1 : UserStrategyBase
    {
        public override void Initialize(BarHistory bars)
        {
            if (bars.EventDataPoints.Count > 0)
            {
                EventDataPoint edp = bars.EventDataPoints[bars.EventDataPoints.Count - 1];
                DrawHeaderText("The most recent event item is " + edp.Text, WLColor.Green, 18);
            }
        }
        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

TooltipText
public string TooltipText

Returns the text used for the event's chart tooltip. The text begins with the value of Text. If ProviderName is not null, empty, or whitespace, a second line is appended in the form Source: ProviderName.


Value
public double Value

The numeric value associated with the event. For example, a 2:1 split could have a Value of 2, while a $1.50 per-share dividend could have a Value of 1.5.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using WealthLab.Data;
namespace WealthLab
{
    public class MyStrategy1 : UserStrategyBase
    {
        public override void Initialize(BarHistory bars)
        {
            if (bars.EventDataPoints.Count > 0)
            {
                EventDataPoint edp = bars.EventDataPoints[bars.EventDataPoints.Count - 1];
                DrawHeaderText("The most recent event item is a " + edp.ItemName + " with a value of " + edp.Value.ToString("N2"), WLColor.Green, 18);
            }
        }
        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}


Members for Derived Classes
GlyphColor
public virtual WLColor GlyphColor

Returns the background color to use for a procedurally generated chart glyph. The default value is null, allowing WealthLab to determine the glyph color procedurally. Derived EventDataPoint classes can override this property to specify a particular color.


GlyphResource
public virtual string GlyphResource

Returns the name of an image resource to use for the event's chart glyph. The default value is null, which causes WealthLab to generate the glyph using GlyphText and GlyphColor. Derived EventDataPoint classes can override this property to supply a custom image resource.


GlyphText
public virtual string GlyphText

Returns the text used when WealthLab procedurally generates a chart glyph for the event. The default implementation returns the first character of ItemName.


ToString
public override string ToString()

Returns the value of DedupText as the string representation of the EventDataPoint.