All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xeiam.xchange.bitstamp.BitstampExchange Maven / Gradle / Ivy

package com.xeiam.xchange.bitstamp;

import si.mazi.rescu.SynchronizedValueFactory;

import com.xeiam.xchange.BaseExchange;
import com.xeiam.xchange.Exchange;
import com.xeiam.xchange.ExchangeSpecification;
import com.xeiam.xchange.bitstamp.service.polling.BitstampAccountService;
import com.xeiam.xchange.bitstamp.service.polling.BitstampMarketDataService;
import com.xeiam.xchange.bitstamp.service.polling.BitstampTradeService;
import com.xeiam.xchange.bitstamp.service.streaming.BitstampPusherService;
import com.xeiam.xchange.bitstamp.service.streaming.BitstampStreamingConfiguration;
import com.xeiam.xchange.service.streaming.ExchangeStreamingConfiguration;
import com.xeiam.xchange.service.streaming.StreamingExchangeService;
import com.xeiam.xchange.utils.nonce.CurrentTimeNonceFactory;

/**
 * @author Matija Mazi
 */
public class BitstampExchange extends BaseExchange implements Exchange {

  private SynchronizedValueFactory nonceFactory = new CurrentTimeNonceFactory();

  @Override
  public void applySpecification(ExchangeSpecification exchangeSpecification) {

    super.applySpecification(exchangeSpecification);

    this.pollingMarketDataService = new BitstampMarketDataService(this);
    this.pollingTradeService = new BitstampTradeService(this);
    this.pollingAccountService = new BitstampAccountService(this);
  }

  @Override
  public ExchangeSpecification getDefaultExchangeSpecification() {

    ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass().getCanonicalName());
    exchangeSpecification.setSslUri("https://www.bitstamp.net");
    exchangeSpecification.setHost("www.bitstamp.net");
    exchangeSpecification.setPort(80);
    exchangeSpecification.setExchangeName("Bitstamp");
    exchangeSpecification.setExchangeDescription("Bitstamp is a Bitcoin exchange registered in Slovenia.");
    return exchangeSpecification;
  }

  @Override
  public StreamingExchangeService getStreamingExchangeService(ExchangeStreamingConfiguration configuration) {

    if (configuration instanceof BitstampStreamingConfiguration) {
      return new BitstampPusherService(this, (BitstampStreamingConfiguration) configuration);
    }

    throw new IllegalArgumentException("Bitstamp only supports BitstampStreamingConfiguration");
  }

  @Override
  public SynchronizedValueFactory getNonceFactory() {

    return nonceFactory;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy