Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Possible values for Price points #316

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@
</issueManagement>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>

Expand Down Expand Up @@ -126,6 +123,15 @@

<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<altDeploymentRepository>
internal.repo::default::file://${project.build.directory}/mvn-repo
</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*******************************************************************************/
package com.github.jnidzwetzki.bitfinex.v2.symbol;

import java.util.Arrays;
import java.util.Objects;

import org.json.JSONObject;
Expand Down Expand Up @@ -59,25 +60,24 @@ public enum Precision {
private final Integer pricePoints;


BitfinexOrderBookSymbol(final BitfinexCurrencyPair currencyPair, final Precision orderBookPrecision,
final Frequency frequency, final Integer pricePoints) {
BitfinexOrderBookSymbol(
final BitfinexCurrencyPair currencyPair, final com.github.jnidzwetzki.bitfinex.v2.symbol.BitfinexOrderBookSymbol.Precision orderBookPrecision,
final com.github.jnidzwetzki.bitfinex.v2.symbol.BitfinexOrderBookSymbol.Frequency frequency, final Integer pricePoints
) {
this.currencyPair = currencyPair;
this.orderBookPrecision = orderBookPrecision;
if (orderBookPrecision != Precision.R0) {
if (orderBookPrecision != com.github.jnidzwetzki.bitfinex.v2.symbol.BitfinexOrderBookSymbol.Precision.R0) {
this.frequency = frequency;

if(pricePoints == null) {
throw new IllegalArgumentException("Price points must be != NULL");
}

if (pricePoints < 25 || pricePoints > 100) {
throw new IllegalArgumentException("Price points must be between 25 and 100");
if (!Arrays.asList(1, 25, 100, 250).contains(pricePoints)) {
throw new IllegalArgumentException("Possible values for Price points are: 1, 25, 100, 250");
}
this.pricePoints = pricePoints;
} else {
this.frequency = null;
this.pricePoints = null;

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void testCommandsJSON() throws BitfinexCommandException {
final BitfinexCandlestickSymbol candleSymbol = BitfinexSymbols.candlesticks(currencyPair, BitfinexCandleTimeFrame.HOUR_1);

BitfinexOrderBookSymbol orderbookConfiguration = BitfinexSymbols.orderBook(currencyPair, BitfinexOrderBookSymbol.Precision.P0,
BitfinexOrderBookSymbol.Frequency.F0, 50);
BitfinexOrderBookSymbol.Frequency.F0, 25);

BitfinexOrderBookSymbol rawOrderbookConfiguration = BitfinexSymbols.rawOrderBook(BitfinexCurrencyPair.of("ETH", "BTC"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public static void registerDefaultCurrencyPairs() {
@Test
public void testTradingOrderbookEquals() {
final BitfinexOrderBookSymbol configuration1 = BitfinexSymbols.orderBook(
BitfinexCurrencyPair.of("BTC","USD"), BitfinexOrderBookSymbol.Precision.P1, BitfinexOrderBookSymbol.Frequency.F1, 50);
BitfinexCurrencyPair.of("BTC","USD"), BitfinexOrderBookSymbol.Precision.P1, BitfinexOrderBookSymbol.Frequency.F1, 25);

final BitfinexOrderBookSymbol configuration2 = BitfinexSymbols.orderBook(
BitfinexCurrencyPair.of("BTC","USD"), BitfinexOrderBookSymbol.Precision.P1, BitfinexOrderBookSymbol.Frequency.F1, 50);
BitfinexCurrencyPair.of("BTC","USD"), BitfinexOrderBookSymbol.Precision.P1, BitfinexOrderBookSymbol.Frequency.F1, 25);

final BitfinexOrderBookSymbol configuration3 = BitfinexSymbols.orderBook(
BitfinexCurrencyPair.of("BTC","USD"), BitfinexOrderBookSymbol.Precision.P0, BitfinexOrderBookSymbol.Frequency.F1, 50);
BitfinexCurrencyPair.of("BTC","USD"), BitfinexOrderBookSymbol.Precision.P0, BitfinexOrderBookSymbol.Frequency.F1, 25);

Assert.assertEquals(configuration1.hashCode(), configuration2.hashCode());
Assert.assertEquals(configuration1, configuration2);
Expand Down