Skip to content

Commit

Permalink
Merge branch 'release/5.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
straumat committed Sep 1, 2021
2 parents e2e8c6f + f8446be commit 406cb31
Show file tree
Hide file tree
Showing 180 changed files with 1,611 additions and 666 deletions.
4 changes: 1 addition & 3 deletions docs/src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ module.exports = {
text: 'Deploy & run',
ariaLabel: 'Deploy & run',
items: [
{text: 'Using Docker', link: '/deploy-and-run/docker'},
{text: 'Using Qovery', link: '/deploy-and-run/qovery'},
{text: 'Using Docker', link: '/deploy-and-run/docker'}
]
},
{
Expand All @@ -131,7 +130,6 @@ module.exports = {
{
text: 'How-tos', items: [
{text: 'Install development tools', link: '/ressources/how-tos/how-to-install-development-tools'},
{text: 'Install terraform', link: '/ressources/how-tos/how-to-install-terraform'},
{text: 'Build from sources', link: '/ressources/how-tos/how-to-build-from-sources'},
{text: 'Create a release', link: '/ressources/how-tos/how-to-create-a-release'},
{text: 'Create a Kucoin account', link: '/ressources/how-tos/how-to-create-a-kucoin-account'},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tagline: Create your java crypto trading bot in minutes
actionText: Quick Start
actionLink: /learn/quickstart
features:
- title: Get into trading with Minimum fuss
- title: Get into trading with minimum fuss
details: Available as a Spring boot starter, Cassandre takes care of exchange connections, accounts, orders, trades, and positions, so you can focus on building your strategy.
- title: Create your strategy in minutes
details: Just code when you want to create short/long positions, set the rules, and we take care of everything (buying, selling, rules management, orders, trades, and tickers).
Expand Down
2 changes: 1 addition & 1 deletion docs/src/learn/dry-mode-and-backtesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You can use the dry mode to test your trading bot with real data, but you can al
## Backtesting
In simple words, backtesting a strategy is the process of testing a trading strategy on prior time periods. Cassandre trading bot allows you to simulate your bots' reaction to historical data during tests.

The first step is to add [cassandre-trading-bot-spring-boot-starter-test](https://mvnrepository.com/artifact/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-starter-test) to your project dependency.
The first step is to add [cassandre-trading-bot-spring-boot-starter-test](https://search.maven.org/search?q=a:cassandre-trading-bot-spring-boot-starter-test) to your project dependency.

Edit your `pom.xml` file and add this dependency :

Expand Down
Binary file modified docs/src/learn/images/cassandre-trading-bot-architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/src/learn/position-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ At this moment, Cassandre will create a buy order of 0.5 ETH (1 ETH costs 1500 U
Note: if you want to check if you have enough funds available (at least 750 USDT in our case) before creating the position, you can use the [canBuy()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#canBuy%28tech.cassandre.trading.bot.dto.user.AccountDTO,tech.cassandre.trading.bot.dto.util.CurrencyPairDTO,java.math.BigDecimal%29) method.
:::

From now on, for every ticker received, Cassandre will automatically calculate, with the new price, if closing the position at that price would trigger one of our two rules (100% stop gain and 50% stop loss).
From now on, for every ticker received, Cassandre will automatically calculate, with the new price (from the ticker), if closing the position at that price would trigger one of our two rules (100% stop gain and 50% stop loss).

For example, if we receive a new price of 3000 USDT for 1 ETH, Cassandre will calculate that if we sell our position right now (meaning "closing the position"), we will get 1 500 USDT, a 100% gain. As our rule is triggered, Cassandre will automatically create a selling order of our 0.5 ETH. The position status will move to [CLOSING](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionStatusDTO.html#CLOSING), and when all the corresponding trades have arrived, the status will move to [CLOSED](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionStatusDTO.html#CLOSED).

Expand All @@ -52,9 +52,9 @@ Note: if you want to check if you have enough funds available (at 1 ETH in our c
:::

## Gains
On a position you can get the:
* The lowest calculated gain with [getLowestPrice()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getLowestCalculatedGain())
* The highest calculated gain with [getHighestGainPrice()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getHighestGainPrice())
* The latest calculated gain with [getLatestGainPrice](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getLatestGainPrice())
On Positions, you can get the:
* The lowest calculated gain with [getLowestCalculatedGain()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getLowestCalculatedGain())
* The highest calculated gain with [getHighestCalculatedGain()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getHighestCalculatedGain())
* The latest calculated gain with [getLatestCalculatedGain()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getLatestCalculatedGain())

Once the position is closed, you can get the final gain & fees with [getGain()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getGain())
On a closed position, you can get the gain & fees with [getGain()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionDTO.html#getGain())
19 changes: 9 additions & 10 deletions docs/src/learn/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mvn archetype:generate \

It will ask for the following parameters:

| Parameters | Description | Examples |
| Parameters | Description | Example values |
| :--- | :--- | :--- |
| groupId | The id of the project's group | com.mycompany.app |
| artifactId | The id of the artifact (project) | my-app |
Expand Down Expand Up @@ -71,7 +71,7 @@ cassandre.trading.bot.exchange.secret=af080d55-afe3-47c9-8ec1-4b479fbcc5e7
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').
# Exchange API calls rates (In ms or standard ISO 8601 duration like 'PT5S').
cassandre.trading.bot.exchange.rates.account=2000
cassandre.trading.bot.exchange.rates.ticker=2000
cassandre.trading.bot.exchange.rates.trade=2000
Expand Down Expand Up @@ -142,9 +142,8 @@ public final class SimpleStrategy extends BasicCassandreStrategy {

@Override
public Optional<AccountDTO> getTradeAccount(Set<AccountDTO> accounts) {
// From all the accounts retrieved by the server, we return the one we used for trading.
// From all the accounts we have on the exchange, we must return the one we use for trading.
if (accounts.size() == 1) {
// Used for Gemini integration tests.
return accounts.stream().findAny();
} else {
return accounts.stream()
Expand All @@ -161,7 +160,7 @@ public final class SimpleStrategy extends BasicCassandreStrategy {

@Override
public final void onTickersUpdates(final Map<CurrencyPairDTO, TickerDTO> tickers) {
// Here we will receive tickers received.
// Here we will receive all tickers we required from the exchange.
tickers.values().forEach(ticker -> System.out.println("Received information about a ticker : " + ticker));
}

Expand Down Expand Up @@ -197,10 +196,10 @@ A Cassandre strategy is a class annotated with [@CassandreStrategy](https://www.

This is how it works :

* In [getRequestedCurrencyPairs()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/CassandreStrategyInterface.html#getRequestedCurrencyPairs%28%29), you have to return the list of currency pairs updates you want to receive from the exchange.
* On the exchange, you usually have several accounts, and Cassandre needs to know which one of your accounts is the trading one. To do so, you have to implement the [getTradeAccount()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/CassandreStrategyInterface.html#getTradeAccount%28java.util.Set%29) method, which gives you as a parameter the list of accounts you own, and from that list, you have to return only one.
* In [getRequestedCurrencyPairs()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/CassandreStrategyInterface.html#getRequestedCurrencyPairs%28%29), you give to Cassandre the list of currency pairs updates you want to receive from the exchange.
* On the exchange, you usually have several accounts, and Cassandre needs to know which one of your accounts is the trading one. To do so, you have to implement the [getTradeAccount()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/CassandreStrategyInterface.html#getTradeAccount%28java.util.Set%29) method, which gives you as a parameter the list of accounts you own, and from that list, you have to return the one you use for trading.
* If there is a change in your account data, [onAccountsUpdates()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#onAccountsUpdates(java.util.Map)) will be called.
* When a new ticker is available, [onTickersUpdates()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#onTickersUpdates(java.util.Map)) will be called.
* When new tickers are available, [onTickersUpdates()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#onTickersUpdates(java.util.Map)) will be called.
* If there is a change in your orders, [onOrdersUpdates()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#onOrdersUpdates(java.util.Map)) will be called.
* If there is a change in your trades, [onTradesUpdates()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#onTradesUpdates(java.util.Map)) will be called.
* If there is a change in your positions, [onPositionsUpdates()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#onPositionsUpdates(java.util.Map)) will be called.
Expand All @@ -226,7 +225,7 @@ This is the list of available methods :
Inside your strategy, you can call [canBuy()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#canBuy%28tech.cassandre.trading.bot.dto.user.AccountDTO,tech.cassandre.trading.bot.dto.util.CurrencyPairDTO,java.math.BigDecimal%29) and [canSell()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#canSell%28tech.cassandre.trading.bot.dto.util.CurrencyDTO,java.math.BigDecimal%29) methods to see if your account has enough money to buy or sell assets.
:::

Cassandre trading bot also provides positions to manage your trade automatically :
Cassandre trading bot also provides positions to manage your trade automatically:

```java
// Create rule.
Expand All @@ -240,7 +239,7 @@ createLongPosition(new CurrencyPairDTO(BTC, USDT),
rules);
```

First, we created a rule saying this position should be closed if the gain is more than 10% or if the loss is more than 5%.
First, we created a [rule](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/dto/position/PositionRulesDTO.html) saying this position should be closed if the gain is more than 10% or if the loss is more than 5%.

Then we called the [createLongPosition()](https://www.javadoc.io/doc/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-autoconfigure/latest/tech/cassandre/trading/bot/strategy/GenericCassandreStrategy.html#createLongPosition(tech.cassandre.trading.bot.dto.util.CurrencyPairDTO,java.math.BigDecimal,tech.cassandre.trading.bot.dto.position.PositionRulesDTO)) method. This will automatically create a buy order. From now, for every ticker received, Cassandre will check the gain or loss made on this position; if it triggers one of the rules, Cassandre will automatically create a sell order to close the position.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/learn/technical-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ On the exchange, you usually have several accounts, and Cassandre needs to know
```java
@Override
public Optional<AccountDTO> getTradeAccount(Set<AccountDTO> accounts) {
// From all the accounts retrieved by the server, we return the one we used for trading.
// From all the accounts we have on the exchange, we must return the one we use for trading.
if (accounts.size() == 1) {
return accounts.stream().findAny();
} else {
Expand Down
3 changes: 0 additions & 3 deletions docs/src/ressources/how-tos/how-to-create-a-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
## Prepare the release
* Fix [Codacy](https://app.codacy.com/gh/cassandre-tech/cassandre-trading-bot/issues) & Intellij warnings.
* Update [security.md](https://github.com/cassandre-tech/cassandre-trading-bot/blob/development/SECURITY.md).
* Update libraries used by archetypes:
* [trading-bot-archetypes/basic-archetype/src/main/resources/archetype-resources/pom.xml](https://github.com/cassandre-tech/cassandre-trading-bot/blob/development/trading-bot-archetypes/basic-archetype/src/main/resources/archetype-resources/pom.xml).
* [trading-bot-archetypes/basic-ta4j-archetype/src/main/resources/archetype-resources/pom.xml](https://github.com/cassandre-tech/cassandre-trading-bot/blob/development/trading-bot-archetypes/basic-ta4j-archetype/src/main/resources/archetype-resources/pom.xml).

## Create the release with Maven
You must be using `ssh` and not `https`. To switch to `ssh`, type :
Expand Down
4 changes: 2 additions & 2 deletions docs/src/why-cassandre/features-and-roadmap.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Features & roadmap

* [Create and execute your strategies in minutes](../learn/quickstart.md).
* Available as a [Spring boot starter](https://mvnrepository.com/artifact/tech.cassandre.trading.bot/cassandre-trading-bot-spring-boot-starter).
* Connect to several cryptocurrency exchanges thanks to [XChange](https://github.com/knowm/XChange).
* Available as a [Spring boot starter](https://search.maven.org/search?q=g:%22tech.cassandre.trading.bot%22%20AND%20a:%22cassandre-trading-bot-spring-boot-starter%22).
* Connect to several cryptocurrency exchanges thanks to [XChange](../why-cassandre/supported-cryptocurrency-exchanges.md).
* User, accounts, and balances management with real-time market data.
* Buy / Sell market & limit orders.
* [Automatic position management](../learn/position-management.md) (with stop gain & stop loss rules).
Expand Down
Loading

0 comments on commit 406cb31

Please sign in to comment.