MCPcopy Index your code
hub / github.com/CCob/bittrex4j

github.com/CCob/bittrex4j @1.0.12

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.12 ↗ · + Follow
380 symbols 1,050 edges 54 files 6 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

bittrex4j

bittrex4j Logo
Travis CI Status codecov Maven Version

Java library for accessing the Bittrex Web API's and Web Sockets. It currently uses a mix of v1.1 and the undocumented v2 API.

Where can I get the latest release?

bittrex4j is published on the maven central repository and can be imported into you project using the following maven coordinates.

<dependency>
  <groupId>com.github.ccob</groupId>
  <artifactId>bittrex4j</artifactId>
  <version>1.0.12</version>
</dependency>

Snapshot builds are also available and published to the Sonatype Nexus repository. You need to enable The Sonatype snapshot repository, for example:

  <repositories>
      <repository>
          <id>sonatype-snapshots</id>
          <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
      </repository>
  </repositories>

Then add the latest bittrex4j snapshot to your dependencies section

Examples

Print Markets by Volume (REST API)

package com.github.ccob.bittrex4j.samples;

import com.github.ccob.bittrex4j.BittrexExchange;
import com.github.ccob.bittrex4j.dao.MarketSummaryResult;
import com.github.ccob.bittrex4j.dao.Response;

import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;

import static java.util.Comparator.comparing;

public class PrintMarketsByVolume {

    public static void main(String[] args) throws IOException {

        BittrexExchange bittrexExchange = new BittrexExchange();

        Response<MarketSummaryResult[]> markets = bittrexExchange.getMarketSummaries();

        if(!markets.isSuccess()){
            System.out.println("Failed to fetch available markets with error " + markets.getMessage());
        }

        System.out.println(String.format("Fetched %d available markets",markets.getResult().length));

        Arrays.stream(markets.getResult())
                .sorted(comparing(m -> m.getSummary().getBaseVolume(),Comparator.reverseOrder()))
                .forEachOrdered(m -> System.out.println(String.format("Market Name: %s, Volume %s",m.getMarket().getMarketName(),m.getSummary().getBaseVolume())));

    }
}

Show Realtime Fills(WebSocket API)

package com.github.ccob.bittrex4j.samples;

import com.github.ccob.bittrex4j.BittrexExchange;
import com.github.ccob.bittrex4j.dao.Fill;
import com.github.ccob.bittrex4j.dao.OrderType;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Properties;

public class ShowRealTimeFills {

    public static void main(String[] args) throws IOException {

        System.out.println("Press any key to quit");

        Properties prop = new Properties();
        prop.load(new FileInputStream("test_keys.properties"));

        try(BittrexExchange bittrexExchange = new BittrexExchange(prop.getProperty("apikey"),prop.getProperty("secret"))) {

            bittrexExchange.onUpdateSummaryState(exchangeSummaryState -> {
                if (exchangeSummaryState.getDeltas().length > 0) {

                    Arrays.stream(exchangeSummaryState.getDeltas())
                            .filter(marketSummary -> marketSummary.getMarketName().equals("BTC-BCC") || marketSummary.getMarketName().equals("BTC-ETH"))
                            .forEach(marketSummary -> System.out.println(
                                    String.format("24 hour volume for market %s: %s",
                                            marketSummary.getMarketName(),
                                            marketSummary.getVolume().toString())));
                }
            });

            bittrexExchange.onUpdateExchangeState(updateExchangeState -> {
                double volume = Arrays.stream(updateExchangeState.getFills())
                        .mapToDouble(Fill::getQuantity)
                        .sum();

                if(updateExchangeState.getFills().length > 0) {
                    System.out.println(String.format("N: %d, %02f volume across %d fill(s) for %s", updateExchangeState.getNounce(),
                            volume, updateExchangeState.getFills().length, updateExchangeState.getMarketName()));
                }
            });

            bittrexExchange.onOrderStateChange(orderDelta -> {
                if(orderDelta.getType() == OrderType.Open || orderDelta.getType() == OrderType.Partial){
                    System.out.println(String.format("%s order open with id %s, remaining %.04f", orderDelta.getOrder().getExchange(),
                            orderDelta.getOrder().getOrderUuid(),orderDelta.getOrder().getQuantityRemaining()));
                }else if(orderDelta.getType() == OrderType.Filled ){
                    System.out.println(String.format("%s order with id %s filled, qty %.04f", orderDelta.getOrder().getExchange(),
                            orderDelta.getOrder().getOrderUuid(),orderDelta.getOrder().getQuantity()));
                }else if(orderDelta.getType() == OrderType.Cancelled){
                    System.out.println(String.format("%s order with id %s cancelled", orderDelta.getOrder().getExchange(),
                            orderDelta.getOrder().getOrderUuid()));
                }
            });

            bittrexExchange.onBalanceStateChange(balanceDelta -> {
                System.out.println(String.format("%s wallet balance updated, available: %s, pending: %s", balanceDelta.getBalance().getCurrency(),
                        balanceDelta.getBalance().getAvailable(),balanceDelta.getBalance().getPending()));
            });

            bittrexExchange.connectToWebSocket(() -> {
                bittrexExchange.queryExchangeState("BTC-ETH",exchangeState -> {
                    System.out.println(String.format("BTC-ETH order book has %d open buy orders and %d open sell orders (500 return limit)",exchangeState.getBuys().length, exchangeState.getSells().length));

                });
                bittrexExchange.subscribeToExchangeDeltas("BTC-ETH", null);
                bittrexExchange.subscribeToMarketSummaries(null);
            });

            System.in.read();
        }

        System.out.println("Closing websocket and exiting");
    }
}

Show Deposit History for BTC (Authenticated REST API)

package com.github.ccob.bittrex4j.samples;

import com.github.ccob.bittrex4j.BittrexExchange;
import com.github.ccob.bittrex4j.dao.Response;
import com.github.ccob.bittrex4j.dao.WithdrawalDeposit;

import java.io.IOException;
import java.util.Arrays;

public class PrintDepositHistory {

    /* Replace apikey and secret values below */
    private static final String apikey = "*";
    private static final String secret = "*";

    public static void main(String[] args) throws IOException {

        BittrexExchange bittrexExchange = new BittrexExchange(5, apikey,secret);

        Response<WithdrawalDeposit[]> markets = bittrexExchange.getDepositHistory("BTC");

        if(!markets.isSuccess()){
            System.out.println("Failed to fetch deposit history with error " + markets.getMessage());
        }

        Arrays.stream(markets.getResult())
                .forEach(deposit -> System.out.println(String.format("Address %s, Amount %02f",deposit.getAddress(),deposit.getAmount())));

    }
}

Thanks

Thanks to platelminto for the java-bittrex project and dparlevliet for the node.bittrex.api where both have been used for inspiration.

Donations

Donation welcome: * BTC 1PXx92jaFZF92jLg64GF7APAsVCU4Tsogx * UBQ 0xAa14EdE8541d1022121a39892821f271A9cdAF33 * ETH 0xC7DC0CADbb497d3e11379c7A2aEE8b08bEc9F30b

Extension points exported contracts — how you extend this code

UpdateSummaryStateListener (Interface)
(no doc) [1 implementers]
src/main/java/com/github/ccob/bittrex4j/listeners/UpdateSummaryStateListener.java
Listener (Interface)
(no doc) [1 implementers]
src/main/java/com/github/ccob/bittrex4j/listeners/Listener.java
UpdateExchangeStateListener (Interface)
(no doc) [1 implementers]
src/main/java/com/github/ccob/bittrex4j/listeners/UpdateExchangeStateListener.java
InvocationResult (Interface)
(no doc)
src/main/java/com/github/ccob/bittrex4j/listeners/InvocationResult.java

Core symbols most depended-on inside this repo

withArgument
called by 31
src/main/java/com/github/ccob/bittrex4j/UrlBuilder.java
isSuccess
called by 31
src/main/java/com/github/ccob/bittrex4j/dao/Response.java
getResult
called by 31
src/main/java/com/github/ccob/bittrex4j/dao/Response.java
getResponse
called by 26
src/main/java/com/github/ccob/bittrex4j/BittrexExchange.java
withGroup
called by 26
src/main/java/com/github/ccob/bittrex4j/UrlBuilder.java
withMethod
called by 26
src/main/java/com/github/ccob/bittrex4j/UrlBuilder.java
v1_1
called by 19
src/main/java/com/github/ccob/bittrex4j/UrlBuilder.java
getKey
called by 16
src/main/java/com/github/ccob/bittrex4j/ApiKeySecret.java

Shape

Method 323
Class 50
Interface 4
Enum 3

Languages

Java100%

Modules by API surface

src/main/java/com/github/ccob/bittrex4j/BittrexExchange.java53 symbols
src/test/java/com/github/ccob/bittrex4j/BittrexExchangeTest.java37 symbols
src/main/java/com/github/ccob/bittrex4j/dao/Order.java27 symbols
src/main/java/com/github/ccob/bittrex4j/dao/WithdrawalDeposit.java15 symbols
src/main/java/com/github/ccob/bittrex4j/dao/MarketSummary.java15 symbols
src/main/java/com/github/ccob/bittrex4j/dao/Market.java14 symbols
src/main/java/com/github/ccob/bittrex4j/dao/Balance.java12 symbols
src/main/java/com/github/ccob/bittrex4j/dao/WalletHealth.java11 symbols
src/main/java/com/github/ccob/bittrex4j/UrlBuilder.java11 symbols
src/main/java/com/github/ccob/bittrex4j/dao/Fill.java10 symbols
src/main/java/com/github/ccob/bittrex4j/dao/Currency.java10 symbols
src/main/java/com/github/ccob/bittrex4j/dao/Tick.java9 symbols

For agents

$ claude mcp add bittrex4j \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page