Esempio n. 1
0
async def run():
    api_key = os.environ['BITVAVOAPIKEY']
    sec_key = os.environ['BITVAVOSECKEY']

    client = CryptoXLib.create_bitvavo_client(api_key, sec_key)

    print("Time:")
    await client.get_time()

    print("Exchange info:")
    await client.get_exchange_info()

    print("Assets:")
    await client.get_assets()

    print("Open orders:")
    await client.get_open_orders()

    print("Create order:")
    try:
        await client.create_order(pair = Pair("BTC", "EUR"), side = enums.OrderSide.BUY, type = enums.OrderType.LIMIT,
                                  amount = "10000", price = "1")
    except BitvavoException as e:
        print(e)

    print("Cancel order:")
    try:
        await client.cancel_order(pair = Pair("BTC", "EUR"), order_id = "1")
    except BitvavoException as e:
        print(e)

    print("Balance:")
    await client.get_balance()

    await client.close()
Esempio n. 2
0
async def run():
    # to retrieve your API/SEC key go to your bitforex account, create the keys and store them in
    # BITFOREXAPIKEY/BITFOREXSECKEY environment variables
    api_key = os.environ['BITFOREXAPIKEY']
    sec_key = os.environ['BITFOREXSECKEY']

    bitforex = CryptoXLib.create_bitforex_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    bitforex.compose_subscriptions([
        OrderBookSubscription(pair=Pair('ETH', 'BTC'),
                              depth="0",
                              callbacks=[order_book_update]),
        OrderBookSubscription(pair=Pair('ETH', 'USDT'),
                              depth="0",
                              callbacks=[order_book_update2]),
        TradeSubscription(pair=Pair('ETH', 'BTC'),
                          size="2",
                          callbacks=[trade_update]),
    ])

    # Bundle subscriptions into a separate websocket
    bitforex.compose_subscriptions([
        TickerSubscription(pair=Pair('BTC', 'USDT'),
                           size="2",
                           interval=enums.CandlestickInterval.I_1MIN,
                           callbacks=[ticker_update]),
        Ticker24hSubscription(pair=Pair('BTC', 'USDT'),
                              callbacks=[ticker24_update])
    ])

    # Execute all websockets asynchronously
    await bitforex.start_websockets()

    await bitforex.close()
Esempio n. 3
0
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_client(api_key, sec_key)

    print("BLVT symbol info:")
    await client.get_blvt_info()

    print("Subscribe BTCUP:")
    try:
        await client.blvt_subscribe("BTCUP", "500000000")
    except Exception as e:
        print(e)

    print("Subscription history:")
    await client.get_blvt_subscribtion_record()

    print("Redeem BTCUP:")
    try:
        await client.blvt_redeem("BTCUP", "500000000")
    except Exception as e:
        print(e)

    print("Redemption history:")
    await client.get_blvt_redemption_record()

    print("BLVT user limits:")
    await client.get_blvt_user_info()

    await client.close()
Esempio n. 4
0
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_usds_m_futures_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        OrderBookTickerSubscription(callbacks=[orderbook_ticker_update]),
        OrderBookSymbolTickerSubscription(symbol=Pair("BTC", "USDT"),
                                          callbacks=[orderbook_ticker_update]),
        CandlestickSubscription(interval=Interval.I_1MIN,
                                symbol=Pair('BTC', 'USDT'),
                                callbacks=[candlestick_update])
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        AccountSubscription(callbacks=[account_update]),
        CompositeIndexSubscription(pair=Pair('DEFI', 'USDT'))
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()

    await client.close()
Esempio n. 5
0
async def run():
    api_key = os.environ['BIBOXAPIKEY']
    sec_key = os.environ['BIBOXSECKEY']

    bibox = CryptoXLib.create_bibox_client(api_key, sec_key)

    print("Ping:")
    await bibox.get_ping()

    print("Pair list:")
    await bibox.get_pairs()

    print("Exchange info:")
    await bibox.get_exchange_info()

    print("User assets:")
    await bibox.get_spot_assets(full=True)

    print("Create order:")
    try:
        await bibox.create_order(pair=Pair('ETH', 'BTC'),
                                 order_type=enums.OrderType.LIMIT,
                                 order_side=enums.OrderSide.BUY,
                                 price="1",
                                 quantity="1")
    except BiboxException as e:
        print(e)

    print("Cancel order:")
    await bibox.cancel_order(order_id="1234567890")

    await bibox.close()
Esempio n. 6
0
async def run():
    api_key = os.environ['BITPANDAAPIKEY']

    client = CryptoXLib.create_bitpanda_client(api_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        AccountSubscription(callbacks = [account_update]),
        PricesSubscription([Pair("BTC", "EUR")]),
        OrderbookSubscription([Pair("BTC", "EUR")], "50", callbacks = [order_book_update]),
        CandlesticksSubscription([CandlesticksSubscriptionParams(Pair("BTC", "EUR"), TimeUnit.MINUTES, 1)]),
        MarketTickerSubscription([Pair("BTC", "EUR")])
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        OrderbookSubscription([Pair("ETH", "EUR")], "3", callbacks = [order_book_update]),
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        TradingSubscription(callbacks = [trading_update]),
        OrdersSubscription(callbacks = [orders_update]),
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()
Esempio n. 7
0
async def run():
    api_key = os.environ['ETERBASEAPIKEY']
    sec_key = os.environ['ETERBASESECKEY']
    acct_key = os.environ['ETERBASEACCTKEY']

    client = CryptoXLib.create_eterbase_client(acct_key, api_key, sec_key)

    markets = await client.get_markets()
    ethusdt_id = get_market_id(markets, 'ETHUSDT')
    xbaseebase_id = get_market_id(markets, 'XBASEEBASE')

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        OrderbookSubscription([ethusdt_id, xbaseebase_id],
                              callbacks=[order_book_update]),
        TradesSubscription([ethusdt_id, xbaseebase_id],
                           callbacks=[trades_update]),
        OHLCVSubscription([ethusdt_id, xbaseebase_id],
                          callbacks=[ohlcv_update]),
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        AccountSubscription([ethusdt_id, xbaseebase_id],
                            callbacks=[account_update]),
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()
Esempio n. 8
0
async def run():
    api_key = os.environ['AAXAPIKEY']
    sec_key = os.environ['AAXSECKEY']

    aax = CryptoXLib.create_bitforex_client(api_key, sec_key)

    print("Exchange info:")
    await aax.get_exchange_info()

    await aax.close()
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_coin_m_futures_client(api_key, sec_key)

    print("Ping:")
    await client.ping()

    print("Server time:")
    await client.get_time()

    print("Exchange info:")
    await client.get_exchange_info()

    print("Order book:")
    await client.get_orderbook(symbol='BTCUSD_PERP',
                               limit=enums.DepthLimit.L_5)

    print("Trades:")
    await client.get_trades(symbol='BTCUSD_PERP', limit=5)

    print("Historical trades:")
    await client.get_historical_trades(symbol='BTCUSD_PERP', limit=5)

    print("Aggregate trades:")
    await client.get_aggregate_trades(symbol='BTCUSD_PERP', limit=5)

    print("Index price candlesticks:")
    await client.get_index_price_candlesticks(pair=Pair('BTC', 'USD'),
                                              interval=enums.Interval.I_1MIN)

    print("24hour price ticker:")
    await client.get_24h_price_ticker(pair=Pair('BTC', 'USD'))

    print("Price ticker:")
    await client.get_price_ticker(pair=Pair('BTC', 'USD'))

    print("Best order book ticker:")
    await client.get_orderbook_ticker(pair=Pair('BTC', 'USD'))

    print("Create limit order:")
    try:
        await client.create_order(
            symbol='BTCUSD_PERP',
            side=enums.OrderSide.BUY,
            type=enums.OrderType.LIMIT,
            quantity="1",
            price="0",
            time_in_force=enums.TimeInForce.GOOD_TILL_CANCELLED,
            new_order_response_type=enums.OrderResponseType.FULL)
    except BinanceException as e:
        print(e)

    await client.close()
Esempio n. 10
0
async def run():
    api_key = os.environ['LIQUIDAPIKEY']
    sec_key = os.environ['LIQUIDSECKEY']

    liquid = CryptoXLib.create_liquid_client(api_key, sec_key)

    print("Products:")
    products = await liquid.get_products()
    for product in products['response']:
        if product['currency_pair_code'] == 'ETHBTC':
            print(json.dumps(product, indent = 4, sort_keys = True))

    print("Product:")
    product = await liquid.get_product(product_id = "1")
    print(json.dumps(product['response'], indent = 4, sort_keys = True))

    print("Orderbook:")
    await liquid.get_order_book("1")

    print("Order:")
    try:
        await liquid.get_order("1")
    except LiquidException as e:
        print(e)

    print("Create order:")
    try:
        await liquid.create_order(product_id = "1", order_side = enums.OrderSide.BUY, order_type = enums.OrderType.LIMIT, quantity = "0",
                                  price = "1")
    except LiquidException as e:
        print(e)

    print("Cancel order:")
    try:
        await liquid.cancel_order(order_id = "1")
    except LiquidException as e:
        print(e)

    print("Crypto accounts:")
    await liquid.get_crypto_accounts()

    print("Fiat accounts:")
    await liquid.get_fiat_accounts()

    print("Account details:")
    await liquid.get_account_details(currency = "BTC")

    print("Currencies:")
    currencies = await liquid.get_currencies()
    for currency in currencies['response']:
        if currency['currency'] in ['BTC', 'ETH', 'USD', 'QASH']:
            print(json.dumps(currency, indent = 4))

    await liquid.close()
Esempio n. 11
0
async def run():
    api_key = os.environ['BTSEAPIKEY']
    sec_key = os.environ['BTSESECKEY']

    client = CryptoXLib.create_btse_client(api_key, sec_key)

    print("Exchange details:")
    await client.get_exchange_info(pair=Pair('BTC', 'USD'))

    print("Account funds:")
    await client.get_funds()

    await client.close()
Esempio n. 12
0
async def run():
    api_key = os.environ['BITPANDAAPIKEY']

    client = CryptoXLib.create_coinmate_client(api_key, "", "")

    print("Trading pairs:")
    await client.get_exchange_info()

    print("Currency pairs:")
    await client.get_currency_pairs()

    print("Ticker:")
    await client.get_ticker(pair = Pair('BTC', 'EUR'))

    await client.close()
async def run():
    api_key = os.environ['HITBTCAPIKEY']
    sec_key = os.environ['HITBTCSECKEY']

    client = CryptoXLib.create_hitbtc_client(api_key, sec_key)

    print("Account balance:")
    await client.get_balance()

    print("Symbols:")
    await client.get_symbols()

    print("Orderbook:")
    await client.get_order_book(pair=Pair("ETH", "BTC"), limit=2)

    await client.close()
Esempio n. 14
0
async def run():
    api_key = os.environ['LIQUIDAPIKEY']
    sec_key = os.environ['LIQUIDSECKEY']

    liquid = CryptoXLib.create_liquid_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    liquid.compose_subscriptions([
        OrderBookSideSubscription(pair = Pair('BTC', 'USD'), order_side = enums.OrderSide.BUY, callbacks = [order_book_update]),
        OrderBookSubscription(pair = Pair('ETH', 'USD'), callbacks = [order_book_update2]),
        OrderBookSubscription(pair = Pair('XRP', 'USD'), callbacks = [order_book_update3]),
        OrderSubscription(quote = "USD", callbacks = [order_update])
    ])

    # Execute all websockets asynchronously
    await liquid.start_websockets()

    await liquid.close()
Esempio n. 15
0
async def run():
    #api_key = os.environ['BIBOXEUROPEAPIKEY']
    #sec_key = os.environ['BIBOXEUROPESECKEY']
    api_key = ""
    sec_key = ""

    bibox = CryptoXLib.create_bibox_europe_client(api_key, sec_key)

    bibox.compose_subscriptions([
        OrderBookSubscription(pair=Pair('ETH', 'BTC'),
                              callbacks=[order_book_update]),
        OrderBookSubscription(pair=Pair('BTC', 'EUR'),
                              callbacks=[order_book_update]),
    ])

    # Execute all websockets asynchronously
    await bibox.start_websockets()

    await bibox.close()
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_client(api_key, sec_key)

    print("All margin assets:")
    await client.get_margin_all_assets()

    print("Margin pair:")
    await client.get_margin_pair(Pair('BTC', 'USDT'))

    print("Margin price index:")
    await client.get_margin_price_index(Pair('BTC', 'USDT'))

    print("Margin account balance:")
    await client.get_margin_account()

    await client.close()
Esempio n. 17
0
async def run():
    api_key = os.environ['BIBOXAPIKEY']
    sec_key = os.environ['BIBOXSECKEY']

    bibox = CryptoXLib.create_bibox_client(api_key, sec_key)

    bibox.compose_subscriptions([
        OrderBookSubscription(pair=Pair('BTC', 'USDT'),
                              callbacks=[order_book_update]),
    ])

    bibox.compose_subscriptions([
        TradeSubscription(pair=Pair('BTC', 'USDT'), callbacks=[trade_update]),
    ])

    # Execute all websockets asynchronously
    await bibox.start_websockets()

    await bibox.close()
async def run():
    api_key = os.environ['ETERBASEAPIKEY']
    sec_key = os.environ['ETERBASESECKEY']
    acct_key = os.environ['ETERBASEACCTKEY']

    client = CryptoXLib.create_eterbase_client(acct_key, api_key, sec_key)

    print("Time:")
    response = await client.get_ping()
    print(f"Headers: {response['headers']}")

    print("Currencies:")
    await client.get_currencies()

    print("Markets:")
    markets = await client.get_markets()

    print("Balances:")
    try:
        await client.get_balances()
    except EterbaseException as e:
        print(e)

    print("Create market order:")
    try:
        await client.create_order(
            pair_id=get_market_id(markets, 'ETHUSDT'),
            side=enums.OrderSide.BUY,
            type=enums.OrderType.LIMIT,
            amount="100000",
            price="1",
            time_in_force=enums.TimeInForce.GOOD_TILL_CANCELLED)
    except EterbaseException as e:
        print(e)

    print("Cancel order:")
    try:
        await client.cancel_order(order_id=str(uuid.uuid4()))
    except EterbaseException as e:
        print(e)

    await client.close()
Esempio n. 19
0
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_client(api_key, sec_key)

    print('Swap pools:')
    await client.get_bswap_pools()

    print('Swap liquidity:')
    await client.get_bswap_liquidity()

    print('Add liquidity:')
    try:
        await client.bswap_add_liquidity(0, 'BTC', '10000000')
    except Exception as e:
        print(e)

    print('Remove liquidity:')
    try:
        await client.bswap_remove_liquidity(
            0, 'BTC', '10000000', type=enums.LiquidityRemovalType.COMBINATION)
    except Exception as e:
        print(e)

    print('Liquidity history:')
    await client.get_bswap_liquidity_operations()

    print('Request quote:')
    await client.get_bswap_quote(Pair('BTC', 'USDT'), '1000')

    print('Swap:')
    try:
        await client.bswap_swap(Pair('BTC', 'USDT'), '100000000000')
    except Exception as e:
        print(e)

    print('Swap hisotry:')
    await client.get_bswap_swap_history()

    await client.close()
Esempio n. 20
0
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_client(api_key, sec_key)

    # initialize three independent websockets
    sub.subscription_set_ids.append(
        client.compose_subscriptions(sub.subscriptions[0]))
    sub.subscription_set_ids.append(
        client.compose_subscriptions(sub.subscriptions[1]))
    sub.subscription_set_ids.append(
        client.compose_subscriptions(sub.subscriptions[2]))

    try:
        await asyncio.gather(*[client.start_websockets(), main_loop(client)])
    except Exception as e:
        print(f"Out: {e}")

    await client.close()
    print("Exiting.")
Esempio n. 21
0
async def run():
    api_key = os.environ['BITVAVOAPIKEY']
    sec_key = os.environ['BITVAVOSECKEY']

    client = CryptoXLib.create_bitvavo_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        AccountSubscription(pairs = [Pair("BTC", "EUR")]),
        TickerSubscription([Pair("BTC", "EUR")], callbacks = [ticker_update]),
        Ticker24Subscription([Pair("BTC", "EUR")], callbacks = [ticker24_update]),
        OrderbookSubscription([Pair("BTC", "EUR")], callbacks = [order_book_update]),
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        CandlesticksSubscription(pairs = [Pair("BTC", "EUR")], intervals = [enums.CandelstickInterval.I_1MIN])
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()
Esempio n. 22
0
async def run():
    api_key = os.environ['BTSEAPIKEY']
    sec_key = os.environ['BTSESECKEY']

    client = CryptoXLib.create_btse_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        AccountSubscription(),
        OrderbookL2Subscription(
            [Pair("BTC", "USD"), Pair('ETH', 'BTC')], depth=1)
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        OrderbookSubscription([Pair('BTSE', 'BTC')],
                              callbacks=[order_book_update]),
        TradeSubscription([Pair('BTSE', 'BTC')])
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()
Esempio n. 23
0
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        BestOrderBookTickerSubscription(callbacks=[orderbook_ticker_update]),
        BestOrderBookSymbolTickerSubscription(
            pair=Pair("BTC", "USDT"), callbacks=[orderbook_ticker_update]),
        TradeSubscription(pair=Pair('ETH', 'BTC'), callbacks=[trade_update])
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions(
        [AccountSubscription(callbacks=[account_update])])

    # Execute all websockets asynchronously
    await client.start_websockets()

    await client.close()
Esempio n. 24
0
async def run():
    api_key = os.environ['HITBTCAPIKEY']
    sec_key = os.environ['HITBTCSECKEY']

    client = CryptoXLib.create_hitbtc_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        AccountSubscription(callbacks=[account_update]),
        OrderbookSubscription(pair=Pair("ETH", "BTC"),
                              callbacks=[order_book_update]),
        TickerSubscription(pair=Pair("BTC", "USD"), callbacks=[ticker_update])
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        TradesSubscription(pair=Pair("ETH", "BTC"),
                           limit=5,
                           callbacks=[trade_update])
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()
Esempio n. 25
0
async def run():
    api_key = os.environ['COINMATEAPIKEY']
    sec_key = os.environ['COINMATESECKEY']
    user_id = os.environ['COINMATEUSERID']

    client = CryptoXLib.create_coinmate_client(user_id, api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        OrderbookSubscription(Pair("BTC", "EUR"), callbacks = [order_book_update]),
        TradesSubscription(Pair("BTC", "EUR"), callbacks = [trades_update])
    ])

    # Bundle private subscriptions into a separate websocket
    client.compose_subscriptions([
        UserOrdersSubscription(callbacks = [account_update]),
        UserTradesSubscription(callbacks = [account_update]),
        UserTransfersSubscription(callbacks = [account_update]),
        BalancesSubscription(callbacks = [account_update])
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()
Esempio n. 26
0
async def run():
    api_key = os.environ['APIKEY']
    sec_key = os.environ['SECKEY']

    client = CryptoXLib.create_binance_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    client.compose_subscriptions([
        CandlestickSubscription(Pair('BTC', 'USDT'),
                                Interval.I_1MIN,
                                callbacks=[candlestick_update])
    ])

    # Bundle another subscriptions into a separate websocket
    client.compose_subscriptions([
        # uncomment if isolated margin account is setup
        #AccountIsolatedMarginSubscription(pair = Pair('BTC', 'USDT'), callbacks = [account_update]),
        AccountCrossMarginSubscription(callbacks=[account_update])
    ])

    # Execute all websockets asynchronously
    await client.start_websockets()

    await client.close()
Esempio n. 27
0
async def run():
    # to retrieve your API/SEC key go to your bitforex account, create the keys and store them in
    # BITFOREXAPIKEY/BITFOREXSECKEY environment variables
    api_key = os.environ['AAXAPIKEY']
    sec_key = os.environ['AAXSECKEY']
    user_id = os.environ['AAXUSERID']

    aax = CryptoXLib.create_aax_client(api_key, sec_key)

    # Bundle several subscriptions into a single websocket
    aax.compose_subscriptions([
        OrderBookSubscription(pair = Pair('BTC', 'USDT'), depth = 20, callbacks = [order_book_update]),
        OrderBookSubscription(pair = Pair('ETH', 'USDT'), depth = 20, callbacks = [order_book_update2]),
    ])

    # Bundle subscriptions into a separate websocket
    aax.compose_subscriptions([
        AccountSubscription(user_id)
    ])

    # Execute all websockets asynchronously
    await aax.start_websockets()

    await aax.close()
Esempio n. 28
0
async def run():
    api_key = os.environ['BITPANDAAPIKEY']

    client = CryptoXLib.create_bitpanda_client(api_key)

    print("Time:")
    response = await client.get_time()
    print(f"Headers: {response['headers']}")

    print("Account balance:")
    await client.get_account_balances()

    print("Account orders:")
    await client.get_account_orders()

    print("Account order:")
    try:
        await client.get_account_order("1")
    except BitpandaException as e:
        print(e)

    print("Create market order:")
    try:
        await client.create_market_order(Pair("BTC", "EUR"), OrderSide.BUY, "10000")
    except BitpandaException as e:
        print(e)

    print("Create limit order:")
    try:
        await client.create_limit_order(Pair("BTC", "EUR"), OrderSide.BUY, "10000", "1")
    except BitpandaException as e:
        print(e)

    print("Create stop loss order:")
    try:
        await client.create_stop_limit_order(Pair("BTC", "EUR"), OrderSide.BUY, "10000", "1", "1")
    except BitpandaException as e:
        print(e)

    print("Delete order:")
    try:
        await client.delete_account_order("1")
    except BitpandaException as e:
        print(e)

    print("Order trades:")
    try:
        await client.get_account_order_trades("1")
    except BitpandaException as e:
        print(e)

    print("Trades:")
    await client.get_account_trades()

    print("Trade:")
    try:
        await client.get_account_trade("1")
    except BitpandaException as e:
        print(e)

    print("Trading volume:")
    await client.get_account_trading_volume()

    print("Currencies:")
    await client.get_currencies()

    print("Candlesticks:")
    await client.get_candlesticks(Pair("BTC", "EUR"), TimeUnit.DAYS, "1",
                                  datetime.datetime.now() - datetime.timedelta(days = 7), datetime.datetime.now())

    print("Fees:")
    await client.get_account_fees()

    print("Instruments:")
    await client.get_instruments()

    print("Order book:")
    await client.get_order_book(Pair("BTC", "EUR"))

    await client.close()
Esempio n. 29
0
 def initialize(cls) -> None:
     cls.client = CryptoXLib.create_bitpanda_client(api_key)
     cls.print_logs = True
     cls.log_level = logging.DEBUG
Esempio n. 30
0
async def run():
    api_key = os.environ['BITPANDAAPIKEY']

    client = CryptoXLib.create_bitpanda_client(api_key)

    candles = await client.get_candlesticks(
        Pair('BTC', 'EUR'), enums.TimeUnit.DAYS, "1",
        datetime.datetime.now() - datetime.timedelta(days=1500),
        datetime.datetime.now())
    candles = candles['response']
    close = [float(x['close']) for x in candles]
    ohlcv = [
        OHLCV(float(x['open']), float(x['high']), float(x['low']),
              float(x['close']), float(x['volume'])) for x in candles
    ]
    print(f"Last OHLCV: {ohlcv[-1]}")

    print(f'AccuDist: {AccuDist(ohlcv)[-1]}')
    print(f'ADX: {ADX(14, 14, ohlcv)[-1]}')
    print(f'ALMA: {ALMA(9, 0.85, 6, close)[-1]}')
    print(f'AO: {AO(5, 34, ohlcv)[-1]}')
    print(f'Aroon: {Aroon(4, ohlcv)[-1]}')
    print(f'ATR: {ATR(14, ohlcv)[-1]}')
    print(f'BB: {BB(20, 2, close)[-1]}')
    print(f'BOP: {BOP(ohlcv)[-1]}')
    print(f'CCI: {CCI(20, ohlcv)[-1]}')
    print(f'ChaikinOsc: {ChaikinOsc(3, 10, ohlcv)[-1]}')
    print(f'ChandeKrollStop: {ChandeKrollStop(10, 2, 9, ohlcv)[-5:]}')
    print(f'CHOP: {CHOP(14, ohlcv)[-5:]}')
    print(f'CoppockCurve: {CoppockCurve(11, 14, 10, close)[-1]}')
    print(f'DEMA: {DEMA(20, close)[-1]}')
    print(f'DonchianChannels: {DonchianChannels(20, ohlcv)[-1]}')
    print(f'DPO: {DPO(20, close)[-1]}')
    print(f'EMA: {EMA(20, close)[-1]}')
    print(f'EMV: {EMV(14, 10000, ohlcv)[-1]}')
    print(f'ForceIndex: {ForceIndex(13, ohlcv)[-1]}')
    print(f'HMA: {HMA(9, close)[-1]}')
    print(f'Ichimoku: {Ichimoku(26, 9, 52, 52, 26, ohlcv)[-1]}')
    print(f'KAMA: {KAMA(14, 2, 30, close)[-1]}')
    print(f'KeltnerChannels: {KeltnerChannels(20, 26, 1, 1, ohlcv)[-1]}')
    print(f'KST: {KST(10, 10, 15, 10, 20, 10, 30, 15, 9, close)[-1]}')
    print(f'KVO: {KVO(34, 55, ohlcv)[-5:]}')
    print(f'MACD: {MACD(12, 26, 9, close)[-1]}')
    print(f'MassIndex: {MassIndex(9, 9, 10, ohlcv)[-1]}')
    print(f'McGinleyDynamic: {McGinleyDynamic(14, close)[-1]}')
    print(f'MeanDev: {MeanDev(10, close)[-1]}')
    print(f'OBV: {OBV(ohlcv)[-1]}')
    print(f'Pivots: {PivotsHL(15, 15, ohlcv)[-4:]}')
    print(f'ROC: {ROC(9, close)[-1]}')
    print(f'RSI: {RSI(14, close)[-1]}')
    print(f"SAR: {ParabolicSAR(0.02, 0.02, 0.2, ohlcv)[-20:]}")
    print(f'SFX: {SFX(12, 12, 3, ohlcv)[-1]}')
    print(f'SMA: {SMA(20, close)[-1]}')
    print(f'SMMA: {SMMA(7, close)[-1]}')
    print(f'SOBV: {SOBV(7, ohlcv)[-1]}')
    print(f'StdDev: {StdDev(7, close)[-1]}')
    print(f'Stoch: {Stoch(14, 3, ohlcv)[-1]}')
    print(f'StochRSI: {StochRSI(14, 14, 3, 3, close)[-1]}')
    print(f'TEMA: {TEMA(20, close)[-1]}')
    print(f'TRIX: {TRIX(18, close)[-1]}')
    print(f'TSI: {TSI(13, 25, close)[-1]}')
    print(f'UO: {UO(7, 14, 28, ohlcv)[-1]}')
    print(f'VTX: {VTX(14, ohlcv)[-1]}')
    print(f'VWMA: {VWMA(20, ohlcv)[-1]}')
    print(f'WMA: {WMA(9, close)[-1]}')

    await client.close()