Moodl/library/Binance
Tanguy Herbron 28c7d39466 Fisrt push
Initial push
-HitBTC synchronisation
-Quick charts
-Detailed/Quick view
2018-01-28 21:56:58 +01:00
..
src Fisrt push 2018-01-28 21:56:58 +01:00
.gitignore Fisrt push 2018-01-28 21:56:58 +01:00
CONTRIBUTING.md Fisrt push 2018-01-28 21:56:58 +01:00
pom.xml Fisrt push 2018-01-28 21:56:58 +01:00
README.md Fisrt push 2018-01-28 21:56:58 +01:00
UNLICENSE Fisrt push 2018-01-28 21:56:58 +01:00

Java client for Binance API

Synopsis

Client for accessing Binance API using Java. An async and a sync versions of the client are available.

Installation

Add the bintray repo to the pom of your maven project:

    <repositories>
        <repository>
          <id>bintray-johnsiu-maven-repo</id>
          <url>https://dl.bintray.com/johnsiu/maven-repo</url>
        </repository>
     </repositories>

then, add the dependency:

    <dependency>
      <groupId>com.github.johnsiu</groupId>
      <artifactId>binance-java-client</artifactId>
      <version>1.0.1</version>
    </dependency>

Usage

Creating an instance of the async client using Guice

    Injector injector = Guice.createInjector(new BinanceClientModule());
    AsyncBinanceClient asyncClient = injector.getInstance(AsyncBinanceClient.class);

Creating an instance of the sync client using Guice

    Injector injector = Guice.createInjector(new BinanceClientModule());
    BinanceClient client = injector.getInstance(BinanceClient.class);

Getting latest price of a symbol

    Ticker ticker = client.getTicker("ETHBTC"));
    double price = ticker.getLastPrice();

Getting depth of a symbol

    Depth depth = client.getDepth("ETHBTC"));

Placing a LIMIT order

    Keys keys = new Keys("YOUR_API_KEY", "YOUR_SECRET_KEY");
    double quantity = 1;
    double price = 0.020041;
    Order order = client.placeLimitOrder(keys, "MCOETH", OrderSide.BUY, TimeInForce.GTC, quantity, price);

Placing a MARKET order

    double quantity = 1;
    Order order = client.placeMarketOrder(keys, "MCOETH", OrderSide.SELL, quantity);

Checking an orders status

    OrderStatus orderStatus = client.checkOrderStatus(keys, order);

Cancelling an order

    CancelOrder cancelOrder = client.cancelOrder(keys, order);
    // or 
    CancelOrder cancelOrder = client.cancelOrder(keys, orderStatus);
    

Getting a list of open orders

    List<OrderStatus> openOrders = client.getOpenOrders(keys, "MCOETH");

Getting a list of current position

    Account account = client.getAccount(keys);
    Map<String, Balance> balances = account.getBalances();

Exception handling

    try {
        Depth depth = client.getDepth("invalid symbol"));
    } catch (ClientErrorException e) {
        int httpStatusCode =  e.getHttpStatusCode();
        String errorCode = e.getErrorDetails().getCode();
        String errorMessage = e.getErrorDetails().getMsg();
    }

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is released into the public domain - see the UNLICENSE file for details.