コード例 #1
0
ファイル: networking.py プロジェクト: nathanmcmillan/napa-bot
def get_parameters(candles, start, end):
    '''volume_low = candles[start].volume
    volume_high = candles[start].volume
    low = candles[start].low
    high = candles[start].high
    for index in range(start, end):
        candle = candles[index]
        if candle.low < low:
            low = candle.low
        if candle.high > high:
            high = candle.high
        if candle.volume < volume_low:
            volume_low = candle.volume
        elif candle.volume > volume_high:
            volume_high = candle.volume
    price_range = high - low
    volume_range = volume_high - volume_low
    parameters = []
    for index in range(start, end):
        candle = candles[index]
        parameters.append((candle.low - low) / price_range)
        parameters.append((candle.open - low) / price_range)
        parameters.append((candle.closing - low) / price_range)
        parameters.append((candle.high - low) / price_range)
        parameters.append((candle.volume - volume_low) / volume_range)
    return parameters'''
    macd = ConvergeDiverge(12, 26, candles[start].closing)
    for index in range(start + 1, end):
        candle = candles[index]
        macd.update(candle.closing)
    parameters = []
    parameters.append(float(macd.signal == 'buy'))
    parameters.append(float(macd.signal == 'sell'))
    parameters.append(float(patterns.trend(candles, end - 12, end) == 'green'))
    parameters.append(float(patterns.trend(candles, end - 12, end) == 'red'))
    for index in range(end - 12, end):
        candle = candles[index]
        parameters.append(float(patterns.marubozu(candle) == 'green'))
        parameters.append(float(patterns.marubozu(candle) == 'red'))
        parameters.append(float(patterns.hammer(candle) == 'green'))
        parameters.append(float(patterns.hammer(candle) == 'red'))
        parameters.append(float(patterns.shooting_star(candle) == 'green'))
        parameters.append(float(patterns.shooting_star(candle) == 'red'))
        parameters.append(float(patterns.color(candle) == 'green'))
        parameters.append(float(patterns.color(candle) == 'red'))
    return parameters
コード例 #2
0
    d = dict()
    ohlcv = coinapi.ohlcv(
                            exchange=a['exchange'],
                            pair=a['pair'],
                            period=a['period'],
                            time_start=a['time_start'],
                            time_end=a['time_end']
                          )
    d.update({'ohlcv': ohlcv})
    d.update({'candles': candles.calculate(d['ohlcv'])})
    d.update({'bollinger': bollinger.calculate(d['ohlcv'])})
    d.update({'obv': obv.calculate(d['ohlcv'])})

    # patterns
    p = dict()
    p.update({'doji': patterns.doji(d['ohlcv'])})
    p.update({'bullish_engulfing': patterns.bullish_engulfing(d['candles'])})
    p.update({'bearish_engulfing': patterns.bearish_engulfing(d['candles'])})
    p.update({'gravestone_doji': patterns.gravestone_doji(d['candles'])})
    p.update({'dragonfly_doji': patterns.dragonfly_doji(d['candles'])})
    p.update({'hammer': patterns.hammer(d['candles'])})
    p.update({'shooting_star': patterns.shooting_star(d['candles'])})
    p.update({'bullish_piercing': patterns.bullish_piercing(d['candles'])})

    # store away
    d.update({'patterns': p})

    #  assets and timeframe
    data.update({f'{a["pair"][0]}_{a["pair"][1]}_{a["period"]}': d})
del d, p, ohlcv
return data
コード例 #3
0
     relative_strength_index.update(candles)
     balance_volume.update(candles)
     directional_index.update(candles)
     for index in range(1, candle_num):
         current_candle = candles[index]
         macd.update(current_candle.closing)
     analysis_text = '{:.2f} | {}'.format(
         candles[-1].closing, patterns.trend(candles, ema_short))
     analysis_text += ' | macd {:.2f}'.format(macd.current)
     analysis_text += ' | flow {:.2f}'.format(money_flow_index.current)
     analysis_text += ' | obv {:.2f}'.format(balance_volume.current)
     analysis_text += ' | rsi {:.2f}'.format(
         relative_strength_index.current)
     analysis_text += ' | hammer {}'.format(patterns.hammer(candles[-1]))
     analysis_text += ' | star {}'.format(
         patterns.shooting_star(candles[-1]))
     analysis_text += ' | marubozu {}'.format(patterns.marubozu(
         candles[-1]))
     analysis_text += ' | adx {}'.format(directional_index.current)
     trading.process(auth, product, orders, orders_file, funds, funds_file,
                     macd.signal)
     if first_iteration:
         wait = time_interval - (time.time() - candles[-1].time)
         if wait < 0.0:
             wait_til = time.time() + time_interval
         else:
             wait_til = time.time() + wait
             first_iteration = False
     else:
         wait_til = time.time() + time_interval
 else:
コード例 #4
0
import patterns as patterns
import utils as utils

symbol = 'INFY'
data = utils.get_symbol_data(symbol=symbol)

res = patterns.shooting_star(data=data)
dates = [d.get('date').strftime('%Y-%m-%d') for d in res]

print dates
コード例 #5
0
 def get(self):
     return self.pattern == patterns.shooting_star(candles[index -
                                                           self.period])
コード例 #6
0
def green_star(candles, index):
    return patterns.shooting_star(candles[index]) == 'green'