Panels#

Panels allow for the interaction and analysis of 3rd party data. The Panel class outlines methods and capabilities of a basic panel created via the Panel Factory.

The Constructor of a Panel will make a call to the Quantamatics API, providing the panelName as a parameter. If any more or less than one panel is found, an exception will be raised. Otherwise, the Panel’s fields of panelID, providerID, and providerName will be filled with the resulting values.

Additionally, the Panel class has three fields under the mapping dictionary: measures, dimensions, and granularity, each have their own getter methods and are initialized to default values upon use of the constructor.

Parameters#

panelName

A String value that references the name of a panel. Necessary for initializing.


Methods#

preProcess()#

The preProcess() method will implicitly call the mapReturnFields(), completeDailyRange(), and applyMeasures() methods depending on the values given for the parameters of mapReturnFields, completeDailyRange, and preProcessMeasures. These values will all be set to True by default.

Additionally, a list of strings may be provided for the dimensions parameter, used within the applyMeasures() method. This parameter is automatically set to None

dimensions

A list of strings set to a default value of None. Used as a parameter for applying measures. Additionally, a Date dimension must exist for the pre processing of the completeDailyRange() method

mapReturnFields

A boolean value set to a default value of True, meaning the mapReturnFields() method will be called.

preProcessMeasures

A boolean value set to a default value of True, meaning the applyMeasures() method will be called with the parameters of dimensions and a functionName of “pre_process”.

completeDailyRange

A boolean value set to a default value of True, meaning the completeDailyRange() method will be called if a “Date” value also exists within dimensions.


getTicker()#

The getTicker() method will return a ticker based off either an instrument object or ticker value. This method is essentially a way of reformatting a ticker to the Quantamatics standard.

instrumentObj

An instrument object from which the instrument’s ticker will be returned.

ticker

A ticker given for reformatting.


mapReturnFields()#

The mapReturnFields() method will rename the columns of the Panel’s dataDF by mapping several measure and dimension fields. If the Panel’s dataDF has not been set, an Exception will be raised.

loadData()#

The loadData() method allows for the Panel’s dataDF field to be populated. This method must be written specifically for each Panel.


completeDailyRange()#

The completeDailyRange() method will update the Panel’s DataFrame such that the Date column will show the full range of dates with a daily granularity. No parameters are available for this method.

If the Panel’s DataFrame is set to None or if the DataFrame is lacking a “Date” column, an Exception will be raised.


applyMeasures()#

The applyMeasures() will map through all the measures within a Panel and apply a given method to each item within the measure. The resulting DataFrame will be returned.

dataDF

A DataFrame value automatically set to None. The applyMeasures() method requires a DataFrame to be stored within the Panel. If the Panel’s dataDF field is not already filled, pass the necessary DataFrame here.

dimensions

A list of strings defaulting to None.

methodName

A string value that references the method that is to be applied to each item within measures. This value defaults to “agg_func”

applyAsAggregate

A boolean value defaulting to False. When set to True, the DataFrame will aggregate the mapped measure item as opposed to applying the method directly to the measure item.

inplace

A boolean value defaulting to True. When set to True, the resulting DataFrame from mapping will replace the existing dataDF of the Panel object.


aggregateDataToCalendarPeriods()#

The aggregateDataToCalendarPeriods() method will take in either a KPI object or a CalendarPeriods object and return an aggregated DataFrame by invoking the applyMeasures() method upon a DataFrame of the provided Calendar Periods. The data stored within the Panel’s dataDF will be aggregated using the calendar periods as start and end points for the aggregation.

Note that a KPI object or CalendarPeriods object as well as data within the Panel.dataDF is required or an exception will be raised. Additionally if Panel.mapping is None, an exception will also be raised.

dimensions

A list of Strings set to a default value of None. Used for grouping periods within the aggregation process.

kpiObj

A CalendarPeriods object set to a default value of None. Either this or a CalendarPeriods object must be provided.

calendarPeriodsObj

A KPI object set to a default value of None. Either this or a KPI object must be provided.

completeCurrentQuarter

A boolean value set to a default value of True. Used for removing incomplete quarters within the collection of periods.


getMeasures()#

returns the measures within Panel.mapping['measures']. May optionally set allMeasures to True to receive all dimensions.


getDimensions()#

returns the dimensions within Panel.mapping['dimensions']. May optionally set allDimensions to True to receive all dimensions.


getGranularity()#

returns the string value representing granularity within Panel.mapping['granularity']


Panel Factory#

The PanelFactory class uses the factory design pattern to load a panel. As such, the Panel Factory class consists of one method.

getPanel()#

The getPanel() method returns a Panel class as identified by the given panelName.

panelName

A unique name for a given panel