Skip to content

Instantly share code, notes, and snippets.

@andre77
Last active May 10, 2021 05:59
Show Gist options
  • Save andre77/b2b1ea6bbf2f158f342b3861247b9f08 to your computer and use it in GitHub Desktop.
Save andre77/b2b1ea6bbf2f158f342b3861247b9f08 to your computer and use it in GitHub Desktop.
Example last trade
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