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

Feature proj 10957 sdk更新 #8

Merged
merged 2 commits into from
Dec 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
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ public class PoloApiConstants {
public static final String Current_Position="/v3/trade/position/opens";
public static final String Position_History="/v3/trade/position/history";
public static final String Adjust_Margin="/v3/trade/position/margin";
public static final String Switch_Cross="/v3/position/switchIsolated";
public static final String Margin_Mode="/v3/position/marginType";
public static final String Get_Leverage="/v3/position/leverage";
// public static final String Switch_Cross="/v3/position/switchIsolated";
// public static final String Margin_Mode="/v3/position/marginType";
// public static final String Get_Leverage="/v3/position/leverage";
public static final String Set_Leverage="/v3/position/leverage";

public static final String Switch_Mode="/v3/position/mode";
public static final String Get_Mode="/v3/position/mode";
public static final String Get_Leverages="/v3/position/leverages";

public static final String Order_Book="/v3/market/orderBook";
public static final String K_line_Data="/v3/market/candles";
public static final String Execution_Info="/v3/market/trades";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ public class AdjustMarginRequest {
private String amt; // Margin amount
@NonNull
private String type; // Operation type: ADD or REDUCE

@NonNull
private String posSide;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public class CloseAtMarketPriceRequest {
@NonNull
private String symbol; // 必需,表示交易对
private String clOrdId; // 可选,客户端指定的订单ID
private String mgnMode;
private String posSide;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public class PlaceMultipleOrdersRequest {
private Boolean reduceOnly; // 可选
private String timeInForce; // 可选,默认值GTC
private String stpMode; // 可选,默认值NONE
private String mgnMode;
private String posSide;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public class PlaceOrderRequest {
private Boolean reduceOnly; // Reduce only, optional
private String timeInForce; // Enumerate FOK, IOC, and GTC. It is an optional field with GTC by default, optional.
private String stpMode; // Enumerate - EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH. Default is NONE, optional.
private String mgnMode;
private String posSide;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ public class SetLeverageRequest {
private String symbol;
@NonNull
private String lever;
@NonNull
private String mgnMode;
@NonNull
private String posSide;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.poloniex.api.client.future.model.request.future;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NonNull;

@Data
@Builder
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class SetModeRequest {
@NonNull
private String posMode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public static class AdjustMargin {
private String amt; // Margin amount
private String type; // Operation type: ADD or REDUCE
private String lever; // Leverage of the current position, from 1 to 75
private String posSide;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static class GetCurrentOrders{
private String deductAmt;
private String stpMode;
private String cTime;
private String uTime;}
private String uTime;
private String posSide;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ public static class GetExecutionDetails {
private String deductCcy; // Currency for Deducted Fees
private String deductAmt; // Cumulative Deducted Fee Amount
private String feeRate; // Fee Rate
private String posSide;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.poloniex.api.client.future.model.response.future;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class GetLeveragesResponse {
private int code;
private String msg;
private List<GetLeverages> data=new ArrayList<GetLeverages>();

@Data
// @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class GetLeverages {
private String symbol;
private String mgnMode;
private String posSide;
private String lever;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.poloniex.api.client.future.model.response.future;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class GetModeResponse {
private int code;
private String msg;
private PositionMode data;

@Data
// @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class PositionMode {
private String posMode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ public static class GetOrderHistory {
private String stpMode = "NONE"; // Default value as NONE
private String cTime;
private String uTime;
private String posSide;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public class SetLeverageResponse {
public static class SetLeverage {
private String symbol;
private String lever;
private String mgnMode;
private String posSide;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.poloniex.api.client.future.model.response.future;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SetModeResponse {
private int code;
private String msg;
private Object data;


}
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,36 @@ Call<GetPositionHistoryResponse> getPositionHistory(@Query("symbol") String s
@Query("limit") Integer limit,
@Query("direct") String direct,
@Query("sTime") String sTime,
@Query("eTime") String eTime);
@Query("eTime") String eTime,
@Query("posSide") String posSide);


@POST(Adjust_Margin)
Call<AdjustMarginResponse> adjustMargin(@Body AdjustMarginRequest request);


@POST(Switch_Cross)
Call<SwitchCrossResponse> switchCross(@Body SwitchCrossRequest request);
// @POST(Switch_Cross)
// Call<SwitchCrossResponse> switchCross(@Body SwitchCrossRequest request);

// @GET(Margin_Mode)
// Call<GetMarginModeResponse> getMarginMode(@Query("symbol") String symbol);

@GET(Margin_Mode)
Call<GetMarginModeResponse> getMarginMode(@Query("symbol") String symbol);

@GET(Get_Leverage)
Call<GetLeverageResponse> getLeverage(@Query("symbol") String symbol);
// @GET(Get_Leverage)
// Call<GetLeverageResponse> getLeverage(@Query("symbol") String symbol);


@POST(Set_Leverage)
Call<SetLeverageResponse> setLeverage(@Body SetLeverageRequest request);

@POST(Switch_Mode)
Call<SetModeResponse> setPositionMode(@Body SetModeRequest request);

@GET(Get_Mode)
Call<GetModeResponse> getPositionMode();

@GET(Get_Leverages)
Call<GetLeveragesResponse> getLeverages(@Query("symbol") String symbol,
@Query("mgnMode") String mgnMode);

/* @GET(Order_Book)
Call<GetOrderBookResponse> getOrderBook(@Query("symbol") String symbol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public GetCurrentPositionResponse getCurrentPosition(String symbol) {
return execute(spotPoloPrivateApiService.getCurrentPosition(symbol));
}

public GetLeveragesResponse getLeverages(String symbol,String mgnModel) {
return execute(spotPoloPrivateApiService.getLeverages(symbol,mgnModel));
}

public GetPositionHistoryResponse getPositionHistory(String symbol,
String mgnMode,
Expand All @@ -163,7 +166,7 @@ public GetPositionHistoryResponse getPositionHistory(String symbol,
String direct,
String sTime,
String eTime) {
return execute(spotPoloPrivateApiService.getPositionHistory(symbol, mgnMode, from, limit, direct, sTime, eTime));
return execute(spotPoloPrivateApiService.getPositionHistory(symbol, mgnMode, from, limit, direct, sTime, eTime, null));
}


Expand All @@ -172,25 +175,28 @@ public AdjustMarginResponse adjustMargin(AdjustMarginRequest request) {
}


public SwitchCrossResponse switchCross(SwitchCrossRequest request) {
return execute(spotPoloPrivateApiService.switchCross(request));
}


public GetMarginModeResponse getMarginMode( String symbol) {
return execute(spotPoloPrivateApiService.getMarginMode(symbol));
}


public GetLeverageResponse getLeverage(String symbol) {
return execute(spotPoloPrivateApiService.getLeverage(symbol));
}
// public SwitchCrossResponse switchCross(SwitchCrossRequest request) {
// return execute(spotPoloPrivateApiService.switchCross(request));
// }
//
//
// public GetMarginModeResponse getMarginMode( String symbol) {
// return execute(spotPoloPrivateApiService.getMarginMode(symbol));
// }
//
//
// public GetLeverageResponse getLeverage(String symbol) {
// return execute(spotPoloPrivateApiService.getLeverage(symbol));
// }


public SetLeverageResponse setLeverage(SetLeverageRequest request) {
return execute(spotPoloPrivateApiService.setLeverage(request));
}

public GetModeResponse getPositionMode() {
return execute(spotPoloPrivateApiService.getPositionMode());
}

public GetOrderBookResponse getOrderBook(String symbol,
String scale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ private static void testPrivateEndpoints(SpotPoloRestClient poloniexApiClient) t
log.info("getCurrentPosition: {}", writer.writeValueAsString(poloniexApiClient.getCurrentPosition("BTC_USDT_PERP")));
log.info("getPositionHistory: {}", writer.writeValueAsString(poloniexApiClient.getPositionHistory("BTC_USDT_PERP",null,null,null,null,null,null)));
log.info("adjustMargin: {}", writer.writeValueAsString(poloniexApiClient.adjustMargin(AdjustMarginRequest.builder().symbol("DOT_USDT_PERP").type("ADD").amt("50").build())));
log.info("switchCross: {}", writer.writeValueAsString(poloniexApiClient.switchCross(SwitchCrossRequest.builder().symbol("DOT_USDT_PERP").mgnMode("CROSS").build())));
log.info("getMarginMode: {}", writer.writeValueAsString(poloniexApiClient.getMarginMode("DOT_USDT_PERP")));
log.info("getLeverage: {}", writer.writeValueAsString(poloniexApiClient.getLeverage("BTC_USDT_PERP")));
// log.info("switchCross: {}", writer.writeValueAsString(poloniexApiClient.switchCross(SwitchCrossRequest.builder().symbol("DOT_USDT_PERP").mgnMode("CROSS").build())));
// log.info("getMarginMode: {}", writer.writeValueAsString(poloniexApiClient.getMarginMode("DOT_USDT_PERP")));
// log.info("getLeverage: {}", writer.writeValueAsString(poloniexApiClient.getLeverage("BTC_USDT_PERP")));
log.info("setLeverage: {}", writer.writeValueAsString(poloniexApiClient.setLeverage(SetLeverageRequest.builder().symbol("BTC_USDT_PERP").lever("7").build())));
}

Expand Down
Loading