macrosynergy.visuals.plotter#

Module containing code for the Plotter class, and all common functionality for the plotter classes. The Plotter class is a base class for all plotter classes, and provides a shared interface for dataframe filtering operations, as well as argvalidation and argcopy decorators for all methods of the plotter classes.

class PlotterMetaClass(name, bases, dct)[source]#

Bases: type

Metaclass for the Plotter class. The purpose of this metaclass is to wrap all methods of the Plotter class with the argvalidation and argcopy decorators, so that all methods of the Plotter class are automatically validated and copied. Meant to be used as a metaclass, i.e. use as follows: ```python … class MyCustomClass(metaclass=PlotterMetaClass):

def __init__(self, …): …

```

class Plotter(df, cids=None, xcats=None, metrics=None, intersect=False, tickers=None, blacklist=None, start=None, end=None, backend='matplotlib')[source]#

Bases: object

Base class for a DataFrame Plotter. The inherited meta class automatically wraps all methods of the Plotter class and any subclasses with the argvalidation and argcopy decorators, so that all methods of the class are automatically validated and copied. This class does not implement any plotting functionality, but provides a shared interface for the plotter classes, and some common functionality - currently just the filtering of the DataFrame. Parameters :type df: DataFrame :param df: A DataFrame with the following columns:

‘cid’, ‘xcat’, ‘real_date’, and at least one metric from - ‘value’, ‘grading’, ‘eop_lag’, or ‘mop_lag’.

Parameters:
  • cids (Optional[List[str]]) – A list of cids to select from the DataFrame. If None, all cids are selected.

  • xcats (Optional[List[str]]) – A list of xcats to select from the DataFrame. If None, all xcats are selected.

  • metrics (Optional[List[str]]) – A list of metrics to select from the DataFrame. If None, all metrics are selected.

  • intersect (Optional[bool]) – if True only retains cids that are available for all xcats. Default is False.

  • tickers (Optional[List[str]]) – A list of tickers that will be selected from the DataFrame if they exist, regardless of start, end, blacklist, and intersect arguments.

  • blacklist (Optional[Dict[str, List[str]]]) – cross-sections with date ranges that should be excluded from the data frame. If one cross-section has several blacklist periods append numbers to the cross-section code.

  • start (Optional[str]) – ISO-8601 formatted date string. Select data from this date onwards. If None, all dates are selected.

  • end (Optional[str]) – ISO-8601 formatted date string. Select data up to and including this date. If None, all dates are selected.

  • backend (Optional[str]) – The plotting backend to use. Currently only ‘matplotlib’ is supported.