Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.bybit.api.client.impl.BybitApiTradeAsyncRestClientImpl Maven / Gradle / Ivy
Go to download
The Official Java API connector for Bybit's HTTP and WebSocket APIs.
Dive into a plethora of functionalities:
- Market Data Retrieval
- Trade Execution
- Position Management
- Account and Asset Info Retrieval
- User and Upgrade Management
— Public Websocket Streaming
- Private Websocket Streaming
- Lending Institution and Client
- Broker Earning Data
package com.bybit.api.client.impl;
import com.bybit.api.client.domain.trade.request.BatchOrderRequest;
import com.bybit.api.client.restApi.BybitApiAsyncTradeRestClient;
import com.bybit.api.client.restApi.BybitApiCallback;
import com.bybit.api.client.restApi.BybitApiService;
import com.bybit.api.client.domain.trade.request.TradeOrderRequest;
import com.bybit.api.client.service.BybitJsonConverter;
import java.io.IOException;
import java.util.Map;
import static com.bybit.api.client.service.BybitApiServiceGenerator.createService;
public class BybitApiTradeAsyncRestClientImpl implements BybitApiAsyncTradeRestClient {
private final BybitApiService bybitApiService;
private final BybitJsonConverter converter = new BybitJsonConverter();
public BybitApiTradeAsyncRestClientImpl(String apiKey, String secret, String baseUrl, boolean debugMode, long recvWindow, String logOption, String referer) {
bybitApiService = createService(BybitApiService.class, apiKey, secret, baseUrl, debugMode, recvWindow, logOption, referer);
}
@Override
public void getOrderHistory(TradeOrderRequest orderHistoryRequest, BybitApiCallback callback) {
bybitApiService.getOrderHistory(
orderHistoryRequest.getCategory().getCategoryTypeId(),
orderHistoryRequest.getSymbol(),
orderHistoryRequest.getBaseCoin(),
orderHistoryRequest.getSettleCoin(),
orderHistoryRequest.getOrderId(),
orderHistoryRequest.getOrderLinkId(),
orderHistoryRequest.getOrderFilter() == null ? null : orderHistoryRequest.getOrderFilter().getOrderFilterType(),
orderHistoryRequest.getOrderStatus(),
orderHistoryRequest.getStartTime(),
orderHistoryRequest.getEndTime(),
orderHistoryRequest.getLimit(),
orderHistoryRequest.getCursor())
.enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void setDisconnectCancelAllTime(TradeOrderRequest orderRequest, BybitApiCallback callback) {
var setDcpRequest = converter.convertMapToDcpRequest(orderRequest);
bybitApiService.setDisconnectCancelAllTime(setDcpRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void getBorrowQuota(TradeOrderRequest borrowQuotaRequest, BybitApiCallback callback) {
bybitApiService.getBorrowQuota(
borrowQuotaRequest.getCategory().getCategoryTypeId(),
borrowQuotaRequest.getSymbol(),
borrowQuotaRequest.getSide() == null ? null : borrowQuotaRequest.getSide().getTransactionSide())
.enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void getOpenOrders(TradeOrderRequest order, BybitApiCallback callback) {
bybitApiService.getOpenOrders(
order.getCategory().getCategoryTypeId(),
order.getSymbol(),
order.getBaseCoin(),
order.getSettleCoin(),
order.getOrderId(),
order.getOrderLinkId(),
order.getOpenOnly(),
order.getOrderFilter() == null ? null : order.getOrderFilter().getOrderFilterType(),
order.getLimit(),
order.getCursor())
.enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void getTradeHistory(TradeOrderRequest order, BybitApiCallback callback) {
bybitApiService.getTradeHistory(
order.getCategory().getCategoryTypeId(),
order.getSymbol(),
order.getOrderId(),
order.getOrderLinkId(),
order.getBaseCoin(),
order.getStartTime(),
order.getEndTime(),
order.getExecType() == null ? null : order.getExecType().getExecTypeId(),
order.getLimit(),
order.getCursor()
).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void createOrder(TradeOrderRequest order, BybitApiCallback callback) {
var placeOrderRequest = converter.convertTradeToPlaceOrderRequest(order);
bybitApiService.createOrder(placeOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void createOrder(Map order, BybitApiCallback callback) {
var singleOrderRequest = converter.convertMapToSingleOrderRequest(order);
var placeOrderRequest = converter.convertTradeToPlaceOrderRequest(singleOrderRequest);
bybitApiService.createOrder(placeOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void createOrder(String order, BybitApiCallback callback) throws IOException {
var singleOrderRequest = converter.convertJsonToSingleOrderRequest(order);
var placeOrderRequest = converter.convertTradeToPlaceOrderRequest(singleOrderRequest);
bybitApiService.createOrder(placeOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void createBatchOrder(BatchOrderRequest batchOrderRequest, BybitApiCallback callback) {
var placeBatchOrderRequest = converter.convertToPlaceBatchOrderRequest(batchOrderRequest);
bybitApiService.createBatchOrder(placeBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void createBathOrder(Map payload, BybitApiCallback callback) {
var batchOrderRequest = converter.convertMapToBatchOrderRequest(payload);
var placeBatchOrderRequest = converter.convertToPlaceBatchOrderRequest(batchOrderRequest);
bybitApiService.createBatchOrder(placeBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void createBathOrder(String json, BybitApiCallback callback) throws IOException {
var batchOrderRequest = converter.jsonToBatchOrderRequest(json);
var placeBatchOrderRequest = converter.convertToPlaceBatchOrderRequest(batchOrderRequest);
bybitApiService.createBatchOrder(placeBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void amendBatchOrder(BatchOrderRequest batchOrderRequest, BybitApiCallback callback) {
var amendBatchOrderRequest = converter.convertToAmendBatchOrderRequest(batchOrderRequest);
bybitApiService.amendBatchOrder(amendBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void amendBatchOrder(Map payload, BybitApiCallback callback) {
var batchOrderRequest = converter.convertMapToBatchOrderRequest(payload);
var amendBatchOrderRequest = converter.convertToAmendBatchOrderRequest(batchOrderRequest);
bybitApiService.amendBatchOrder(amendBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void amendBatchOrder(String json, BybitApiCallback callback) throws IOException {
var batchOrderRequest = converter.jsonToBatchOrderRequest(json);
var amendBatchOrderRequest = converter.convertToAmendBatchOrderRequest(batchOrderRequest);
bybitApiService.amendBatchOrder(amendBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void cancelBatchOrder(BatchOrderRequest batchOrderRequest, BybitApiCallback callback) {
var cancelBatchOrderRequest = converter.convertToCancelBatchOrderRequest(batchOrderRequest);
bybitApiService.cancelBatchOrder(cancelBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void cancelBatchOrder(Map payload, BybitApiCallback callback) {
var batchOrderRequest = converter.convertMapToBatchOrderRequest(payload);
var cancelBatchOrderRequest = converter.convertToCancelBatchOrderRequest(batchOrderRequest);
bybitApiService.cancelBatchOrder(cancelBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void cancelBatchOrder(String json, BybitApiCallback callback) throws IOException {
var batchOrderRequest = converter.jsonToBatchOrderRequest(json);
var cancelBatchOrderRequest = converter.convertToCancelBatchOrderRequest(batchOrderRequest);
bybitApiService.cancelBatchOrder(cancelBatchOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void cancelOrder(TradeOrderRequest order, BybitApiCallback callback) {
var cancelOrderRequest = converter.convertTradeToCancelOrderRequest(order);
bybitApiService.cancelOrder(cancelOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void cancelAllOrder(TradeOrderRequest order, BybitApiCallback callback) {
var cancelAllOrderRequest = converter.convertTradeToCancelAllOrdersRequest(order);
bybitApiService.cancelAllOrder(cancelAllOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void amendOrder(TradeOrderRequest order, BybitApiCallback callback) {
var amendOrderRequest = converter.convertTradeToAmendOrderRequest(order);
bybitApiService.amendOrder(amendOrderRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
}