-
-
Save alimogh/dd5d21621f26a7fb8eb7a728e4df75f5 to your computer and use it in GitHub Desktop.
Example last trade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.List; | |
import bittrex.BittrexWS; | |
import bittrex.CurrencyPair; | |
import bittrex.Trade; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
BittrexWS ws = new BittrexWS(); | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
do { | |
String readLine = br.readLine(); | |
if (readLine != null && readLine.length() > 0) { | |
try { | |
switch (readLine.charAt(0)) { | |
case 't': | |
List<Trade> trades = ws.getTrades(new CurrencyPair(readLine.substring(2))); | |
System.out.println(trades.isEmpty() | |
? "no trades so far" | |
: "Last trade: " + trades.get(0)); | |
break; | |
default: | |
help(); | |
break; | |
} | |
} catch (Throwable t) { | |
System.out.println("failed " + t.getMessage()); | |
} | |
} else { | |
help(); | |
} | |
} while(true); | |
} | |
private static void help() { | |
System.out.println("type 't XXX/YYY' to fetch the last trade."); | |
System.out.println("where XXX: base currency, YYY: counter currency, i.e. BTC/USDT -> bittrex market USDT-BTC"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment