Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Aug 7, 2020
2 parents 8097bfd + 51865dc commit 2e2b20f
Show file tree
Hide file tree
Showing 134 changed files with 6,930 additions and 2,548 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,18 @@ jobs:
KUCOIN_PASSPHRASE: ${{ secrets.KUCOIN_PASSPHRASE }}
KUCOIN_KEY: ${{ secrets.KUCOIN_KEY }}
KUCOIN_SECRET: ${{ secrets.KUCOIN_SECRET }}
run: mvn deploy -B -Dgpg.passphrase=${GPG_PASSPHRASE}
run: |
mvn deploy -B -Dgpg.passphrase=${GPG_PASSPHRASE}
echo "::set-output name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
# ================================================================================================================
- 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 -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
12 changes: 0 additions & 12 deletions .github/workflows/release-creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,6 @@ jobs:
asset_name: cassandre-trading-bot-spring-boot-starter-${{ steps.package.outputs.version }}.jar
asset_content_type: application/java-archive

# ================================================================================================================
# Upload cassandre-trading-bot-spring-boot-starter-archetype assets to the release (jar).
- name: Upload cassandre-trading-bot-spring-boot-starter-archetype jar
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: trading-bot-spring-boot-starter-archetype/target/cassandre-trading-bot-spring-boot-starter-archetype-${{ steps.package.outputs.version }}.jar
asset_name: cassandre-trading-bot-spring-boot-starter-archetype-${{ steps.package.outputs.version }}.jar
asset_content_type: application/java-archive

# ================================================================================================================
- name : Publish the release announce on Twitter
uses: ethomson/send-tweet-action@v1
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ index.md
/images/
/trading-bot-strategies/technical_analysis/ta4j-strategy/.idea/
/trading-bot-strategies/technical_analysis/ta4j-strategy/.idea/libraries/
/archetype-test-basic/
/archetype-test-ta4j-basic/
11 changes: 11 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Security Policy

## Supported Versions

| Version | Supported |
| ------- | ------------------ |
| 1.0.x | :white_check_mark: |

## Reporting a Vulnerability

Send an email to [email protected] and we will reply within 24 hours.
7 changes: 3 additions & 4 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>1.0.0</version>
<version>2.0.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.2.6.RELEASE</version>
<version>2.3.2.RELEASE</version>
<relativePath/>
</parent>
<!-- =========================================================================================================== -->
Expand All @@ -58,8 +58,7 @@
<module>trading-bot-spring-boot-autoconfigure</module>
<module>trading-bot-spring-boot-starter</module>
<module>trading-bot-spring-boot-starter-archetype</module>
<module>trading-bot-strategies/dumb</module>
<module>trading-bot-strategies/technical_analysis/ta4j-strategy</module>
<module>trading-bot-spring-boot-starter-basic-ta4j-archetype</module>
</modules>
<!-- =========================================================================================================== -->

Expand Down
23 changes: 15 additions & 8 deletions trading-bot-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.1.2.Final</version>
<version>6.1.5.Final</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
Expand All @@ -45,12 +45,19 @@
<dependency>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-core</artifactId>
<version>4.4.2</version>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-kucoin</artifactId>
<version>4.4.2</version>
<version>5.0.1</version>
</dependency>

<!-- Ta4j -->
<dependency>
<groupId>org.ta4j</groupId>
<artifactId>ta4j-core</artifactId>
<version>0.13</version>
</dependency>

<!-- Util -->
Expand Down Expand Up @@ -80,13 +87,13 @@
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>0.5.5</version>
<version>0.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -99,7 +106,7 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-bom</artifactId>
<version>Dysprosium-SR6</version>
<version>Dysprosium-SR10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -121,7 +128,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.31</version>
<version>8.35</version>
</dependency>
</dependencies>
<executions>
Expand Down Expand Up @@ -255,7 +262,7 @@
<parent>
<groupId>tech.cassandre.trading.bot</groupId>
<artifactId>cassandre-trading-bot-project</artifactId>
<version>1.0.0</version>
<version>2.0.0</version>
</parent>
<!-- =========================================================================================================== -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Set;

/**
* Account flux.
* Account flux - push {@link AccountDTO}.
*/
public class AccountFlux extends BaseFlux<AccountDTO> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Set;

/**
* Order flux.
* Order flux - push {@link OrderDTO}.
*/
public class OrderFlux extends BaseFlux<OrderDTO> {

Expand Down Expand Up @@ -41,12 +41,11 @@ protected final Set<OrderDTO> getNewValues() {
OrderDTO existingOrder = previousValues.get(order.getId());
// If it does not exist or something changed, we do it.
if (existingOrder == null || !existingOrder.equals(order)) {
getLogger().debug("OrderFlux - order {} has changed : {}", order.getId(), order);
getLogger().debug("OrderFlux - Order {} has changed : {}", order.getId(), order);
previousValues.put(order.getId(), order);
newValues.add(order);
}
});
// TODO Removing all the orders no more returned by the exchange.
getLogger().debug("OrderFlux - {} order(s) updated", newValues.size());
return newValues;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package tech.cassandre.trading.bot.batch;

import tech.cassandre.trading.bot.dto.position.PositionDTO;
import tech.cassandre.trading.bot.service.PositionService;
import tech.cassandre.trading.bot.util.base.BaseFlux;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

/**
* Position flux - push {@link PositionDTO}.
*/
public class PositionFlux extends BaseFlux<PositionDTO> {

/** Position service. */
private final PositionService positionService;

/** Previous values. */
private final Map<Long, PositionDTO> previousValues = new LinkedHashMap<>();

/**
* Constructor.
*
* @param newPositionService position service
*/
public PositionFlux(final PositionService newPositionService) {
this.positionService = newPositionService;
}

@Override
@SuppressWarnings("unused")
protected final Set<PositionDTO> getNewValues() {
getLogger().debug("PositionFlux - Retrieving new values");
Set<PositionDTO> newValues = new LinkedHashSet<>();

// Finding which positions has been updated.
positionService.getPositions().forEach(position -> {
getLogger().debug("PositionFlux - Treating position : {}", position.getId());
PositionDTO existingPosition = previousValues.get(position.getId());
if (existingPosition == null || !existingPosition.equals(position)) {
getLogger().debug("PositionFlux - Flux {} has changed : {}", position.getId(), position);
previousValues.put(position.getId(), position);
newValues.add(position);
}
});

getLogger().debug("PositionFlux - {} position(s) updated", newValues.size());
return newValues;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Set;

/**
* Ticker flux.
* Ticker flux - push {@link TickerDTO}.
*/
public class TickerFlux extends BaseFlux<TickerDTO> {

Expand Down Expand Up @@ -52,13 +52,13 @@ public void updateRequestedCurrencyPairs(final Set<CurrencyPairDTO> newRequested
@Override
@SuppressWarnings("unused")
protected final Set<TickerDTO> getNewValues() {
getLogger().debug("TickerDTO - Retrieving new values");
getLogger().debug("TickerFlux - Retrieving new values");
Set<TickerDTO> newValues = new LinkedHashSet<>();
getCurrencyPairToTreat()
.flatMap(marketService::getTicker)
.ifPresent(t -> {
if (!t.equals(previousValues.get(t.getCurrencyPair()))) {
getLogger().debug("TickerDTO - new ticker received : {}", t);
getLogger().debug("TickerFlux - New ticker received : {}", t);
previousValues.replace(t.getCurrencyPair(), t);
newValues.add(t);
}
Expand All @@ -72,7 +72,6 @@ protected final Set<TickerDTO> getNewValues() {
* @return currency pair to treat.
*/
private Optional<CurrencyPairDTO> getCurrencyPairToTreat() {
// TODO Optimize this.
final CurrencyPairDTO nextCurrencyPairToTreat;

// No currency pairs required.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package tech.cassandre.trading.bot.batch;

import tech.cassandre.trading.bot.dto.trade.TradeDTO;
import tech.cassandre.trading.bot.service.TradeService;
import tech.cassandre.trading.bot.util.base.BaseFlux;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

/**
* Trade flux - push {@link TradeDTO}.
*/
public class TradeFlux extends BaseFlux<TradeDTO> {

/** Trade service. */
private final TradeService tradeService;

/** Previous values. */
private final Map<String, TradeDTO> previousValues = new LinkedHashMap<>();

/**
* Constructor.
*
* @param newTradeService trade service
*/
public TradeFlux(final TradeService newTradeService) {
this.tradeService = newTradeService;
}

@Override
@SuppressWarnings("unused")
protected final Set<TradeDTO> getNewValues() {
getLogger().debug("TradeFlux - Retrieving new values");
Set<TradeDTO> newValues = new LinkedHashSet<>();

// Finding which trades has been updated.
tradeService.getTrades().forEach(trade -> {
getLogger().debug("TradeFlux - Treating trade : {}", trade.getId());
TradeDTO existingTrade = previousValues.get(trade.getId());
if (existingTrade == null || !existingTrade.equals(trade)) {
getLogger().debug("TradeFlux - Trade {} has changed : {}", trade.getId(), trade);
previousValues.put(trade.getId(), trade);
newValues.add(trade);
}
});
getLogger().debug("TradeFlux - {} trade(s) updated", newValues.size());
return newValues;
}

}
Loading

0 comments on commit 2e2b20f

Please sign in to comment.