예제 #1
0
def test_ema(ema_type):
    prices = np.array([
        22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23, 22.43, 22.24, 22.29,
        22.15, 22.39, 22.38, 22.61, 23.36, 24.05, 23.75, 23.83, 23.95, 23.63,
        23.82, 23.87, 23.65, 23.19, 23.10, 23.33, 22.68, 23.10, 22.40, 22.17
    ])
    results = [
        [
            22.221, 22.20809091, 22.24116529, 22.26640796, 22.32887924,
            22.51635574, 22.79520015, 22.96880013, 23.12538192, 23.27531248,
            23.33980112, 23.42711001, 23.50763546, 23.53351992, 23.47106176,
            23.40359598, 23.39021489, 23.26108491, 23.23179675, 23.08056097,
            22.91500443
        ],
        [
            22.27, 22.25545455, 22.22355372, 22.21381668, 22.20766819,
            22.1935467, 22.20017457, 22.24196102, 22.24160447, 22.25040366,
            22.23214845, 22.26084873, 22.2825126, 22.34205576, 22.52713653,
            22.8040208, 22.97601702, 23.13128665, 23.28014362, 23.34375387,
            23.43034408, 23.51028152, 23.53568488, 23.47283308, 23.40504525,
            23.39140066, 23.26205508, 23.23259052, 23.08121043, 22.9155358
        ],
        [
            22.28588695, 22.174706, 22.35085492, 22.37470018, 22.5672175,
            23.21585701, 23.89833692, 23.77696963, 23.82035739, 23.9264279,
            23.68389526, 23.79525297, 23.85640891, 23.68752817, 23.28045894,
            23.13280996, 23.29414649, 22.79166223, 23.04393782, 22.51707883,
            22.23310448
        ]
    ]
    np.testing.assert_allclose(tai.ema(prices, period=10, ema_type=ema_type),
                               results[ema_type],
                               rtol=1e-09,
                               atol=1e-15)
예제 #2
0
파일: test_tai.py 프로젝트: jcrmatos/tai
def test_ema(ema_type):
    prices = np.array([22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23, 22.43,
                       22.24, 22.29, 22.15, 22.39, 22.38, 22.61, 23.36, 24.05,
                       23.75, 23.83, 23.95, 23.63, 23.82, 23.87, 23.65, 23.19,
                       23.10, 23.33, 22.68, 23.10, 22.40, 22.17])
    results  = [[22.221,      22.20809091, 22.24116529, 22.26640796,
                 22.32887924, 22.51635574, 22.79520015, 22.96880013,
                 23.12538192, 23.27531248, 23.33980112, 23.42711001,
                 23.50763546, 23.53351992, 23.47106176, 23.40359598,
                 23.39021489, 23.26108491, 23.23179675, 23.08056097,
                 22.91500443],
                [22.27,       22.25545455, 22.22355372, 22.21381668,
                 22.20766819, 22.1935467,  22.20017457, 22.24196102,
                 22.24160447, 22.25040366, 22.23214845, 22.26084873,
                 22.2825126,  22.34205576, 22.52713653, 22.8040208,
                 22.97601702, 23.13128665, 23.28014362, 23.34375387,
                 23.43034408, 23.51028152, 23.53568488, 23.47283308,
                 23.40504525, 23.39140066, 23.26205508, 23.23259052,
                 23.08121043, 22.9155358],
                [22.28588695, 22.174706,   22.35085492, 22.37470018,
                 22.5672175,  23.21585701, 23.89833692, 23.77696963,
                 23.82035739, 23.9264279,  23.68389526, 23.79525297,
                 23.85640891, 23.68752817, 23.28045894, 23.13280996,
                 23.29414649, 22.79166223, 23.04393782, 22.51707883,
                 22.23310448]]
    np.testing.assert_allclose(tai.ema(prices, period=10, ema_type=ema_type),
                               results[ema_type],
                               rtol=1e-09, atol=1e-15)
예제 #3
0
 def test_ema0(self):
     prices = np.array([22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23,
                        22.43, 22.24, 22.29, 22.15, 22.39, 22.38, 22.61,
                        23.36, 24.05, 23.75, 23.83, 23.95, 23.63, 23.82,
                        23.87, 23.65, 23.19, 23.10, 23.33, 22.68, 23.10,
                        22.40, 22.17])
     np.testing.assert_allclose(tai.ema(prices, period=10, ema_type=0),
                                [22.221,      22.20809091, 22.24116529,
                                 22.26640796, 22.32887924, 22.51635574,
                                 22.79520015, 22.96880013, 23.12538192,
                                 23.27531248, 23.33980112, 23.42711001,
                                 23.50763546, 23.53351992, 23.47106176,
                                 23.40359598, 23.39021489, 23.26108491,
                                 23.23179675, 23.08056097, 22.91500443],
                                rtol=1e-09, atol=1e-15)
예제 #4
0
 def test_ema2(self):
     prices = np.array([22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23,
                        22.43, 22.24, 22.29, 22.15, 22.39, 22.38, 22.61,
                        23.36, 24.05, 23.75, 23.83, 23.95, 23.63, 23.82,
                        23.87, 23.65, 23.19, 23.10, 23.33, 22.68, 23.10,
                        22.40, 22.17])
     np.testing.assert_allclose(tai.ema(prices, period=10, ema_type=2),
                                [22.28588695, 22.174706,   22.35085492,
                                 22.37470018, 22.5672175,  23.21585701,
                                 23.89833692, 23.77696963, 23.82035739,
                                 23.9264279,  23.68389526, 23.79525297,
                                 23.85640891, 23.68752817, 23.28045894,
                                 23.13280996, 23.29414649, 22.79166223,
                                 23.04393782, 22.51707883, 22.23310448],
                                rtol=1e-09, atol=1e-15)
예제 #5
0
 def test_ema1(self):
     prices = np.array([22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23,
                        22.43, 22.24, 22.29, 22.15, 22.39, 22.38, 22.61,
                        23.36, 24.05, 23.75, 23.83, 23.95, 23.63, 23.82,
                        23.87, 23.65, 23.19, 23.10, 23.33, 22.68, 23.10,
                        22.40, 22.17])
     np.testing.assert_allclose(tai.ema(prices, period=10, ema_type=1),
                                [22.27,       22.25545455, 22.22355372,
                                 22.21381668, 22.20766819, 22.1935467,
                                 22.20017457, 22.24196102, 22.24160447,
                                 22.25040366, 22.23214845, 22.26084873,
                                 22.2825126,  22.34205576, 22.52713653,
                                 22.8040208,  22.97601702, 23.13128665,
                                 23.28014362, 23.34375387, 23.43034408,
                                 23.51028152, 23.53568488, 23.47283308,
                                 23.40504525, 23.39140066, 23.26205508,
                                 23.23259052, 23.08121043, 22.9155358],
                                rtol=1e-09, atol=1e-15)
예제 #6
0
파일: app.py 프로젝트: fatm400/trading
                        hspace=0)
    plt.show()


def convert_array(ohlc, fuente=4):
    # fuente = 0 open timestamp
    # fuente = 1 open price
    # fuente = 2 high price
    # fuente = 3 low price
    # fuente = 4 closed price
    # fuente = 6 volumen
    # fuente = 7 closed timestamp
    try:
        source = []
        for elemento in ohlc:
            source.append(elemento[int(fuente)])

        source_array = np.asarray(source)

        return source_array

    except IndexError:
        print "error convert_array"


ohlc = ohlc(klines)
a = convert_array(ohlc)
b = tai.ema(a, 20)
c = tai.rsi(a)
candlestick(ohlc, ax1)