-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'github/develop' into gateio-v4
- Loading branch information
Showing
70 changed files
with
3,188 additions
and
1,081 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
349 changes: 314 additions & 35 deletions
349
xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitAdapters.java
Large diffs are not rendered by default.
Oops, something went wrong.
118 changes: 95 additions & 23 deletions
118
xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitAuthenticated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,118 @@ | ||
package org.knowm.xchange.bybit; | ||
|
||
import jakarta.ws.rs.*; | ||
import static org.knowm.xchange.bybit.service.BybitDigest.X_BAPI_API_KEY; | ||
import static org.knowm.xchange.bybit.service.BybitDigest.X_BAPI_SIGN; | ||
import static org.knowm.xchange.bybit.service.BybitDigest.X_BAPI_TIMESTAMP; | ||
|
||
import jakarta.ws.rs.FormParam; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.HeaderParam; | ||
import jakarta.ws.rs.POST; | ||
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.math.BigDecimal; | ||
import org.knowm.xchange.bybit.dto.BybitResult; | ||
import org.knowm.xchange.bybit.dto.account.BybitBalances; | ||
import org.knowm.xchange.bybit.dto.trade.BybitOrderDetails; | ||
import org.knowm.xchange.bybit.dto.trade.BybitOrderRequest; | ||
import org.knowm.xchange.bybit.dto.account.allcoins.BybitAllCoinsBalance; | ||
import org.knowm.xchange.bybit.dto.account.feerates.BybitFeeRates; | ||
import org.knowm.xchange.bybit.dto.account.walletbalance.BybitWalletBalance; | ||
import org.knowm.xchange.bybit.dto.trade.BybitOrderResponse; | ||
import org.knowm.xchange.bybit.dto.trade.details.BybitOrderDetail; | ||
import org.knowm.xchange.bybit.dto.trade.details.BybitOrderDetails; | ||
import org.knowm.xchange.bybit.service.BybitException; | ||
import si.mazi.rescu.ParamsDigest; | ||
import si.mazi.rescu.SynchronizedValueFactory; | ||
|
||
@Path("/spot/v1") | ||
@Path("/v5") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public interface BybitAuthenticated { | ||
|
||
/** | ||
* @apiSpec <a href="https://bybit-exchange.github.io/docs/v5/account/wallet-balance">API</a> | ||
*/ | ||
@GET | ||
@Path("/account/wallet-balance") | ||
BybitResult<BybitWalletBalance> getWalletBalance( | ||
@HeaderParam(X_BAPI_API_KEY) String apiKey, | ||
@HeaderParam(X_BAPI_SIGN) ParamsDigest signature, | ||
@HeaderParam(X_BAPI_TIMESTAMP) SynchronizedValueFactory<Long> timestamp, | ||
@QueryParam("accountType") String accountType) | ||
throws IOException, BybitException; | ||
|
||
/** | ||
* @apiSpec <a href="https://bybit-exchange.github.io/docs/v5/asset/all-balance">API</a> | ||
*/ | ||
@GET | ||
@Path("/asset/transfer/query-account-coins-balance") | ||
BybitResult<BybitAllCoinsBalance> getAllCoinsBalance( | ||
@HeaderParam(X_BAPI_API_KEY) String apiKey, | ||
@HeaderParam(X_BAPI_SIGN) ParamsDigest signature, | ||
@HeaderParam(X_BAPI_TIMESTAMP) SynchronizedValueFactory<Long> timestamp, | ||
@QueryParam("accountType") String accountType) | ||
throws IOException, BybitException; | ||
|
||
/** | ||
* @apiSpec <a href="https://bybit-exchange.github.io/docs/v5/account/fee-rate">API</a> | ||
*/ | ||
@GET | ||
@Path("/account") | ||
BybitResult<BybitBalances> getWalletBalances( | ||
@QueryParam("api_key") String apiKey, | ||
@QueryParam("timestamp") SynchronizedValueFactory<Long> timestamp, | ||
@QueryParam("sign") ParamsDigest signature) | ||
@Path("/account/fee-rate") | ||
BybitResult<BybitFeeRates> getFeeRates( | ||
@HeaderParam(X_BAPI_API_KEY) String apiKey, | ||
@HeaderParam(X_BAPI_SIGN) ParamsDigest signature, | ||
@HeaderParam(X_BAPI_TIMESTAMP) SynchronizedValueFactory<Long> timestamp, | ||
@QueryParam("category") String category, | ||
@QueryParam("symbol") String symbol) | ||
throws IOException, BybitException; | ||
|
||
/** | ||
* @apiSpec <a href="https://bybit-exchange.github.io/docs/v5/order/open-order">API</a> | ||
*/ | ||
@GET | ||
@Path("/order") | ||
BybitResult<BybitOrderDetails> getOrder( | ||
@QueryParam("api_key") String apiKey, | ||
@QueryParam("orderId") String orderId, | ||
@QueryParam("timestamp") SynchronizedValueFactory<Long> timestamp, | ||
@QueryParam("sign") ParamsDigest signature) | ||
@Path("/order/realtime") | ||
BybitResult<BybitOrderDetails<BybitOrderDetail>> getOpenOrders( | ||
@HeaderParam(X_BAPI_API_KEY) String apiKey, | ||
@HeaderParam(X_BAPI_SIGN) ParamsDigest signature, | ||
@HeaderParam(X_BAPI_TIMESTAMP) SynchronizedValueFactory<Long> timestamp, | ||
@QueryParam("category") String category, | ||
@QueryParam("orderId") String orderId) | ||
throws IOException, BybitException; | ||
|
||
/** | ||
* @apiSpec <a href="https://bybit-exchange.github.io/docs/v5/order/create-order">API</a> | ||
*/ | ||
@POST | ||
@Path("/order/create") | ||
BybitResult<BybitOrderResponse> placeMarketOrder( | ||
@HeaderParam(X_BAPI_API_KEY) String apiKey, | ||
@HeaderParam(X_BAPI_SIGN) ParamsDigest signature, | ||
@HeaderParam(X_BAPI_TIMESTAMP) SynchronizedValueFactory<Long> timestamp, | ||
@FormParam("category") String category, | ||
@FormParam("symbol") String symbol, | ||
@FormParam("side") String side, | ||
@FormParam("orderType") String orderType, | ||
@FormParam("qty") BigDecimal qty, | ||
@FormParam("orderLinkId") String orderLinkId) | ||
throws IOException, BybitException; | ||
|
||
/** | ||
* @apiSpec <a href="https://bybit-exchange.github.io/docs/v5/order/create-order">API</a> | ||
*/ | ||
@POST | ||
@Path("/order") | ||
BybitResult<BybitOrderRequest> placeOrder( | ||
@FormParam("api_key") String apiKey, | ||
@Path("/order/create") | ||
BybitResult<BybitOrderResponse> placeLimitOrder( | ||
@HeaderParam(X_BAPI_API_KEY) String apiKey, | ||
@HeaderParam(X_BAPI_SIGN) ParamsDigest signature, | ||
@HeaderParam(X_BAPI_TIMESTAMP) SynchronizedValueFactory<Long> timestamp, | ||
@FormParam("category") String category, | ||
@FormParam("symbol") String symbol, | ||
@FormParam("qty") long qty, | ||
@FormParam("side") String side, | ||
@FormParam("type") String type, | ||
@FormParam("timestamp") SynchronizedValueFactory<Long> timestamp, | ||
@FormParam("sign") ParamsDigest signature) | ||
@FormParam("orderType") String orderType, | ||
@FormParam("qty") BigDecimal qty, | ||
@FormParam("price") BigDecimal price, | ||
@FormParam("positionIdx") Integer positionIdx, | ||
@FormParam("orderLinkId") String orderLinkId, | ||
@FormParam("reduceOnly") Boolean reduceOnly) | ||
throws IOException, BybitException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
xchange-bybit/src/main/java/org/knowm/xchange/bybit/dto/BybitCategorizedPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.knowm.xchange.bybit.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.util.List; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class BybitCategorizedPayload<T> { | ||
|
||
@JsonProperty("category") | ||
BybitCategory category; | ||
|
||
@JsonProperty("list") | ||
List<T> list; | ||
} |
16 changes: 16 additions & 0 deletions
16
xchange-bybit/src/main/java/org/knowm/xchange/bybit/dto/BybitCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.knowm.xchange.bybit.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum BybitCategory { | ||
SPOT("spot"), | ||
LINEAR("linear"), | ||
INVERSE("inverse"), | ||
OPTION("option"); | ||
|
||
@JsonValue private final String value; | ||
} |
20 changes: 7 additions & 13 deletions
20
xchange-bybit/src/main/java/org/knowm/xchange/bybit/dto/BybitResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.