Skip to content

Commit

Permalink
Fix some warnings #881
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Mar 3, 2022
1 parent 8d3b117 commit 0abfb2d
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 49 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<!-- Tests -->
<junit-pioneer.version>1.6.1</junit-pioneer.version>
<awaitility.version>4.1.1</awaitility.version>
<hsqldb.version>2.6.0</hsqldb.version>
<hsqldb.version>2.6.1</hsqldb.version>
<jackson.version>2.12.6</jackson.version>

<!-- GraphQL API -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Map;

import static graphql.Assert.assertFalse;
import static java.math.BigDecimal.ZERO;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
*/
public final class MathConstants {

/**
* Private constructor - Utility class.
*/
private MathConstants() {

}

/** 100 (usually used for percentage). */
public static final BigDecimal ONE_HUNDRED_BIG_DECIMAL = new BigDecimal("100");

/** Big integer scale (used for divisions). */
public static final int BIGINTEGER_SCALE = 8;

/**
* Private constructor - Utility class.
*/
private MathConstants() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ public static class Rates {
@Rate(message = "Invalid account rate - Enter a long value (ex: 123) or a standard ISO 8601 duration (ex: PT10H)")
private String account;

/** Delay between calls to ticker API. */
@NotNull(message = "Delay between calls to ticker API is mandatory")
@Rate(message = "Invalid ticker rate - Enter a long value (ex: 123) or a standard ISO 8601 duration (ex: PT10H)")
private String ticker;

/** Delay between calls to trade API. */
@NotNull(message = "Delay between calls to trade API is mandatory")
@Rate(message = "Invalid trade rate - Enter a long value (ex: 123) or a standard ISO 8601 duration (ex: PT10H)")
private String trade;

/**
* Returns account rate value in ms.
*
Expand All @@ -112,11 +122,6 @@ public long getAccountValueInMs() {
return getRateValue(account);
}

/** Delay between calls to ticker API. */
@NotNull(message = "Delay between calls to ticker API is mandatory")
@Rate(message = "Invalid ticker rate - Enter a long value (ex: 123) or a standard ISO 8601 duration (ex: PT10H)")
private String ticker;

/**
* Returns ticker rate value in ms.
*
Expand All @@ -126,11 +131,6 @@ public long getTickerValueInMs() {
return getRateValue(ticker);
}

/** Delay between calls to trade API. */
@NotNull(message = "Delay between calls to trade API is mandatory")
@Rate(message = "Invalid trade rate - Enter a long value (ex: 123) or a standard ISO 8601 duration (ex: PT10H)")
private String trade;

/**
* Returns trade rate value in ms.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tech.cassandre.trading.bot.test.core.batch.mocks;

import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Balance;
import org.knowm.xchange.dto.account.Wallet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.dto.trade.UserTrades;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import tech.cassandre.trading.bot.service.PositionService;
import tech.cassandre.trading.bot.service.PositionServiceCassandreImplementation;
import tech.cassandre.trading.bot.test.util.junit.BaseMock;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import tech.cassandre.trading.bot.dto.util.CurrencyAmountDTO;
import tech.cassandre.trading.bot.dto.util.CurrencyDTO;
import tech.cassandre.trading.bot.service.PositionService;
import tech.cassandre.trading.bot.service.UserService;
import tech.cassandre.trading.bot.test.core.services.dry.mocks.PositionServiceDryModeTestMock;
import tech.cassandre.trading.bot.test.util.junit.BaseTest;
import tech.cassandre.trading.bot.test.util.junit.configuration.Configuration;
Expand Down Expand Up @@ -61,9 +60,6 @@ public class UserServiceWithPositionsTest extends BaseTest {
@Autowired
private AccountFlux accountFlux;

@Autowired
private UserService userService;

@Autowired
private PositionService positionService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.time.ZonedDateTime;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -553,7 +552,7 @@ public void checkTradeUpdate() {

@Test
@DisplayName("Check close position")
public void checkClosePosition() throws InterruptedException {
public void checkClosePosition() {
// =============================================================================================================
// Creates position 1 (ETH/BTC, 0.0001, 100% stop gain).
final PositionCreationResultDTO creationResult1 = strategy.createLongPosition(ETH_BTC,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tech.cassandre.trading.bot.test.core.services.xchange.mocks;

import org.knowm.xchange.dto.Order;
import org.knowm.xchange.dto.trade.MarketOrder;
import org.knowm.xchange.dto.trade.UserTrades;
import org.knowm.xchange.service.trade.TradeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Wallet;
import org.knowm.xchange.dto.marketdata.Ticker;
import org.knowm.xchange.dto.trade.OpenOrders;
import org.knowm.xchange.dto.trade.UserTrades;
import org.knowm.xchange.instrument.Instrument;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.marketdata.MarketDataService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -28,10 +26,7 @@
import tech.cassandre.trading.bot.service.UserServiceXChangeImplementation;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import static java.math.BigDecimal.ZERO;
import static org.knowm.xchange.dto.marketdata.Trades.TradeSortType.SortByTimestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import tech.cassandre.trading.bot.dto.position.PositionDTO;
import tech.cassandre.trading.bot.dto.util.CurrencyAmountDTO;
import tech.cassandre.trading.bot.dto.util.CurrencyDTO;
import tech.cassandre.trading.bot.dto.util.GainDTO;
import tech.cassandre.trading.bot.service.PositionService;
import tech.cassandre.trading.bot.test.util.junit.BaseTest;
import tech.cassandre.trading.bot.test.util.junit.configuration.Configuration;
import tech.cassandre.trading.bot.test.util.junit.configuration.Property;
Expand All @@ -19,9 +17,7 @@
import java.util.Map;
import java.util.Optional;

import static java.math.BigDecimal.ZERO;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -41,18 +37,12 @@ public class Issue510Test extends BaseTest {
@Autowired
private TestableCassandreStrategy strategy;

@Autowired
private PositionService positionService;

@Test
@DisplayName("Fix empty openingOrder or closing order")
public void checkEmptyOrderFix() {
final Map<CurrencyDTO, GainDTO> gains = positionService.getGains();

// Check fees in position 6 (they must be in USDT in Kucoin data).
final Optional<PositionDTO> position = strategy.getPositionByPositionId(6);
assertTrue(position.isPresent());
System.out.println("==>" + position.get().getDescription());
final Map<CurrencyDTO, CurrencyAmountDTO> fees = position.get().getGain().getOrdersFees();
assertEquals(1, fees.size());
assertNull(position.get().getGain().getOrdersFees().get(BTC));
Expand Down

0 comments on commit 0abfb2d

Please sign in to comment.