Skip to content

Commit

Permalink
Merge pull request #10 from charvam/master
Browse files Browse the repository at this point in the history
Removed 'transaction price' updated logging
  • Loading branch information
rpanak-generalbytes authored Oct 23, 2020
2 parents 13f8081 + e2ed008 commit 3d3e77f
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 56 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
projectVersion=1.4.0
projectVersion=1.4.1
pf4jVersion=3.4.0
xchangeVersion=0f636cbfff10de85d8c111e19e8e3d142b728951
requiredEverytradeVersion=>=20201014
requiredEverytradeVersion=>=20201023
checkstyleVersion=8.34
spotbugsVersion=4.1.2
owaspDependencyCheckGradlePluginVersion=6.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class ImportedTransactionBean {
private final TransactionType action;
private final BigDecimal baseQuantity;
private final BigDecimal unitPrice;
private final BigDecimal transactionPrice;
private final BigDecimal feeQuote;
private final Instant imported = Instant.now();
private final ImportDetail importDetail;
Expand All @@ -32,7 +31,6 @@ public ImportedTransactionBean(
TransactionType action,
BigDecimal baseQuantity,
BigDecimal unitPrice,
BigDecimal transactionPrice,
BigDecimal feeQuote
) {
this(
Expand All @@ -43,7 +41,6 @@ public ImportedTransactionBean(
action,
baseQuantity,
unitPrice,
transactionPrice,
feeQuote,
ImportDetail.noError()
);
Expand All @@ -57,7 +54,6 @@ public ImportedTransactionBean(
TransactionType action,
BigDecimal baseQuantity,
BigDecimal unitPrice,
BigDecimal transactionPrice,
BigDecimal feeQuote,
ImportDetail importDetail
) {
Expand All @@ -67,12 +63,8 @@ public ImportedTransactionBean(
Objects.requireNonNull(this.quote = quote);
Objects.requireNonNull(this.action = action);
Objects.requireNonNull(this.baseQuantity = baseQuantity);
this.unitPrice = unitPrice;
this.transactionPrice = transactionPrice;
if (this.unitPrice == null || this.transactionPrice == null) {
throw new IllegalArgumentException("Unit price and transaction price can't both be null.");
}
this.feeQuote = feeQuote;
Objects.requireNonNull(this.unitPrice = unitPrice);
Objects.requireNonNull(this.feeQuote = feeQuote);
Objects.requireNonNull(this.importDetail = importDetail);
}

Expand Down Expand Up @@ -112,10 +104,6 @@ public BigDecimal getUnitPrice() {
return unitPrice;
}

public BigDecimal getTransactionPrice() {
return transactionPrice;
}

public BigDecimal getFeeQuote() {
return feeQuote;
}
Expand All @@ -134,7 +122,6 @@ public String toString() {
", action=" + action +
", baseQuantity=" + baseQuantity +
", unitPrice=" + unitPrice +
", transactionPrice=" + transactionPrice +
", feeQuote=" + feeQuote +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public ImportedTransactionBean toImportedTransactionBean() {
TransactionType.valueOf(action), //action
quantity, //base quantity
volume.divide(quantity, 10, RoundingMode.HALF_UP), //unit price
volume, //transaction price
fee //fee quote
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public ImportedTransactionBean toImportedTransactionBean() {
TransactionType.valueOf(action), //action
quantity, //base quantity
volume.divide(quantity, 10, RoundingMode.HALF_UP), //unit price
volume, //transaction price
fee //fee quote
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public ImportedTransactionBean toImportedTransactionBean() {
side, //action
filledSize, //base quantity
priceAvg, //unit price
filledSize.multiply(priceAvg).setScale(DECIMAL_SCALE,RoundingMode.HALF_UP), //transaction price
convertedFee //fee quote
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.knowm.xchange.instrument.Instrument;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Instant;

public class XChangeApiTransactionBean /*extends ExchangeBean*/ {
Expand Down Expand Up @@ -79,7 +78,6 @@ public ImportedTransactionBean toImportedTransactionBean() {
type, //action
originalAmount, //base quantity
price, //unit price
price.divide(originalAmount, 10, RoundingMode.HALF_UP), //transaction price
feeAmount //fee quote
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
package io.everytrade.server.plugin.impl.everytrade;

import io.everytrade.server.model.SupportedExchange;
import io.everytrade.server.parser.exchange.XChangeApiTransactionBean;
import io.everytrade.server.plugin.api.IPlugin;
import io.everytrade.server.plugin.api.connector.ConnectorDescriptor;
import io.everytrade.server.plugin.api.connector.ConnectorParameterDescriptor;
import io.everytrade.server.plugin.api.connector.ConnectorParameterType;
import io.everytrade.server.plugin.api.connector.DownloadResult;
import io.everytrade.server.plugin.api.connector.IConnector;
import io.everytrade.server.plugin.api.parser.ConversionStatistic;
import io.everytrade.server.plugin.api.parser.ImportedTransactionBean;
import io.everytrade.server.plugin.api.parser.ParseResult;
import io.everytrade.server.plugin.api.parser.RowError;
import io.everytrade.server.plugin.api.parser.RowErrorType;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.ExchangeFactory;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.bittrex.BittrexExchange;
import org.knowm.xchange.dto.trade.UserTrade;
import org.knowm.xchange.service.trade.TradeService;
import org.knowm.xchange.service.trade.params.TradeHistoryParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static io.everytrade.server.plugin.impl.everytrade.ConnectorUtils.findDuplicate;

public class BittrexConnector implements IConnector {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private static final String ID = EveryTradePlugin.ID + IPlugin.PLUGIN_PATH_SEPARATOR + "bittrexApiConnector";

private static final ConnectorParameterDescriptor PARAMETER_API_SECRET =
Expand Down Expand Up @@ -84,7 +75,7 @@ public DownloadResult getTransactions(String lastTransactionId) {
? lastTransactionId
: userTrades.get(userTrades.size() - 1).getId();

final ParseResult parseResult = getParseResult(userTrades);
final ParseResult parseResult = XChangeConnectorParser.getParseResult(userTrades, SupportedExchange.BITTREX);

return new DownloadResult(parseResult, actualLastTransactionId);
}
Expand Down Expand Up @@ -117,26 +108,6 @@ private List<UserTrade> download(String lastTransactionId, TradeService tradeSer
return userTradesToAdd;
}

private ParseResult getParseResult(List<UserTrade> userTrades) {
final List<ImportedTransactionBean> importedTransactionBeans = new ArrayList<>();
final List<RowError> errorRows = new ArrayList<>();
for (UserTrade userTrade : userTrades) {
try {
XChangeApiTransactionBean xChangeApiTransactionBean
= new XChangeApiTransactionBean(userTrade, SupportedExchange.BITTREX);
importedTransactionBeans.add(xChangeApiTransactionBean.toImportedTransactionBean());
} catch (Exception e) {
log.error("Error converting to ImportedTransactionBean.", e);
errorRows.add(new RowError(userTrade.toString(), e.getMessage(), RowErrorType.FAILED));
}
}

return new ParseResult(
importedTransactionBeans,
new ConversionStatistic(errorRows, 0)
);
}

@Override
public void close() {
//AutoCloseable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public DownloadResult getTransactions(String lastTransactionId) {
try {
importedTransactions.add(transaction.toImportedTransactionBean());
} catch (Exception e) {
log.error("Error converting to ImportedTransactionBean: {}", e.getMessage());
log.debug("Exception by converting to ImportedTransactionBean.", e);
errorRows.add(new RowError(transaction.toString(), e.getMessage(), RowErrorType.FAILED));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public static ParseResult getParseResult(List<OrderInfo> orderInfos) {
OkexApiTransactionBean okexApiTransactionBean = new OkexApiTransactionBean(orderInfo);
importedTransactionBeans.add(okexApiTransactionBean.toImportedTransactionBean());
} catch (Exception e) {
LOG.error("Error converting to ImportedTransactionBean.", e);
LOG.error("Error converting to ImportedTransactionBean: {}", e.getMessage());
LOG.debug("Exception by converting to ImportedTransactionBean.", e);
errorRows.add(new RowError(orderInfo.toString(), e.getMessage(), RowErrorType.FAILED));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public static ParseResult getParseResult(List<UserTrade> userTrades, SupportedEx
= new XChangeApiTransactionBean(userTrade, supportedExchange);
importedTransactionBeans.add(xchangeApiTransactionBean.toImportedTransactionBean());
} catch (Exception e) {
LOG.error("Error converting to ImportedTransactionBean.", e);
LOG.error("Error converting to ImportedTransactionBean: {}", e.getMessage());
LOG.debug("Exception by converting to ImportedTransactionBean.", e);
errorRows.add(new RowError(userTrade.toString(), e.getMessage(), RowErrorType.FAILED));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public DownloadResult getTransactions(String lastTransactionId) {
importedTransactions.add(transaction.toImportedTransactionBean());
}
} catch (Exception e) {
log.error("Error converting to ImportedTransactionBean: {}", e.getMessage());
log.debug("Exception by converting to ImportedTransactionBean.", e);
errorRows.add(new RowError(transaction.toString(), e.getMessage(), RowErrorType.FAILED));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ private void printResult(DownloadResult downloadResult) {
.append("action").append(columnSeparator)
.append("baseQuantity").append(columnSeparator)
.append("unitPrice").append(columnSeparator)
.append("transactionPrice").append(columnSeparator)
.append("feeQuote").append(lineSeparator);

for (ImportedTransactionBean b : parseResult.getImportedTransactionBeans()) {
Expand All @@ -139,7 +138,6 @@ private void printResult(DownloadResult downloadResult) {
.append(b.getAction()).append(columnSeparator)
.append(b.getBaseQuantity()).append(columnSeparator)
.append(b.getUnitPrice()).append(columnSeparator)
.append(b.getTransactionPrice()).append(columnSeparator)
.append(b.getFeeQuote()).append(lineSeparator);
}
log.info("importedTransactionBeans = \n" + stringBuilder.toString());
Expand Down

0 comments on commit 3d3e77f

Please sign in to comment.