Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 3
0
 def initialize(cls) -> None:
     cls.client = CryptoXLib.create_bitforex_client(api_key, sec_key)
     cls.print_logs = True
     cls.log_level = logging.DEBUG
Exemplo n.º 4
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)

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

    print("Order book:")
    await bitforex.get_order_book(pair=Pair('ETH', 'BTC'), depth="1")

    print("Ticker:")
    await bitforex.get_ticker(pair=Pair('ETH', 'BTC'))

    print("Single fund:")
    await bitforex.get_single_fund(currency="NOBS")

    print("Funds:")
    await bitforex.get_funds()

    print("Trades:")
    await bitforex.get_trades(pair=Pair('ETH', 'BTC'), size="1")

    print("Candlesticks:")
    await bitforex.get_candlesticks(pair=Pair('ETH', 'BTC'),
                                    interval=enums.CandlestickInterval.I_1W,
                                    size="5")

    print("Create order:")
    try:
        await bitforex.create_order(Pair("ETH", "BTC"),
                                    side=enums.OrderSide.SELL,
                                    quantity="1",
                                    price="1")
    except BitforexException as e:
        print(e)

    print("Create multiple orders:")
    await bitforex.create_multi_order(Pair("ETH", "BTC"),
                                      orders=[("1", "1", enums.OrderSide.SELL),
                                              ("2", "1", enums.OrderSide.SELL)
                                              ])

    print("Cancel order:")
    await bitforex.cancel_order(pair=Pair('ETH', 'BTC'), order_id="10")

    print("Cancel multiple orders:")
    await bitforex.cancel_multi_order(pair=Pair('ETH', 'BTC'),
                                      order_ids=["10", "20"])

    print("Cancel all orders:")
    await bitforex.cancel_all_orders(pair=Pair('ETH', 'BTC'))

    print("Get order:")
    try:
        await bitforex.get_order(pair=Pair('ETH', 'BTC'), order_id="1")
    except BitforexException as e:
        print(e)

    print("Get orders:")
    await bitforex.get_orders(pair=Pair('ETH', 'BTC'), order_ids=["1", "2"])

    print("Find orders:")
    await bitforex.find_order(pair=Pair('ETH', 'BTC'),
                              state=enums.OrderState.PENDING)

    await bitforex.close()
Exemplo n.º 5
0
 async def init_test(self):
     self.client = CryptoXLib.create_bitforex_client(api_key, sec_key)