示例#1
0
def get_fund_asset_prices():
    pol_ticker = get_ticker()
    bfx_cli = Client()
    
    price_d = {
        'XBT/USD': float(bfx_cli.ticker('btcusd')['last_price']),
        'FCT/XBT': float(pol_ticker['BTC_FCT']['last']),
        'XRP/XBT': float(pol_ticker['BTC_XRP']['last']),
        'NXT/XBT': float(pol_ticker['BTC_NXT']['last']),
        'MMNXT/XBT': float(pol_ticker['BTC_MMNXT']['last']),
        'DASH/XBT': float(pol_ticker['BTC_DASH']['last']),
        'COINOMAT1/XBT': get_coinomat1_xbt(),
        'LTC/XBT': float(pol_ticker['BTC_LTC']['last']),
    }
    return price_d
示例#2
0
def get_price_graph():
    pol_ticker = get_ticker()
    bfx_cli = Client()
    
    G = nx.DiGraph()
    G.add_nodes_from(["XBT","USD","FCT","XRP",
                      "NXT","MMNXT","DASH",
                      "COINOMAT1", "LTC"])
    G.add_edges_from([("USD","XBT",{"value":float(bfx_cli.ticker('btcusd')['last_price'])}),
                      ("XBT","FCT",{"value":float(pol_ticker['BTC_FCT']['last'])}),
                      ("XBT","XRP",{"value":float(pol_ticker['BTC_XRP']['last'])}),
                      ("XBT","NXT",{"value":float(pol_ticker['BTC_NXT']['last'])}),
                      ("XBT","MMNXT",{"value":float(pol_ticker['BTC_MMNXT']['last'])}),
                      ("XBT","DASH",{"value":float(pol_ticker['BTC_DASH']['last'])}),
                      ("NXT","COINOMAT1",{"value":get_coinomat1_nxt()}),
                      ("XBT","LTC",{"value":float(pol_ticker['BTC_LTC']['last'])})])

    # compute inverse for opposite direction price computation
    for from_node, to_node in G.edges():
        G.add_edge(to_node, from_node, value = 1.0 / G.edge[from_node][to_node]["value"])

    return G
示例#3
0
    def __init__(self, telegram_token, auth_pass, btfx_key, btfx_secret):
        LOGGER.info("Here be dragons")
        self.userdata = utils.read_userdata()
        self.auth_pass = auth_pass
        self.btfx_client = Client(btfx_key, btfx_secret)
        self.btfx_client2 = Client2(btfx_key, btfx_secret)
        self.btfx_symbols = self.btfx_client.symbols()

        updater = Updater(telegram_token)
        self.tbot = updater.bot
        self.btfxwss = Bfxwss(self.tbot,
                              self.send_to_users,
                              key=btfx_key,
                              secret=btfx_secret)
        # Get the dispatcher to register handlers
        qdp = updater.dispatcher
        # on different commands - answer in Telegram
        qdp.add_handler(CommandHandler("start", self.cb_start))
        qdp.add_handler(CommandHandler("graph", self.cb_graph, pass_args=True))
        qdp.add_handler(CommandHandler("auth", self.cb_auth, pass_args=True))
        qdp.add_handler(
            CommandHandler("option", self.cb_option, pass_args=True))
        qdp.add_handler(
            CommandHandler("neworder", self.cb_new_order, pass_args=True))
        qdp.add_handler(
            CommandHandler("orders", self.cb_orders, pass_args=True))
        qdp.add_handler(CommandHandler("calc", self.cb_calc, pass_args=True))
        qdp.add_handler(CommandHandler("help", self.cb_help, pass_args=True))
        qdp.add_handler(
            CallbackQueryHandler(self.cb_btn_cancel_order,
                                 pattern=r'^cancel_order:[0-9]+$'))
        qdp.add_handler(
            CallbackQueryHandler(self.cb_btn_orders, pattern=r'^orders:\w+$'))

        # log all errors
        qdp.add_error_handler(self.cb_error)

        # Start the Bot
        updater.start_polling(timeout=60, read_latency=0.2)

        # Block until you press Ctrl-C or the process receives SIGINT, SIGTERM or
        # SIGABRT. This should be used most of the time, since start_polling() is
        # non-blocking and will stop the bot gracefully.
        updater.idle()
示例#4
0
from bitfinex import Client

client = Client()

symbols = client.symbols()
print(symbols)

symbol = 'btcusd'

print(client.ticker(symbol))
print(client.today(symbol))
print(client.stats(symbol))

parameters = {'limit_asks': 2, 'limit_bids': 2}

print(client.lendbook('btc', parameters))
print(client.order_book(symbol, parameters))
示例#5
0
    def __init__(self, telegram_token, auth_pass, btfx_key, btfx_secret):
        LOGGER.info("Here be dragons")
        self.userdata = utils.read_userdata()
        self.auth_pass = auth_pass
        self.btfx_client = Client(btfx_key, btfx_secret)
        self.btfx_client2 = Client2(btfx_key, btfx_secret)
        self.btfx_symbols = self.btfx_client.symbols()
        self.currencies = utils.get_currencies(self.btfx_symbols)

        updater = Updater(telegram_token)
        self.tbot = updater.bot
        self.btfxwss = Bfxwss(self.send_to_users,
                              key=btfx_key,
                              secret=btfx_secret)
        # Get the dispatcher to register handlers
        qdp = updater.dispatcher
        # on different commands - answer in Telegram
        qdp.add_handler(CommandHandler("start", self.cb_start))
        qdp.add_handler(CommandHandler("auth", self.cb_auth, pass_args=True))
        qdp.add_handler(CommandHandler("graph", self.cb_graph, pass_args=True))
        qdp.add_handler(CommandHandler("set", self._cb_set, pass_args=True))
        qdp.add_handler(
            CommandHandler("getbalance", self._cb_get_balance, pass_args=True))
        qdp.add_handler(
            CommandHandler("enable", self.cb_enable, pass_args=True))
        qdp.add_handler(
            CommandHandler("disable", self.cb_disable, pass_args=True))
        qdp.add_handler(
            CommandHandler("neworder", self.cb_new_order, pass_args=True))
        qdp.add_handler(
            CommandHandler("newalert", self._cb_new_alert, pass_args=True))
        qdp.add_handler(
            CommandHandler("orders", self._cb_orders, pass_args=True))
        qdp.add_handler(CommandHandler("calc", self._cb_calc, pass_args=True))
        qdp.add_handler(CommandHandler("help", self._cb_help, pass_args=True))
        qdp.add_handler(CommandHandler("ticker", self.ticker, pass_args=True))

        update_volume_handler = CallbackQueryHandler(
            self.cb_btn_update_volume,
            pattern=r'^update_volume:[0-9]+$',
            pass_user_data=True)
        new_volume_handler = MessageHandler(Filters.text,
                                            self.cb_new_volume,
                                            pass_user_data=True)
        upvh = ConversationHandler(
            entry_points=[update_volume_handler],
            states={UPDVOLUME: [new_volume_handler]},
            fallbacks=[CommandHandler('cancel', self.cb_cancel)])
        qdp.add_handler(upvh)

        update_price_handler = CallbackQueryHandler(
            self.cb_btn_update_price,
            pattern=r'^update_price:[0-9]+$',
            pass_user_data=True)
        new_price_handler = MessageHandler(Filters.text,
                                           self.cb_new_price,
                                           pass_user_data=True)

        upch = ConversationHandler(
            entry_points=[update_price_handler],
            states={UPDPRICE: [new_price_handler]},
            fallbacks=[CommandHandler('cancel', self.cb_cancel)])

        qdp.add_handler(upch)

        qdp.add_handler(
            CallbackQueryHandler(self.cb_btn_cancel_order,
                                 pattern=r'^cancel_order:[0-9]+$'))
        qdp.add_handler(
            CallbackQueryHandler(self.cb_btn_orders, pattern=r'^orders:\w+$'))

        # log all errors
        qdp.add_error_handler(self.cb_error)

        # Start the Bot
        updater.start_polling(timeout=60, read_latency=0.2)

        # Block until you press Ctrl-C or the process receives SIGINT, SIGTERM or
        # SIGABRT. This should be used most of the time, since start_polling() is
        # non-blocking and will stop the bot gracefully.
        updater.idle()
示例#6
0
def get_xbt_usd():
    """
    Returns the XBT price in terms of USD.
    """
    bfx_cli = Client()
    return float(bfx_cli.ticker("btcusd")["last_price"])