macrosynergy.management.validation#
- class QDFArgs(df: DataFrame, cids: List[str], xcats: List[str], metrics: List[str], start: str, end: str)[source]#
Bases:
NamedTuple
Contains the QuantamentalDataFrame and associated arguments.
- validate_and_reduce_qdf(df, cids=None, xcats=None, metrics=None, intersect=False, tickers=None, blacklist=None, start=None, end=None)[source]#
Validates the inputs to a function that takes a DataFrame as its first argument. The DataFrame is then reduced according to the inputs.
- Parameters:
df (
DataFrame
) – A DataFrame with the following columns: ‘cid’, ‘xcat’, ‘real_date’, and at least one metric from - ‘value’, ‘grading’, ‘eop_lag’, or ‘mop_lag’.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.
- Return <QDFArgs>:
A NamedTuple that contains the validated arguments.