Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Sep 25, 2020
2 parents 2407c87 + 1c74297 commit c853d64
Show file tree
Hide file tree
Showing 236 changed files with 4,315 additions and 2,736 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ jobs:
# ================================================================================================================
- name : Test Cassandre trading bot maven archetype - basic strategy
run: |
mvn -B archetype:generate -DarchetypeGroupId=tech.cassandre.trading.bot -DarchetypeArtifactId=cassandre-trading-bot-spring-boot-starter-archetype -DarchetypeVersion=${{ steps.package.outputs.version }} -DgroupId=tech.cassandre -DartifactId=archetype-test-basic -Dversion=1.0-SNAPSHOT -Dpackage=tech.cassandre
mvn -B archetype:generate -DarchetypeGroupId=tech.cassandre.trading.bot -DarchetypeArtifactId=cassandre-trading-bot-spring-boot-starter-basic-archetype -DarchetypeVersion=${{ steps.package.outputs.version }} -DgroupId=tech.cassandre -DartifactId=archetype-test-basic -Dversion=1.0-SNAPSHOT -Dpackage=tech.cassandre
mvn -f archetype-test-basic/pom.xml test
# ================================================================================================================
- name : Test Cassandre trading bot maven archetype - basic ta4j strategy
run: |
mvn -B archetype:generate -DarchetypeGroupId=tech.cassandre.trading.bot -DarchetypeArtifactId=cassandre-trading-bot-spring-boot-starter-basic-ta4j-archetype -DarchetypeVersion=${{ steps.package.outputs.version }} -DgroupId=tech.cassandre -DartifactId=archetype-test-ta4j-basic -Dversion=1.0-SNAPSHOT -Dpackage=tech.cassandre
mvn -f archetype-test-ta4j-basic/pom.xml test
mvn -f archetype-test-ta4j-basic/pom.xml test
34 changes: 34 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Integration tests

on:
schedule:
- cron: '0 2 1 * *'

jobs:
build:
# ==================================================================================================================
# Configuration.
runs-on: ubuntu-latest

steps:
# ================================================================================================================
- name: Retrieve the sources
uses: actions/checkout@v1

# ================================================================================================================
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11.0.x

# ================================================================================================================
- name: Build, run tests, package and deploy to Maven central
env: # Environment variables.
# Kucoin credentials.
KUCOIN_NAME: ${{ secrets.KUCOIN_NAME }}
KUCOIN_USERNAME: ${{ secrets.KUCOIN_USERNAME }}
KUCOIN_PASSPHRASE: ${{ secrets.KUCOIN_PASSPHRASE }}
KUCOIN_KEY: ${{ secrets.KUCOIN_KEY }}
KUCOIN_SECRET: ${{ secrets.KUCOIN_SECRET }}
run: |
mvn -Pintegration package
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tmp/**/*
# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
# Locally stored "Eclipse launch configuration"
*.launch

# Mobile Tools for Java (J2ME)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Cassandre
![Continuous integration](https://github.com/cassandre-tech/cassandre-trading-bot/workflows/Continuous%20integration/badge.svg) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f26dc41008a64bb18dcd404b46b69fc8)](https://www.codacy.com/gh/cassandre-tech/cassandre-trading-bot?utm_source=github.com&utm_medium=referral&utm_content=cassandre-tech/cassandre-trading-bot&utm_campaign=Badge_Grade) [![Maven Central](https://img.shields.io/maven-central/v/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-starter-archetype.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22tech.cassandre.trading.bot%22%20AND%20a:%22cassandre-trading-bot-spring-boot-starter-archetype%22)

With our Spring boot starter you can easily create your trading bot in minutes.

A trading bot is a computer program that can automatically place orders to a market or exchange without the need for human intervention. Automated trading strategies are the future of investing, they are working for you 24/7 and never lose their focus.

Our goal with this project was to learn trading & data analysis by building an automated trading system for the cryptocurrencies markets. While learning, we built the bot and we decided to share our code, the problems encountered, the lessons learned and technologies used.
Expand Down
28 changes: 20 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Project information -->
<groupId>tech.cassandre.trading.bot</groupId>
<artifactId>cassandre-trading-bot-project</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
<packaging>pom</packaging>
<name>Cassandre trading bot</name>
<url>https://github.com/cassandre-tech/cassandre-trading-bot</url>
Expand Down Expand Up @@ -36,7 +36,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<version>2.3.4.RELEASE</version>
<relativePath/>
</parent>
<!-- =========================================================================================================== -->
Expand All @@ -56,14 +56,14 @@
<!-- Modules -->
<modules>
<!-- Trading bot spring boot starter -->
<module>trading-bot-spring-boot-autoconfigure</module>
<module>trading-bot-spring-boot-starter</module>
<module>spring-boot-starter/autoconfigure</module>
<module>spring-boot-starter/starter</module>
<!-- Trading bot spring boot starter test -->
<module>trading-bot-spring-boot-starter-test-autoconfigure</module>
<module>trading-bot-spring-boot-starter-test</module>
<module>spring-boot-starter-test/autoconfigure</module>
<module>spring-boot-starter-test/starter</module>
<!-- Archetypes -->
<module>trading-bot-spring-boot-starter-archetype</module>
<module>trading-bot-spring-boot-starter-basic-ta4j-archetype</module>
<module>trading-bot-archetypes/basic-archetype</module>
<module>trading-bot-archetypes/basic-ta4j-archetype</module>
</modules>
<!-- =========================================================================================================== -->

Expand Down Expand Up @@ -93,6 +93,18 @@
</commitMessages>
</configuration>
</plugin>
<!-- Deploy to sonartype -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<!-- GPG signing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<groupId>tech.cassandre.trading.bot</groupId>
<artifactId>cassandre-trading-bot-spring-boot-autoconfigure</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<!-- Tests -->
Expand Down Expand Up @@ -63,7 +64,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.35</version>
<version>8.36.1</version>
</dependency>
</dependencies>
<executions>
Expand All @@ -77,7 +78,7 @@
<configuration>
<excludes>**/mapper/**/*</excludes>
<consoleOutput>true</consoleOutput>
<configLocation>${project.parent.basedir}/checkstyle_configuration.xml</configLocation>
<configLocation>../../checkstyle_configuration.xml</configLocation>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
</configuration>
Expand Down Expand Up @@ -133,7 +134,8 @@
<parent>
<groupId>tech.cassandre.trading.bot</groupId>
<artifactId>cassandre-trading-bot-project</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import tech.cassandre.trading.bot.batch.TickerFlux;
import tech.cassandre.trading.bot.dto.market.TickerDTO;
import tech.cassandre.trading.bot.service.MarketService;
Expand All @@ -26,6 +28,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand All @@ -47,6 +50,8 @@
*/
@SuppressWarnings("checkstyle:DesignForExtension")
@TestConfiguration
@EntityScan(basePackages = "tech.cassandre.trading.bot.domain")
@EnableJpaRepositories(basePackages = "tech.cassandre.trading.bot.repository")
public class TickerFluxMock {

/** Logger. */
Expand Down Expand Up @@ -88,6 +93,11 @@ public MarketService marketService() {

@Override
public Object answer(final InvocationOnMock invocationOnMock) {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
logger.debug("InterruptedException");
}
if (tickers.hasNext()) {
return Optional.of(tickers.next());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import static tech.cassandre.trading.bot.util.dto.CurrencyDTO.KCS;
import static tech.cassandre.trading.bot.util.dto.CurrencyDTO.USDT;

/**
* Tests fpr ticker flux.
*/
@SpringBootTest
@Import(TickerFluxMock.class)
@DisplayName("Ticker flux mock test")
Expand All @@ -37,7 +34,6 @@ public class TickerFluxMockTest extends BaseTest {
@Autowired
private TickerFluxMock tickerFluxMock;


@Test
@DisplayName("Check tickers received")
public void checkTickersReceived() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Exchange configuration.
cassandre.trading.bot.exchange.name=kucoin
cassandre.trading.bot.exchange.username=[email protected]
cassandre.trading.bot.exchange.passphrase=cassandre
cassandre.trading.bot.exchange.key=5df8eea30092f40009cb3c6a
cassandre.trading.bot.exchange.secret=5f6e91e0-796b-4947-b75e-eaa5c06b6bed
#
# Exchange specification.
# cassandre.trading.bot.exchange.proxyHost=127.0.0.1
# cassandre.trading.bot.exchange.proxyPort=4780
#
# Modes.
cassandre.trading.bot.exchange.modes.sandbox=true
cassandre.trading.bot.exchange.modes.dry=false
#
# Exchange API calls rates (ms or standard ISO 8601 duration like 'PT5S').
cassandre.trading.bot.exchange.rates.account=100
cassandre.trading.bot.exchange.rates.ticker=101
cassandre.trading.bot.exchange.rates.trade=102
#
# Database used for backup.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:mem:cassandre
spring.datasource.username=sa
spring.datasource.password=
#
# ======================================================================================================================
# Technical parameters for tests.
#
# Console logging pattern.
logging.pattern.console=%d{HH:mm:ss} - %msg%n
#
# File logging pattern.
logging.pattern.file=%d{HH:mm:ss} - %msg%n
#
# Useful for tests.
spring.main.allow-bean-definition-overriding=true
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.35</version>
<version>8.36.1</version>
</dependency>
</dependencies>
<executions>
Expand All @@ -59,7 +59,7 @@
</executions>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>${project.parent.basedir}/checkstyle_configuration.xml</configLocation>
<configLocation>../../checkstyle_configuration.xml</configLocation>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
</configuration>
Expand Down Expand Up @@ -115,7 +115,8 @@
<parent>
<groupId>tech.cassandre.trading.bot</groupId>
<artifactId>cassandre-trading-bot-project</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,26 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.5.1</version>
</dependency>

<!-- XChange -->
<dependency>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-core</artifactId>
<version>5.0.1</version>
<version>5.0.2</version>
</dependency>
<dependency>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-kucoin</artifactId>
<version>5.0.1</version>
<version>5.0.2</version>
</dependency>

<!-- Ta4j -->
Expand Down Expand Up @@ -90,12 +99,6 @@
<version>4.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>0.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- =========================================================================================================== -->

Expand All @@ -106,7 +109,7 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-bom</artifactId>
<version>Dysprosium-SR11</version>
<version>Dysprosium-SR12</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -128,7 +131,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.35</version>
<version>8.36.1</version>
</dependency>
</dependencies>
<executions>
Expand All @@ -142,7 +145,7 @@
<configuration>
<excludes>**/mapper/**/*</excludes>
<consoleOutput>true</consoleOutput>
<configLocation>${project.parent.basedir}/checkstyle_configuration.xml</configLocation>
<configLocation>../../checkstyle_configuration.xml</configLocation>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
</configuration>
Expand Down Expand Up @@ -262,7 +265,8 @@
<parent>
<groupId>tech.cassandre.trading.bot</groupId>
<artifactId>cassandre-trading-bot-project</artifactId>
<version>2.0.2</version>
<version>2.1.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<!-- =========================================================================================================== -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public AccountFlux(final UserService newUserService) {
}

@Override
@SuppressWarnings("unused")
protected final Set<AccountDTO> getNewValues() {
getLogger().debug("AccountFlux - Retrieving new values");
Set<AccountDTO> newValues = new LinkedHashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public OrderFlux(final TradeService newTradeService) {
}

@Override
@SuppressWarnings("unused")
protected final Set<OrderDTO> getNewValues() {
getLogger().debug("OrderFlux - Retrieving new values");
Set<OrderDTO> newValues = new LinkedHashSet<>();
Expand Down
Loading

0 comments on commit c853d64

Please sign in to comment.