def get_macd(market, aggregate): from_currency = market[market.index("-") + 1:] to_currency = market[:market.index("-")] data = historical_api.get_historical_hour(from_currency, to_currency, limit=200, aggregate=aggregate) close = np.array([d['close'] for d in data]) values = talib.MACD(close, fastperiod=12, slowperiod=26, signalperiod=9) return values
def get_rsi(market, aggregate): period = 14 from_currency = market[market.index("-") + 1:] to_currency = market[:market.index("-")] data = historical_api.get_historical_hour(from_currency, to_currency, limit=200, aggregate=aggregate) close = np.array([d['close'] for d in data]) values = talib.RSI(close, period) return values
def stoch_rsi(market): period = 14 from_currency = market[market.index("-") + 1:] to_currency = market[:market.index("-")] data = historical_api.get_historical_hour(from_currency, to_currency) close = np.array([d['close'] for d in data]) values = talib.STOCHRSI(close, timeperiod=period, fastk_period=3, fastd_period=3, fastd_matype=0) return values
def __get_data(market, aggregate): from_currency = market[market.index("-") + 1:] to_currency = market[:market.index("-")] data = historical_api.get_historical_hour(from_currency, to_currency, limit=200, aggregate=aggregate) close = __extract("close", data) high = __extract("high", data) low = __extract("low", data) return close, high, low
def dynamic_stop_loss_loop(currency, timeframe_hours): balance = float(get_balance(currency)['Balance']) while balance > 0.0: try: period = 22 datapoints = historical_api.get_historical_hour( currency, "BTC", limit=100, aggregate=timeframe_hours) exit_price = get_long_chandelier_exit(datapoints, period=period) print(exit_price) market = market_for_currency(currency) force_put_conditional_sell_all_order(market=market, rate=exit_price) except Exception as e: print("Temporary failure: %" % str(e)) time.sleep(60 * 10) # update every ten minutes