<commit_before>package com.xeiam.xchange.btcchina.service.fix;

import java.math.BigDecimal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.xeiam.xchange.btcchina.BTCChinaAdapters;
import com.xeiam.xchange.btcchina.service.fix.fix44.AccountInfoRequest;
import com.xeiam.xchange.btcchina.service.fix.fix44.AccountInfoResponse;
import com.xeiam.xchange.currency.CurrencyPair;
import com.xeiam.xchange.dto.account.AccountInfo;
import com.xeiam.xchange.dto.marketdata.Ticker;
import com.xeiam.xchange.utils.nonce.CurrentNanosecondTimeIncrementalNonceFactory;

import quickfix.Application;
import quickfix.DoNotSend;
import quickfix.FieldNotFound;
import quickfix.IncorrectDataFormat;
import quickfix.IncorrectTagValue;
import quickfix.Message;
import quickfix.RejectLogon;
import quickfix.Session;
import quickfix.SessionID;
import quickfix.UnsupportedMessageType;
import quickfix.fix44.MarketDataIncrementalRefresh;
import quickfix.fix44.MarketDataSnapshotFullRefresh;
import quickfix.fix44.MessageCracker;
import quickfix.fix44.NewOrderSingle;
import quickfix.fix44.OrderCancelRequest;
import quickfix.fix44.OrderMassStatusRequest;
import quickfix.fix44.OrderStatusRequest;
import si.mazi.rescu.SynchronizedValueFactory;

/**
 * {@link Application} implementation for BTCChina.
 */
public class BTCChinaApplication extends MessageCracker implements Application {

  private final Logger log = LoggerFactory.getLogger(BTCChinaApplication.class);

  private SynchronizedValueFactory<Long> nonceFactory = new CurrentNanosecondTimeIncrementalNonceFactory();

  private volatile Ticker ticker;

  @Override
  public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {

    log.debug("fromAdmin: {}", message);
  }

  @Override
  public void toAdmin(Message message, SessionID sessionId) {

    log.debug("toAdmin: {}", message);
  }

  @Override
  public void fromApp(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {

    log.debug("fromApp: {}", message);

    crack(message, sessionId);
  }

  @Override
  public void toApp(Message message, SessionID sessionId) throws DoNotSend {

    log.debug("toApp: {} {}", sessionId, message);
  }

  @Override
  public void onCreate(SessionID sessionId) {

  }

  @Override
  public void onLogon(SessionID sessionId) {

    log.debug("onLogon: {}", sessionId);
  }

  @Override
  public void onLogout(SessionID sessionId) {

    log.debug("onLogout: {}", sessionId);
  }

  @Override
  public void onMessage(MarketDataSnapshotFullRefresh message, SessionID sessionId) throws FieldNotFound {

    log.debug("{}", message);

    setTicker(BTCChinaFIXAdapters.adaptTicker(message));
    onTicker(ticker, sessionId);
  }

  @Override
  public void onMessage(MarketDataIncrementalRefresh message, SessionID sessionId) throws FieldNotFound {

    log.debug("{}", message);

    setTicker(BTCChinaFIXAdapters.adaptUpdate(getTicker(), message));
    onTicker(ticker, sessionId);
  }

  public void onMessage(AccountInfoResponse message, SessionID sessionId) throws FieldNotFound {

    log.debug("{}", message);

    onAccountInfo(message.getAccReqID().getValue(), new AccountInfo(BTCChinaFIXAdapters.adaptWallet(message)), sessionId);
  }

  /**
   * Callback of ticker refreshed.
   *
   * @param ticker the refreshed ticker.
   * @param sessionId the FIX session ID.
   */
  protected void onTicker(Ticker ticker, SessionID sessionId) {
    onTicker(ticker);
  }

  /**
   * Callback of ticker refreshed.
   *
   * @param ticker the refreshed ticker.
   * @deprecated Use {@link #onTicker(Ticker, SessionID)} instead.
   */
  @Deprecated
  protected void onTicker(Ticker ticker) {
  }

  /**
   * Callback of account info got from server.
   *
   * @param accReqId the account request ID as assigned in the request.
   * @param accountInfo the account info.
   */
  protected void onAccountInfo(String accReqId, AccountInfo accountInfo, SessionID sessionId) {
    this.onAccountInfo(accReqId, accountInfo);
  }

  /**
   * Callback of account info got from server.
   *
   * @param accReqId the account request ID as assigned in the request.
   * @param accountInfo the account info.
   * @deprecated Use {@link #onAccountInfo(String, AccountInfo, SessionID)} instead.
   */
  @Deprecated
  protected void onAccountInfo(String accReqId, AccountInfo accountInfo) {
  }

  public Ticker getTicker() {

    return ticker;
  }

  protected void setTicker(Ticker ticker) {<commit_msg>remove deprecated code BTCChina<commit_after>package com.xeiam.xchange.btcchina.service.fix;

import java.math.BigDecimal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.xeiam.xchange.btcchina.BTCChinaAdapters;
import com.xeiam.xchange.btcchina.service.fix.fix44.AccountInfoRequest;
import com.xeiam.xchange.btcchina.service.fix.fix44.AccountInfoResponse;
import com.xeiam.xchange.currency.CurrencyPair;
import com.xeiam.xchange.dto.account.AccountInfo;
import com.xeiam.xchange.dto.marketdata.Ticker;
import com.xeiam.xchange.utils.nonce.CurrentNanosecondTimeIncrementalNonceFactory;

import quickfix.Application;
import quickfix.DoNotSend;
import quickfix.FieldNotFound;
import quickfix.IncorrectDataFormat;
import quickfix.IncorrectTagValue;
import quickfix.Message;
import quickfix.RejectLogon;
import quickfix.Session;
import quickfix.SessionID;
import quickfix.UnsupportedMessageType;
import quickfix.fix44.MarketDataIncrementalRefresh;
import quickfix.fix44.MarketDataSnapshotFullRefresh;
import quickfix.fix44.MessageCracker;
import quickfix.fix44.NewOrderSingle;
import quickfix.fix44.OrderCancelRequest;
import quickfix.fix44.OrderMassStatusRequest;
import quickfix.fix44.OrderStatusRequest;
import si.mazi.rescu.SynchronizedValueFactory;

/**
 * {@link Application} implementation for BTCChina.
 */
public class BTCChinaApplication extends MessageCracker implements Application {

  private final Logger log = LoggerFactory.getLogger(BTCChinaApplication.class);

  private SynchronizedValueFactory<Long> nonceFactory = new CurrentNanosecondTimeIncrementalNonceFactory();

  private volatile Ticker ticker;

  @Override
  public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {

    log.debug("fromAdmin: {}", message);
  }

  @Override
  public void toAdmin(Message message, SessionID sessionId) {

    log.debug("toAdmin: {}", message);
  }

  @Override
  public void fromApp(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {

    log.debug("fromApp: {}", message);

    crack(message, sessionId);
  }

  @Override
  public void toApp(Message message, SessionID sessionId) throws DoNotSend {

    log.debug("toApp: {} {}", sessionId, message);
  }

  @Override
  public void onCreate(SessionID sessionId) {

  }

  @Override
  public void onLogon(SessionID sessionId) {

    log.debug("onLogon: {}", sessionId);
  }

  @Override
  public void onLogout(SessionID sessionId) {

    log.debug("onLogout: {}", sessionId);
  }

  @Override
  public void onMessage(MarketDataSnapshotFullRefresh message, SessionID sessionId) throws FieldNotFound {

    log.debug("{}", message);

    setTicker(BTCChinaFIXAdapters.adaptTicker(message));
    onTicker(ticker, sessionId);
  }

  @Override
  public void onMessage(MarketDataIncrementalRefresh message, SessionID sessionId) throws FieldNotFound {

    log.debug("{}", message);

    setTicker(BTCChinaFIXAdapters.adaptUpdate(getTicker(), message));
    onTicker(ticker, sessionId);
  }

  public void onMessage(AccountInfoResponse message, SessionID sessionId) throws FieldNotFound {

    log.debug("{}", message);

    onAccountInfo(message.getAccReqID().getValue(), new AccountInfo(BTCChinaFIXAdapters.adaptWallet(message)), sessionId);
  }

  /**
   * Callback of ticker refreshed.
   *
   * @param ticker the refreshed ticker.
   * @param sessionId the FIX session ID.
   */
  protected void onTicker(Ticker ticker, SessionID sessionId) {
  }

  /**
   * Callback of account info got from server.
   *
   * @param accReqId the account request ID as assigned in the request.
   * @param accountInfo the account info.
   */
  protected void onAccountInfo(String accReqId, AccountInfo accountInfo, SessionID sessionId) {
  }

  public Ticker getTicker() {

    return ticker;
  }

  protected void setTicker(Ticker ticker) {
{'fraction_non_alphanumeric': 0.0949648711943794, 'fraction_numerical': 0.00468384074941452, 'mean_word_length': 5.066051136363637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7492648', 'n_tokens_mistral': 2668, 'n_tokens_neox': 2550, 'n_words': 579}