示例#1
0
def preProcessCalculation(df, limit):
    df = df.reset_index()
    adx = np.array(
        average_directional_index(df['close'], df['high'], df['low'], limit))
    mfi = np.array(
        money_flow_index(df['close'], df['high'], df['low'], df['volume'],
                         limit - 1))
    atr = np.array(average_true_range(df['close'], limit))
    obv = np.array(on_balance_volume(df['close'], df['volume']))
    rocr = np.array(rate_of_change(df['close'], limit))
    mom = np.array(momentum(df['close'], limit))
    return adx, mfi, atr, obv, rocr, mom
示例#2
0
 def test_roc_invalid_period(self):
     period = 128
     with self.assertRaises(Exception) as cm:
         rate_of_change.rate_of_change(self.data, period)
     expected = "Error: data_len < period"
     self.assertEqual(str(cm.exception), expected)
示例#3
0
 def test_roc_period_10(self):
     period = 10
     roc = rate_of_change.rate_of_change(self.data, period)
     np.testing.assert_array_equal(roc, self.roc_period_10_expected)