Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_chaikin_money_flow(testdata_1m_btc):
from technical.indicators import cmf, chaikin_money_flow
assert cmf is chaikin_money_flow
result = chaikin_money_flow(testdata_1m_btc, 14)
# drop nan, they are exspected, based on the period
result = result[~numpy.isnan(result)]
assert result.min() >= -1
assert result.max() <= 1
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe['cmf'] = cmf(dataframe, 21)
return dataframe
def evaluate_cmf(self, period=12, prefix="cmf", impact_buy=1, impact_sell=1):
"""
evaluates the osc
:param dataframe:
:param period:
:param prefix:
:return:
"""
from technical.indicators import cmf
self._weights(impact_buy, impact_sell)
dataframe = self.dataframe
name = '{}_{}'.format(prefix, period)
dataframe[name] = cmf(dataframe, period)
dataframe.loc[
(
(dataframe[name] > 0.5)
),
'buy_{}'.format(name)
] = (1 * impact_buy)
dataframe.loc[
(
(dataframe[name] < -0.5)
),
'sell_{}'.format(name)
] = (1 * impact_sell)