Code Monkey home page Code Monkey logo

btc_e_assist_api's Introduction

Assist TradeApi for BTC-E. Version 1.4

###Java library for simple and comfortable use of BTC-e API.

Private BTC-E API documentation https://btc-e.com/tapi/docs

Public BTC-E API documentation https://btc-e.com/api/3/docs

NOTE: after version 1.3 previous API-key and Secret not working (new method of generating nonce parameter)

NOTE: added proxy for blocked countries. Thx to http://noblockme.ru

NOTE: if you use Oracle JDK 7, you may face the problem of certificates. Read more here http://stackoverflow.com/questions/18746565/godaddy-ssl-cert-not-working-with-java

To fix it, you can download gdroot-g2.crt and gdig2.crt from here https://certs.godaddy.com/repository and then run in the terminal:

sudo $JAVA_HOME/bin/keytool -import -file gdroot-g2.crt -alias gdrootg2 -storepass changeit -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts
sudo $JAVA_HOME/bin/keytool -import -file gdig2.crt -alias gdig2 -storepass changeit -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts

If you want to build the library yourself, you will need: ####Jackson library http://wiki.fasterxml.com/Home ####Apache Commons Codec (TM) http://commons.apache.org/proper/commons-codec/

Common algorithm:

  • set parametres for BTC-E API method
  • run method
  • if server responce consist of few parts (few pairs, few trades, etc.) swith to next or specific
  • get current item value (current last price, current last fee, etc.)
  • switch to next element
  • ???
  • PROFIT

If you use it in loop, do not forget to call resetParams, otherwise parametres string will be as: "...btc_usd-btc-usd" and server return error.

Note: by default, if you add nonexistent pair (but not duplicate), library set "ignore invalid" to "true" and you can get valid answer, but without nonexistent pair. You can change this behavior, if call method setReverseIgnoreInvalid(), it reverse API method state, or you can get valid pairs list from Info API method.

###Examples:

  1. Get last price for BTC-USD and LTC-USD
TradeApi ta = new TradeApi(); 
ta.ticker.addPair("btc_usd"); // add btc_usd pair to ticker method
ta.ticker.addPair("ltc_usd");
ta.ticker.runMethod();// run ticker API method with added parametres
while(ta.ticker.hasNextPair()){
	ta.ticker.switchNextPair();// in this case, switch to first pairs, i.e. btc_usd, for the next iteration it will be ltc_usd
	System.out.println(ta.ticker.getCurrentLast()); // print last price for current pair
}
  1. Get active orders for BTC-USD (depth API method)
TradeApi ta = new TradeApi();
ta.depth.addPair("btc_usd");
ta.depth.setLimit(100);
ta.depth.runMethod();
ta.depth.setCurrentPair("btc_usd");// now instead switchNextPair we can use this method, but switchNextPair works too
while (ta.depth.hasNextAsk()) {
	ta.depth.switchNextAsk();// switch to next ask. In this case we can switch pairs and can switch asks and bids for each pair
	System.out.println(ta.depth.getCurrentAskPrice());
}
  1. Get your balance
String aKey = "TK7HD88A-ENLZZBCW-P4L5JYVR-18K9NZZP-CYQ7WKKH"; //API-key
String aSecret = "b7738a9f4d62da1b6ebbcd7ff2d7b5ddb93de88b71f017ae600b7ab3ed5b7015"; //SECRET-key
TradeApi t = new TradeApi(aKey,aSecret);// we can use constructor, we can use empty constructor and after that t.setKeys(...) and so on.
t.getInfo.runMethod();
System.out.println(t.getInfo.getBalance("usd")); // get USD balance. We can get currency list with getCurrencyList()

TradeApi is the Main class, that contains other objects with public modifiers and private objects for some usefull methods as tryMaximumBuy(...) and other.

Example of using this library you also can see in BTC-e Assist app, TradeControl class: https://github.com/alexandersjn/btc-e-assist/blob/master/src/com/btc_e_assist/TradeControl.java

###Donation:

BTC 1GQJ5iH84EVcsr5qxLCgoopLb3ttDtrQVa

LTC LQ2M5qSmD4QVMRAWw5o6cipQm8F8hAMosJ

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.