Exemple #1
0
def getTickerMessage(ticker, pair, fiat):
    pairsplit = pair.split("_")
    coin = CoinMarketCap.getReadableCoinName(pairsplit[0])

    flLast = float(ticker["last"])
    price = "Current Price: `" + "{:.8f}".format(flLast)
    if fiat:
        fiatConv = coindeskWrap.getTickerData(fiat)
        fin = flLast * float(fiatConv["rate_float"])
        fiatDisplay = " / {:.2f}".format(fin) + " " + fiat + "`\n"
    else:
        btc = coindeskWrap.getTickerData("USD")
        fin = flLast * btc["rate_float"]
        fiatDisplay = " / {:.2f}".format(fin) + " USD`\n"

    final = price + fiatDisplay
    header = coin + " (" + pairsplit[0] + ")"

    # changeNum = round(((ticker["Last"] - ticker["PrevDay"]) / ticker["PrevDay"]) * 100, 2)
    # sign = "+" if changeNum > 0 else ""
    # change = "24hr Percent Change: ```diff\n" + sign + str(changeNum) + "%```"
    change = "24hr Percent Change: ```diff\n Not supported by CryptoBridge API```"

    data = final + change

    # if changeNum < 0:
    #     col = 0xFF0000
    # elif changeNum > 0:
    #     col = 0x00ff00
    col = 0x630057  #just make it purple for now, until cryptobridge supports change %

    embed = discord.Embed(title=header, description=data, color=col)
    embed.set_footer(text="via CryptoBridge | ?help for more bot info")

    return embed
def getTickerMessage(ticker, pair, fiat):
    coin = CoinMarketCap.getReadableCoinName(pair.split("_")[0])

    price = "Current Price: `" + "{:.8f}".format(ticker["LastPrice"])
    if fiat:
        fiatConv = coindeskWrap.getTickerData(fiat)
        fin = float(ticker["LastPrice"]) * float(fiatConv["rate_float"])
        fin = fin
        fiatDisplay = " / {:.2f}".format(fin) + " " + fiat + "`\n"
    else:
        btc = coindeskWrap.getTickerData("USD")
        fin = float(ticker["LastPrice"]) * btc["rate_float"]
        fiatDisplay = " / {:.2f}".format(fin) + " USD`\n"

    final = price + fiatDisplay
    header = coin + " (" + pair.split("_")[0] + ")"

    changeNum = ticker["Change"]
    sign = "+" if changeNum > 0 else ""
    change = "Percent Change: ```diff\n" + sign + str(changeNum) + "%```"

    data = final + change

    if changeNum < 0:
        col = 0xFF0000
    elif changeNum > 0:
        col = 0x00ff00

    embed = discord.Embed(title=header, description=data, color=col)
    embed.set_footer(text="via Cryptopia | ?help for more bot info")

    return embed
Exemple #3
0
def getTickerMessage(ticker, pair, fiat):
    ticker = ticker[0]
    coin = pair.split("-")[1]
    coin = getReadableCoinName(pair.split("-")[1])

    price = "Current Price: `" + "{:.8f}".format(ticker["Last"])
    if fiat:
        fiatConv = coindeskWrap.getTickerData(fiat)
        fin = ticker["Last"] * float(fiatConv["rate_float"])
        fiatDisplay = " / {:.2f}".format(fin) + " " + fiat + "`\n"
    else:
        btc = coindeskWrap.getTickerData("USD")
        fin = ticker["Last"] * btc["rate_float"]
        fiatDisplay = " / {:.2f}".format(fin) + " USD`\n"

    final = price + fiatDisplay
    header = coin + " (" + pair.split("-")[1] + ")"

    changeNum = round(
        ((ticker["Last"] - ticker["PrevDay"]) / ticker["PrevDay"]) * 100, 2)
    sign = "+" if changeNum > 0 else ""
    change = "24hr Percent Change: ```diff\n" + sign + str(changeNum) + "%```"

    data = final + change

    if changeNum < 0:
        col = 0xFF0000
    elif changeNum > 0:
        col = 0x00ff00

    embed = discord.Embed(title=header, description=data, color=col)
    embed.set_footer(text="via Bittrex | ?help for more bot info")

    return embed
Exemple #4
0
def getTickerMessage(ticker, pair, fiat):
    pairPri = pair[:-3]
    coin = CoinMarketCap.getReadableCoinName(pairPri)

    price = "Current Price: `" + ticker["lastPrice"]
    if fiat:
        fiatConv = coindeskWrap.getTickerData(fiat)
        fin = float(ticker["lastPrice"]) * float(fiatConv["rate_float"])
        fiatDisplay = " / {:.2f}".format(fin) + " " + fiat + "`\n"
    else:
        btc = coindeskWrap.getTickerData("USD")
        fin = float(ticker["lastPrice"]) * btc["rate_float"]
        fiatDisplay = " / {:.2f}".format(fin) + " USD`\n"


    header = coin + " (" + pairPri + ")"
    final = price + fiatDisplay

    changeNum = float(ticker["priceChangePercent"])
    sign = "+" if changeNum > 0 else ""
    change = "24hr Percent Change: ```diff\n" + sign + "{:.2f}".format(changeNum) + "%```"

    data = final + change

    if changeNum < 0:
        col = 0xFF0000
    elif changeNum > 0:
        col = 0x00ff00

    embed = discord.Embed(title = header, description = data, color = col)
    embed.set_footer(text = "via Binance | ?help for more bot info")

    return embed
Exemple #5
0
def getTickerMessage(ticker, pair, fiat):
    pair = pair.upper()
    pairN = pair[3:]
    pairU = pair[:-4]
    coin = CoinMarketCap.getReadableCoinName(pairN)

    notNano = CoinMarketCap.getCoinData(pairU)

    flLast = float(ticker["last_trade"])
    flOpen = float(ticker["price_change"])

    price = "Current Price: `" + "{:.2f}".format(
        flLast) + " " + coin + " per " + pairU
    if fiat:
        fiatConv = coindeskWrap.getTickerData(fiat)
        fin = float(fiatConv["rate_float"]) / flLast
        fiatDisplay = " / {:.2f}".format(fin) + " " + fiat + "`\n"
    else:
        fin = float(notNano["price_usd"]) / flLast
        fiatDisplay = " / {:.2f}".format(fin) + " USD`\n"

    final = price + fiatDisplay
    header = coin + " (" + pairN + ")"

    changeNum = flOpen
    sign = "+" if changeNum > 0 else ""
    change = "Percent Change: ```diff\n" + sign + "{:.2f}".format(
        changeNum) + "%```"

    data = final + change

    if changeNum < 0:
        col = 0xFF0000
    elif changeNum > 0:
        col = 0x00ff00

    embed = discord.Embed(title=header, description=data, color=col)
    embed.set_footer(text="via Nanex | ?help for more bot info")

    return embed