Basic operations¶
- class src.lib.analysis.basic.Basic¶
Bases:
object
- calc_EMA(dataframe: pandas.core.frame.DataFrame, source_column: str, length: int, result_column: str = '', value_prediction=nan)¶
Calculate the exponential moving average (EMA) for the specified column and length in a Pandas dataframe. Depending on the parameters, the result will be a new column on the same dataframe.
- Parameters
source_column (string) – Name of the column in the Pandas Dataframe to be used for the calculation of the moving average.
length (int) – Number of samples to be used as rolling window for the average calculation.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: EMA length source_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- calc_MovingStdDev(dataframe: pandas.core.frame.DataFrame, source_column: str, length: int, minimum_length: Optional[int] = None, result_column: str = '', value_prediction=nan)¶
Calculate the simple moving standard deviation for the specified column and length in a Pandas dataframe. Depending on the parameters, the result will be a new column on the same dataframe.
- Parameters
source_column (string) – Name of the column in the Pandas Dataframe to be used for the calculation of the moving average.
length (int) – Number of samples to be used as rolling window for the average calculation.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: SMA length source_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- calc_SMA(dataframe: pandas.core.frame.DataFrame, source_column: str, length: int, minimum_length: Optional[int] = None, result_column: str = '', value_prediction=nan)¶
Calculate the simple moving average (SMA) for the specified column and length in a Pandas dataframe. Depending on the parameters, the result will be a new column on the same dataframe.
- Parameters
source_column (string) – Name of the column in the Pandas Dataframe to be used for the calculation of the moving average.
length (int) – Number of samples to be used as rolling window for the average calculation.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: SMA length source_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- calc_absolute(dataframe: pandas.core.frame.DataFrame, source_column: str, result_column: str = '', value_prediction=nan)¶
Calculate de delta value between the Close (Final) and the Open value for the ticker. It will add a column called “Delta” to the Pandas dataframe.
- Parameters
none –
- calc_change(dataframe: pandas.core.frame.DataFrame, source_column: str, shift: int, result_column: str = '', value_prediction=nan)¶
Calculate the difference between entries from a column. For example the closing price difference for every day.
- Parameters
source_column (string) – Name of the column in the Pandas Dataframe to be used for the calculation of the change.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: SMA length source_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- calc_delta(dataframe: pandas.core.frame.DataFrame, value_prediction=nan)¶
Calculate de delta value between the Close (Final) and the Open value for the ticker. It will add a column called “Delta” to the Pandas dataframe.
- Parameters
None –
The input for the calculation is based on the Pandas dataframe data which is already available. The expected column for this operation is:
Open
Close Final
- Returns
The outcome from the calculation is not explicitly returned, but added to the Pandas dataframe as new columns. The new columns are:
Delta: Result of the difference between Close Final and Open values for every sample.
- Return type
None
- calc_difference(dataframe: pandas.core.frame.DataFrame, minuend_column: str, subtrahend_column: str, result_column: str = '', value_prediction=nan)¶
Calculate the difference between 2 columns from a Pandas Dataframe.
- Parameters
minuend_column (string) – Name of the column in the Pandas Dataframe to be used as the minuend of the differentiation operation.
subtrahend_column (string) – Name of the column in the Pandas Dataframe to be used as the subtrahend of the differentiation operation.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: minuend_column minus subtrahend_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- Returns
The outcome from the calculation is not explicitly returned, but added to the Pandas dataframe as new columns. The new columns are:
result_column: Result of the difference operation.
- Return type
None
- calc_division(dataframe: pandas.core.frame.DataFrame, dividend_column: str, divisor_column: str, result_column: str = '', value_prediction=nan)¶
Calculate the division between 2 columns from a Pandas Dataframe.
- Parameters
dividend_column (string) – Name of the column in the Pandas Dataframe to be used as the dividend of the division operation.
divisor_column (string) – Name of the column in the Pandas Dataframe to be used as the divisor of the division operation.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: minuend_column minus subtrahend_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- calc_integration(dataframe: pandas.core.frame.DataFrame, source_column: str, length: int = 0, result_column: str = '', value_prediction=nan)¶
Calculate the integration for the specified column for a window in a Pandas dataframe. For length equals 0, the complete series is used. Depending on the parameters, the result will be a new column on the same dataframe.
- calc_maximum(dataframe: pandas.core.frame.DataFrame, source_column: str, length: int, result_column: str = '', value_prediction=nan)¶
Calculate the rolling maximum.
- calc_minimum(dataframe: pandas.core.frame.DataFrame, source_column: str, length: int, result_column: str = '', value_prediction=nan)¶
Calculate the rolling minimum.
- calc_multiplication(dataframe: pandas.core.frame.DataFrame, factor1_column: str, factor2_column: str, result_column: str = '', value_prediction=nan)¶
Calculate the division between 2 columns from a Pandas Dataframe.
- Parameters
factor1_column (string) – Name of the column in the Pandas Dataframe to be used as the dividend of the division operation.
factor2_column (string) – Name of the column in the Pandas Dataframe to be used as the divisor of the division operation.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: minuend_column minus subtrahend_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- calc_scalar_multiplication(dataframe: pandas.core.frame.DataFrame, factor1_column: str, factor2: float, result_column: str = '', value_prediction=nan)¶
Calculate the multiplication between a column from a Pandas Dataframe and a number.
- Parameters
factor1_column (string) – Name of the column in the Pandas Dataframe to be used as the dividend of the division operation.
factor2_column (float) – Value of the factor.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: minuend_column minus subtrahend_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- Returns
The outcome from the calculation is not explicitly returned, but added to the Pandas dataframe as new columns. The new columns are:
result_column: Result of the scalar multiplication operation.
- Return type
None
- calc_threshold(dataframe: pandas.core.frame.DataFrame, source_column: str, threshold: float, comparison: str, replace_value: float, result_column: str = '', value_prediction=nan)¶
Replaces values below or above a threshold, replacing them by a new one.
- Parameters
source_column (string) – Name of the column in the Pandas Dataframe to be used for the calculation of the change.
result_column (string, optional) – Name of the column in the Pandas Dataframe to be used as the result of the operation. If no information is passed, then the name will be in the format: SMA length source_column.
result_dataframe (Pandas Dataframe, optional) – If passed, the result of the operation will be stored in the new dataframe, otherwise, the original dataframe is used.
- convert_numpy(dataframe: pandas.core.frame.DataFrame, source_column: str)¶
- split_data(data, percetage_learning: float = - 1, sequence_length: int = 0)¶