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

[bitget] Add bitget exchange #4944

Merged
merged 9 commits into from
Sep 5, 2024
Merged
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
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<module>xchange-bitcointoyou</module>
<module>xchange-bitfinex</module>
<module>xchange-bitflyer</module>
<module>xchange-bitget</module>
<module>xchange-bithumb</module>
<module>xchange-bitmex</module>
<module>xchange-bitso</module>
Expand Down
5 changes: 5 additions & 0 deletions xchange-bitget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# private properties for idea rest client
http-client.private.env.json

# private properties for integration tests
integration-test.env.properties
21 changes: 21 additions & 0 deletions xchange-bitget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Using IntelliJ Idea HTTP client

There are *.http files stored in `src/test/resources/rest` that can be used with IntelliJ Idea HTTP Client.

Some requests need authorization, so the api credentials have to be stored in `http-client.private.env.json` in module's root. Sample content can be found in `example.http-client.private.env.json`

> [!CAUTION]
> Never commit your api credentials to the repository!


[HTTP Client documentation](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html)

## Running integration tests that require API keys

Integration tests that require API keys read them from environment variables. They can be defined in `integration-test.env.properties`. Sample content can be found in `example.integration-test.env.properties`.

If no keys are provided the integration tests that need them are skipped.

> [!CAUTION]
> Never commit your api credentials to the repository!

7 changes: 7 additions & 0 deletions xchange-bitget/example.http-client.private.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default": {
"api_key": "change_me",
"api_secret": "change_me",
"api_passphrase": "change_me"
}
}
3 changes: 3 additions & 0 deletions xchange-bitget/example.integration-test.env.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiKey=change_me
secretKey=change_me
passphrase=change_me
5 changes: 5 additions & 0 deletions xchange-bitget/http-client.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"default": {
"api_host": "https://api.bitget.com"
}
}
2 changes: 2 additions & 0 deletions xchange-bitget/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lombok.equalsAndHashCode.callSuper = call
lombok.tostring.callsuper = call
73 changes: 73 additions & 0 deletions xchange-bitget/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-parent</artifactId>
<version>5.2.1-SNAPSHOT</version>
</parent>

<artifactId>xchange-bitget</artifactId>

<name>XChange Bitget</name>
<description>XChange implementation for the Bitget Exchange</description>

<url>http://knowm.org/open-source/xchange/</url>
<inceptionYear>2012</inceptionYear>

<organization>
<name>Knowm Inc.</name>
<url>http://knowm.org/open-source/xchange/</url>
</organization>

<dependencies>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${version.fasterxml}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.knowm.xchange</groupId>
<artifactId>xchange-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertiesFile>integration-test.env.properties</systemPropertiesFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>

</build>

</project>
50 changes: 50 additions & 0 deletions xchange-bitget/src/main/java/org/knowm/xchange/bitget/Bitget.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.knowm.xchange.bitget;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import java.io.IOException;
import java.util.List;
import org.knowm.xchange.bitget.dto.BitgetException;
import org.knowm.xchange.bitget.dto.BitgetResponse;
import org.knowm.xchange.bitget.dto.marketdata.BitgetCoinDto;
import org.knowm.xchange.bitget.dto.marketdata.BitgetMarketDepthDto;
import org.knowm.xchange.bitget.dto.marketdata.BitgetServerTime;
import org.knowm.xchange.bitget.dto.marketdata.BitgetSymbolDto;
import org.knowm.xchange.bitget.dto.marketdata.BitgetTickerDto;

@Path("")
@Produces(MediaType.APPLICATION_JSON)
public interface Bitget {

@GET
@Path("api/v2/public/time")
BitgetResponse<BitgetServerTime> serverTime() throws IOException, BitgetException;


@GET
@Path("api/v2/spot/public/coins")
BitgetResponse<List<BitgetCoinDto>> coins(@QueryParam("coin") String coin) throws IOException, BitgetException;


@GET
@Path("api/v2/spot/public/symbols")
BitgetResponse<List<BitgetSymbolDto>> symbols(@QueryParam("symbol") String symbol)
throws IOException, BitgetException;


@GET
@Path("api/v2/spot/market/tickers")
BitgetResponse<List<BitgetTickerDto>> tickers(@QueryParam("symbol") String symbol)
throws IOException, BitgetException;


@GET
@Path("api/v2/spot/market/orderbook")
BitgetResponse<BitgetMarketDepthDto> orderbook(@QueryParam("symbol") String symbol)
throws IOException, BitgetException;


}
Loading
Loading