diff --git a/examples/hitbtc_rest_apy.py b/examples/hitbtc_rest_apy.py index d606d14..5569843 100644 --- a/examples/hitbtc_rest_apy.py +++ b/examples/hitbtc_rest_apy.py @@ -5,8 +5,6 @@ from cryptoxlib.CryptoXLib import CryptoXLib from cryptoxlib.Pair import Pair -from cryptoxlib.clients.bitpanda.exceptions import BitpandaException -from cryptoxlib.clients.bitpanda.enums import OrderSide, TimeUnit LOG = logging.getLogger("cryptoxlib") LOG.setLevel(logging.DEBUG) @@ -19,83 +17,19 @@ async def order_book_update(response: dict) -> None: print(f"Callback order_book_update: [{response}]") async def run(): - api_key = os.environ['BITPANDAAPIKEY'] + api_key = os.environ['HITBTCAPIKEY'] + sec_key = os.environ['HITBTCSECKEY'] - client = CryptoXLib.create_bitpanda_client(api_key) - - print("Time:") - response = await client.get_time() - print(f"Headers: {response['headers']}") + client = CryptoXLib.create_hitbtc_client(api_key, sec_key) 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() + await client.get_balance() - print("Instruments:") - await client.get_instruments() + print("Symbols:") + await client.get_symbols() - print("Order book:") - await client.get_order_book(Pair("BTC", "EUR")) + print("Orderbook:") + await client.get_order_book(pair = Pair("ETH", "BTC"), limit = 2) await client.close() diff --git a/examples/hitbtc_ws.py b/examples/hitbtc_ws.py index 61d9702..960149f 100644 --- a/examples/hitbtc_ws.py +++ b/examples/hitbtc_ws.py @@ -4,9 +4,8 @@ from cryptoxlib.CryptoXLib import CryptoXLib from cryptoxlib.Pair import Pair -from cryptoxlib.clients.bitpanda.enums import TimeUnit -from cryptoxlib.clients.bitpanda.BitpandaWebsocket import AccountSubscription, PricesSubscription, \ - OrderbookSubscription, CandlesticksSubscription, CandlesticksSubscriptionParams, MarketTickerSubscription +from cryptoxlib.clients.hitbtc.HitbtcWebsocket import TickerSubscription, OrderbookSubscription, TradesSubscription, \ + AccountSubscription LOG = logging.getLogger("cryptoxlib") LOG.setLevel(logging.DEBUG) @@ -18,24 +17,29 @@ async def order_book_update(response: dict) -> None: print(f"Callback order_book_update: [{response}]") +async def ticker_update(response: dict) -> None: + print(f"Callback ticker_update: [{response}]") + +async def trade_update(response: dict) -> None: + print(f"Callback trade_update: [{response}]") + async def run(): - api_key = os.environ['BITPANDAAPIKEY'] + api_key = os.environ['HITBTCAPIKEY'] + sec_key = os.environ['HITBTCSECKEY'] - client = CryptoXLib.create_bitpanda_client(api_key) + client = CryptoXLib.create_hitbtc_client(api_key, sec_key) # Bundle several subscriptions into a single websocket client.compose_subscriptions([ AccountSubscription(), - 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")]) + OrderbookSubscription(pair = Pair("BTC", "USD"), callbacks = [order_book_update]), + TickerSubscription(pair = Pair("BTC", "USD"), callbacks = [ticker_update]) ]) # Bundle another subscriptions into a separate websocket client.compose_subscriptions([ - OrderbookSubscription([Pair("ETH", "EUR")], "3", callbacks = [order_book_update]), + TradesSubscription(pair = Pair("ETH", "BTC"), limit = 5,callbacks = [trade_update]) ]) # Execute all websockets asynchronously