def add_volume_ta(df: pd.DataFrame, high: str, low: str, close: str, volume: str, fillna: bool = False, colprefix: str = ""): """Add volume technical analysis features to dataframe. Args: df (pandas.core.frame.DataFrame): Dataframe base. high (str): Name of 'high' column. low (str): Name of 'low' column. close (str): Name of 'close' column. volume (str): Name of 'volume' column. fillna(bool): if True, fill nan values. colprefix(str): Prefix column names inserted Returns: pandas.core.frame.DataFrame: Dataframe with new features. """ # Accumulation Distribution Index df[f'{colprefix}volume_adi'] = AccDistIndexIndicator( high=df[high], low=df[low], close=df[close], volume=df[volume], fillna=fillna).acc_dist_index() # On Balance Volume df[f'{colprefix}volume_obv'] = OnBalanceVolumeIndicator( close=df[close], volume=df[volume], fillna=fillna).on_balance_volume() # Chaikin Money Flow df[f'{colprefix}volume_cmf'] = ChaikinMoneyFlowIndicator( high=df[high], low=df[low], close=df[close], volume=df[volume], fillna=fillna).chaikin_money_flow() # Force Index df[f'{colprefix}volume_fi'] = ForceIndexIndicator( close=df[close], volume=df[volume], fillna=fillna).force_index() # Ease of Movement indicator = EaseOfMovementIndicator(high=df[high], low=df[low], volume=df[volume], n=14, fillna=fillna) df[f'{colprefix}volume_em'] = indicator.ease_of_movement() df[f'{colprefix}volume_sma_em'] = indicator.sma_ease_of_movement() # Volume Price Trend df[f'{colprefix}volume_vpt'] = VolumePriceTrendIndicator( close=df[close], volume=df[volume], fillna=fillna).volume_price_trend() # Negative Volume Index df[f'{colprefix}volume_nvi'] = NegativeVolumeIndexIndicator( close=df[close], volume=df[volume], fillna=fillna).negative_volume_index() return df