Code Monkey home page Code Monkey logo

binance_api's Introduction

Java Binance API

Overview

A java client for binance REST api.For more information on the API and parameters for requests visit https://www.binance.com/restapipub.htm This client use lombok to help the cleanness of code. For more information about lombok please visit https://projectlombok.org/

Features

  • Implementation of General, Market Data and Account endpoints
  • No need to handle authentication and timestamp
  • simple handling of logger and exception

Maven

  1. install to local repository with command mvn install
  2. add maven dependency
    <dependency>
        <groupId>com.binance</groupId>
        <artifactId>binance-api</artifactId>
        <version>1.0.0</version>
    </dependency>
    

Examples

First Init BinanceApi

BinanceApi binanceApi = new BinanceApi("apiKey","apiSecret");
Get the server time
Long serverTime = binanceApi.getServerTime();
Get the depth of symbol
BinanceApi.OrderBook orderBook = binanceApi.getDepth("LTCBTC");
// get depth with limit number
BinanceApi.OrderBook orderBook20 = binanceApi.getDepth("LTCBTC", 20);
Get latest price of symbol
BigDecimal price = binanceApi.getLatestPrice("LTCBTC");
Place limit order
BinanceApi.PlaceOrderRequest placeOrderRequest = new BinanceApi.PlaceOrderRequest();
placeOrderRequest.setOrderSide(BinanceApi.OrderSide.BUY);
placeOrderRequest.setSymbol("LTCBTC");
placeOrderRequest.setPrice(new BigDecimal("0.005"));
placeOrderRequest.setQuantity(new BigDecimal("1"));
BinanceApi.PlaceOrderResponse placeOrderResponse = binanceApi.placeLimitOrder(placeOrderRequest);
Place market order
BinanceApi.PlaceOrderRequest placeOrderRequest = new BinanceApi.PlaceOrderRequest();
placeOrderRequest.setOrderSide(BinanceApi.OrderSide.BUY);
placeOrderRequest.setSymbol("LTCBTC");
placeOrderRequest.setQuantity(new BigDecimal("1"));
BinanceApi.PlaceOrderResponse placeOrderResponse = binanceApi.placeMarketOrder(placeOrderRequest);
Get order
BinanceApi.Order order = binanceApi.getOrder("LTCBTC", 123456L);
Cancel order
BinanceApi.CancelOrderResponse cancelOrderResponse = binanceApi.cancelOrder("LTCBTC", 123456L);
Get Open orders
List<BinanceApi.Order> orders = binanceApi.openOrders("LTCBTC");
Get Account Info
BinanceApi.AccountInfo accountInfo = binanceApi.getAccount();
// specify the recWindow
BinanceApi.AccountInfo accountInfoRecWindwo = binanceApi.getAccount(5000L);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.