30 mBTC - How do you start from scratch?
Although I use to code awhile back I am completely out of the loop now. I am trying to run an example from the example source directory here. I am using CodeRunner (but have Eclipse as well) and am trying to do something as simple as getting a quote from an exchange. However, I get errors such as:
TickerDemo.java:5: cannot find symbol symbol : class Exchange location: package com.xeiam.xchange import com.xeiam.xchange.Exchange;
I am assuming I am not setting up my classpath correctly but have been unable to resolve. How do I use XChange to get a quote from btc-e? Assuming, I know no Java. Thanks.
the sample code I am using is:
package com.xeiam.xchange.examples.btce.marketdata;
import java.io.IOException;
import com.xeiam.xchange.Exchange; import com.xeiam.xchange.ExchangeFactory; import com.xeiam.xchange.btce.v3.BTCEExchange; import com.xeiam.xchange.btce.v3.dto.marketdata.BTCETickerWrapper; import com.xeiam.xchange.btce.v3.service.polling.BTCEMarketDataServiceRaw; import com.xeiam.xchange.currency.CurrencyPair; import com.xeiam.xchange.dto.marketdata.Ticker; import com.xeiam.xchange.service.polling.PollingMarketDataService;
/**
-
Demonstrate requesting Order Book at BTC-E */ public class TickerDemo {
public static void main(String[] args) throws IOException {
// Use the factory to get BTC-E exchange API using default settings Exchange btce = ExchangeFactory.INSTANCE.createExchange(BTCEExchange.class.getName()); generic(btce); raw(btce); }
private static void generic(Exchange exchange) throws IOException {
// Interested in the public polling market data feed (no authentication) PollingMarketDataService marketDataService = exchange.getPollingMarketDataService();
// Get the latest ticker data showing BTC to CAD Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_USD);
System.out.println("Last: " + ticker.getLast().toString()); System.out.println("Volume: " + ticker.getVolume().toString()); System.out.println("High: " + ticker.getHigh().toString()); System.out.println("Low: " + ticker.getLow().toString());
System.out.println(ticker.toString()); }
private static void raw(Exchange exchange) throws IOException {
// Interested in the public polling market data feed (no authentication) BTCEMarketDataServiceRaw marketDataService = (BTCEMarketDataServiceRaw) exchange.getPollingMarketDataService();
// Get the latest ticker data showing BTC to USD BTCETickerWrapper ticker = marketDataService.getBTCETicker("btc_usd"); System.out.println(ticker.toString()); }
}
And the file TickerDemo.java is in the same directory as v 1.10 of the xchange jar files.
try the 2.0.0 snapshot version as the 1.10 version is very outdated.
@mahrens917 2.0.0 was just released and can be downloaded