Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add **extra_params To POST Router Commands #6253

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Econometrics Router."""

# pylint: disable=unused-argument

import re
from itertools import combinations
from typing import Dict, List, Literal
Expand Down Expand Up @@ -43,7 +45,10 @@
APIEx(parameters={"data": APIEx.mock_data("timeseries")}),
],
)
def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]:
def correlation_matrix(
data: List[Data],
**extra_params,
) -> OBBject[List[Data]]:
"""Get the correlation matrix of an input dataset.

The correlation matrix provides a view of how different variables in your dataset relate to one another.
Expand All @@ -55,6 +60,9 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]:
----------
data : List[Data]
Input dataset.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -101,6 +109,7 @@ def ols_regression(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Dict]:
"""Perform Ordinary Least Squares (OLS) regression.

Expand All @@ -117,6 +126,9 @@ def ols_regression(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -153,6 +165,7 @@ def ols_regression_summary(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Data]:
"""Perform Ordinary Least Squares (OLS) regression.

Expand All @@ -166,6 +179,9 @@ def ols_regression_summary(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -238,6 +254,7 @@ def autocorrelation(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Data]:
"""Perform Durbin-Watson test for autocorrelation.

Expand All @@ -257,6 +274,9 @@ def autocorrelation(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -293,6 +313,7 @@ def residual_autocorrelation(
y_column: str,
x_columns: List[str],
lags: PositiveInt = 1,
**extra_params,
) -> OBBject[Data]:
"""Perform Breusch-Godfrey Lagrange Multiplier tests for residual autocorrelation.

Expand All @@ -314,6 +335,9 @@ def residual_autocorrelation(
List of columns to use as exogenous variables.
lags: PositiveInt
Number of lags to use in the test.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -351,6 +375,7 @@ def residual_autocorrelation(
def cointegration(
data: List[Data],
columns: List[str],
**extra_params,
) -> OBBject[Data]:
"""Show co-integration between two timeseries using the two step Engle-Granger test.

Expand All @@ -371,6 +396,9 @@ def cointegration(
Data columns to check cointegration
maxlag: PositiveInt
Number of lags to use in the test.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -426,6 +454,7 @@ def causality(
y_column: str,
x_column: str,
lag: PositiveInt = 3,
**extra_params,
) -> OBBject[Data]:
"""Perform Granger causality test to determine if X 'causes' y.

Expand All @@ -447,6 +476,9 @@ def causality(
Columns to use as exogenous variables.
lag: PositiveInt
Number of lags to use in the test.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -494,6 +526,7 @@ def unit_root(
data: List[Data],
column: str,
regression: Literal["c", "ct", "ctt"] = "c",
**extra_params,
) -> OBBject[Data]:
"""Perform Augmented Dickey-Fuller (ADF) unit root test.

Expand All @@ -515,6 +548,9 @@ def unit_root(
regression: Literal["c", "ct", "ctt"]
Regression type to use in the test. Either "c" for constant only, "ct" for constant and trend, or "ctt" for
constant, trend, and trend-squared.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -549,6 +585,7 @@ def panel_random_effects(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Dict]:
"""Perform One-way Random Effects model for panel data.

Expand All @@ -565,6 +602,9 @@ def panel_random_effects(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -596,6 +636,7 @@ def panel_between(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Dict]:
"""Perform a Between estimator regression on panel data.

Expand All @@ -612,6 +653,9 @@ def panel_between(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -641,6 +685,7 @@ def panel_pooled(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Dict]:
"""Perform a Pooled coefficient estimator regression on panel data.

Expand All @@ -658,6 +703,9 @@ def panel_pooled(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -687,6 +735,7 @@ def panel_fixed(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Dict]:
"""One- and two-way fixed effects estimator for panel data.

Expand All @@ -703,6 +752,9 @@ def panel_fixed(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -732,6 +784,7 @@ def panel_first_difference(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Dict]:
"""Perform a first-difference estimate for panel data.

Expand All @@ -748,6 +801,9 @@ def panel_first_difference(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -777,6 +833,7 @@ def panel_fmac(
data: List[Data],
y_column: str,
x_columns: List[str],
**extra_params,
) -> OBBject[Dict]:
"""Fama-MacBeth estimator for panel data.

Expand All @@ -794,6 +851,9 @@ def panel_fmac(
Target column.
x_columns: List[str]
List of columns to use as exogenous variables.
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""Quantitative Performance Router."""

# pylint: disable=unused-argument

from typing import List

import numpy as np
Expand Down Expand Up @@ -47,6 +51,7 @@ def omega_ratio(
target: str,
threshold_start: float = 0.0,
threshold_end: float = 1.5,
**extra_params,
) -> OBBject[List[OmegaModel]]:
"""Calculate the Omega Ratio.

Expand All @@ -64,6 +69,9 @@ def omega_ratio(
Start threshold, by default 0.0
threshold_end : float, optional
End threshold, by default 1.5
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -122,6 +130,7 @@ def sharpe_ratio(
rfr: float = 0.0,
window: PositiveInt = 252,
index: str = "date",
**extra_params,
) -> OBBject[List[Data]]:
"""Get Rolling Sharpe Ratio.

Expand All @@ -143,6 +152,9 @@ def sharpe_ratio(
window : PositiveInt, optional
Window size, by default 252
index : str, optional
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
Expand Down Expand Up @@ -193,6 +205,7 @@ def sortino_ratio(
window: PositiveInt = 252,
adjusted: bool = False,
index: str = "date",
**extra_params,
) -> OBBject[List[Data]]:
"""Get rolling Sortino Ratio.

Expand Down Expand Up @@ -222,6 +235,10 @@ def sortino_ratio(
Adjust sortino ratio to compare it to sharpe ratio, by default False
index:str
Index column for input data
**extra_params : Optional[Dict[str, Any]]
Extra parameters to be passed to the command execution.
API POST requests are sent in the body with data.

Returns
-------
OBBject[List[Data]]
Expand Down