Your interactive trading laboratory!
 • 
21 users online

Quantacula Help

How-To
C# API Reference
Extensions
Development Blog
API-Extensions
Indicator Spotlights

QCommunity Extensions
The open-source GitHub repository of source code for the QCommunity Extensions library. Contains indicators and other extensions submitted by the Quantacula Community. Look for QCommunity indicators when you create a Building Block model, mark the "QCommunity" library check box to expose them.

TASC-Extensions
The open-source GitHub repository of source code for the TASCExtensions Quantacula extension. Contains indicators and other extensions adapted from the Traders' Tips articles in Technical Analysis of Stocks & Commodities magazine.
Fundamental Data Source
Published by Q Glitch on 12/10/2018

A Fundamental Data Source is responsible for providing fundamental data to Quantacula. Typical fundamental data items are stock splits, dividends, and earnings. Unlike price data, fundamental data occurs more sporadically along the history of a tradable instrument. Like all Quantacula extensions, it is implemented as a .NET class, compiled into a .NET class library. You can create a Fundamental Data Source by using an external development tool such as Microsoft Visual Studio or SharpDevelop.

Creating the Class Library

  1. Be sure your project targets .NET Core 3.1.
  2. Add references to the QuantaculaCore and QuantaculaData class libraries, located in your Quantacula Studio installation folder.

TargetDotNet471

FundamentalLoaderBase Class Reference

Fundamental Data Loaders descend from the FundamentalLoaderBase base class. The development of this extension involves these tasks:

  1. Create a new class derived from FundamentalLoaderBase.
  2. Override descriptive properties: Name, Glyph, HelpDescription, etc. described below.
  3. Optionally support initialization, configuration and persistence.
  4. Handle the request for fundamental data for a specific symbol.

Descriptive Properties

ItemNames

public abstract List<string> ItemNames

Override this property to return a list of strings containing the names of the fundamental items that your Fundamental Data Source returns,

Name

public abstract string Name

Override this property to return the name of your Fundamental Data Source.

Glyph

public abstract Bitmap Glyph

Override this property to return a 24x24 bitmap to represent your Fundamental Data Source.

HelpDescription

public abstract string HelpDescription

Override this property to return a brief description of your Fundamental Data Source.

HelpURL

public virtual string HelpURL

Optionally override this property to return a URL that leads to a web page providing more information about your Fundamental Data Provider.

Configuration Related Properties and Methods

NeedsConfiguration

public virtual bool NeedsConfiguration

Override this property to return true if your Fundamental Data Source requires configuration by the user. A data provider might require a user login, API key, or may expose settings that you'd like to interface with. If you enable configuration, also implement the Configure method below.

Configure

public virtual void Configure(string configuration)

Implement this method to handle configuration of your Fundamental Data Source. The provider's configuration is boiled down to one string variable, which is passed to you in this method via the configuration parameter. In your implementation, you'd typically bring up a Windows Forms modal dialog which allows the user to provide configuration information. Your method should distill the configuration from this UI into one string and assign this to the Configuration property.

Configuration

public string Configuration

This string contains the configuration that was established by the user during the call to Configure, above.

IsConfigured

public bool IsConfigured

This read-only property returns true if the Configuration string has a value assigned to it.

Persisting Fundamental Data

FundamentalLoaderBase contains these properties and methods to offer built-in support for persisting historical fundamental data to the user's file system. You can opt-in to this support, ignore it and implement your own persistence scheme as needed, or just ignore persistence completely if does not make sense for your Fundamental Data Source. The built-in mechanism works by maintaining files for each symbol's fundamental data, and then passing the stored fundamental items to the provider during the update request, so the provider can determine what data needs to be updated.

UsePersistentStorage

public virtual bool UsesPersistentStorage

To opt-in to the built-in persistent storage scheme, simply override this property and return true.

ApplyDataPoints

protected abstract void ApplyDataPoints(BarHistory bh, FundamentalDataCollection fdc)

Override this method to load the fundamental items from persistent storage into the BarHistory instance specified in the bh parameter. The fdc parameter is of type FundamentalDataCollection, which has a property DataPoints that is a List containing instances of the FundamentalDataPoint class.

When implementing ApplyDataPoints, follow these steps:

  1. Iterate over the FundamentalDataPoint instances in the fdc.DataPoints list.
  2. Optionally create new specialized instances of FundamentalDataPoint derived classes that you might have defined. For example, you may have created a specialized class called MyEarningsItem to represent earnings data points in your provider. You can examine a FundamentalDataPoint's Name property to determine if it an "Earnings" item. If so, you can create a specialized instance of MyEarningsItem instead of using the plain vanilla FundamentalDataPoint instance.
  3. Add the FundamentalDataPoint instance, or the instance of your specialized derived class, to the bh.Fundamentals list property.

Initialization

public virtual void Initialize(IHost host)

Optionally override this method to perform any required initialization for your Fundamental Data Provider. Be sure to call base.Initialize if you implement this method. The method provides you an instance of the IHost interface that you can use to access information about the Quantacula installation.

Host Property

public IHost Host

Returns the instance of the IHost interface that you can use to access information about the Quantacula installation.

Requesting Fundamental Data

protected abstract void LoadFundamentalData(BarHistory bh, FundamentalDataCollection preloaded)

Override this method to handle the request for fundamental data for a specific symbol. The bh parameter contains the BarHistory for which fundamental data is being requested. Use its Symbol property to determine what symbol is being processed. The preloaded parameter is a collection of FundamenalDataPoint instances representing the fundamental data already loaded from persistent storage (if any). This parameter will contain null if there are no items. Follow these steps when implementing LoadFundamentalData:

  1. Examine the items in the preloaded.DataPoints list (containing instances of the FundamentalDataPoint class) to determine the date of the most recent fundamental item. As an alternative, the FundamentalDataCollection class provides a property called RecentItemDate that returns the date of the most recent fundamental item. So you can examine preloaded.RecentDateTime to get the most recent fundamental data's date.
  2. If required, request new fundamental data from whatever provider you are sourcing the fundamental data from. This typically involves a call to a web service or similar outside source.
  3. Create instances of FundamentalDataPoint, or instances of specialized derived classes, to represent the fundamental data. The important properties of FundamentalDataPoint are Name (for example "Split" or "Dividend"), Date, and Value. Consult the FundamentalDataPoint reference for more information on this class.
  4. Add the instances to the bh.Fundamentals property list.

Specialized Derived Classes

You can use plain vanilla FundamentalDataPoint instances, or derive new classes to handle your fundamental data. The main reason for deriving new classes is to override the Text property to return a more friendly value for the hint that appears when the user hovers over a fundamental item on the chart.

Quantacula comes with two specialized FundamentalDataPoint descendants; FundamentalDataPointSplit and FundamentalDataPointDividend. If your Fundamental Data Source provides splits and dividends, you can use these descendant classes.

As an example of creating a new FundamentalDataPoint descendant, here is the complete source code for FundamentalDataPointDividend.

using System;

namespace QuantaculaCore
{
    public class FundamentalDataPointDividend : FundamentalDataPoint
    {
        //constructors
        public FundamentalDataPointDividend()
        {
        }
        public FundamentalDataPointDividend(string name, DateTime dt, double value = 0) : base(name, dt, value)
        {
        }

        //override hint text
        public override string Text
        {
            get
            {
                return Value.ToString("N2") + " per share Dividend";
            }
        }
    }
}