XChange 是一个提供简单和一致的 API 用于和多样化的金融安全交换数据,包括对 Bitcoin 的支持。
示例代码:
package com.xeiam.xchange.examples.mtgox.v1.polling; import com.xeiam.xchange.Exchange; import com.xeiam.xchange.ExchangeFactory; import com.xeiam.xchange.ExchangeSpecification; import com.xeiam.xchange.dto.trade.AccountInfo; import com.xeiam.xchange.service.trade.polling.PollingTradeService; /** * Demo requesting account info at MtGox */ public class AccountInfoDemo { private static PollingTradeService tradeService; public static void main(String[] args) { // Use the factory to get the version 1 MtGox exchange API using default settings ExchangeSpecification exchangeSpecification = new ExchangeSpecification("com.xeiam.xchange.mtgox.v1.MtGoxExchange"); exchangeSpecification.setApiKey("150c6db9-e5ab-47ac-83d6-4440d1b9ce49"); exchangeSpecification.setSecretKey("olHM/yl3CAuKMXFS2+xlP/MC0Hs1M9snHpaHwg0UZW52Ni0Tf4FhGFELO9cHcDNGKvFrj8CgyQUA4VsMTZ6dXg=="); exchangeSpecification.setUri("https://mtgox.com"); exchangeSpecification.setVersion("1"); Exchange mtgox = ExchangeFactory.INSTANCE.createExchange(exchangeSpecification); // Interested in the private trading functionality (authentication) tradeService = mtgox.getPollingTradeService(); // Get the account information AccountInfo accountInfo = tradeService.getAccountInfo(); System.out.println("AccountInfo as String: " + accountInfo.toString()); } }