def ao(candles, short_window, long_window): """Awesome Oscillator""" highs = util.filtership(candles, "max") lows = util.filtership(candles, "min") result = ta.ao(highs, lows, short_window, long_window) return result
def stoch(candles, window): """Stochastic Oscillator""" highs = util.filtership(candles, "max") lows = util.filtership(candles, "min") closes = util.filtership(candles, "close") result = ta.stoch(highs, lows, closes, window) return result
def money_flow_index(candles, window): """Money Flow Index""" highs = util.filtership(candles, "max") lows = util.filtership(candles, "min") closes = util.filtership(candles, "close") volumes = util.filtership(candles, "volume") result = ta.money_flow_index(highs, lows, closes, volumes, window) return result
def tsi(candles, high_window, low_window): """True strength Index""" closes = util.filtership(candles, "close") result = ta.tsi(closes, high_window, low_window) return result
def rsi(candles, window): """Relative Strength Index""" closes = util.filtership(candles, "close") result = ta.rsi(closes, window) return result
import requests import util session = requests.session() def get(url): response = session.get(url) return response.json() state = "" candles = get("https://api.hitbtc.com/api/2/public/candles/ETHUSD") close = float(util.filtership(candles, "close")[98]) _open = float(util.filtership(candles, "open")[98]) low = float(util.filtership(candles, "min")[98]) high = float(util.filtership(candles, "max")[98]) if close - _open > 0: state = "HPlus" if close - _open < 0.5 * (_open - low) and close - _open > 1.1 * (high - close): state = "Doji" if close - _open < 0.25 * (high - close) and close - _open < 0.5 * (_open - low): state = "Doji" if close - _open < 0.5 * (high - close) and close - _open > 1.1 * (_open - low):