def start_again(coin_pair, coin, coin_2): time.sleep(int(get_config()["common_cooldown_time_sec"])) try: notificator("Bot id : " + show_bot_id()) stake_per_trade = get_stake_size(coin_2) if use_bnb_for_fee == "YES": notificator("We will be use BNB for fee") notificator("BNB balance " + str(fetch_balance("BNB"))) if (check_balance_before_start(coin_2, stake_per_trade) is True and fetch_ticker(coin_pair) == coin_pair): if start_buy_trail_on_buy_signal == "YES": notificator("Awaiting for signal from indicators ...") if get_indicators_signal(coin, coin_2)["signal"] == "BUY": trail_buy(coin, coin_2, stake_per_trade) else: trail_buy(coin, coin_2, stake_per_trade) except Exception as e: if show_error == "YES": notificator(str(e))
def get_stake_size(coin_2): if get_config()["use_all_balance"] == "YES": notificator("We will use all " + str(coin_2) + " balance for trade") return demo_or_full(fetch_balance(coin_2), coin_2) else: return demo_or_full(float(get_config()["stake_per_trade"]), coin_2)
def ingnore_signal_time(signal, time_sec): notificator("{} signal received, sleep {} sec ...".format( signal["signal"], time_sec)) time.sleep(time_sec) notificator("Execute {}, after sleep {} sec ".format( signal["signal"], time_sec)) return signal
def make_payment(): if request.method == "POST" and request.form["bot_id"] != None: bot_id_from_form = request.form["bot_id"] if check_login_data(bot_id_from_form) != "error": billing_api_answer = login_on_billing_like_user(bot_id_from_form) if "exist" not in billing_api_answer["message"]: url_safe = write_bot_id_and_url_safe_to_db( bot_id_from_form, gen_url_safe()) xpub = get_xpub() btc_address_dict = gen_payment(bot_id_from_form, url_safe, xpub) if "message" not in btc_address_dict: btc_address = btc_address_dict["address"] value = get_amount_for_one_month() update_payment_data( bot_id_from_form, url_safe, None, btc_address, value, None, "BTC", ) # return jsonify({"btc_address": btc_address, "btc_value": value}) # return "Send to " + str(btc_address) + " " + str(value) + " BTC" # qr = qrcode.make(btc_address) # qr_img = qr.get_image() # heroku don't allow save file to it's disc, therefore we will don't save and show qr to user return render_template("payment.html", btc_address=btc_address, value=value) else: set_used_to_xpub(xpub) notificator(btc_address_dict) # return jsonify(btc_address_dict) error = "There is no BTC wallet address, try again later ... or pay with ETH ...." return render_template("error.html", error=error) else: # return "id not found" error = "id not found" return render_template("error.html", error=error) else: return abort(401) # return redirect(url_for("login")) else: return render_template("make_payment.html")
def set_used_to_xpub(xpub): try: xpub_to_set = XpubKeys.find_by_xpub(xpub) xpub_to_set.used = "yes" xpub_to_set.update_on_db() notificator("{} is used".format(xpub)) except Exception as e: notificator(str(e))
def adv_messages(): try: adv_messages = requests.get(get_billig_url() + messages_url).json() adv = [] for i in adv_messages["messages"]: for k, v in i.items(): if k == "adv": adv.append(v) notificator(adv[-1:][0]) # first fresh message except requests.exceptions.RequestException: pass except Exception: pass
def get_xpub(): xpub = XpubKeys.get_xpubs() try: t = [] for i in xpub["xpubs"]: if i["used"] == None: print(i["xpub"]) t.append(i["xpub"]) # notificator(t[0]) return t[0] except Exception as e: # notificator(str(e)) notificator("All not used xPub's ended, put more to psql")
def ignore_buy_signal_times(signal, times): global ignore_buy_signal_counter if signal["signal"] == "BUY" and ignore_buy_signal_counter < times: notificator("Ignore {} {} ... cooldown {} seconds".format( signal["signal"], str(ignore_buy_signal_counter + 1), get_config()["ignore_buy_cooldown_sec"], )) ignore_buy_signal_counter = ignore_buy_signal_counter + 1 time.sleep(int(get_config()["ignore_buy_cooldown_sec"])) return "PASS" else: notificator("Execute {}".format(signal["signal"])) ignore_buy_signal_counter = 0 return "OK"
def trade_result( buy_order_id, sell_order_id, coin_pair, coin_2, sell_order, buy_order, coin, stake_per_trade, ): try: profit_lst = calculate_profit(coin_2) notificator("Profit :\n\n" + number_for_human(profit_lst[0]) + " " + coin_2 + "\n" + str(profit_lst[2])[:6] + " %") datetime_start = check_order_date_time_by_id(buy_order_id, coin_pair) datetime_end = check_order_date_time_by_id(sell_order_id, coin_pair) if save_to_sqlite == "YES": save_result_to_sqlite( str(sell_order), str(buy_order), datetime_start, datetime_end, profit_lst[0], str(coin_2), str(coin_pair), ) if save_to_firebase == "YES": save_result_to_firebase( str(sell_order), str(buy_order), datetime_start, datetime_end, profit_lst[0], str(coin_2), str(coin_pair), ) start_again(coin_pair, coin, coin_2) except Exception as e: if show_error == "YES": notificator(str(e))
def save_result_to_sqlite(sell_order, buy_order, datetime_start, datetime_end, profit, coin_2, coin_pair): try: query = db.insert(trades) values_list = [{ "datetime_start": datetime_start, "datetime_end": datetime_end, "profit_base_currency": profit, "trading_pair": coin_pair, "base_currency": coin_2, "unparsed_buy_orders": buy_order, "unparsed_sell_orders": sell_order, }] ResultProxy = connection.execute(query, values_list) notificator("result to db success") except Exception as e: if show_error == "YES": notificator(str(e))
def save_result_to_firebase(sell_order, buy_order, datetime_start, datetime_end, profit, coin_2, coin_pair): try: db_ref = firebase_db.reference("trades") db_ref.push({ "datetime_start": datetime_start, "datetime_end": datetime_end, "profit_base_currency": profit, "trading_pair": coin_pair, "base_currency": coin_2, "unparsed_buy_orders": buy_order, "unparsed_sell_orders": sell_order, }) notificator("result to firebase success") except Exception as e: if show_error == "YES": notificator(str(e))
def info_messages(): global inf_messages try: x = requests.get(get_billig_url() + messages_url).json() if x == inf_messages: pass else: inf_messages = x info = [] for i in inf_messages["messages"]: for k, v in i.items(): if k == "info": info.append(v) notificator(info[-1:][0]) # first fresh message from db except requests.exceptions.RequestException: pass except Exception: pass
def demo_or_full(stake_per_trade, coin_2): #return stake_per_trade stake_demo_btc = 0.03 demo_message = ( "This is DEMO edition :(\n\nLimit for trading " + str(stake_demo_btc) + " BTC " + "\n\n" + "In DEMO allowed trading with BTC only" + "\n\n" + "For get more trade limit and trade other pairs, please, buy Full edition :)" + "\n\n" + "https://axe-bot.com") try: if (coin_2 == "BTC" and stake_per_trade > stake_demo_btc and check_licence_is_expire() is True): notificator(demo_message) return stake_demo_btc if (coin_2 in "ETH, BNB, XRP, USDT, TUSD, PAX, USDS, USDC" and check_licence_is_expire() is True): notificator(demo_message) sys.exit() else: return stake_per_trade except Exception as e: if show_error == "YES": notificator(str(e))
def check_order_status_by_id(order_id, coin_pair): try: while True: if exchange.has["fetchOrder"]: filled_order_status_dict = exchange.fetchOrder( id=order_id, symbol=coin_pair, params={}) if filled_order_status_dict["status"] == "open": if cancel_order_by_time == "YES": cancel_limit_order_by_inactivity(order_id, coin_pair) time.sleep(api_requests_frequency) continue else: time.sleep(api_requests_frequency) continue if filled_order_status_dict["status"] == "canceled": return "canceled" break if filled_order_status_dict["status"] == "closed": return "closed" break except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def calculate_amount_to_by(coin_pair, stake_per_trade, coin_2, current_price): global number_failed_connect_to_billing_server try: current_balance_coin_2 = fetch_balance(coin_2) if use_limit_orders == "YES": coin_price = current_price else: coin_price = check_coin_price(coin_pair) if current_balance_coin_2 < stake_per_trade: amount = current_balance_coin_2 / coin_price else: amount = stake_per_trade / coin_price amount_str = str(amount) dot_pos = amount_str.find(".") amount = float(amount_str[:dot_pos + 8]) return amount except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def minimum_order_size(coin, stake_per_trade): if coin == "BTC": if minimal_order_size_btc > stake_per_trade: notificator("Minimal order size " + str(minimal_order_size_btc) + " " + coin) return False else: return True if coin == "ETH": if minimal_order_size_eth > stake_per_trade: notificator("Minimal order size " + str(minimal_order_size_eth) + " " + coin) return False else: return True if coin == "BNB": if minimal_order_size_bnb > stake_per_trade: notificator("Minimal order size " + str(minimal_order_size_bnb) + " " + coin) return False else: return True if coin == "XRP": if minimal_order_size_xrp > stake_per_trade: notificator("Minimal order size " + str(minimal_order_size_xrp) + " " + coin) return False else: return True if coin in USD_X: if minimal_order_size_usd_x > stake_per_trade: notificator("Minimal order size " + str(minimal_order_size_usd_x) + " " + coin) return False else: return True
def main(): coin_pair = coin + "/" + coin_2 try: balance_coin_2_is_enough = check_balance_before_start( coin_2, stake_per_trade) if balance_coin_2_is_enough is True: tiker = fetch_ticker(coin_pair) if tiker == coin_pair: if start_buy_trail_on_buy_signal == "YES": notificator("Awaiting for signal from indicators ...") if get_indicators_signal(coin, coin_2)["signal"] == "BUY": trail_buy(coin, coin_2, stake_per_trade) else: trail_buy(coin, coin_2, stake_per_trade) except Exception as e: if show_error == "YES": notificator(str(e))
def fetch_ticker(coin_pair): try: response = exchange.fetch_ticker(coin_pair)["symbol"] notificator(response) return response except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def fetch_balance(coin): try: balance = exchange.fetch_balance() balance = balance[coin]["free"] return balance except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def fetch_filled_order_amount_by_id(order_id, coin_pair): try: if exchange.has["fetchOrder"]: filled_order_cost_dict = exchange.fetchOrder(id=order_id, symbol=coin_pair, params={}) return filled_order_cost_dict["filled"] except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def exchange(): try: key = get_config()["key"] secret = get_config()["secret"] exchange = ccxt.binance({ "apiKey": key, "secret": secret, "enableRateLimit": True }) return exchange except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def check_order_date_time_by_id(order_id, coin_pair): try: if exchange.has["fetchOrder"]: order_datetime_dict = exchange.fetchOrder(id=order_id, symbol=coin_pair, params={}) order_datetime = order_datetime_dict["datetime"] order_datetime = order_datetime.replace("T", " ") order_datetime = order_datetime.replace("Z", "") return order_datetime except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def make_order(coin_pair, type_ord, side, amount, price): try: symbol = coin_pair type_o = type_ord # "market" or "limit" side = side # "buy" or "sell" amount = amount price = price params = {} order = (symbol, type, side, amount, price, params) order = exchange.create_order(symbol, type_o, side, amount, price, params) return order except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
def cancel_limit_order_by_inactivity(order_id, coin_pair): # here using datetime.utcnow() insted datetime.now() # because binance has UTC time, and gives orders time in UTC params = {} try: order_datetime = check_order_date_time_by_id(order_id, coin_pair) tm_inact = time_to_cancel_order_by_inactivity_minutes order_date = dt.datetime.fromisoformat(order_datetime) + timedelta( minutes=tm_inact) if order_date < dt.datetime.utcnow(): exchange.cancel_order(order_id, coin_pair, params) except ccxt.NetworkError as e: notificator(str(e)) except ccxt.ExchangeError as e: notificator(str(e)) except Exception as e: notificator(str(e))
def check_balance_before_start(coin, stake_per_trade): balance = fetch_balance(coin) if balance >= stake_per_trade and minimum_order_size( coin, stake_per_trade) is True: if check_licence_is_expire(): adv_messages() notificator("You have " + number_for_human(balance) + " " + str(coin)) notificator("Stake will be " + number_for_human(stake_per_trade) + " " + str(coin)) notificator("We will trade :") return True else: if check_licence_is_expire(): adv_messages() notificator("You have " + number_for_human(balance) + " " + str(coin)) notificator("Stake " + number_for_human(stake_per_trade) + " " + str(coin)) notificator("Small " + str(coin) + " balance !") notificator("Bot stopped") return False
def trail_buy(coin, coin_2, stake_per_trade): try: buy_trail_step = float(get_config()["buy_trail_step"]) coin_pair = coin + "/" + coin_2 coin_pair_for_get_bars = ( coin + coin_2 ) # another format(ETHBTC) then coin_pair(ETH/BTC) for ccxt notificator("Awaiting buy ...") start_price = check_coin_price(coin_pair_for_get_bars) time.sleep(1) current_price = check_coin_price(coin_pair_for_get_bars) current_change_percent = ( (float(current_price) - start_price) / start_price) * 100 last_change_percent = current_change_percent while True: if last_change_percent + buy_trail_step >= current_change_percent: if last_change_percent > current_change_percent: last_change_percent = current_change_percent current_price = check_coin_price(coin_pair_for_get_bars) current_change_percent = ( (float(current_price) - start_price) / start_price) * 100 if debug == "YES": notificator("last_change_percent :\n" + str(last_change_percent)[:9] + "\n\n" + "current_change_percent :\n" + str(current_change_percent)[:9] + "\n\n" + "buy_trail_step :\n" + str(buy_trail_step)) time.sleep(api_requests_frequency) continue else: if use_limit_orders == "YES": amount_to_buy = calculate_amount_to_by( coin_pair, stake_per_trade, coin_2, current_price) buy_order_new = make_order(coin_pair, "limit", "buy", amount_to_buy, current_price) buy_order_id = buy_order_new["id"] if check_order_status_by_id(buy_order_id, coin_pair) == "canceled": notificator("Buy order was canceled, restart ...") start_again(coin_pair, coin, coin_2) break if check_order_status_by_id(buy_order_id, coin_pair) == "closed": buy_order = fetch_full_closed_order_by_id( buy_order_id, coin_pair) price_buy = fetch_filled_price_by_id( buy_order_id, coin_pair) amount_filled = fetch_filled_order_amount_by_id( buy_order_id, coin_pair) notificator("Buy (limit) " + number_for_human(amount_filled) + " " + coin + " at price " + number_for_human(price_buy) + " success") if start_sell_trail_on_sell_signal == "YES": notificator("Awaiting SELL signal ...") if (get_indicators_signal_sell( coin, coin_2, price_buy)["signal"] == "SELL"): trail_sell( coin_pair, buy_order_id, price_buy, coin, coin_2, buy_order, stake_per_trade, coin_pair_for_get_bars, ) break trail_sell( coin_pair, buy_order_id, price_buy, coin, coin_2, buy_order, stake_per_trade, coin_pair_for_get_bars, ) break else: while True: amount_to_buy = calculate_amount_to_by( coin_pair, stake_per_trade, coin_2, current_price) buy_order = make_order(coin_pair, "market", "buy", amount_to_buy, None) if buy_order is not None: break else: continue buy_order_id = buy_order["id"] price_buy = fetch_filled_price_by_id( buy_order_id, coin_pair) amount_filled = fetch_filled_order_amount_by_id( buy_order_id, coin_pair) notificator("Buy (market) " + number_for_human(amount_filled) + " " + coin + " at price " + number_for_human(price_buy) + " success") notificator("Awaiting sell ...") if start_sell_trail_on_sell_signal == "YES": notificator("Awaiting SELL signal ...") if (get_indicators_signal_sell( coin, coin_2, price_buy)["signal"] == "SELL"): trail_sell( coin_pair, buy_order_id, price_buy, coin, coin_2, buy_order, stake_per_trade, coin_pair_for_get_bars, ) break trail_sell( coin_pair, buy_order_id, price_buy, coin, coin_2, buy_order, stake_per_trade, coin_pair_for_get_bars, ) break except ccxt.NetworkError as e: if show_error == "YES": notificator(str(e)) except ccxt.ExchangeError as e: if show_error == "YES": notificator(str(e)) except Exception as e: if show_error == "YES": notificator(str(e))
show_error = "YES" check_config_error() registration_on_billing() info_messages() coin = get_config()["coin"].upper() coin_2 = get_config()["coin_2"].upper() use_bnb_for_fee = get_config()["use_bnb_for_fee"] start_buy_trail_on_buy_signal = get_config()["start_buy_trail_on_buy_signal"] notificator("Bot id : " + show_bot_id()) stake_per_trade = get_stake_size(coin_2) if use_bnb_for_fee == "YES": notificator("We will be use BNB for fee") notificator("BNB balance " + str(fetch_balance("BNB"))) def main(): coin_pair = coin + "/" + coin_2 try: balance_coin_2_is_enough = check_balance_before_start(
trades = db.Table( "trades", metadata, db.Column("datetime_start", db.String()), db.Column("datetime_end", db.String()), db.Column("profit_base_currency", db.Float()), db.Column("trading_pair", db.String()), db.Column("base_currency", db.String()), db.Column("unparsed_buy_orders", db.String()), db.Column("unparsed_sell_orders", db.String()), ) metadata.create_all(engine) except Exception as e: if show_error == "YES": notificator(str(e)) if save_to_firebase == "YES": firebase_credentials_file_name = get_config( )["firebase_credentials_file_name"] firebase_databaseURL = get_config()["firebase_databaseURL"] credentials = credentials.Certificate(firebase_credentials_file_name) firebase_admin.initialize_app(credentials, {"databaseURL": firebase_databaseURL}) def save_result_to_sqlite(sell_order, buy_order, datetime_start, datetime_end, profit, coin_2, coin_pair): try: query = db.insert(trades) values_list = [{
def get_indicators_signal(coin, coin_2): coin_pair_for_get_bars = ( coin + coin_2 ) # another format(ETHBTC) then coin_pair(ETH/BTC) for ccxt try: while True: if buy_indicators_type == "RSI+BB": coin_price = check_coin_price(coin_pair_for_get_bars) bb_low = bollingerband(coin_pair_for_get_bars, buy_indicators_timeframe)[0] rsi_data_now = rsi(coin_pair_for_get_bars, buy_indicators_timeframe) if coin_price < bb_low and rsi_data_now < rsi_buy_level: notificator("Pair " + str(coin_pair_for_get_bars) + "\n" + "Price " + str(number_for_human(coin_price)) + "\n" + "BB low " + str(number_for_human(bb_low))[:9] + "\n" + "RSI " + str(rsi_data_now)[:9] + "\n" + "Timeframe " + str(buy_indicators_timeframe) + "\n" + "BUY") signal = { "pair": coin_pair_for_get_bars, "price": coin_price, "bb_low": bb_low, "rsi_data_now": rsi_data_now, "signal": "BUY", } if get_config()["ignore_buy_signal_enable"] == "YES": if get_config()["ignore_buy_signal_type"] == "time": return ingnore_signal_time( signal, int(get_config() ["ignore_buy_signal_time_sec"])) break if get_config()["ignore_buy_signal_type"] == "times": if (ignore_buy_signal_times( signal, int(get_config() ["ignore_buy_signal_times"])) == "OK"): return signal break else: return signal break else: if debug == "YES": notificator("Awaiting for Signal ...") time.sleep(api_requests_frequency) continue if buy_indicators_type == "RSI": coin_price = check_coin_price(coin_pair_for_get_bars) rsi_data_now = rsi(coin_pair_for_get_bars, buy_indicators_timeframe) if rsi_data_now < rsi_buy_level: notificator("Pair " + str(coin_pair_for_get_bars) + "\n" + "RSI " + str(rsi_data_now)[:9] + "\n" + "Timeframe " + str(buy_indicators_timeframe) + "\n" + "BUY") signal = { "pair": coin_pair_for_get_bars, "price": coin_price, "rsi_data_now": rsi_data_now, "signal": "BUY", } if get_config()["ignore_buy_signal_enable"] == "YES": if get_config()["ignore_buy_signal_type"] == "time": return ingnore_signal_time( signal, int(get_config() ["ignore_buy_signal_time_sec"])) break if get_config()["ignore_buy_signal_type"] == "times": if (ignore_buy_signal_times( signal, int(get_config() ["ignore_buy_signal_times"])) == "OK"): return signal break else: return signal break else: if debug == "YES": notificator("Awaiting for Signal ...") time.sleep(api_requests_frequency) continue if buy_indicators_type == "BB": coin_price = check_coin_price(coin_pair_for_get_bars) bb_low = bollingerband(coin_pair_for_get_bars, buy_indicators_timeframe)[0] if coin_price < bb_low: notificator("Pair " + str(coin_pair_for_get_bars) + "\n" + "Price " + str(number_for_human(coin_price)) + "\n" + "BB low " + str(number_for_human(bb_low))[:9] + "\n" + "Timeframe " + str(buy_indicators_timeframe) + "\n" + "BUY") signal = { "pair": coin_pair_for_get_bars, "price": coin_price, "bb_low": bb_low, "signal": "BUY", } if get_config()["ignore_buy_signal_enable"] == "YES": if get_config()["ignore_buy_signal_type"] == "time": return ingnore_signal_time( signal, int(get_config() ["ignore_buy_signal_time_sec"])) break if get_config()["ignore_buy_signal_type"] == "times": if (ignore_buy_signal_times( signal, int(get_config() ["ignore_buy_signal_times"])) == "OK"): return signal break else: return signal break else: if debug == "YES": notificator("Awaiting for Signal ...") time.sleep(api_requests_frequency) continue except Exception as e: if show_error == "YES": notificator(str(e) + ' from get_indicators_signal')
def get_indicators_signal_sell(coin, coin_2, price_buy): coin_pair_for_get_bars = ( coin + coin_2 ) # another format(ETHBTC) then coin_pair(ETH/BTC) for ccxt try: while True: if sell_indicators_type == "RSI+BB": price_ok_tmp = (price_buy / 100) * price_buffer price_ok = price_buy + price_ok_tmp coin_price = check_coin_price(coin_pair_for_get_bars) bb_up = bollingerband(coin_pair_for_get_bars, sell_indicators_timeframe)[1] rsi_data_now = rsi(coin_pair_for_get_bars, sell_indicators_timeframe) stop_loss = price_buy - ( (price_buy / 100) * stop_loss_percent_for_start_sell_on_sell_signal) if use_stop_loss_while_start_sell_on_sell_signal == "YES": if coin_price <= stop_loss: notificator("Stop loss, selling") return {"signal": "SELL"} break if (coin_price > bb_up and rsi_data_now > rsi_sell_level and price_ok < coin_price): notificator("Pair " + str(coin_pair_for_get_bars) + "\n" + "Price " + str(number_for_human(coin_price)) + "\n" + "BB up " + str(number_for_human(bb_up))[:9] + "\n" + "RSI " + str(rsi_data_now)[:9] + "\n" + "Timeframe " + str(sell_indicators_timeframe) + "\n" + "SELL") signal = { "pair": coin_pair_for_get_bars, "price": coin_price, "bb_up": bb_up, "rsi_data_now": rsi_data_now, "signal": "SELL", } if get_config()["ignore_sell_signal_enable"] == "YES": if get_config()["ignore_sell_signal_type"] == "time": return ingnore_signal_time( signal, int(get_config() ["ignore_sell_signal_time_sec"])) break if get_config()["ignore_sell_signal_type"] == "times": if (ignore_sell_signal_times( signal, int(get_config() ["ignore_sell_signal_times"]), ) == "OK"): return signal break else: return signal break else: if debug == "YES": notificator("Awaiting for SELL Signal ...") time.sleep(api_requests_frequency) continue if sell_indicators_type == "RSI": price_ok_tmp = (price_buy / 100) * price_buffer price_ok = price_buy + price_ok_tmp coin_price = check_coin_price(coin_pair_for_get_bars) rsi_data_now = rsi(coin_pair_for_get_bars, sell_indicators_timeframe) stop_loss = price_buy - ( (price_buy / 100) * stop_loss_percent_for_start_sell_on_sell_signal) if use_stop_loss_while_start_sell_on_sell_signal == "YES": if coin_price <= stop_loss: notificator("Stop loss, selling") return {"signal": "SELL"} break if rsi_data_now > rsi_sell_level and price_ok < coin_price: notificator("Pair " + str(coin_pair_for_get_bars) + "\n" + "RSI " + str(rsi_data_now)[:9] + "\n" + "Timeframe " + str(sell_indicators_timeframe) + "\n" + "SELL") signal = { "pair": coin_pair_for_get_bars, "price": coin_price, "rsi_data_now": rsi_data_now, "signal": "SELL", } if get_config()["ignore_sell_signal_enable"] == "YES": if get_config()["ignore_sell_signal_type"] == "time": return ingnore_signal_time( signal, int(get_config() ["ignore_sell_signal_time_sec"])) break if get_config()["ignore_sell_signal_type"] == "times": if (ignore_sell_signal_times( signal, int(get_config() ["ignore_sell_signal_times"]), ) == "OK"): return signal break else: return signal break else: if debug == "YES": notificator("Awaiting for SELL Signal ...") time.sleep(api_requests_frequency) continue if sell_indicators_type == "BB": price_ok_tmp = (price_buy / 100) * price_buffer price_ok = price_buy + price_ok_tmp coin_price = check_coin_price(coin_pair_for_get_bars) bb_up = bollingerband(coin_pair_for_get_bars, sell_indicators_timeframe)[1] stop_loss = price_buy - ( (price_buy / 100) * stop_loss_percent_for_start_sell_on_sell_signal) if use_stop_loss_while_start_sell_on_sell_signal == "YES": if coin_price <= stop_loss: notificator("Stop loss, selling") return {"signal": "SELL"} break if coin_price > bb_up and price_ok < coin_price: notificator("Pair " + str(coin_pair_for_get_bars) + "\n" + "Price " + str(number_for_human(coin_price)) + "\n" + "BB up " + str(number_for_human(bb_up))[:9] + "\n" + "Timeframe " + str(sell_indicators_timeframe) + "\n" + "SELL") signal = { "pair": coin_pair_for_get_bars, "price": coin_price, "bb_up": bb_up, "signal": "SELL", } if get_config()["ignore_sell_signal_enable"] == "YES": if get_config()["ignore_sell_signal_type"] == "time": return ingnore_signal_time( signal, int(get_config() ["ignore_sell_signal_time_sec"])) break if get_config()["ignore_sell_signal_type"] == "times": if (ignore_sell_signal_times( signal, int(get_config() ["ignore_sell_signal_times"]), ) == "OK"): return signal break else: return signal break else: if debug == "YES": notificator("Awaiting for SELL Signal ...") time.sleep(api_requests_frequency) continue except Exception as e: if show_error == "YES": notificator(str(e) + ' from get_indicators_signal_sell')