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.BybitApiAsyncPositionRestClientImpl 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.position.request.BatchMovePositionRequest;
import com.bybit.api.client.restApi.BybitApiAsyncPositionRestClient;
import com.bybit.api.client.restApi.BybitApiCallback;
import com.bybit.api.client.restApi.BybitApiService;
import com.bybit.api.client.domain.position.request.PositionDataRequest;
import com.bybit.api.client.service.BybitJsonConverter;
import static com.bybit.api.client.service.BybitApiServiceGenerator.createService;
/**
* Implementation of Bybit's REST API using Retrofit with asynchronous/non-blocking method calls.
*/
public class BybitApiAsyncPositionRestClientImpl implements BybitApiAsyncPositionRestClient {
private final BybitApiService bybitApiService;
private final BybitJsonConverter converter = new BybitJsonConverter();
public BybitApiAsyncPositionRestClientImpl(String apiKey, String secret, String baseUrl, boolean debugMode, long recvWindow, String logOption) {
bybitApiService = createService(BybitApiService.class, apiKey, secret, baseUrl, debugMode, recvWindow, logOption, "");
}
// Position Data
@Override
public void getPositionInfo(PositionDataRequest positionListRequest, BybitApiCallback callback) {
bybitApiService.getPositionInfo(
positionListRequest.getCategory().getCategoryTypeId(),
positionListRequest.getSymbol(),
positionListRequest.getBaseCoin(),
positionListRequest.getSettleCoin(),
positionListRequest.getLimit(),
positionListRequest.getCursor()
).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void setPositionLeverage(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var setLeverageRequest = converter.mapToSetLeverageRequest(positionDataRequest);
bybitApiService.setPositionLeverage(setLeverageRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void swithMarginRequest(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var switchMarginRequest = converter.mapToSwitchMarginRequest(positionDataRequest);
bybitApiService.swithMarginRequest(switchMarginRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void switchPositionMode(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var switchPositionModeRequest = converter.mapToSwitchPositionModeRequest(positionDataRequest);
bybitApiService.switchPositionMode(switchPositionModeRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
@Deprecated
public void setTpslMode(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var setTpSlModeRequest = converter.mapToSetTpSlModeRequest(positionDataRequest);
bybitApiService.setTpslMode(setTpSlModeRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
@Deprecated
public void setRiskLimit(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var setRiskLimitRequest = converter.mapToSetRiskLimitRequest(positionDataRequest);
bybitApiService.setRiskLimit(setRiskLimitRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void setTradingStop(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var tradingStopRequest = converter.mapToTradingStopRequest(positionDataRequest);
bybitApiService.setTradingStop(tradingStopRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void setAutoAddMargin(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var setAutoAddMarginRequest = converter.mapToSetAutoAddMarginRequest(positionDataRequest);
bybitApiService.setAutoAddMargin(setAutoAddMarginRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void modifyPositionMargin(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var modifyMarginRequest = converter.mapToModifyMarginRequest(positionDataRequest);
bybitApiService.modifyPositionMargin(modifyMarginRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void getClosePnlList(PositionDataRequest closePnlHistoryRequest, BybitApiCallback callback) {
bybitApiService.getClosePnlList(
closePnlHistoryRequest.getCategory().getCategoryTypeId(),
closePnlHistoryRequest.getSymbol(),
closePnlHistoryRequest.getStartTime(),
closePnlHistoryRequest.getEndTime(),
closePnlHistoryRequest.getLimit(),
closePnlHistoryRequest.getCursor()
).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void getMovePositionHistory(PositionDataRequest movePositionHistoryRequest, BybitApiCallback callback) {
bybitApiService.getMovePositionHistory(
movePositionHistoryRequest.getCategory().getCategoryTypeId(),
movePositionHistoryRequest.getSymbol(),
movePositionHistoryRequest.getStartTime(),
movePositionHistoryRequest.getEndTime(),
movePositionHistoryRequest.getStatus() == null ? null : movePositionHistoryRequest.getStatus().getMovePositionStatus(),
movePositionHistoryRequest.getBlockTradeId(),
movePositionHistoryRequest.getLimit(),
movePositionHistoryRequest.getCursor()
).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void batchMovePositions(BatchMovePositionRequest batchMovePositionRequest, BybitApiCallback callback) {
bybitApiService.batchMovePositions(batchMovePositionRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
@Override
public void confirmPositionRiskLimit(PositionDataRequest positionDataRequest, BybitApiCallback callback) {
var confirmNewRiskLimitRequest = converter.mapToConfirmNewRiskLimitRequest(positionDataRequest);
bybitApiService.confirmPositionRiskLimit(confirmNewRiskLimitRequest).enqueue(new BybitApiCallbackAdapter<>(callback));
}
}