Esempio n. 1
0
def average_true_range_percent(close_data, period):
    """
    Average True Range Percent.

    Formula:
    ATRP = (ATR / CLOSE) * 100
    """
    catch_errors.check_for_period_error(close_data, period)
    atrp = (atr(close_data, period) / np.array(close_data)) * 100
    return atrp
Esempio n. 2
0
def negative_directional_index(close_data, high_data, low_data, period):
    """
    Negative Directional Index (-DI).

    Formula:
    -DI = 100 * SMMA(-DM) / ATR
    """
    catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
    ndi = (100 *
           smma(negative_directional_movement(high_data, low_data), period) /
           atr(close_data, period))
    return ndi
Esempio n. 3
0
def positive_directional_index(close_data, high_data, low_data, period):
    """
    Positive Directional Index (+DI).

    Formula:
    +DI = 100 * SMMA(+DM) / ATR
    """
    catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
    pdi = (100 *
           smma(positive_directional_movement(high_data, low_data), period) /
           atr(close_data, period))
    return pdi
Esempio n. 4
0
def screen():
    client = Client("api-key", "api-secret", {"verify": False, "timeout": 20})
    positiveCoin = get_positive_coin.positiveCoin
    bullishKScoin = []
    for m in positiveCoin:
        candles = client.get_klines(symbol=m,
                                    interval=client.KLINE_INTERVAL_30MINUTE)
        if candles[-2][1] < candles[-2][4] <= candles[-1][1] < candles[-1][4]:
            bullishKScoin.append(m)

    atrCoin = []
    for m in bullishKScoin:
        candles = client.get_klines(symbol=m,
                                    interval=client.KLINE_INTERVAL_5MINUTE)
        close = []
        for n in candles:
            close.append(float(n[4]))
        avgtr = atr(close, 14)
        if avgtr[-1] / close[-1] > 0.01:
            atrCoin.append(m)

    maxDemandRatio = 0
    buyingCoin = ''
    for m in atrCoin:
        depth = client.get_order_book(symbol=m)
        buyingVol = 0
        sellingVol = 0
        for n in depth['bids'][0:20]:
            buyingVol = buyingVol + float(n[1])
        for n in depth['asks'][0:20]:
            sellingVol = sellingVol + float(n[1])
        demandRatio = buyingVol / sellingVol
        print(demandRatio)
        print(maxDemandRatio)
        if demandRatio > maxDemandRatio:
            maxDemandRatio = demandRatio
            buyingCoin = m

    if maxDemandRatio < 1.5:
        buyingCoin = ''

    print(bullishKScoin)
    print(atrCoin)
    print(buyingCoin)
    return buyingCoin
Esempio n. 5
0
 def get_analysis(self, data):
     return atr(data, self.params['period'])[-1]
Esempio n. 6
0
def average_true_range(data, period):
    return atr(data, period)