Package com.xeiam.xchange.coinsetter.dto.clientsession.response

Examples of com.xeiam.xchange.coinsetter.dto.clientsession.response.CoinsetterClientSession


   * {@inheritDoc}
   */
  @Override
  public AccountInfo getAccountInfo() throws IOException {

    CoinsetterClientSession session = getSession();
    CoinsetterAccount account = accountServiceRaw.get(session.getUuid(), getAccountUuid());
    return CoinsetterAdapters.adaptAccountInfo(session.getUsername(), account);
  }
View Full Code Here


   * {@inheritDoc}
   */
  @Override
  public OpenOrders getOpenOrders() throws IOException {

    CoinsetterClientSession session = getSession();
    CoinsetterOrderList orderList = orderServiceRaw.list(session.getUuid(), getAccountUuid(), "OPEN");
    return CoinsetterAdapters.adaptOpenOrders(orderList);
  }
View Full Code Here

    return add(limitOrder.getCurrencyPair(), limitOrder.getType(), limitOrder.getTradableAmount(), limitOrder.getLimitPrice());
  }

  private String add(CurrencyPair currencyPair, OrderType orderType, BigDecimal quantity, BigDecimal price) throws IOException {

    CoinsetterClientSession session = getSession();
    CoinsetterOrderRequest request =
        new CoinsetterOrderRequest(session.getCustomerUuid(), getAccountUuid(), CoinsetterAdapters.adaptSymbol(currencyPair), CoinsetterAdapters.adaptSide(orderType), price == null ? "MARKET"
            : "LIMIT", quantity, 2, price);
    return orderServiceRaw.add(getSession().getUuid(), request).getUuid().toString();
  }
View Full Code Here

    heartbeatMaxFailureTimes = (Integer) exchangeSpecification.getExchangeSpecificParametersItem(SESSION_HEARTBEAT_MAX_FAILURE_TIMES_KEY);
  }

  public CoinsetterClientSession getSession() throws IOException {

    CoinsetterClientSession session = readSession();

    if (session == null) {
      writeSession();

      // Read again, as we should have.
View Full Code Here

    clientSessionServiceRaw.logout(readSession().getUuid());
  }

  private CoinsetterClientSession readSession() {

    final CoinsetterClientSession session;
    try {
      lock.readLock().lock();
      session = (CoinsetterClientSession) exchangeSpecification.getExchangeSpecificParametersItem(SESSION_KEY);
    } finally {
      lock.readLock().unlock();
View Full Code Here

      // Check if it is updated by someone else, before we got the write lock.
      if ((CoinsetterClientSession) exchangeSpecification.getExchangeSpecificParametersItem(SESSION_KEY) == null) {
        // It is still null, retrieve one from server.

        final CoinsetterClientSession session = login();
        exchangeSpecification.setExchangeSpecificParametersItem(SESSION_KEY, session);

        final String heatbeatThreadName = String.format("Coinsetter-heatbeat-%s(%s)-%s", session.getUsername(), session.getCustomerUuid(), session.getUuid());
        heartbeatThread = new HeartbeatThread(heatbeatThreadName, session, heartbeatInterval, heartbeatMaxFailureTimes);
        heartbeatThread.start();

        if (exchangeSpecification.getExchangeSpecificParametersItem(ACCOUNT_UUID_KEY) == null) {
          CoinsetterAccountList accountList = accountServiceRaw.list(session.getUuid());
          CoinsetterAccount account = accountList.getAccountList()[0];
          exchangeSpecification.setExchangeSpecificParametersItem(ACCOUNT_UUID_KEY, account.getAccountUuid());
        }
      }
    } finally {
View Full Code Here

  }

  private CoinsetterClientSession login() throws IOException {

    String ipAddress = (String) exchangeSpecification.getExchangeSpecificParametersItem(SESSION_IP_ADDRESS_KEY);
    CoinsetterClientSession session = clientSessionServiceRaw.login(exchangeSpecification.getUserName(), exchangeSpecification.getPassword(), ipAddress);
    return session;
  }
View Full Code Here

    Exchange coinsetter = CoinsetterExamplesUtils.getExchange();
    CoinsetterClientSessionServiceRaw clientSessionService = new CoinsetterClientSessionServiceRaw(coinsetter.getExchangeSpecification());
    CoinsetterNewsAlertServiceRaw newsAlertService = new CoinsetterNewsAlertServiceRaw(coinsetter.getExchangeSpecification());

    CoinsetterClientSession clientSession = clientSessionService.login(username, password, ipAddress);
    log.info("Client session: {}", clientSession);

    CoinsetterNewsAlertList newsAlerts = newsAlertService.list(clientSession.getUuid());

    for (CoinsetterNewsAlert alert : newsAlerts.getMessageList()) {
      log.info("{}", alert);
    }

    clientSessionService.logout(clientSession.getUuid());
  }
View Full Code Here

    Exchange coinsetter = CoinsetterExamplesUtils.getExchange();
    CoinsetterClientSessionServiceRaw clientSessionService = new CoinsetterClientSessionServiceRaw(coinsetter.getExchangeSpecification());
    CoinsetterAccountServiceRaw accountService = new CoinsetterAccountServiceRaw(coinsetter.getExchangeSpecification());
    CoinsetterFinancialTransactionServiceRaw financialTransactionService = new CoinsetterFinancialTransactionServiceRaw(coinsetter.getExchangeSpecification());

    CoinsetterClientSession clientSession = clientSessionService.login(username, password, ipAddress);
    log.info("Client session: {}", clientSession);

    CoinsetterAccountList coinsetterAccounts = accountService.list(clientSession.getUuid());
    for (CoinsetterAccount account : coinsetterAccounts.getAccountList()) {
      log.info("account: {}", account.getAccountUuid());

      CoinsetterAccount a = accountService.get(clientSession.getUuid(), account.getAccountUuid());
      log.info("account: {}", a);

      CoinsetterFinancialTransactionList financialTransactions = financialTransactionService.list(clientSession.getUuid(), account.getAccountUuid());
      for (CoinsetterFinancialTransaction transaction : financialTransactions.getFinancialTransactionList()) {
        CoinsetterFinancialTransaction t = financialTransactionService.get(clientSession.getUuid(), transaction.getUuid());
        log.info("Transaction: {}", t);
      }
    }

    clientSessionService.logout(clientSession.getUuid());
  }
View Full Code Here

    Exchange coinsetter = CoinsetterExamplesUtils.getExchange();
    CoinsetterClientSessionServiceRaw clientSessionService = new CoinsetterClientSessionServiceRaw(coinsetter.getExchangeSpecification());
    CoinsetterAccountServiceRaw accountService = new CoinsetterAccountServiceRaw(coinsetter.getExchangeSpecification());
    CoinsetterOrderServiceRaw orderService = new CoinsetterOrderServiceRaw(coinsetter.getExchangeSpecification());

    CoinsetterClientSession clientSession = clientSessionService.login(username, password, ipAddress);
    log.info("Client session: {}", clientSession);

    CoinsetterAccount tradeAccount = null;
    CoinsetterAccountList coinsetterAccounts = accountService.list(clientSession.getUuid());
    for (CoinsetterAccount account : coinsetterAccounts.getAccountList()) {
      log.info("account: {}", account.getAccountUuid());

      CoinsetterAccount a = accountService.get(clientSession.getUuid(), account.getAccountUuid());
      log.info("account: {}", a);

      tradeAccount = a;
    }

    // Add order
    log.info("Adding order...");
    CoinsetterOrderRequest request =
        new CoinsetterOrderRequest(clientSession.getCustomerUuid(), tradeAccount.getAccountUuid(), "BTCUSD", "BUY", "LIMIT", new BigDecimal("0.01"), 2, new BigDecimal("0.01"));
    CoinsetterOrderResponse orderResponse = orderService.add(clientSession.getUuid(), request);
    log.info("add order response: {}", orderResponse);

    // Get order
    log.info("Getting order...");
    CoinsetterOrder orderStatus = orderService.get(clientSession.getUuid(), orderResponse.getUuid());
    log.info("order {}: {}", orderStatus.getUuid(), orderStatus.getStage());

    // List order
    log.info("Listing order...");
    CoinsetterOrderList orderList = orderService.list(clientSession.getUuid(), tradeAccount.getAccountUuid(), "NEW-FILL");
    for (CoinsetterOrder order : orderList.getOrderList()) {
      log.info("order {}: {}", order.getUuid(), order.getStage());
    }

    // Cancel order
    log.info("Cancelling order...");
    orderResponse = orderService.cancel(clientSession.getUuid(), orderResponse.getUuid());
    log.info("cancel order response: {}", orderResponse);

    clientSessionService.logout(clientSession.getUuid());
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.coinsetter.dto.clientsession.response.CoinsetterClientSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.