To interact with the Coins.ph Exchange via REST, use the ExchangeFactory to create a CoinsphExchange instance. You must configure your API credentials using ExchangeSpecification.
Supported features include:
- Market Data: Ticker, order book, and trades.
- Trading: Account info, open orders, market/limit/stop orders, order cancellation, order status, and trade history.
// Create Exchange
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CoinsphExchange.class);
// Configure API keys
ExchangeSpecification spec = exchange.getDefaultExchangeSpecification();
spec.setApiKey("your-api-key");
spec.setSecretKey("your-secret-key");
spec.setExchangeSpecificParametersItem(Exchange.USE_SANDBOX, false); // Set to true for sandbox
exchange.applySpecification(spec);
// Get market data
MarketDataService marketDataService = exchange.getMarketDataService();
Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_PHP);
// Get account info
AccountService accountService = exchange.getAccountService();
AccountInfo accountInfo = accountService.getAccountInfo();
// Place order
TradeService tradeService = exchange.getTradeService();
MarketOrder marketOrder = new MarketOrder.Builder(Order.OrderType.BID, CurrencyPair.BTC_PHP)
.originalAmount(new BigDecimal("0.001"))
.build();
String orderId = tradeService.placeMarketOrder(marketOrder);