com.codemonkeylab.idex:java-api-idex

JAVA wrapper of the IDEX market interface

License

License

Categories

Categories

IDE Development Tools Java Languages KeY Data Data Formats Formal Verification Dex General Purpose Libraries Utility
GroupId

GroupId

com.codemonkeylab.idex
ArtifactId

ArtifactId

java-api-idex
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.codemonkeylab.idex:java-api-idex
JAVA wrapper of the IDEX market interface
Project URL

Project URL

https://github.com/CodeMonkeyLab/java-api-idex/
Source Code Management

Source Code Management

https://github.com/CodeMonkeyLab/java-api-idex

Download java-api-idex

How to add to project

<!-- https://jarcasting.com/artifacts/com.codemonkeylab.idex/java-api-idex/ -->
<dependency>
    <groupId>com.codemonkeylab.idex</groupId>
    <artifactId>java-api-idex</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.codemonkeylab.idex/java-api-idex/
implementation 'com.codemonkeylab.idex:java-api-idex:0.1.0'
// https://jarcasting.com/artifacts/com.codemonkeylab.idex/java-api-idex/
implementation ("com.codemonkeylab.idex:java-api-idex:0.1.0")
'com.codemonkeylab.idex:java-api-idex:jar:0.1.0'
<dependency org="com.codemonkeylab.idex" name="java-api-idex" rev="0.1.0">
  <artifact name="java-api-idex" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.codemonkeylab.idex', module='java-api-idex', version='0.1.0')
)
libraryDependencies += "com.codemonkeylab.idex" % "java-api-idex" % "0.1.0"
[com.codemonkeylab.idex/java-api-idex "0.1.0"]

Dependencies

compile (5)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-core jar 2.9.9
com.fasterxml.jackson.core : jackson-databind jar 2.9.9
org.web3j : crypto jar 4.3.1
org.asynchttpclient : async-http-client jar 2.10.0
org.slf4j : slf4j-api jar 1.7.25

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.3.2
org.junit.jupiter : junit-jupiter-engine jar 5.3.2
org.junit.vintage : junit-vintage-engine jar 5.3.2
org.junit.platform : junit-platform-launcher jar 1.3.2
org.junit.platform : junit-platform-runner jar 1.3.2

Project Modules

There are no modules declared in this project.

java-api-idex

IDEX API JAVA

This library uses the IDEX API.

Installation

Using Maven

Add the following dependency to your project's Maven pom.xml:

<dependency>
	<groupId>com.codemonkeylab.idex</groupId>
	<artifactId>java-api-idex</artifactId>
	<version>0.1.0</version>
</dependency>

Usage

You will need a Ethereum private key with some ether loaded to trade. Some interactions (read) does not require private key.

import org.web3j.crypto.Credentials;
import com.cml.idex.IDexAPI;

final Credentials credentials = Credentials.create("WALLET_PRIVATE_KEY");
final IDexAPI idex = new IDexAPI();
try {
   // Your code here
}
finally {
   idex.shutdown();
}

When interacting with ETH trading pair use the IDexAPI.DEFAULT_ETH_ADR as the token address.

Examples

Balance

Returns available balances for an address(total deposited minus amount in open orders) indexed by token symbol.

import com.cml.idex.IDexAPI;

final IDexAPI idex = new IDexAPI();
try {
   CompletableFuture<Map<String, BigDecimal>> balFuture = idex.returnBalances("ETH_ADR");
   balFuture.get().entrySet()
      .forEach(entry -> System.out.println("ERC20: " + entry.getKey() + ", Balance: " + entry.getValue()));
} catch (InterruptedException | ExecutionException e) {
   e.printStackTrace();
} finally {
   idex.shutdown();
}

IDEX Contract Address

Returns the contract address used for depositing, withdrawing, and posting orders.

import com.cml.idex.IDexAPI;

final IDexAPI idex = new IDexAPI();
try {
   System.out.println("IDEX Contract Address : " + idex.returnContractAddress().get());
} catch (InterruptedException | ExecutionException e) {
   e.printStackTrace();
} finally {
   idex.shutdown();
}

Trade History for Market

To get trading history for Token Pair. The Results object returned allows you paginate through the results.

import com.cml.idex.IDexAPI;

final IDexAPI idex = new IDexAPI();
try {
   // Market History for ETH_ZCC
   CompletableFuture<Page<List<TradeHistory>>> tradeHistoryF = idex.returnTradeHistoryPage("ETH_ZCC", null,
            LocalDateTime.of(2019, 1, 1, 1, 1), LocalDateTime.now(), SortOrder.ASC, 50);

   future.join();

   while (tradeHistoryF.get().getResults() != null && !tradeHistoryF.get().getResults().isEmpty()) {
      // Current page
      final Page<List<TradeHistory>> page = tradeHistoryF.get();
      // Results for this page
      final List<TradeHistory> trades = page.getResults();
      
      System.out.println("Size = " + trades.size());
      // Return the next Page results
      tradeHistoryF = page.nextPage();
      tradeHistoryF.join();
   }
} catch (InterruptedException | ExecutionException e) {
   e.printStackTrace();
} finally {
   idex.shutdown();
}

Versions

Version
0.1.0
0.0.3
0.0.2