Beispiel #1
0
  /** Demonstrates how to connect to the AccountService for MtGox */
  private static void demoTradeService() {

    // Use the factory to get the version 1 MtGox exchange API using default settings
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(ExchangeSpecification.API_KEY, "XXX");
    params.put(ExchangeSpecification.API_SECRET, "YYY");
    params.put(ExchangeSpecification.API_URI, "https://mtgox.com");
    params.put(ExchangeSpecification.API_VERSION, "1");
    ExchangeSpecification exchangeSpecification =
        new ExchangeSpecification("com.xeiam.xchange.mtgox.v1.MtGoxExchange", params);
    Exchange mtgox = ExchangeFactory.INSTANCE.createExchange(exchangeSpecification);

    // Interested in the public market data feed (no authentication)
    TradeService tradeService = mtgox.getTradeService();

    // Get the account information
    // AccountInfo accountInfo = tradeService.getAccountInfo();
    // System.out.printf("Account info: %s", accountInfo);

    // Get the open orders
    OpenOrders openOrders = tradeService.getOpenOrders();
    System.out.printf("Open Orders: %s", openOrders);
  }