コード例 #1
0
ファイル: equity.py プロジェクト: jaiveerk/FML
    def bollinger_bands(self, period=20, stds=2, verbose=False):
        """[The Bolinger Bands is essentially a confidence interval of 
        stds Deviations where the price should be based on the last 
        period periods of prices]
        
        Keyword Arguments:
            period {int} -- [The period over which to look over the 
            prices] (default: {20})
            stds {int} -- [The number of standard deviations the bands 
            should take up] (default: {2})
        
        Returns:
            [float[], float[]] -- [Upper Bolinger Band, Lower Bolinger Band vectors respectively]
        """
        tp = self.typical_prices()
        ma = Indicators.sma(prices=tp, period=period)
        std = Indicators.calc_std(prices=tp, period=period)

        bolu = np.array([ma[i] + stds * std[i] for i in range(len(ma))])
        bold = np.array([ma[i] + stds * std[i] for i in range(len(ma))])

        return bolu, bold
コード例 #2
0
 def test_sma(self):
     prices = np.arange(10)
     expected = np.array([0, 0, 0, 0, 0, 2, 3, 4, 5, 6])
     assert (Indicators.sma(period=5, prices=prices) == expected).all()
コード例 #3
0
    def test_sma(self, period):
        prices = np.arange(10)

        print(Indicators.sma(prices, period))
コード例 #4
0
ファイル: feature_generation.py プロジェクト: jaiveerk/FML
def sma_feature(eq, period):
    sma_vec = np.array(Indicators.sma(eq.closes, period))
    sma_vec = sma_vec.T

    return [Indicator(sma_vec)]