├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main └── java │ └── xyz │ └── felh │ └── okx │ └── v5 │ ├── OkxApi.java │ ├── OkxApiService.java │ ├── OkxWsApiService.java │ ├── WsMessageListener.java │ ├── constant │ └── OkxConstants.java │ ├── entity │ ├── IOkxObject.java │ ├── rest │ │ ├── IOkxRestObject.java │ │ ├── IOkxRestReq.java │ │ ├── IOkxRestRsp.java │ │ ├── IRestEntity.java │ │ ├── OkeHttpException.java │ │ ├── OkxRestError.java │ │ ├── OkxRestResponse.java │ │ ├── account │ │ │ └── Balance.java │ │ └── trading │ │ │ ├── RsiBackTesting.java │ │ │ ├── grid │ │ │ ├── AddGridInvestmentReq.java │ │ │ ├── AddGridInvestmentRsp.java │ │ │ ├── AdjustGridMarginBalanceReq.java │ │ │ ├── AdjustGridMarginBalanceRsp.java │ │ │ ├── AmendGridAlgoOrderReq.java │ │ │ ├── AmendGridAlgoOrderRsp.java │ │ │ ├── CancelClosePositionOrderForContractGridReq.java │ │ │ ├── CancelClosePositionOrderForContractGridRsp.java │ │ │ ├── ClosePositionForContractGridReq.java │ │ │ ├── ClosePositionForContractGridRsp.java │ │ │ ├── ComputeGridMarginBalanceReq.java │ │ │ ├── ComputeGridMarginBalanceRsp.java │ │ │ ├── ComputeGridMinInvestmentReq.java │ │ │ ├── ComputeGridMinInvestmentRsp.java │ │ │ ├── GridAlgoOrder.java │ │ │ ├── GridAlgoOrderPosition.java │ │ │ ├── GridAlgoSubOrder.java │ │ │ ├── GridApiParam.java │ │ │ ├── InstantTriggerGridAlgoOrderReq.java │ │ │ ├── InstantTriggerGridAlgoOrderRsp.java │ │ │ ├── PlaceGridAlgoOrderReq.java │ │ │ ├── PlaceGridAlgoOrderRsp.java │ │ │ ├── SpotGridWithdrawIncomeReq.java │ │ │ ├── SpotGridWithdrawIncomeRsp.java │ │ │ ├── StopGridAlgoOrderReq.java │ │ │ └── StopGridAlgoOrderRsp.java │ │ │ └── order │ │ │ └── booking │ │ │ ├── CancelOrderReq.java │ │ │ ├── CancelOrderRsp.java │ │ │ ├── PlaceOrderReq.java │ │ │ └── PlaceOrderRsp.java │ └── ws │ │ ├── IOkxWsObject.java │ │ ├── WsArg.java │ │ ├── WsSubscribeEntity.java │ │ ├── biz │ │ ├── AdvanceAlgoOrder.java │ │ ├── AlgoOrder.java │ │ ├── DepositInfo.java │ │ ├── EconomicCalendar.java │ │ ├── GridOrderContract.java │ │ ├── GridOrderSpot.java │ │ ├── GridPositions.java │ │ ├── GridSubOrder.java │ │ ├── IndexCandlesticks.java │ │ ├── MarkPriceCandlesticks.java │ │ └── WithdrawalInfo.java │ │ ├── pri │ │ ├── Account.java │ │ ├── AccountGreeks.java │ │ ├── BalanceAndPosition.java │ │ ├── LiquidationWarning.java │ │ ├── Order.java │ │ └── Positions.java │ │ ├── pub │ │ ├── AdlWarning.java │ │ ├── EstimatedPrice.java │ │ ├── FundingRate.java │ │ ├── IndexTickers.java │ │ ├── Instruments.java │ │ ├── LiquidationOrders.java │ │ ├── MarkPrice.java │ │ ├── OpenInterest.java │ │ ├── OptionSummary.java │ │ └── PriceLimit.java │ │ ├── request │ │ ├── WsChannelRequestArg.java │ │ ├── WsOnceRequest.java │ │ ├── WsRequest.java │ │ ├── WsRequestArg.java │ │ ├── biz │ │ │ ├── AdvanceAlgoOrderArg.java │ │ │ ├── AlgoOrderArg.java │ │ │ ├── DepositInfoArg.java │ │ │ ├── EconomicCalendarArg.java │ │ │ ├── GridOrderContractArg.java │ │ │ ├── GridOrderSpotArg.java │ │ │ ├── GridPositionsArg.java │ │ │ ├── GridSubOrderArg.java │ │ │ ├── IndexCandlesticksArg.java │ │ │ ├── MarkPriceCandlesticksArg.java │ │ │ └── WithdrawalInfoArg.java │ │ ├── pri │ │ │ ├── AccountArg.java │ │ │ ├── AccountGreeksArg.java │ │ │ ├── AmendOrderArg.java │ │ │ ├── BalanceAndPositionArg.java │ │ │ ├── CancelOrderArg.java │ │ │ ├── LiquidationWarningArg.java │ │ │ ├── LoginArg.java │ │ │ ├── MassCancelOrderArg.java │ │ │ ├── OrderArg.java │ │ │ ├── PlaceOrderArg.java │ │ │ └── PositionsArg.java │ │ └── pub │ │ │ ├── AdlWarningArg.java │ │ │ ├── EstimatedPriceArg.java │ │ │ ├── FundingRateArg.java │ │ │ ├── IndexTickersArg.java │ │ │ ├── InstrumentsArg.java │ │ │ ├── LiquidationOrdersArg.java │ │ │ ├── MarkPriceArg.java │ │ │ ├── OpenInterestArg.java │ │ │ ├── OptionSummaryArg.java │ │ │ └── PriceLimitArg.java │ │ └── response │ │ ├── CommonResponse.java │ │ ├── ErrorResponse.java │ │ ├── Event.java │ │ ├── IWsResponse.java │ │ ├── LoginResponse.java │ │ ├── WsChannelResponseArg.java │ │ ├── WsOnceResponse.java │ │ ├── WsResponse.java │ │ ├── WsResponseArg.java │ │ ├── WsSubscribeResponse.java │ │ ├── biz │ │ ├── AdvanceAlgoOrderArg.java │ │ ├── AlgoOrderArg.java │ │ ├── DepositInfoArg.java │ │ ├── EconomicCalendarArg.java │ │ ├── GridOrderContractArg.java │ │ ├── GridOrderSpotArg.java │ │ ├── GridPositionsArg.java │ │ ├── GridSubOrderArg.java │ │ ├── IndexCandlesticksArg.java │ │ ├── MarkPriceCandlesticksArg.java │ │ └── WithdrawalInfoArg.java │ │ ├── pri │ │ ├── AccountArg.java │ │ ├── AccountGreeksArg.java │ │ ├── AmendOrderArg.java │ │ ├── BalanceAndPositionArg.java │ │ ├── CancelOrderArg.java │ │ ├── LiquidationWarningArg.java │ │ ├── MassCancelOrderArg.java │ │ ├── OrderArg.java │ │ ├── PlaceOrderArg.java │ │ └── PositionsArg.java │ │ └── pub │ │ ├── AdlWarningArg.java │ │ ├── EstimatedPriceArg.java │ │ ├── FundingRateArg.java │ │ ├── IndexTickersArg.java │ │ ├── InstrumentsArg.java │ │ ├── LiquidationOrdersArg.java │ │ ├── MarkPriceArg.java │ │ ├── OpenInterestArg.java │ │ ├── OptionSummaryArg.java │ │ └── PriceLimitArg.java │ ├── enumeration │ ├── AlgoOrderType.java │ ├── ContractDirection.java │ ├── InstrumentType.java │ ├── OrderCategory.java │ ├── OrderState.java │ ├── OrderType.java │ ├── PositionsSide.java │ ├── Side.java │ ├── StpMode.java │ ├── TpOrderKind.java │ ├── TriggerAction.java │ ├── TriggerCondition.java │ ├── TriggerPxType.java │ ├── TriggerStrategy.java │ ├── TriggerType.java │ └── ws │ │ ├── AdlWarningState.java │ │ ├── Channel.java │ │ ├── EventType.java │ │ ├── ExecType.java │ │ ├── FundingRateMethod.java │ │ ├── FundingRateSettleState.java │ │ ├── MgnMode.java │ │ ├── Operation.java │ │ ├── PriceType.java │ │ ├── QuickMgnType.java │ │ ├── TdMode.java │ │ └── WsChannel.java │ ├── handler │ ├── WsErrorHandler.java │ ├── WsHandler.java │ ├── WsHandlerFactory.java │ ├── WsLoginHandler.java │ ├── WsOnceHandler.java │ ├── WsSubscribeHandler.java │ └── WsSubscribePushHandler.java │ ├── interceptor │ └── AuthenticationInterceptor.java │ ├── util │ ├── DateUtils.java │ └── SignUtils.java │ └── ws │ ├── BusinessWsListener.java │ ├── FelhWsListener.java │ ├── PrivateWsListener.java │ ├── PublicWsListener.java │ └── SubscribeStateService.java └── test └── java └── xyz └── felh └── okx └── v5 ├── OkxServiceTest.java └── OkxWsServiceTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | target/ 3 | pom.xml.versionsBackup 4 | */pom.xml.versionsBackup -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Wang Lin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/constant/OkxConstants.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.constant; 2 | 3 | /** 4 | * OKX constants 5 | */ 6 | public interface OkxConstants { 7 | 8 | String BASE_URL = "https://www.okx.com"; 9 | String WS_PUBLIC_URL = "wss://ws.okx.com:8443/ws/v5/public"; 10 | String WS_PRIVATE_URL = "wss://ws.okx.com:8443/ws/v5/private"; 11 | String WS_BUSINESS_URL = "wss://ws.okx.com:8443/ws/v5/business"; 12 | 13 | String SIM_BASE_URL = "https://www.okx.com"; 14 | String SIM_WS_PUBLIC_URL = "wss://wspap.okx.com:8443/ws/v5/public?brokerId=9999"; 15 | String SIM_WS_PRIVATE_URL = "wss://wspap.okx.com:8443/ws/v5/private?brokerId=9999"; 16 | String SIM_WS_BUSINESS_URL = "wss://wspap.okx.com:8443/ws/v5/business?brokerId=9999"; 17 | 18 | /** 19 | * 字符串类型的APIKey 20 | */ 21 | String HEADER_OK_ACCESS_KEY = "OK-ACCESS-KEY"; 22 | /** 23 | * 使用HMAC SHA256哈希函数获得哈希值,再使用Base-64编码(请参阅签名)。 24 | */ 25 | String HEADER_OK_ACCESS_SIGN = "OK-ACCESS-SIGN"; 26 | /** 27 | * 发起请求的时间(UTC),如:2020-12-08T09:08:57.715Z 28 | */ 29 | String HEADER_OK_ACCESS_TIMESTAMP = "OK-ACCESS-TIMESTAMP"; 30 | /** 31 | * 您在创建API密钥时指定的Passphrase 32 | */ 33 | String HEADER_OK_ACCESS_PASSPHRASE = "OK-ACCESS-PASSPHRASE"; 34 | 35 | /** 36 | * 模拟盘 37 | */ 38 | String HEADER_X_SIMULATED_TRADING = "x-simulated-trading"; 39 | 40 | /** 41 | * 发送的心跳信息 42 | */ 43 | String HEARTBEAT_REQ_MESSAGE = "ping"; 44 | /** 45 | * 回复的心跳信息 46 | */ 47 | String HEARTBEAT_RSP_MESSAGE = "pong"; 48 | int HEARTBEAT_INTERVAL_SEC = 25; 49 | 50 | // 订阅消息中的常量 51 | String RSP_CHANNEL = "channel"; 52 | String RSP_ARG = "arg"; 53 | String RSP_EVENT = "event"; 54 | String RSP_ID = "id"; 55 | String RSP_OP = "op"; 56 | String RSP_DATA = "data"; 57 | 58 | // common 59 | String EMPTY = ""; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/IOkxObject.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity; 2 | 3 | 4 | import java.io.Serializable; 5 | 6 | /** 7 | * The interface for all object from OKX 8 | */ 9 | public interface IOkxObject extends Serializable { 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/IOkxRestObject.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest; 2 | 3 | import xyz.felh.okx.v5.entity.IOkxObject; 4 | 5 | /** 6 | * for rest api 7 | */ 8 | public interface IOkxRestObject extends IOkxObject { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/IOkxRestReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest; 2 | 3 | public interface IOkxRestReq { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/IOkxRestRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest; 2 | 3 | public interface IOkxRestRsp { 4 | } 5 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/IRestEntity.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest; 2 | 3 | /** 4 | * for all rest entity 5 | */ 6 | public interface IRestEntity extends IOkxRestObject { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/OkeHttpException.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest; 2 | 3 | public class OkeHttpException extends RuntimeException { 4 | 5 | private final OkxRestError okxRestError; 6 | 7 | public OkeHttpException(OkxRestError okxRestError, String message, Throwable cause) { 8 | super(message, cause); 9 | this.okxRestError = okxRestError; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/OkxRestError.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | 8 | @Data 9 | @ToString 10 | public class OkxRestError implements IOkxRestObject { 11 | 12 | @JSONField(name = "code") 13 | @JsonProperty("code") 14 | private Integer code; 15 | 16 | @JSONField(name = "msg") 17 | @JsonProperty("msg") 18 | private String msg; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/OkxRestResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | 8 | import java.util.List; 9 | 10 | @Data 11 | @ToString 12 | public class OkxRestResponse implements IOkxRestObject { 13 | 14 | /** 15 | * 结果代码,0表示成功 16 | */ 17 | @JSONField(name = "code") 18 | @JsonProperty("code") 19 | private Integer code; 20 | 21 | /** 22 | * 错误信息,代码为0时,该字段为空 23 | */ 24 | @JSONField(name = "msg") 25 | @JsonProperty("msg") 26 | private String msg; 27 | 28 | @JSONField(name = "data") 29 | @JsonProperty("data") 30 | private List data; 31 | 32 | /** 33 | * REST网关接收请求时的时间戳,Unix时间戳的微秒数格式,如 1597026383085123 34 | * 返回的时间是请求验证后的时间。 35 | */ 36 | @JSONField(name = "inTime") 37 | @JsonProperty("inTime") 38 | private Long inTime; 39 | 40 | /** 41 | * REST网关发送响应时的时间戳,Unix时间戳的微秒数格式,如 1597026383085123 42 | */ 43 | @JSONField(name = "outTime") 44 | @JsonProperty("outTime") 45 | private Long outTime; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/RsiBackTesting.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 7 | import xyz.felh.okx.v5.entity.rest.IRestEntity; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading 12 | * @class RsiBackTesting 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | @Builder 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class RsiBackTesting implements IRestEntity, IOkxRestRsp { 22 | 23 | /** 24 | * 触发次数 25 | */ 26 | @JSONField(name = "triggerNum") 27 | @JsonProperty("triggerNum") 28 | private Integer triggerNum; 29 | 30 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/AddGridInvestmentReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | import java.math.BigDecimal; 9 | 10 | /** 11 | * @author Forest Wang 12 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 13 | * @class AddGridInvestmentReq 14 | * @email forestwanglin@gmail.cn 15 | * @date 2024/7/25 16 | */ 17 | @Data 18 | @ToString 19 | @Builder 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class AddGridInvestmentReq implements IOkxRestReq { 23 | 24 | /** 25 | * 策略订单ID 26 | */ 27 | @NonNull 28 | @JSONField(name = "algoId") 29 | @JsonProperty("algoId") 30 | private String algoId; 31 | 32 | /** 33 | * 加仓数量 34 | */ 35 | @NonNull 36 | @JSONField(name = "amt") 37 | @JsonProperty("amt") 38 | private BigDecimal amt; 39 | 40 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/AddGridInvestmentRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class AddGridInvestmentRsp 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class AddGridInvestmentRsp implements IOkxRestRsp { 19 | 20 | @JSONField(name = "algoId") 21 | @JsonProperty("algoId") 22 | private String algoId; 23 | 24 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/AdjustGridMarginBalanceReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | import java.math.BigDecimal; 9 | 10 | /** 11 | * @author Forest Wang 12 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 13 | * @class AdjustGridMarginBalanceReq 14 | * @email forestwanglin@gmail.cn 15 | * @date 2024/7/25 16 | */ 17 | @Data 18 | @ToString 19 | @Builder 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class AdjustGridMarginBalanceReq implements IOkxRestReq { 23 | 24 | /** 25 | * 策略订单ID 26 | */ 27 | @NonNull 28 | @JSONField(name = "algoId") 29 | @JsonProperty("algoId") 30 | private String algoId; 31 | 32 | /** 33 | * 调整保证金类型 34 | * add:增加,reduce:减少 35 | */ 36 | @NonNull 37 | @JSONField(name = "type") 38 | @JsonProperty("type") 39 | private String type; 40 | 41 | /** 42 | * 调整保证金数量 43 | * amt和percent必须传一个 44 | */ 45 | @JSONField(name = "amt") 46 | @JsonProperty("amt") 47 | private BigDecimal amt; 48 | 49 | /** 50 | * 调整保证金百分比 51 | */ 52 | @JSONField(name = "percent") 53 | @JsonProperty("percent") 54 | private BigDecimal percent; 55 | 56 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/AdjustGridMarginBalanceRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class AdjustGridMarginBalanceRsp 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class AdjustGridMarginBalanceRsp implements IOkxRestRsp { 19 | 20 | /** 21 | * 策略订单ID 22 | */ 23 | @JSONField(name = "algoId") 24 | @JsonProperty("algoId") 25 | private String algoId; 26 | 27 | /** 28 | * 用户自定义策略ID 29 | */ 30 | @JSONField(name = "algoClOrdId") 31 | @JsonProperty("algoClOrdId") 32 | private String algoClOrdId; 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/AmendGridAlgoOrderReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | import xyz.felh.okx.v5.enumeration.TriggerAction; 8 | import xyz.felh.okx.v5.enumeration.TriggerStrategy; 9 | 10 | import java.math.BigDecimal; 11 | import java.util.List; 12 | 13 | /** 14 | * @author Forest Wang 15 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 16 | * @class AmendGridAlgoOrderReq 17 | * @email forestwanglin@gmail.cn 18 | * @date 2024/7/25 19 | */ 20 | @Data 21 | @ToString 22 | @Builder 23 | @AllArgsConstructor 24 | @NoArgsConstructor 25 | public class AmendGridAlgoOrderReq implements IOkxRestReq { 26 | 27 | /** 28 | * 策略订单ID 29 | */ 30 | @NonNull 31 | @JSONField(name = "algoId") 32 | @JsonProperty("algoId") 33 | private String algoId; 34 | 35 | /** 36 | * 产品ID,如BTC-USDT 37 | */ 38 | @NonNull 39 | @JSONField(name = "instId") 40 | @JsonProperty("instId") 41 | private String instId; 42 | 43 | /** 44 | * 止盈触发价 45 | * 适用于现货网格/合约网格 46 | */ 47 | @JSONField(name = "tpTriggerPx") 48 | @JsonProperty("tpTriggerPx") 49 | private BigDecimal tpTriggerPx; 50 | 51 | /** 52 | * 止损触发价 53 | * 适用于现货网格/合约网格 54 | */ 55 | @JSONField(name = "slTriggerPx") 56 | @JsonProperty("slTriggerPx") 57 | private BigDecimal slTriggerPx; 58 | 59 | /** 60 | * 止盈比率,0.1 代表 10%,仅适用于合约网格 61 | * 当值为""则代表取消止盈比率 62 | */ 63 | @JSONField(name = "tpRatio") 64 | @JsonProperty("tpRatio") 65 | private BigDecimal tpRatio; 66 | 67 | /** 68 | * 止损比率,0.1 代表 10%,仅适用于合约网格 69 | * 当值为""则代表取消止损比率 70 | */ 71 | @JSONField(name = "slRatio") 72 | @JsonProperty("slRatio") 73 | private BigDecimal slRatio; 74 | 75 | /** 76 | * 信号触发参数 77 | * 适用于现货网格/合约网格 78 | */ 79 | @JSONField(name = "triggerParams") 80 | @JsonProperty("triggerParams") 81 | private List triggerParams; 82 | 83 | @Data 84 | @Builder 85 | @ToString 86 | @AllArgsConstructor 87 | @NoArgsConstructor 88 | public static class TriggerParam { 89 | 90 | /** 91 | * Trigger action 92 | * start 93 | * stop 94 | */ 95 | @JSONField(name = "triggerAction") 96 | @JsonProperty("triggerAction") 97 | private TriggerAction triggerAction; 98 | 99 | /** 100 | * Trigger strategy 101 | */ 102 | @JSONField(name = "triggerStrategy") 103 | @JsonProperty("triggerStrategy") 104 | private TriggerStrategy triggerStrategy; 105 | 106 | /** 107 | * Trigger Price 108 | * This field is only valid when triggerStrategy is price 109 | */ 110 | @JSONField(name = "triggerPx") 111 | @JsonProperty("triggerPx") 112 | private BigDecimal triggerPx; 113 | 114 | /** 115 | * Stop type 116 | * Spot grid 1: Sell base currency 2: Keep base currency 117 | * Contract grid 1: Market Close All positions 2: Keep positions 118 | * This field is only valid when triggerAction is stop 119 | */ 120 | @JSONField(name = "stopType") 121 | @JsonProperty("stopType") 122 | private Integer stopType; 123 | 124 | } 125 | 126 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/AmendGridAlgoOrderRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class AmendGridAlgoOrderReq 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class AmendGridAlgoOrderRsp implements IOkxRestRsp { 19 | 20 | /** 21 | * 策略订单ID 22 | */ 23 | @JSONField(name = "algoId") 24 | @JsonProperty("algoId") 25 | private String algoId; 26 | 27 | /** 28 | * 用户自定义策略ID 29 | */ 30 | @JSONField(name = "algoClOrdId") 31 | @JsonProperty("algoClOrdId") 32 | private String algoClOrdId; 33 | 34 | /** 35 | * 事件执行结果的code,0代表成功 36 | */ 37 | @JSONField(name = "sCode") 38 | @JsonProperty("sCode") 39 | private String sCode; 40 | 41 | /** 42 | * 事件执行失败时的msg 43 | */ 44 | @JSONField(name = "sMsg") 45 | @JsonProperty("sMsg") 46 | private String sMsg; 47 | 48 | /** 49 | * 订单标签 50 | */ 51 | @JSONField(name = "tag") 52 | @JsonProperty("tag") 53 | private String tag; 54 | 55 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/CancelClosePositionOrderForContractGridReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | /** 9 | * @author Forest Wang 10 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 11 | * @class CancelClosePositionOrderForContractGridReq 12 | * @email forestwanglin@gmail.cn 13 | * @date 2024/7/25 14 | */ 15 | @Data 16 | @ToString 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class CancelClosePositionOrderForContractGridReq implements IOkxRestReq { 21 | 22 | /** 23 | * 策略订单ID 24 | */ 25 | @NonNull 26 | @JSONField(name = "algoId") 27 | @JsonProperty("algoId") 28 | private String algoId; 29 | 30 | /** 31 | * 平仓单ID 32 | */ 33 | @NonNull 34 | @JSONField(name = "ordId") 35 | @JsonProperty("ordId") 36 | private String ordId; 37 | 38 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/CancelClosePositionOrderForContractGridRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class CancelClosePositionOrderForContractGridReq 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class CancelClosePositionOrderForContractGridRsp implements IOkxRestRsp { 19 | 20 | /** 21 | * 策略订单ID 22 | */ 23 | @JSONField(name = "algoId") 24 | @JsonProperty("algoId") 25 | private String algoId; 26 | 27 | /** 28 | * 平仓单ID 29 | */ 30 | @JSONField(name = "ordId") 31 | @JsonProperty("ordId") 32 | private String ordId; 33 | 34 | /** 35 | * 用户自定义策略ID 36 | */ 37 | @JSONField(name = "algoClOrdId") 38 | @JsonProperty("algoClOrdId") 39 | private String algoClOrdId; 40 | 41 | /** 42 | * 订单标签 43 | */ 44 | @JSONField(name = "tag") 45 | @JsonProperty("tag") 46 | private String tag; 47 | 48 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/ClosePositionForContractGridReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | import java.math.BigDecimal; 9 | 10 | /** 11 | * @author Forest Wang 12 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 13 | * @class ClosePositionForContractGridReq 14 | * @email forestwanglin@gmail.cn 15 | * @date 2024/7/25 16 | */ 17 | @Data 18 | @ToString 19 | @Builder 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class ClosePositionForContractGridReq implements IOkxRestReq { 23 | 24 | /** 25 | * 策略订单ID 26 | */ 27 | @NonNull 28 | @JSONField(name = "algoId") 29 | @JsonProperty("algoId") 30 | private String algoId; 31 | 32 | /** 33 | * 是否市价全平 34 | * true:市价全平,false:部分平仓 35 | */ 36 | @NonNull 37 | @JSONField(name = "mktClose") 38 | @JsonProperty("mktClose") 39 | private Boolean mktClose; 40 | 41 | /** 42 | * 平仓数量,单位为张 43 | * 部分平仓时必传 44 | */ 45 | @JSONField(name = "sz") 46 | @JsonProperty("sz") 47 | private BigDecimal sz; 48 | 49 | /** 50 | * 平仓价格 51 | * 部分平仓时必传 52 | */ 53 | @JSONField(name = "px") 54 | @JsonProperty("px") 55 | private BigDecimal px; 56 | 57 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/ClosePositionForContractGridRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class ClosePositionForContractGridReq 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class ClosePositionForContractGridRsp implements IOkxRestRsp { 19 | 20 | /** 21 | * 策略订单ID 22 | */ 23 | @JSONField(name = "algoId") 24 | @JsonProperty("algoId") 25 | private String algoId; 26 | 27 | /** 28 | * 平仓单ID 29 | * 市价全平时,该字段为"" 30 | */ 31 | @JSONField(name = "ordId") 32 | @JsonProperty("ordId") 33 | private String ordId; 34 | 35 | /** 36 | * 用户自定义策略ID 37 | */ 38 | @JSONField(name = "algoClOrdId") 39 | @JsonProperty("algoClOrdId") 40 | private String algoClOrdId; 41 | 42 | /** 43 | * 订单标签 44 | */ 45 | @JSONField(name = "tag") 46 | @JsonProperty("tag") 47 | private String tag; 48 | 49 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/ComputeGridMarginBalanceReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | import java.math.BigDecimal; 9 | 10 | /** 11 | * @author Forest Wang 12 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 13 | * @class ComputeGridMarginBalanceReq 14 | * @email forestwanglin@gmail.cn 15 | * @date 2024/7/25 16 | */ 17 | @Data 18 | @ToString 19 | @Builder 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class ComputeGridMarginBalanceReq implements IOkxRestReq { 23 | 24 | /** 25 | * 策略订单ID 26 | */ 27 | @NonNull 28 | @JSONField(name = "algoId") 29 | @JsonProperty("algoId") 30 | private String algoId; 31 | 32 | /** 33 | * 调整保证金类型 34 | * add:增加,reduce:减少 35 | */ 36 | @NonNull 37 | @JSONField(name = "type") 38 | @JsonProperty("type") 39 | private String type; 40 | 41 | /** 42 | * 调整保证金数量 43 | */ 44 | @JSONField(name = "amt") 45 | @JsonProperty("amt") 46 | private BigDecimal amt; 47 | 48 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/ComputeGridMarginBalanceRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | import java.math.BigDecimal; 10 | 11 | /** 12 | * @author Forest Wang 13 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 14 | * @class ComputeGridMarginBalanceRsp 15 | * @email forestwanglin@gmail.cn 16 | * @date 2024/7/25 17 | */ 18 | @ToString 19 | @Data 20 | public class ComputeGridMarginBalanceRsp implements IOkxRestRsp { 21 | 22 | /** 23 | * 最多可调整的保证金数量 24 | */ 25 | @JSONField(name = "maxAmt") 26 | @JsonProperty("maxAmt") 27 | private BigDecimal maxAmt; 28 | 29 | /** 30 | * 调整保证金后的杠杠倍数 31 | */ 32 | @JSONField(name = "lever") 33 | @JsonProperty("lever") 34 | private Integer lever; 35 | 36 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/ComputeGridMinInvestmentReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | import xyz.felh.okx.v5.enumeration.AlgoOrderType; 8 | import xyz.felh.okx.v5.enumeration.ContractDirection; 9 | 10 | import java.math.BigDecimal; 11 | import java.util.List; 12 | 13 | /** 14 | * @author Forest Wang 15 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 16 | * @class ComputeGridMinInvestmentReq 17 | * @email forestwanglin@gmail.cn 18 | * @date 2024/7/25 19 | */ 20 | @Data 21 | @ToString 22 | @Builder 23 | @AllArgsConstructor 24 | @NoArgsConstructor 25 | public class ComputeGridMinInvestmentReq implements IOkxRestReq { 26 | 27 | /** 28 | * Instrument ID 29 | */ 30 | @JSONField(name = "instId") 31 | @JsonProperty("instId") 32 | private String instId; 33 | 34 | /** 35 | * 币Algo order type 36 | * grid: Spot grid 37 | */ 38 | @JSONField(name = "algoOrdType") 39 | @JsonProperty("algoOrdType") 40 | private AlgoOrderType algoOrdType; 41 | 42 | /** 43 | * Upper price of price range 44 | */ 45 | @JSONField(name = "maxPx") 46 | @JsonProperty("maxPx") 47 | private BigDecimal maxPx; 48 | 49 | /** 50 | * Lower price of price range 51 | */ 52 | @JSONField(name = "minPx") 53 | @JsonProperty("minPx") 54 | private BigDecimal minPx; 55 | 56 | /** 57 | * Grid quantity 58 | */ 59 | @JSONField(name = "gridNum") 60 | @JsonProperty("gridNum") 61 | private BigDecimal gridNum; 62 | 63 | /** 64 | * 网格类型 65 | * 1:等差,2:等比 66 | */ 67 | @JSONField(name = "runType") 68 | @JsonProperty("runType") 69 | private String runType; 70 | 71 | /** 72 | * 合约网格类型 73 | * 仅适用于合约网格 74 | */ 75 | @JSONField(name = "direction") 76 | @JsonProperty("direction") 77 | private ContractDirection direction; 78 | 79 | /** 80 | * 杠杆倍数 81 | */ 82 | @JSONField(name = "lever") 83 | @JsonProperty("lever") 84 | private Integer lever; 85 | 86 | /** 87 | * 是否开底仓 88 | * 默认为false 89 | */ 90 | @JSONField(name = "basePos") 91 | @JsonProperty("basePos") 92 | private Boolean basePos; 93 | 94 | /** 95 | * 投资信息 96 | */ 97 | @JSONField(name = "investmentData") 98 | @JsonProperty("investmentData") 99 | private List investmentData; 100 | 101 | @Data 102 | @Builder 103 | @ToString 104 | @AllArgsConstructor 105 | @NoArgsConstructor 106 | public static class InvestmentData { 107 | 108 | @JSONField(name = "amt") 109 | @JsonProperty("amt") 110 | private BigDecimal amt; 111 | 112 | @JSONField(name = "ccy") 113 | @JsonProperty("ccy") 114 | private String ccy; 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/ComputeGridMinInvestmentRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | import java.math.BigDecimal; 10 | import java.util.List; 11 | 12 | /** 13 | * @author Forest Wang 14 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 15 | * @class ComputeGridMinInvestmentReq 16 | * @email forestwanglin@gmail.cn 17 | * @date 2024/7/25 18 | */ 19 | @ToString 20 | @Data 21 | public class ComputeGridMinInvestmentRsp implements IOkxRestRsp { 22 | 23 | /** 24 | * 最小投入信息 25 | */ 26 | @JSONField(name = "minInvestmentData") 27 | @JsonProperty("minInvestmentData") 28 | private List minInvestmentData; 29 | 30 | /** 31 | * 单网格买卖量 32 | * 现货网格单位为计价币 33 | * 合约网格单位为张 34 | */ 35 | @JSONField(name = "singleAmt") 36 | @JsonProperty("singleAmt") 37 | private BigDecimal singleAmt; 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/GridApiParam.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 7 | import xyz.felh.okx.v5.entity.rest.IRestEntity; 8 | import xyz.felh.okx.v5.enumeration.AlgoOrderType; 9 | import xyz.felh.okx.v5.enumeration.ContractDirection; 10 | 11 | import java.math.BigDecimal; 12 | 13 | /** 14 | * @author Forest Wang 15 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 16 | * @class GridAlgoOrder 17 | * @email forestwanglin@gmail.cn 18 | * @date 2024/7/25 19 | */ 20 | @ToString 21 | @Data 22 | @Builder 23 | @NoArgsConstructor 24 | @AllArgsConstructor 25 | public class GridApiParam implements IRestEntity, IOkxRestRsp { 26 | 27 | /** 28 | * Instrument ID 29 | */ 30 | @JSONField(name = "instId") 31 | @JsonProperty("instId") 32 | private String instId; 33 | 34 | /** 35 | * 币Algo order type 36 | * grid: Spot grid 37 | */ 38 | @JSONField(name = "algoOrdType") 39 | @JsonProperty("algoOrdType") 40 | private AlgoOrderType algoOrdType; 41 | 42 | /** 43 | * 回测周期 44 | * 7D:7天,30D:30天,180D:180天 45 | */ 46 | @JSONField(name = "duration") 47 | @JsonProperty("duration") 48 | private String duration; 49 | 50 | /** 51 | * Upper price of price range 52 | */ 53 | @JSONField(name = "maxPx") 54 | @JsonProperty("maxPx") 55 | private BigDecimal maxPx; 56 | 57 | /** 58 | * Lower price of price range 59 | */ 60 | @JSONField(name = "minPx") 61 | @JsonProperty("minPx") 62 | private BigDecimal minPx; 63 | 64 | /** 65 | * Grid quantity 66 | */ 67 | @JSONField(name = "gridNum") 68 | @JsonProperty("gridNum") 69 | private BigDecimal gridNum; 70 | 71 | /** 72 | * 单网格最高利润率 73 | */ 74 | @JSONField(name = "perMaxProfitRate") 75 | @JsonProperty("perMaxProfitRate") 76 | private BigDecimal perMaxProfitRate; 77 | 78 | /** 79 | * 单网格最低利润率 80 | */ 81 | @JSONField(name = "perMinProfitRate") 82 | @JsonProperty("perMinProfitRate") 83 | private BigDecimal perMinProfitRate; 84 | 85 | /** 86 | * 网格年化收益率 87 | */ 88 | @JSONField(name = "annualizedRate") 89 | @JsonProperty("annualizedRate") 90 | private BigDecimal annualizedRate; 91 | 92 | /** 93 | * 最小投资数量 94 | */ 95 | @JSONField(name = "minInvestment") 96 | @JsonProperty("minInvestment") 97 | private BigDecimal minInvestment; 98 | 99 | /** 100 | * 投资币种 101 | */ 102 | @JSONField(name = "ccy") 103 | @JsonProperty("ccy") 104 | private String ccy; 105 | 106 | /** 107 | * 网格类型 108 | * 1:等差,2:等比 109 | */ 110 | @JSONField(name = "runType") 111 | @JsonProperty("runType") 112 | private String runType; 113 | 114 | /** 115 | * 合约网格类型 116 | * 仅适用于合约网格 117 | */ 118 | @JSONField(name = "direction") 119 | @JsonProperty("direction") 120 | private ContractDirection direction; 121 | 122 | /** 123 | * 杠杆倍数 124 | */ 125 | @JSONField(name = "lever") 126 | @JsonProperty("lever") 127 | private Integer lever; 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/InstantTriggerGridAlgoOrderReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | /** 9 | * @author Forest Wang 10 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 11 | * @class InstantTriggerGridAlgoOrderReq 12 | * @email forestwanglin@gmail.cn 13 | * @date 2024/7/25 14 | */ 15 | @Data 16 | @ToString 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class InstantTriggerGridAlgoOrderReq implements IOkxRestReq { 21 | 22 | /** 23 | * 策略订单ID 24 | */ 25 | @NonNull 26 | @JSONField(name = "algoId") 27 | @JsonProperty("algoId") 28 | private String algoId; 29 | 30 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/InstantTriggerGridAlgoOrderRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class InstantTriggerGridAlgoOrderReq 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class InstantTriggerGridAlgoOrderRsp implements IOkxRestRsp { 19 | 20 | /** 21 | * 策略订单ID 22 | */ 23 | @JSONField(name = "algoId") 24 | @JsonProperty("algoId") 25 | private String algoId; 26 | 27 | /** 28 | * 用户自定义策略ID 29 | */ 30 | @JSONField(name = "algoClOrdId") 31 | @JsonProperty("algoClOrdId") 32 | private String algoClOrdId; 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/PlaceGridAlgoOrderRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class PlaceGridAlgoOrderReq 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class PlaceGridAlgoOrderRsp implements IOkxRestRsp { 19 | 20 | /** 21 | * 策略订单ID 22 | */ 23 | @JSONField(name = "algoId") 24 | @JsonProperty("algoId") 25 | private String algoId; 26 | 27 | /** 28 | * 用户自定义策略ID 29 | */ 30 | @JSONField(name = "algoClOrdId") 31 | @JsonProperty("algoClOrdId") 32 | private String algoClOrdId; 33 | 34 | /** 35 | * 事件执行结果的code,0代表成功 36 | */ 37 | @JSONField(name = "sCode") 38 | @JsonProperty("sCode") 39 | private String sCode; 40 | 41 | /** 42 | * 事件执行失败时的msg 43 | */ 44 | @JSONField(name = "sMsg") 45 | @JsonProperty("sMsg") 46 | private String sMsg; 47 | 48 | /** 49 | * 订单标签 50 | */ 51 | @JSONField(name = "tag") 52 | @JsonProperty("tag") 53 | private String tag; 54 | 55 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/SpotGridWithdrawIncomeReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | /** 9 | * @author Forest Wang 10 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 11 | * @class SpotGridWithdrawIncomeReq 12 | * @email forestwanglin@gmail.cn 13 | * @date 2024/7/25 14 | */ 15 | @Data 16 | @ToString 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class SpotGridWithdrawIncomeReq implements IOkxRestReq { 21 | 22 | /** 23 | * 策略订单ID 24 | */ 25 | @NonNull 26 | @JSONField(name = "algoId") 27 | @JsonProperty("algoId") 28 | private String algoId; 29 | 30 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/SpotGridWithdrawIncomeRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | import java.math.BigDecimal; 10 | 11 | /** 12 | * @author Forest Wang 13 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 14 | * @class SpotGridWithdrawIncomeRsp 15 | * @email forestwanglin@gmail.cn 16 | * @date 2024/7/25 17 | */ 18 | @ToString 19 | @Data 20 | public class SpotGridWithdrawIncomeRsp implements IOkxRestRsp { 21 | 22 | /** 23 | * 策略订单ID 24 | */ 25 | @JSONField(name = "algoId") 26 | @JsonProperty("algoId") 27 | private String algoId; 28 | 29 | /** 30 | * 用户自定义策略ID 31 | */ 32 | @JSONField(name = "algoClOrdId") 33 | @JsonProperty("algoClOrdId") 34 | private String algoClOrdId; 35 | 36 | /** 37 | * 提取的利润 38 | */ 39 | @JSONField(name = "profit") 40 | @JsonProperty("profit") 41 | private BigDecimal profit; 42 | 43 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/StopGridAlgoOrderReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | import xyz.felh.okx.v5.enumeration.AlgoOrderType; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class StopGridAlgoOrderReq 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @Data 17 | @ToString 18 | @Builder 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class StopGridAlgoOrderReq implements IOkxRestReq { 22 | 23 | /** 24 | * 策略订单ID 25 | */ 26 | @NonNull 27 | @JSONField(name = "algoId") 28 | @JsonProperty("algoId") 29 | private String algoId; 30 | 31 | /** 32 | * 产品ID,如BTC-USDT 33 | */ 34 | @NonNull 35 | @JSONField(name = "instId") 36 | @JsonProperty("instId") 37 | private String instId; 38 | 39 | /** 40 | * 策略订单类型 41 | * grid:现货网格委托 42 | * contract_grid:合约网格委托 43 | */ 44 | @NonNull 45 | @JSONField(name = "algoOrdType") 46 | @JsonProperty("algoOrdType") 47 | private AlgoOrderType algoOrdType; 48 | 49 | /** 50 | * 网格策略停止类型 51 | * 现货网格 1:卖出交易币,2:不卖出交易币 52 | * 合约网格 1:市价全平 2:停止不平仓 53 | */ 54 | @NonNull 55 | @JSONField(name = "stopType") 56 | @JsonProperty("stopType") 57 | private String stopType; 58 | 59 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/grid/StopGridAlgoOrderRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.grid; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | /** 10 | * @author Forest Wang 11 | * @package xyz.felh.okx.v5.entity.rest.trading.grid 12 | * @class StopGridAlgoOrderReq 13 | * @email forestwanglin@gmail.cn 14 | * @date 2024/7/25 15 | */ 16 | @ToString 17 | @Data 18 | public class StopGridAlgoOrderRsp implements IOkxRestRsp { 19 | 20 | /** 21 | * 策略订单ID 22 | */ 23 | @JSONField(name = "algoId") 24 | @JsonProperty("algoId") 25 | private String algoId; 26 | 27 | /** 28 | * 用户自定义策略ID 29 | */ 30 | @JSONField(name = "algoClOrdId") 31 | @JsonProperty("algoClOrdId") 32 | private String algoClOrdId; 33 | 34 | /** 35 | * 事件执行结果的code,0代表成功 36 | */ 37 | @JSONField(name = "sCode") 38 | @JsonProperty("sCode") 39 | private String sCode; 40 | 41 | /** 42 | * 事件执行失败时的msg 43 | */ 44 | @JSONField(name = "sMsg") 45 | @JsonProperty("sMsg") 46 | private String sMsg; 47 | 48 | /** 49 | * 订单标签 50 | */ 51 | @JSONField(name = "tag") 52 | @JsonProperty("tag") 53 | private String tag; 54 | 55 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/order/booking/CancelOrderReq.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.order.booking; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import xyz.felh.okx.v5.entity.rest.IOkxRestReq; 7 | 8 | @Data 9 | @ToString 10 | @Builder 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class CancelOrderReq implements IOkxRestReq { 14 | 15 | /** 16 | * 产品ID,如 BTC-USDT 17 | */ 18 | @NonNull 19 | @JSONField(name = "instId") 20 | @JsonProperty("instId") 21 | private String instId; 22 | 23 | /** 24 | * 订单ID, ordId和clOrdId必须传一个,若传两个,以ordId为主 25 | */ 26 | @JSONField(name = "ordId") 27 | @JsonProperty("ordId") 28 | private String ordId; 29 | 30 | /** 31 | * 用户自定义ID 32 | */ 33 | @JSONField(name = "clOrdId") 34 | @JsonProperty("clOrdId") 35 | private String clOrdId; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/order/booking/CancelOrderRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.order.booking; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | @ToString 10 | @Data 11 | public class CancelOrderRsp implements IOkxRestRsp { 12 | 13 | /** 14 | * 订单ID 15 | */ 16 | @JSONField(name = "ordId") 17 | @JsonProperty("ordId") 18 | private String ordId; 19 | 20 | /** 21 | * 客户自定义订单ID 22 | */ 23 | @JSONField(name = "clOrdId") 24 | @JsonProperty("clOrdId") 25 | private String clOrdId; 26 | 27 | /** 28 | * 事件执行结果的code,0代表成功 29 | */ 30 | @JSONField(name = "sCode") 31 | @JsonProperty("sCode") 32 | private Integer sCode; 33 | 34 | /** 35 | * 事件执行失败或成功时的msg 36 | */ 37 | @JSONField(name = "sMsg") 38 | @JsonProperty("sMsg") 39 | private String sMsg; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/rest/trading/order/booking/PlaceOrderRsp.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.rest.trading.order.booking; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | import xyz.felh.okx.v5.entity.rest.IOkxRestRsp; 8 | 9 | @ToString 10 | @Data 11 | public class PlaceOrderRsp implements IOkxRestRsp { 12 | 13 | /** 14 | * 订单ID 15 | */ 16 | @JSONField(name = "ordId") 17 | @JsonProperty("ordId") 18 | private String ordId; 19 | 20 | /** 21 | * 客户自定义订单ID 22 | */ 23 | @JSONField(name = "clOrdId") 24 | @JsonProperty("clOrdId") 25 | private String clOrdId; 26 | 27 | /** 28 | * 订单标签 29 | */ 30 | @JSONField(name = "tag") 31 | @JsonProperty("tag") 32 | private String tag; 33 | 34 | /** 35 | * 事件执行结果的code,0代表成功 36 | */ 37 | @JSONField(name = "sCode") 38 | @JsonProperty("sCode") 39 | private Integer sCode; 40 | 41 | /** 42 | * 事件执行失败或成功时的msg 43 | */ 44 | @JSONField(name = "sMsg") 45 | @JsonProperty("sMsg") 46 | private String sMsg; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/IOkxWsObject.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws; 2 | 3 | import xyz.felh.okx.v5.entity.IOkxObject; 4 | 5 | /** 6 | * for websocket 7 | */ 8 | public interface IOkxWsObject extends IOkxObject { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/WsArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws; 2 | 3 | /** 4 | * The interface of websocket argument 5 | */ 6 | public interface WsArg { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/WsSubscribeEntity.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws; 2 | 3 | public interface WsSubscribeEntity extends IOkxWsObject { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/biz/DepositInfo.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | 12 | import java.math.BigDecimal; 13 | 14 | @Data 15 | @ToString(callSuper = true) 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class DepositInfo implements WsSubscribeEntity { 20 | 21 | /** 22 | * (产生数据者的)用户标识 23 | */ 24 | @JSONField(name = "uid") 25 | @JsonProperty("uid") 26 | private String uid; 27 | 28 | /** 29 | * 子账户名称 30 | * 如果是母账户产生的数据,该字段返回"" 31 | */ 32 | @JSONField(name = "subAcct") 33 | @JsonProperty("subAcct") 34 | private String subAcct; 35 | 36 | /** 37 | * 推送时间,Unix时间戳的毫秒数格式,如 1597026383085 38 | */ 39 | @JSONField(name = "pTime") 40 | @JsonProperty("pTime") 41 | private Long pTime; 42 | 43 | /** 44 | * 币种名称,如 BTC 45 | */ 46 | @JSONField(name = "ccy") 47 | @JsonProperty("ccy") 48 | private String ccy; 49 | 50 | /** 51 | * 币种链信息 52 | * 有的币种下有多个链,必须要做区分,如USDT下有USDT-ERC20,USDT-TRC20多个链 53 | */ 54 | @JSONField(name = "chain") 55 | @JsonProperty("chain") 56 | private String chain; 57 | 58 | /** 59 | * 充值数量 60 | */ 61 | @JSONField(name = "amt") 62 | @JsonProperty("amt") 63 | private BigDecimal amt; 64 | 65 | /** 66 | * 充值账户,只显示内部账户转账地址,不显示区块链充值地址 67 | */ 68 | @JSONField(name = "from") 69 | @JsonProperty("from") 70 | private String from; 71 | 72 | /** 73 | * 如果from为手机号,该字段为该手机号的区号 74 | */ 75 | @JSONField(name = "areaCodeFrom") 76 | @JsonProperty("areaCodeFrom") 77 | private String areaCodeFrom; 78 | 79 | /** 80 | * 到账地址 81 | */ 82 | @JSONField(name = "to") 83 | @JsonProperty("to") 84 | private String to; 85 | 86 | /** 87 | * 区块转账哈希记录 88 | */ 89 | @JSONField(name = "txId") 90 | @JsonProperty("txId") 91 | private String txId; 92 | 93 | /** 94 | * 充值记录创建时间,Unix 时间戳的毫秒数格式,如 1655251200000 95 | */ 96 | @JSONField(name = "ts") 97 | @JsonProperty("ts") 98 | private Long ts; 99 | 100 | /** 101 | * 账充值状态 102 | * 0:等待确认 103 | * 1:确认到账 104 | * 2:充值成功 105 | * 8:因该币种暂停充值而未到账,恢复充值后自动到账 106 | * 11:命中地址黑名单 107 | * 12:账户或充值被冻结 108 | * 13:子账户充值拦截 109 | * 14:KYC限额 110 | */ 111 | @JSONField(name = "state") 112 | @JsonProperty("state") 113 | private Integer state; 114 | 115 | /** 116 | * 充值记录 ID 117 | */ 118 | @JSONField(name = "depId") 119 | @JsonProperty("depId") 120 | private String depId; 121 | 122 | /** 123 | * 内部转账发起者提币申请 ID 124 | * 如果该笔充值来自于内部转账,则该字段展示内部转账发起者的提币申请 ID,其他情况返回"" 125 | */ 126 | @JSONField(name = "fromWdId") 127 | @JsonProperty("fromWdId") 128 | private String fromWdId; 129 | 130 | /** 131 | * 最新的充币网络确认数 132 | */ 133 | @JSONField(name = "actualDepBlkConfirm") 134 | @JsonProperty("actualDepBlkConfirm") 135 | private Integer actualDepBlkConfirm; 136 | 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/biz/EconomicCalendar.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | 12 | import java.math.BigDecimal; 13 | 14 | @Data 15 | @ToString(callSuper = true) 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class EconomicCalendar implements WsSubscribeEntity { 20 | 21 | /** 22 | * 事件名 23 | */ 24 | @JSONField(name = "event") 25 | @JsonProperty("event") 26 | private String event; 27 | 28 | /** 29 | * 国家,地区或实体 30 | */ 31 | @JSONField(name = "region") 32 | @JsonProperty("region") 33 | private String region; 34 | 35 | /** 36 | * 类别名 37 | */ 38 | @JSONField(name = "category") 39 | @JsonProperty("category") 40 | private String category; 41 | 42 | /** 43 | * 事件实际值 44 | */ 45 | @JSONField(name = "actual") 46 | @JsonProperty("actual") 47 | private BigDecimal actual; 48 | 49 | /** 50 | * 当前事件上个周期的最新实际值 51 | * 若发生数据修正,该字段存储上个周期修正后的实际值 52 | */ 53 | @JSONField(name = "previous") 54 | @JsonProperty("previous") 55 | private BigDecimal previous; 56 | 57 | /** 58 | * 由权威经济学家共同得出的预测值 59 | */ 60 | @JSONField(name = "forecast") 61 | @JsonProperty("forecast") 62 | private BigDecimal forecast; 63 | 64 | /** 65 | * 该事件上一周期的初始值 66 | * 仅在修正发生时有值 67 | */ 68 | @JSONField(name = "prevInitial") 69 | @JsonProperty("prevInitial") 70 | private BigDecimal prevInitial; 71 | 72 | /** 73 | * actual字段值的预期发布时间,Unix时间戳的毫秒数格式,如 1597026383085 74 | */ 75 | @JSONField(name = "date") 76 | @JsonProperty("date") 77 | private Long date; 78 | 79 | /** 80 | * 当前事件指向的日期 81 | */ 82 | @JSONField(name = "refDate") 83 | @JsonProperty("refDate") 84 | private Long refDate; 85 | 86 | /** 87 | * 经济日历ID 88 | */ 89 | @JSONField(name = "calendarId") 90 | @JsonProperty("calendarId") 91 | private String calendarId; 92 | 93 | /** 94 | * 推送时间,Unix 时间戳的毫秒数格式,如 1655251200000 95 | */ 96 | @JSONField(name = "ts") 97 | @JsonProperty("ts") 98 | private Long ts; 99 | 100 | /** 101 | * 事件实际值对应的单位 102 | */ 103 | @JSONField(name = "unit") 104 | @JsonProperty("unit") 105 | private String unit; 106 | 107 | /** 108 | * 事件实际值对应的货币 109 | */ 110 | @JSONField(name = "ccy") 111 | @JsonProperty("ccy") 112 | private String ccy; 113 | 114 | /** 115 | * 重要性 116 | * 1: 低 117 | * 2: 中等 118 | * 3: 高 119 | */ 120 | @JSONField(name = "importance") 121 | @JsonProperty("importance") 122 | private Integer importance; 123 | 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/biz/IndexCandlesticks.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | 12 | import java.math.BigDecimal; 13 | 14 | @Data 15 | @ToString(callSuper = true) 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class IndexCandlesticks implements WsSubscribeEntity { 20 | 21 | /** 22 | * 开始时间,Unix时间戳的毫秒数格式,如 1597026383085 23 | */ 24 | @JSONField(name = "ts") 25 | @JsonProperty("ts") 26 | private Long ts; 27 | 28 | /** 29 | * 开盘价格 30 | */ 31 | @JSONField(name = "o") 32 | @JsonProperty("o") 33 | private BigDecimal o; 34 | 35 | /** 36 | * 最高价格 37 | */ 38 | @JSONField(name = "h") 39 | @JsonProperty("h") 40 | private BigDecimal h; 41 | 42 | /** 43 | * 最低价格 44 | */ 45 | @JSONField(name = "l") 46 | @JsonProperty("l") 47 | private BigDecimal l; 48 | 49 | /** 50 | * 收盘价格 51 | */ 52 | @JSONField(name = "c") 53 | @JsonProperty("c") 54 | private BigDecimal c; 55 | 56 | /** 57 | * K线状态 58 | */ 59 | @JSONField(name = "confirm") 60 | @JsonProperty("confirm") 61 | private Boolean confirm; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/biz/MarkPriceCandlesticks.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | 12 | import java.math.BigDecimal; 13 | 14 | @Data 15 | @ToString(callSuper = true) 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class MarkPriceCandlesticks implements WsSubscribeEntity { 20 | 21 | /** 22 | * 开始时间,Unix时间戳的毫秒数格式,如 1597026383085 23 | */ 24 | @JSONField(name = "ts") 25 | @JsonProperty("ts") 26 | private Long ts; 27 | 28 | /** 29 | * 开盘价格 30 | */ 31 | @JSONField(name = "o") 32 | @JsonProperty("o") 33 | private BigDecimal o; 34 | 35 | /** 36 | * 最高价格 37 | */ 38 | @JSONField(name = "h") 39 | @JsonProperty("h") 40 | private BigDecimal h; 41 | 42 | /** 43 | * 最低价格 44 | */ 45 | @JSONField(name = "l") 46 | @JsonProperty("l") 47 | private BigDecimal l; 48 | 49 | /** 50 | * 收盘价格 51 | */ 52 | @JSONField(name = "c") 53 | @JsonProperty("c") 54 | private BigDecimal c; 55 | 56 | /** 57 | * K线状态 58 | */ 59 | @JSONField(name = "confirm") 60 | @JsonProperty("confirm") 61 | private Boolean confirm; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pri/AccountGreeks.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | 12 | import java.math.BigDecimal; 13 | 14 | @Data 15 | @ToString(callSuper = true) 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class AccountGreeks implements WsSubscribeEntity { 20 | 21 | /** 22 | * 美金本位账户资产delta 23 | */ 24 | @JSONField(name = "deltaBS") 25 | @JsonProperty("deltaBS") 26 | private BigDecimal deltaBS; 27 | 28 | /** 29 | * 币本位账户资产delta 30 | */ 31 | @JSONField(name = "deltaPA") 32 | @JsonProperty("deltaPA") 33 | private BigDecimal deltaPA; 34 | 35 | /** 36 | * 美金本位账户资产gamma,仅适用于期权 37 | */ 38 | @JSONField(name = "gammaBS") 39 | @JsonProperty("gammaBS") 40 | private BigDecimal gammaBS; 41 | 42 | /** 43 | * 币本位账户资产gamma,仅适用于期权 44 | */ 45 | @JSONField(name = "gammaPA") 46 | @JsonProperty("gammaPA") 47 | private BigDecimal gammaPA; 48 | 49 | /** 50 | * 美金本位账户资产theta,仅适用于期权 51 | */ 52 | @JSONField(name = "thetaBS") 53 | @JsonProperty("thetaBS") 54 | private BigDecimal thetaBS; 55 | 56 | /** 57 | * 币本位账户资产theta,仅适用于期权 58 | */ 59 | @JSONField(name = "thetaPA") 60 | @JsonProperty("thetaPA") 61 | private BigDecimal thetaPA; 62 | 63 | /** 64 | * 美金本位账户资产vega,仅适用于期权 65 | */ 66 | @JSONField(name = "vegaBS") 67 | @JsonProperty("vegaBS") 68 | private BigDecimal vegaBS; 69 | 70 | /** 71 | * 币本位账户资产vega,仅适用于期权 72 | */ 73 | @JSONField(name = "vegaPA") 74 | @JsonProperty("vegaPA") 75 | private BigDecimal vegaPA; 76 | 77 | /** 78 | * 币种 79 | */ 80 | @JSONField(name = "ccy") 81 | @JsonProperty("ccy") 82 | private String ccy; 83 | 84 | /** 85 | * 获取greeks的时间,Unix时间戳的毫秒数格式,如 1597026383085 86 | */ 87 | @JSONField(name = "ts") 88 | @JsonProperty("ts") 89 | private Long ts; 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pri/LiquidationWarning.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | import xyz.felh.okx.v5.enumeration.InstrumentType; 12 | import xyz.felh.okx.v5.enumeration.ws.MgnMode; 13 | import xyz.felh.okx.v5.enumeration.PositionsSide; 14 | 15 | import java.math.BigDecimal; 16 | 17 | @Data 18 | @ToString(callSuper = true) 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @SuperBuilder(toBuilder = true) 22 | public class LiquidationWarning implements WsSubscribeEntity { 23 | 24 | /** 25 | * 产品类型 26 | */ 27 | @JSONField(name = "instType") 28 | @JsonProperty("instType") 29 | private InstrumentType instType; 30 | 31 | /** 32 | * 保证金模式 33 | */ 34 | @JSONField(name = "mgnMode") 35 | @JsonProperty("mgnMode") 36 | private MgnMode mgnMode; 37 | 38 | /** 39 | * 持仓ID 40 | */ 41 | @JSONField(name = "posId") 42 | @JsonProperty("posId") 43 | private String posId; 44 | 45 | /** 46 | * 持仓方向 47 | */ 48 | @JSONField(name = "posSide") 49 | @JsonProperty("posSide") 50 | private PositionsSide posSide; 51 | 52 | /** 53 | * 持仓数量 54 | */ 55 | @JSONField(name = "pos") 56 | @JsonProperty("pos") 57 | private BigDecimal pos; 58 | 59 | /** 60 | * 持仓数量币种,仅适用于币币杠杆 61 | */ 62 | @JSONField(name = "posCcy") 63 | @JsonProperty("posCcy") 64 | private String posCcy; 65 | 66 | /** 67 | * 产品ID,如 BTC-USD-180216 68 | */ 69 | @JSONField(name = "instId") 70 | @JsonProperty("instId") 71 | private String instId; 72 | 73 | /** 74 | * 杠杆倍数,不适用于期权卖方 75 | */ 76 | @JSONField(name = "lever") 77 | @JsonProperty("lever") 78 | private BigDecimal lever; 79 | 80 | /** 81 | * 标记价格 82 | */ 83 | @JSONField(name = "markPx") 84 | @JsonProperty("markPx") 85 | private BigDecimal markPx; 86 | 87 | /** 88 | * 保证金率 89 | */ 90 | @JSONField(name = "mgnRatio") 91 | @JsonProperty("mgnRatio") 92 | private BigDecimal mgnRatio; 93 | 94 | /** 95 | * 占用保证金的币种 96 | */ 97 | @JSONField(name = "ccy") 98 | @JsonProperty("ccy") 99 | private String ccy; 100 | 101 | /** 102 | * 持仓创建时间,Unix时间戳的毫秒数格式,如 1597026383085 103 | */ 104 | @JSONField(name = "cTime") 105 | @JsonProperty("cTime") 106 | private Long cTime; 107 | 108 | /** 109 | * 最近一次持仓更新时间,Unix时间戳的毫秒数格式,如 1597026383085 110 | */ 111 | @JSONField(name = "uTime") 112 | @JsonProperty("uTime") 113 | private Long uTime; 114 | 115 | /** 116 | * 持仓信息的推送时间,Unix时间戳的毫秒数格式,如 1597026383085 117 | */ 118 | @JSONField(name = "pTime") 119 | @JsonProperty("pTime") 120 | private Long pTime; 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/EstimatedPrice.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | import xyz.felh.okx.v5.enumeration.InstrumentType; 12 | 13 | import java.math.BigDecimal; 14 | 15 | @Data 16 | @ToString(callSuper = true) 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @SuperBuilder(toBuilder = true) 20 | public class EstimatedPrice implements WsSubscribeEntity { 21 | 22 | /** 23 | * 产品类型 24 | */ 25 | @JSONField(name = "instType") 26 | @JsonProperty("instType") 27 | private InstrumentType instType; 28 | 29 | /** 30 | * 产品ID,如 BTC-USD-170310 31 | */ 32 | @JSONField(name = "instId") 33 | @JsonProperty("instId") 34 | private String instId; 35 | 36 | /** 37 | * 预估交割/行权价 38 | */ 39 | @JSONField(name = "settlePx") 40 | @JsonProperty("settlePx") 41 | private BigDecimal settlePx; 42 | 43 | /** 44 | * 数据更新时间,Unix时间戳的毫秒数格式,如 1597026383085 45 | */ 46 | @JSONField(name = "ts") 47 | @JsonProperty("ts") 48 | private Long ts; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/FundingRate.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | import xyz.felh.okx.v5.enumeration.ws.FundingRateMethod; 12 | import xyz.felh.okx.v5.enumeration.ws.FundingRateSettleState; 13 | import xyz.felh.okx.v5.enumeration.InstrumentType; 14 | 15 | import java.math.BigDecimal; 16 | 17 | @Data 18 | @ToString(callSuper = true) 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @SuperBuilder(toBuilder = true) 22 | public class FundingRate implements WsSubscribeEntity { 23 | 24 | /** 25 | * 产品类型,SWAP 26 | */ 27 | @JSONField(name = "instType") 28 | @JsonProperty("instType") 29 | private InstrumentType instType; 30 | 31 | /** 32 | * 产品ID,如 LTC-USD-SWAP 33 | */ 34 | @JSONField(name = "instId") 35 | @JsonProperty("instId") 36 | private String instId; 37 | 38 | /** 39 | * 资金费收取逻辑 40 | */ 41 | @JSONField(name = "method") 42 | @JsonProperty("method") 43 | private FundingRateMethod method; 44 | 45 | /** 46 | * 资金费率 47 | */ 48 | @JSONField(name = "fundingRate") 49 | @JsonProperty("fundingRate") 50 | private BigDecimal fundingRate; 51 | 52 | /** 53 | * 最新的到期结算的资金费时间,Unix时间戳的毫秒数格式,如 1597026383085 54 | */ 55 | @JSONField(name = "fundingTime") 56 | @JsonProperty("fundingTime") 57 | private Long fundingTime; 58 | 59 | /** 60 | * 下一期预测资金费率 61 | */ 62 | @JSONField(name = "nextFundingRate") 63 | @JsonProperty("nextFundingRate") 64 | private BigDecimal nextFundingRate; 65 | 66 | /** 67 | * 下一期资金费时间,Unix时间戳的毫秒数格式,如 1622851200000 68 | */ 69 | @JSONField(name = "nextFundingTime") 70 | @JsonProperty("nextFundingTime") 71 | private Long nextFundingTime; 72 | 73 | /** 74 | * 下一期的预测资金费率下限 75 | */ 76 | @JSONField(name = "minFundingRate") 77 | @JsonProperty("minFundingRate") 78 | private BigDecimal minFundingRate; 79 | 80 | /** 81 | * 下一期的预测资金费率上限 82 | */ 83 | @JSONField(name = "maxFundingRate") 84 | @JsonProperty("maxFundingRate") 85 | private BigDecimal maxFundingRate; 86 | 87 | /** 88 | * 资金费率结算状态 89 | * processing:结算中 90 | * settled:已结算 91 | */ 92 | @JSONField(name = "settState") 93 | @JsonProperty("settState") 94 | private FundingRateSettleState settState; 95 | 96 | /** 97 | * 若 settState = processing,该字段代表用于本轮结算的资金费率;若 settState = settled,该字段代表用于上轮结算的资金费率 98 | */ 99 | @JSONField(name = "settFundingRate") 100 | @JsonProperty("settFundingRate") 101 | private BigDecimal settFundingRate; 102 | 103 | /** 104 | * 溢价,为合约的中间价和指数价格的差异 105 | */ 106 | @JSONField(name = "premium") 107 | @JsonProperty("premium") 108 | private BigDecimal premium; 109 | 110 | /** 111 | * 数据更新时间,Unix时间戳的毫秒数格式,如 1597026383085 112 | */ 113 | @JSONField(name = "ts") 114 | @JsonProperty("ts") 115 | private Long ts; 116 | 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/IndexTickers.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | 12 | import java.math.BigDecimal; 13 | 14 | @Data 15 | @ToString(callSuper = true) 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class IndexTickers implements WsSubscribeEntity { 20 | 21 | /** 22 | * 指数,以USD、USDT、BTC 为计价货币的指数,如 BTC-USDT 23 | */ 24 | @JSONField(name = "instId") 25 | @JsonProperty("instId") 26 | private String instId; 27 | 28 | /** 29 | * 最新指数价格 30 | */ 31 | @JSONField(name = "idxPx") 32 | @JsonProperty("idxPx") 33 | private BigDecimal idxPx; 34 | 35 | /** 36 | * 24小时开盘价 37 | */ 38 | @JSONField(name = "open24h") 39 | @JsonProperty("open24h") 40 | private BigDecimal open24h; 41 | 42 | /** 43 | * 24小时指数最高价格 44 | */ 45 | @JSONField(name = "high24h") 46 | @JsonProperty("high24h") 47 | private BigDecimal high24h; 48 | 49 | /** 50 | * 24小时指数最低价格 51 | */ 52 | @JSONField(name = "low24h") 53 | @JsonProperty("low24h") 54 | private BigDecimal low24h; 55 | 56 | /** 57 | * UTC 0 时开盘价 58 | */ 59 | @JSONField(name = "sodUtc0") 60 | @JsonProperty("sodUtc0") 61 | private BigDecimal sodUtc0; 62 | 63 | /** 64 | * UTC+8 时开盘价 65 | */ 66 | @JSONField(name = "sodUtc8") 67 | @JsonProperty("sodUtc8") 68 | private BigDecimal sodUtc8; 69 | 70 | /** 71 | * 指数价格更新时间,Unix时间戳的毫秒数格式,如 1597026383085 72 | */ 73 | @JSONField(name = "ts") 74 | @JsonProperty("ts") 75 | private Long ts; 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/Instruments.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.enumeration.InstrumentType; 11 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 12 | 13 | @Data 14 | @ToString(callSuper = true) 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @SuperBuilder(toBuilder = true) 18 | public class Instruments implements WsSubscribeEntity { 19 | 20 | /** 21 | * 产品类型 22 | */ 23 | @JSONField(name = "instType") 24 | @JsonProperty("instType") 25 | private InstrumentType instType; 26 | 27 | /** 28 | * 产品ID,如 LTC-USD-SWAP 29 | */ 30 | @JSONField(name = "instId") 31 | @JsonProperty("instId") 32 | private String instId; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/LiquidationOrders.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 8 | import xyz.felh.okx.v5.enumeration.PositionsSide; 9 | import xyz.felh.okx.v5.enumeration.Side; 10 | import xyz.felh.okx.v5.enumeration.InstrumentType; 11 | 12 | import java.math.BigDecimal; 13 | import java.util.List; 14 | 15 | @Data 16 | @ToString(callSuper = true) 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @SuperBuilder(toBuilder = true) 20 | public class LiquidationOrders implements WsSubscribeEntity { 21 | 22 | /** 23 | * 产品类型 24 | */ 25 | @JSONField(name = "instType") 26 | @JsonProperty("instType") 27 | private InstrumentType instType; 28 | 29 | /** 30 | * 产品ID,如 LTC-USD-SWAP 31 | */ 32 | @JSONField(name = "instId") 33 | @JsonProperty("instId") 34 | private String instId; 35 | 36 | /** 37 | * 标的指数,仅适用于交割/永续/期权 38 | */ 39 | @JSONField(name = "uly") 40 | @JsonProperty("uly") 41 | private String uly; 42 | 43 | /** 44 | * 详细内容 45 | */ 46 | @JSONField(name = "details") 47 | @JsonProperty("details") 48 | private List details; 49 | 50 | @Data 51 | @Builder 52 | @AllArgsConstructor 53 | @NoArgsConstructor 54 | public static class Detail { 55 | 56 | /** 57 | * 订单方向 58 | * buy:买 59 | * sell:卖,仅适用于交割/永续 60 | */ 61 | @JSONField(name = "side") 62 | @JsonProperty("side") 63 | private Side side; 64 | 65 | /** 66 | * 持仓方向 67 | * long:多 68 | * short:空 69 | * side和posSide组合方式,sell/long:强平多 ; buy/short:强平空,仅适用于交割/永续 70 | */ 71 | @JSONField(name = "posSide") 72 | @JsonProperty("posSide") 73 | private PositionsSide posSide; 74 | 75 | /** 76 | * 破产价格,与系统爆仓账号委托成交的价格,仅适用于交割/永续 77 | */ 78 | @JSONField(name = "bkPx") 79 | @JsonProperty("bkPx") 80 | private BigDecimal bkPx; 81 | 82 | /** 83 | * 强平数量,仅适用于杠杆/交割/永续 84 | */ 85 | @JSONField(name = "sz") 86 | @JsonProperty("sz") 87 | private BigDecimal sz; 88 | 89 | /** 90 | * 穿仓亏损数量 91 | */ 92 | @JSONField(name = "bkLoss") 93 | @JsonProperty("bkLoss") 94 | private BigDecimal bkLoss; 95 | 96 | /** 97 | * 强平币种,仅适用于币币杠杆 98 | */ 99 | @JSONField(name = "ccy") 100 | @JsonProperty("ccy") 101 | private String ccy; 102 | 103 | /** 104 | * 强平发生的时间,Unix时间戳的毫秒数格式,如 1597026383085 / 105 | */ 106 | @JSONField(name = "ts") 107 | @JsonProperty("ts") 108 | private Long ts; 109 | 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/MarkPrice.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | import xyz.felh.okx.v5.enumeration.InstrumentType; 12 | 13 | import java.math.BigDecimal; 14 | 15 | @Data 16 | @ToString(callSuper = true) 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @SuperBuilder(toBuilder = true) 20 | public class MarkPrice implements WsSubscribeEntity { 21 | 22 | /** 23 | * 产品类型 24 | */ 25 | @JSONField(name = "instType") 26 | @JsonProperty("instType") 27 | private InstrumentType instType; 28 | 29 | /** 30 | * 产品ID 31 | */ 32 | @JSONField(name = "instId") 33 | @JsonProperty("instId") 34 | private String instId; 35 | 36 | /** 37 | * 标记价格 38 | */ 39 | @JSONField(name = "markPx") 40 | @JsonProperty("markPx") 41 | private BigDecimal markPx; 42 | 43 | /** 44 | * 标记价格数据更新时间 ,Unix时间戳的毫秒数格式,如 1597026383085 45 | */ 46 | @JSONField(name = "ts") 47 | @JsonProperty("ts") 48 | private Long ts; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/OpenInterest.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | import xyz.felh.okx.v5.enumeration.InstrumentType; 12 | 13 | import java.math.BigDecimal; 14 | 15 | @Data 16 | @ToString(callSuper = true) 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @SuperBuilder(toBuilder = true) 20 | public class OpenInterest implements WsSubscribeEntity { 21 | 22 | /** 23 | * 产品类型 24 | */ 25 | @JSONField(name = "instType") 26 | @JsonProperty("instType") 27 | private InstrumentType instType; 28 | 29 | /** 30 | * 产品ID,如 LTC-USD-SWAP 31 | */ 32 | @JSONField(name = "instId") 33 | @JsonProperty("instId") 34 | private String instId; 35 | 36 | /** 37 | * 持仓量,按张为单位,open interest 38 | */ 39 | @JSONField(name = "oi") 40 | @JsonProperty("oi") 41 | private BigDecimal openInterest; 42 | 43 | /** 44 | * 持仓量,按币为单位 45 | */ 46 | @JSONField(name = "oiCcy") 47 | @JsonProperty("oiCcy") 48 | private BigDecimal openInterestCcy; 49 | 50 | /** 51 | * 数据更新的时间,Unix时间戳的毫秒数格式,如 1597026383085 52 | */ 53 | @JSONField(name = "ts") 54 | @JsonProperty("ts") 55 | private Long timestamp; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/OptionSummary.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | import xyz.felh.okx.v5.enumeration.InstrumentType; 12 | 13 | import java.math.BigDecimal; 14 | 15 | @Data 16 | @ToString(callSuper = true) 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @SuperBuilder(toBuilder = true) 20 | public class OptionSummary implements WsSubscribeEntity { 21 | 22 | /** 23 | * 产品类型, OPTION 24 | */ 25 | @JSONField(name = "instType") 26 | @JsonProperty("instType") 27 | private InstrumentType instType; 28 | 29 | /** 30 | * 产品ID 31 | */ 32 | @JSONField(name = "instId") 33 | @JsonProperty("instId") 34 | private String instId; 35 | 36 | /** 37 | * 标的指数 38 | */ 39 | @JSONField(name = "uly") 40 | @JsonProperty("uly") 41 | private String uly; 42 | 43 | /** 44 | * 期权价格对uly价格的敏感度 45 | */ 46 | @JSONField(name = "uly") 47 | @JsonProperty("uly") 48 | private BigDecimal delta; 49 | 50 | /** 51 | * delta对uly价格的敏感度 52 | */ 53 | @JSONField(name = "gamma") 54 | @JsonProperty("gamma") 55 | private BigDecimal gamma; 56 | 57 | /** 58 | * 期权价格对隐含波动率的敏感度 59 | */ 60 | @JSONField(name = "vega") 61 | @JsonProperty("vega") 62 | private BigDecimal vega; 63 | 64 | /** 65 | * 期权价格对剩余期限的敏感度 66 | */ 67 | @JSONField(name = "theta") 68 | @JsonProperty("theta") 69 | private BigDecimal theta; 70 | 71 | /** 72 | * BS模式下期权价格对uly价格的敏感度 73 | */ 74 | @JSONField(name = "deltaBS") 75 | @JsonProperty("deltaBS") 76 | private BigDecimal deltaBS; 77 | 78 | /** 79 | * BS模式下delta对uly价格的敏感度 80 | */ 81 | @JSONField(name = "gammaBS") 82 | @JsonProperty("gammaBS") 83 | private BigDecimal gammaBS; 84 | 85 | /** 86 | * BS模式下期权价格对隐含波动率的敏感度 87 | */ 88 | @JSONField(name = "vegaBS") 89 | @JsonProperty("vegaBS") 90 | private BigDecimal vegaBS; 91 | 92 | /** 93 | * BS模式下期权价格对剩余期限的敏感度 94 | */ 95 | @JSONField(name = "thetaBS") 96 | @JsonProperty("thetaBS") 97 | private BigDecimal thetaBS; 98 | 99 | /** 100 | * 杠杆倍数 101 | */ 102 | @JSONField(name = "lever") 103 | @JsonProperty("lever") 104 | private BigDecimal lever; 105 | 106 | /** 107 | * 标记波动率 108 | */ 109 | @JSONField(name = "markVol") 110 | @JsonProperty("markVol") 111 | private BigDecimal markVol; 112 | 113 | /** 114 | * bid波动率 115 | */ 116 | @JSONField(name = "bidVol") 117 | @JsonProperty("bidVol") 118 | private BigDecimal bidVol; 119 | 120 | /** 121 | * ask波动率 122 | */ 123 | @JSONField(name = "askVol") 124 | @JsonProperty("askVol") 125 | private BigDecimal askVol; 126 | 127 | /** 128 | * 129 | */ 130 | @JSONField(name = "realVol") 131 | @JsonProperty("realVol") 132 | private BigDecimal realVol; 133 | 134 | /** 135 | * 136 | */ 137 | @JSONField(name = "volLv") 138 | @JsonProperty("volLv") 139 | private BigDecimal volLv; 140 | 141 | /** 142 | * 远期价格 143 | */ 144 | @JSONField(name = "fwdPx") 145 | @JsonProperty("fwdPx") 146 | private BigDecimal fwdPx; 147 | 148 | /** 149 | * 数据更新时间,Unix时间戳的毫秒数格式,如 1597026383085 150 | */ 151 | @JSONField(name = "ts") 152 | @JsonProperty("ts") 153 | private Long ts; 154 | 155 | } 156 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/pub/PriceLimit.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 11 | import xyz.felh.okx.v5.enumeration.InstrumentType; 12 | 13 | import java.math.BigDecimal; 14 | 15 | @Data 16 | @ToString(callSuper = true) 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @SuperBuilder(toBuilder = true) 20 | public class PriceLimit implements WsSubscribeEntity { 21 | 22 | /** 23 | * 产品类型 24 | */ 25 | @JSONField(name = "instType") 26 | @JsonProperty("instType") 27 | private InstrumentType instType; 28 | 29 | /** 30 | * 产品ID,如 LTC-USD-SWAP 31 | */ 32 | @JSONField(name = "instId") 33 | @JsonProperty("instId") 34 | private String instId; 35 | 36 | /** 37 | * 最高买价 38 | * 当enabled为false时,返回"" 39 | */ 40 | @JSONField(name = "buyLmt") 41 | @JsonProperty("buyLmt") 42 | private BigDecimal buyLmt; 43 | 44 | /** 45 | * 最低卖价 46 | * 当enabled为false时,返回"" 47 | */ 48 | @JSONField(name = "sellLmt") 49 | @JsonProperty("sellLmt") 50 | private BigDecimal sellLmt; 51 | 52 | /** 53 | * 限价数据更新时间 ,Unix时间戳的毫秒数格式,如 1597026383085 54 | */ 55 | @JSONField(name = "ts") 56 | @JsonProperty("ts") 57 | private Long ts; 58 | 59 | /** 60 | * 限价是否生效 61 | * true:限价生效 62 | * false:限价不生效 63 | */ 64 | @JSONField(name = "enabled") 65 | @JsonProperty("enabled") 66 | private Boolean enabled; 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/WsChannelRequestArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request; 2 | 3 | import xyz.felh.okx.v5.enumeration.ws.Channel; 4 | 5 | /** 6 | * The interface of websocket channel argument 7 | */ 8 | public interface WsChannelRequestArg extends WsRequestArg { 9 | 10 | Channel getChannel(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/WsOnceRequest.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | 8 | 9 | @EqualsAndHashCode(callSuper = true) 10 | @ToString(callSuper = true) 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class WsOnceRequest extends WsRequest { 16 | 17 | /** 18 | * Unique identifier of the message 19 | * Provided by client. It will be returned in response message for identifying the corresponding request. 20 | * A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. 21 | */ 22 | @NonNull 23 | @JSONField(name = "id") 24 | @JsonProperty("id") 25 | private String id; 26 | 27 | /** 28 | * Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085 29 | */ 30 | @JSONField(name = "expTime") 31 | @JsonProperty("expTime") 32 | private Long expTime; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/WsRequest.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.enumeration.ws.Operation; 11 | 12 | import java.util.List; 13 | 14 | @ToString(callSuper = true) 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class WsRequest { 20 | 21 | @JSONField(name = "op") 22 | @JsonProperty("op") 23 | private Operation op; 24 | 25 | @JSONField(name = "args") 26 | @JsonProperty("args") 27 | private List args; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/WsRequestArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request; 2 | 3 | import xyz.felh.okx.v5.entity.ws.WsArg; 4 | 5 | /** 6 | * The interface of websocket request argument 7 | */ 8 | public interface WsRequestArg extends WsArg { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/AdvanceAlgoOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class AdvanceAlgoOrderArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.ADVANCE_ALGO_ORDERS; 23 | 24 | /** 25 | * Instrument type 26 | * SPOT 27 | * MARGIN 28 | * SWAP 29 | * FUTURES 30 | * ANY 31 | */ 32 | @JSONField(name = "instType") 33 | @JsonProperty("instType") 34 | private InstrumentType instType; 35 | 36 | /** 37 | * Instrument ID 38 | */ 39 | @JSONField(name = "instId") 40 | @JsonProperty("instId") 41 | private String instId; 42 | 43 | /** 44 | * Algo Order ID 45 | */ 46 | @JSONField(name = "algoId") 47 | @JsonProperty("algoId") 48 | private String algoId; 49 | 50 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/AlgoOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class AlgoOrderArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.ALGO_ORDERS; 23 | 24 | /** 25 | * Instrument type 26 | * SPOT 27 | * MARGIN 28 | * SWAP 29 | * FUTURES 30 | * ANY 31 | */ 32 | @NonNull 33 | @JSONField(name = "instType") 34 | @JsonProperty("instType") 35 | private InstrumentType instType; 36 | 37 | /** 38 | * Instrument family 39 | * Applicable to FUTURES/SWAP/OPTION 40 | */ 41 | @JSONField(name = "instFamily") 42 | @JsonProperty("instFamily") 43 | private String instFamily; 44 | 45 | /** 46 | * Instrument ID 47 | */ 48 | @JSONField(name = "instId") 49 | @JsonProperty("instId") 50 | private String instId; 51 | 52 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/DepositInfoArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class DepositInfoArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.DEPOSIT_INFO; 23 | 24 | @NonNull 25 | @JSONField(name = "ccy") 26 | @JsonProperty("ccy") 27 | private String ccy; 28 | 29 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/EconomicCalendarArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class EconomicCalendarArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.ECONOMIC_CALENDAR; 23 | 24 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/GridOrderContractArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class GridOrderContractArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.GRID_ORDERS_CONTRACT; 23 | 24 | /** 25 | * Instrument type 26 | * SWAP 27 | * FUTURES 28 | * ANY 29 | */ 30 | @NonNull 31 | @JSONField(name = "instType") 32 | @JsonProperty("instType") 33 | private InstrumentType instType; 34 | 35 | /** 36 | * Instrument ID 37 | */ 38 | @JSONField(name = "instId") 39 | @JsonProperty("instId") 40 | private String instId; 41 | 42 | /** 43 | * Algo Order ID 44 | */ 45 | @JSONField(name = "algoId") 46 | @JsonProperty("algoId") 47 | private String algoId; 48 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/GridOrderSpotArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class GridOrderSpotArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.GRID_ORDERS_SPOT; 23 | 24 | /** 25 | * Instrument type 26 | * SPOT 27 | * ANY 28 | */ 29 | @NonNull 30 | @JSONField(name = "instType") 31 | @JsonProperty("instType") 32 | private InstrumentType instType; 33 | 34 | /** 35 | * Instrument ID 36 | */ 37 | @JSONField(name = "instId") 38 | @JsonProperty("instId") 39 | private String instId; 40 | 41 | /** 42 | * Algo Order ID 43 | */ 44 | @JSONField(name = "algoId") 45 | @JsonProperty("algoId") 46 | private String algoId; 47 | 48 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/GridPositionsArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class GridPositionsArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.GRID_POSITIONS; 22 | 23 | /** 24 | * Algo Order ID 25 | */ 26 | @NonNull 27 | @JSONField(name = "algoId") 28 | @JsonProperty("algoId") 29 | private String algoId; 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/GridSubOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class GridSubOrderArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.GRID_SUB_ORDERS; 22 | 23 | /** 24 | * Algo Order ID 25 | */ 26 | @NonNull 27 | @JSONField(name = "algoId") 28 | @JsonProperty("algoId") 29 | private String algoId; 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/IndexCandlesticksArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class IndexCandlesticksArg implements WsChannelRequestArg { 17 | 18 | // 新建的时候必须指定channel 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel; 22 | 23 | /** 24 | * 现货指数,如 BTC-USD 25 | */ 26 | @NonNull 27 | @JSONField(name = "instId") 28 | @JsonProperty("instId") 29 | private String instId; 30 | 31 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/MarkPriceCandlesticksArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class MarkPriceCandlesticksArg implements WsChannelRequestArg { 18 | 19 | // 新建的时候必须指定channel 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel; 23 | 24 | /** 25 | * 产品ID 26 | */ 27 | @NonNull 28 | @JSONField(name = "instId") 29 | @JsonProperty("instId") 30 | private String instId; 31 | 32 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/biz/WithdrawalInfoArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class WithdrawalInfoArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.WITHDRAWAL_INFO; 23 | 24 | @NonNull 25 | @JSONField(name = "ccy") 26 | @JsonProperty("ccy") 27 | private String ccy; 28 | 29 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/AccountArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class AccountArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.ACCOUNT; 23 | 24 | @NonNull 25 | @JSONField(name = "ccy") 26 | @JsonProperty("ccy") 27 | private String ccy; 28 | 29 | /** 30 | * 0: 仅根据账户事件推送数据 31 | * 若不添加该字段或将其设置为除0外的其他值,数据将根据事件推送并定时推送。 32 | * 使用该字段需严格遵守以下格式。 33 | * "extraParams": " 34 | * { 35 | * \"updateInterval\": \"0\" 36 | * } 37 | * " 38 | */ 39 | @JSONField(name = "extraParams") 40 | @JsonProperty("extraParams") 41 | private String extraParams; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/AccountGreeksArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class AccountGreeksArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.ACCOUNT_GREEKS; 22 | 23 | /** 24 | * 币种 25 | */ 26 | @JSONField(name = "ccy") 27 | @JsonProperty("ccy") 28 | private String ccy; 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/AmendOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 8 | 9 | import java.math.BigDecimal; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class AmendOrderArg implements WsRequestArg { 17 | 18 | /** 19 | * Instrument ID, e.g. BTC-USDT 20 | */ 21 | @NonNull 22 | @JSONField(name = "instId") 23 | @JsonProperty("instId") 24 | private String instId; 25 | 26 | /** 27 | * Whether the order needs to be automatically canceled when the order amendment fails 28 | * Valid options: false or true, the default is false. 29 | */ 30 | @JSONField(name = "cxlOnFail") 31 | @JsonProperty("cxlOnFail") 32 | private Boolean cxlOnFail; 33 | 34 | /** 35 | * Order ID 36 | * Either ordId or clOrdId is required, if both are passed, ordId will be used. 37 | */ 38 | @JSONField(name = "ordId") 39 | @JsonProperty("ordId") 40 | private String ordId; 41 | 42 | /** 43 | * Client Order ID as assigned by the client 44 | */ 45 | @JSONField(name = "clOrdId") 46 | @JsonProperty("clOrdId") 47 | private String clOrdId; 48 | 49 | /** 50 | * Client Request ID as assigned by the client for order amendment 51 | * A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. 52 | */ 53 | @JSONField(name = "reqId") 54 | @JsonProperty("reqId") 55 | private String reqId; 56 | 57 | /** 58 | * New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled. 59 | */ 60 | @JSONField(name = "newSz") 61 | @JsonProperty("newSz") 62 | private BigDecimal newSz; 63 | 64 | /** 65 | * New price after amendment. 66 | * When modifying options orders, users can only fill in one of the following: newPx, newPxUsd, or newPxVol. It must be consistent with parameters when placing orders. For example, if users placed the order using px, they should use newPx when modifying the order. 67 | */ 68 | @JSONField(name = "newPx") 69 | @JsonProperty("newPx") 70 | private BigDecimal newPx; 71 | 72 | /** 73 | * Modify options orders using USD prices 74 | * Only applicable to options. 75 | * When modifying options orders, users can only fill in one of the following: newPx, newPxUsd, or newPxVol. 76 | */ 77 | @JSONField(name = "newPxUsd") 78 | @JsonProperty("newPxUsd") 79 | private BigDecimal newPxUsd; 80 | 81 | /** 82 | * Modify options orders based on implied volatility, where 1 represents 100% 83 | * Only applicable to options. 84 | * When modifying options orders, users can only fill in one of the following: newPx, newPxUsd, or newPxVol. 85 | */ 86 | @JSONField(name = "newPxVol") 87 | @JsonProperty("newPxVol") 88 | private BigDecimal newPxVol; 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/BalanceAndPositionArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class BalanceAndPositionArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.BALANCE_AND_POSITION; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/CancelOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 8 | 9 | @Data 10 | @ToString(callSuper = true) 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | @SuperBuilder(toBuilder = true) 14 | public class CancelOrderArg implements WsRequestArg { 15 | 16 | /** 17 | * Instrument ID, e.g. BTC-USDT 18 | */ 19 | @NonNull 20 | @JSONField(name = "instId") 21 | @JsonProperty("instId") 22 | private String instId; 23 | 24 | /** 25 | * Client Order ID as assigned by the client 26 | * A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. 27 | */ 28 | @JSONField(name = "clOrdId") 29 | @JsonProperty("clOrdId") 30 | private String clOrdId; 31 | 32 | /** 33 | * Order ID 34 | * Either ordId or clOrdId is required, if both are passed, ordId will be used 35 | */ 36 | @JSONField(name = "ordId") 37 | @JsonProperty("ordId") 38 | private String ordId; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/LiquidationWarningArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class LiquidationWarningArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.LIQUIDATION_WARNING; 22 | 23 | /** 24 | * 产品类型 25 | */ 26 | @NonNull 27 | @JSONField(name = "instType") 28 | @JsonProperty("instType") 29 | private InstrumentType instType; 30 | 31 | /** 32 | * 交易品种 33 | * 适用于交割/永续/期权 34 | */ 35 | @JSONField(name = "instFamily") 36 | @JsonProperty("instFamily") 37 | private String instFamily; 38 | 39 | /** 40 | * 产品ID 41 | */ 42 | @JSONField(name = "instId") 43 | @JsonProperty("instId") 44 | private String instId; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/LoginArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.WsArg; 11 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 12 | 13 | 14 | @Data 15 | @ToString(callSuper = true) 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @SuperBuilder(toBuilder = true) 19 | public class LoginArg implements WsRequestArg { 20 | 21 | /** 22 | * APIKey 23 | */ 24 | @JSONField(name = "apiKey") 25 | @JsonProperty("apiKey") 26 | private String apiKey; 27 | 28 | /** 29 | * APIKey 的密码 30 | */ 31 | @JSONField(name = "passphrase") 32 | @JsonProperty("passphrase") 33 | private String passphrase; 34 | 35 | /** 36 | * 时间戳,Unix Epoch时间,单位是秒 37 | */ 38 | @JSONField(name = "timestamp") 39 | @JsonProperty("timestamp") 40 | private String timestamp; 41 | 42 | /** 43 | * 签名字符串 44 | */ 45 | @JSONField(name = "sign") 46 | @JsonProperty("sign") 47 | private String sign; 48 | 49 | } -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/MassCancelOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 8 | import xyz.felh.okx.v5.enumeration.InstrumentType; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class MassCancelOrderArg implements WsRequestArg { 16 | 17 | /** 18 | * Instrument type 19 | * OPTION 20 | */ 21 | @NonNull 22 | @JSONField(name = "instType") 23 | @JsonProperty("instType") 24 | private InstrumentType instType; 25 | 26 | /** 27 | * Instrument family 28 | */ 29 | @JSONField(name = "instFamily") 30 | @JsonProperty("instFamily") 31 | private String instFamily; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/OrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class OrderArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.ORDERS; 23 | 24 | /** 25 | * 产品类型 26 | * SPOT:币币 27 | * MARGIN:币币杠杆 28 | * SWAP:永续合约 29 | * FUTURES:交割合约 30 | * OPTION:期权 31 | * ANY:全部 32 | */ 33 | @NonNull 34 | @JSONField(name = "instType") 35 | @JsonProperty("instType") 36 | private InstrumentType instType; 37 | 38 | /** 39 | * 交易品种 40 | * 适用于交割/永续/期权 41 | */ 42 | @JSONField(name = "instFamily") 43 | @JsonProperty("instFamily") 44 | private String instFamily; 45 | 46 | /** 47 | * 产品ID 48 | */ 49 | @JSONField(name = "instId") 50 | @JsonProperty("instId") 51 | private String instId; 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pri/PositionsArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class PositionsArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.POSITIONS; 23 | 24 | @NonNull 25 | @JSONField(name = "instType") 26 | @JsonProperty("instType") 27 | private InstrumentType instType; 28 | 29 | /** 30 | * 交易品种 31 | * 适用于交割/永续/期权 32 | */ 33 | @JSONField(name = "instFamily") 34 | @JsonProperty("instFamily") 35 | private String instFamily; 36 | 37 | /** 38 | * 产品ID 39 | */ 40 | @JSONField(name = "instId") 41 | @JsonProperty("instId") 42 | private String instId; 43 | 44 | /** 45 | * 0: 仅根据持仓事件推送数据 46 | * 2000, 3000, 4000: 根据持仓事件推送,且根据设置的时间间隔定时推送(ms) 47 | *

48 | * 若不添加该字段或将其设置为上述合法值以外的其他值,数据将根据事件推送并大约每 5 秒定期推送一次。 49 | *

50 | * 使用该字段需严格遵守以下格式。 51 | * "extraParams": " 52 | * { 53 | * \"updateInterval\": \"0\" 54 | * } 55 | * " 56 | */ 57 | @JSONField(name = "extraParams") 58 | @JsonProperty("extraParams") 59 | private String extraParams; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/AdlWarningArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class AdlWarningArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.ADL_WARNINGS; 23 | 24 | /** 25 | * 产品类型 26 | * FUTURES:交割合约 27 | * SWAP:永续合约 28 | * OPTION:期权 29 | */ 30 | @NonNull 31 | @JSONField(name = "instType") 32 | @JsonProperty("instType") 33 | private InstrumentType instType; 34 | 35 | /** 36 | * 交易品种 37 | */ 38 | @JSONField(name = "instFamily") 39 | @JsonProperty("instFamily") 40 | private String instFamily; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/EstimatedPriceArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class EstimatedPriceArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.ESTIMATED_PRICE; 23 | 24 | /** 25 | * 产品类型 26 | * FUTURES:交割合约 27 | * SWAP:永续合约 28 | * OPTION:期权 29 | */ 30 | @NonNull 31 | @JSONField(name = "instType") 32 | @JsonProperty("instType") 33 | private InstrumentType instType; 34 | 35 | /** 36 | * 交易品种 37 | * instFamily和instId必须指定一个 38 | */ 39 | @JSONField(name = "instFamily") 40 | @JsonProperty("instFamily") 41 | private String instFamily; 42 | 43 | 44 | /** 45 | * 产品ID 46 | * instFamily和instId必须指定一个 47 | */ 48 | @JSONField(name = "instId") 49 | @JsonProperty("instId") 50 | private String instId; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/FundingRateArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class FundingRateArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.FUNDING_RATE; 23 | 24 | /** 25 | * 产品ID 26 | */ 27 | @NonNull 28 | @JSONField(name = "instId") 29 | @JsonProperty("instId") 30 | private String instId; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/IndexTickersArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class IndexTickersArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.INDEX_TICKERS; 23 | 24 | /** 25 | * 指数,以USD、USDT、BTC、USDC 为计价货币的指数,如 BTC-USDT 26 | */ 27 | @NonNull 28 | @JSONField(name = "instId") 29 | @JsonProperty("instId") 30 | private String instId; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/InstrumentsArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class InstrumentsArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.INSTRUMENTS; 22 | 23 | @NonNull 24 | @JSONField(name = "instType") 25 | @JsonProperty("instType") 26 | private InstrumentType instType; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/LiquidationOrdersArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class LiquidationOrdersArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.LIQUIDATION_ORDERS; 23 | 24 | /** 25 | * 产品类型 26 | * MARGIN:币币杠杆 27 | * SWAP:永续合约 28 | * FUTURES:交割合约 29 | * OPTION:期权 30 | */ 31 | @NonNull 32 | @JSONField(name = "instType") 33 | @JsonProperty("instType") 34 | private InstrumentType instType; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/MarkPriceArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class MarkPriceArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.MARK_PRICE; 23 | 24 | /** 25 | * 产品ID 26 | */ 27 | @NonNull 28 | @JSONField(name = "instId") 29 | @JsonProperty("instId") 30 | private String instId; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/OpenInterestArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class OpenInterestArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.OPEN_INTEREST; 22 | 23 | /** 24 | * 产品ID 25 | */ 26 | @NonNull 27 | @JSONField(name = "instId") 28 | @JsonProperty("instId") 29 | private String instId; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/OptionSummaryArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class OptionSummaryArg implements WsChannelRequestArg { 18 | 19 | @Builder.Default 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel = Channel.OPT_SUMMARY; 23 | 24 | /** 25 | * 交易品种 26 | */ 27 | @NonNull 28 | @JSONField(name = "instFamily") 29 | @JsonProperty("instFamily") 30 | private String instFamily; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/request/pub/PriceLimitArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.request.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.request.WsChannelRequestArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class PriceLimitArg implements WsChannelRequestArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.PRICE_LIMIT; 22 | 23 | /** 24 | * 产品ID 25 | */ 26 | @NonNull 27 | @JSONField(name = "instId") 28 | @JsonProperty("instId") 29 | private String instId; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/CommonResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | 11 | @ToString 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public abstract class CommonResponse implements IWsResponse { 17 | 18 | @JSONField(name = "event") 19 | @JsonProperty("event") 20 | private Event event; 21 | 22 | /** 23 | * WebSocket连接ID 24 | */ 25 | @JSONField(name = "connId") 26 | @JsonProperty("connId") 27 | private String connId; 28 | 29 | /** 30 | * 错误码 31 | */ 32 | @JSONField(name = "code") 33 | @JsonProperty("code") 34 | private String code; 35 | 36 | /** 37 | * 错误消息 38 | */ 39 | @JSONField(name = "msg") 40 | @JsonProperty("msg") 41 | private String msg; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/ErrorResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import lombok.ToString; 7 | import lombok.experimental.SuperBuilder; 8 | 9 | @EqualsAndHashCode(callSuper = true) 10 | @ToString 11 | @Data 12 | @AllArgsConstructor 13 | @SuperBuilder(toBuilder = true) 14 | public class ErrorResponse extends CommonResponse { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/Event.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | 8 | @Getter 9 | public enum Event { 10 | 11 | LOGIN("login"), 12 | SUBSCRIBE("subscribe"), 13 | UNSUBSCRIBE("unsubscribe"), 14 | ERROR("error"); 15 | 16 | private final String value; 17 | 18 | Event(final String value) { 19 | this.value = value; 20 | } 21 | 22 | @JsonValue 23 | public String value() { 24 | return value; 25 | } 26 | 27 | public static Event fromValue(final String value) { 28 | return Arrays.stream(values()).filter(it -> it.getValue().equals(value)).findAny().orElse(null); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/IWsResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | /** 4 | * all ws response 5 | */ 6 | public interface IWsResponse { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/LoginResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | import lombok.ToString; 7 | import lombok.experimental.SuperBuilder; 8 | 9 | @EqualsAndHashCode(callSuper = true) 10 | @ToString 11 | @Data 12 | @AllArgsConstructor 13 | @SuperBuilder(toBuilder = true) 14 | public class LoginResponse extends CommonResponse { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/WsChannelResponseArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import xyz.felh.okx.v5.enumeration.ws.Channel; 4 | 5 | /** 6 | * The interface of websocket channel argument 7 | */ 8 | public interface WsChannelResponseArg extends WsResponseArg { 9 | 10 | Channel getChannel(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/WsOnceResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import com.alibaba.fastjson2.TypeReference; 5 | import com.alibaba.fastjson2.annotation.JSONField; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | import lombok.ToString; 11 | import lombok.experimental.SuperBuilder; 12 | import lombok.extern.slf4j.Slf4j; 13 | import xyz.felh.okx.v5.enumeration.ws.Operation; 14 | 15 | import java.util.List; 16 | 17 | @Slf4j 18 | @ToString(callSuper = true) 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | @SuperBuilder(toBuilder = true) 23 | public class WsOnceResponse implements IWsResponse { 24 | 25 | /** 26 | * Unique identifier of the message 27 | * Provided by client. It will be returned in response message for identifying the corresponding request. 28 | * A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. 29 | */ 30 | @JSONField(name = "id") 31 | @JsonProperty("id") 32 | private String id; 33 | 34 | @JSONField(name = "op") 35 | @JsonProperty("op") 36 | private Operation op; 37 | 38 | @JSONField(name = "data") 39 | @JsonProperty("data") 40 | private List data; 41 | 42 | /** 43 | * 错误码 44 | */ 45 | @JSONField(name = "code") 46 | @JsonProperty("code") 47 | private String code; 48 | 49 | /** 50 | * 错误消息 51 | */ 52 | @JSONField(name = "msg") 53 | @JsonProperty("msg") 54 | private String msg; 55 | 56 | /** 57 | * Timestamp at Websocket gateway when the request is received, Unix timestamp format in microseconds, e.g. 1597026383085123 58 | */ 59 | @JSONField(name = "inTime") 60 | @JsonProperty("inTime") 61 | private Long inTime; 62 | 63 | /** 64 | * Timestamp at Websocket gateway when the response is sent, Unix timestamp format in microseconds, e.g. 1597026383085123 65 | */ 66 | @JSONField(name = "outTime") 67 | @JsonProperty("outTime") 68 | private Long outTime; 69 | 70 | public static WsOnceResponse tryParse(Class tClass, String message) { 71 | try { 72 | return JSONObject.parseObject(message, new TypeReference<>(tClass) { 73 | }); 74 | } catch (Exception ex) { 75 | log.error("tryParse error", ex); 76 | } 77 | return null; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/WsResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import com.alibaba.fastjson2.TypeReference; 5 | import com.alibaba.fastjson2.annotation.JSONField; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | import lombok.*; 8 | import lombok.experimental.SuperBuilder; 9 | import lombok.extern.slf4j.Slf4j; 10 | 11 | @Slf4j 12 | @ToString 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class WsResponse implements IWsResponse { 18 | 19 | @JSONField(name = "event") 20 | @JsonProperty("event") 21 | private Event event; 22 | 23 | @JSONField(name = "arg") 24 | @JsonProperty("arg") 25 | private T arg; 26 | 27 | /** 28 | * WebSocket连接ID 29 | */ 30 | @JSONField(name = "connId") 31 | @JsonProperty("connId") 32 | private String connId; 33 | 34 | /** 35 | * 错误码 36 | */ 37 | @JSONField(name = "code") 38 | @JsonProperty("code") 39 | private String code; 40 | 41 | /** 42 | * 错误消息 43 | */ 44 | @JSONField(name = "msg") 45 | @JsonProperty("msg") 46 | private String msg; 47 | 48 | public static WsResponse tryParse(Class tClass, String message) { 49 | try { 50 | WsResponse response = JSONObject.parseObject(message, new TypeReference<>() { 51 | }); 52 | if (response != null 53 | && response.getEvent() != null 54 | && response.getArg() != null 55 | && (response.getEvent() == Event.SUBSCRIBE || response.getEvent() == Event.UNSUBSCRIBE)) { 56 | WsResponse result = new WsResponse<>(); 57 | result.setCode(response.getCode()); 58 | result.setMsg(response.getMsg()); 59 | result.setEvent(response.getEvent()); 60 | result.setConnId(response.getConnId()); 61 | result.setArg(JSONObject.parseObject(response.getArg().toString(), tClass)); 62 | return result; 63 | } 64 | } catch (Exception ex) { 65 | log.error("tryParse error", ex); 66 | } 67 | return null; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/WsResponseArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import xyz.felh.okx.v5.entity.ws.WsArg; 4 | 5 | /** 6 | * The interface of websocket response argument 7 | */ 8 | public interface WsResponseArg extends WsArg { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/WsSubscribeResponse.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response; 2 | 3 | import com.alibaba.fastjson2.JSONArray; 4 | import com.alibaba.fastjson2.JSONObject; 5 | import com.alibaba.fastjson2.TypeReference; 6 | import com.alibaba.fastjson2.annotation.JSONField; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | import lombok.*; 9 | import lombok.extern.slf4j.Slf4j; 10 | import xyz.felh.okx.v5.entity.ws.biz.IndexCandlesticks; 11 | import xyz.felh.okx.v5.entity.ws.biz.MarkPriceCandlesticks; 12 | 13 | import java.lang.reflect.Field; 14 | import java.lang.reflect.InvocationTargetException; 15 | import java.util.List; 16 | import java.util.Objects; 17 | 18 | @Slf4j 19 | @ToString 20 | @Data 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | @Builder 24 | public class WsSubscribeResponse implements IWsResponse { 25 | 26 | @JSONField(name = "arg") 27 | @JsonProperty("arg") 28 | private T arg; 29 | 30 | @JSONField(name = "data") 31 | @JsonProperty("data") 32 | private List data; 33 | 34 | public static WsSubscribeResponse tryParse(Class tClass, Class dClass, String message) { 35 | try { 36 | WsSubscribeResponse response = JSONObject.parseObject(message, new TypeReference<>() { 37 | }); 38 | if (response != null && response.getData() != null && response.getArg() != null) { 39 | WsSubscribeResponse result = new WsSubscribeResponse<>(); 40 | result.setArg(JSONObject.parseObject(response.getArg().toString(), tClass)); 41 | 42 | if (dClass == MarkPriceCandlesticks.class || dClass == IndexCandlesticks.class) { 43 | result.setData(response.getData().stream().map(it -> { 44 | D instance = null; 45 | try { 46 | JSONArray array = (JSONArray) it; 47 | instance = dClass.getDeclaredConstructor().newInstance(); 48 | Field field = dClass.getDeclaredField("ts"); 49 | field.setAccessible(true); 50 | field.set(instance, array.getLong(0)); 51 | field = dClass.getDeclaredField("o"); 52 | field.setAccessible(true); 53 | field.set(instance, array.getBigDecimal(1)); 54 | field = dClass.getDeclaredField("h"); 55 | field.setAccessible(true); 56 | field.set(instance, array.getBigDecimal(2)); 57 | field = dClass.getDeclaredField("l"); 58 | field.setAccessible(true); 59 | field.set(instance, array.getBigDecimal(3)); 60 | field = dClass.getDeclaredField("c"); 61 | field.setAccessible(true); 62 | field.set(instance, array.getBigDecimal(4)); 63 | field = dClass.getDeclaredField("confirm"); 64 | field.setAccessible(true); 65 | field.set(instance, array.getIntValue(5) == 1); 66 | } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | 67 | InvocationTargetException | NoSuchFieldException e) { 68 | log.error("new instance error", e); 69 | } 70 | return instance; 71 | }).filter(Objects::nonNull).toList()); 72 | } else { 73 | result.setData(JSONArray.parseArray(response.getData().toString(), dClass)); 74 | } 75 | return result; 76 | } 77 | } catch (Exception ex) { 78 | log.error("tryParse error", ex); 79 | } 80 | return null; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/AdvanceAlgoOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class AdvanceAlgoOrderArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.ADVANCE_ALGO_ORDERS; 22 | 23 | /** 24 | * Instrument type 25 | * SPOT 26 | * MARGIN 27 | * SWAP 28 | * FUTURES 29 | * ANY 30 | */ 31 | @JSONField(name = "instType") 32 | @JsonProperty("instType") 33 | private InstrumentType instType; 34 | 35 | /** 36 | * Instrument ID 37 | */ 38 | @JSONField(name = "instId") 39 | @JsonProperty("instId") 40 | private String instId; 41 | 42 | /** 43 | * Algo Order ID 44 | */ 45 | @JSONField(name = "algoId") 46 | @JsonProperty("algoId") 47 | private String algoId; 48 | 49 | /** 50 | * User Identifier 51 | */ 52 | @JSONField(name = "uid") 53 | @JsonProperty("uid") 54 | private String uid; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/AlgoOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class AlgoOrderArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.ALGO_ORDERS; 22 | 23 | /** 24 | * Instrument type 25 | * SPOT 26 | * MARGIN 27 | * SWAP 28 | * FUTURES 29 | * ANY 30 | */ 31 | @JSONField(name = "instType") 32 | @JsonProperty("instType") 33 | private InstrumentType instType; 34 | 35 | /** 36 | * Instrument family 37 | * Applicable to FUTURES/SWAP/OPTION 38 | */ 39 | @JSONField(name = "instFamily") 40 | @JsonProperty("instFamily") 41 | private String instFamily; 42 | 43 | /** 44 | * Instrument ID 45 | */ 46 | @JSONField(name = "instId") 47 | @JsonProperty("instId") 48 | private String instId; 49 | 50 | /** 51 | * User Identifier 52 | */ 53 | @JSONField(name = "uid") 54 | @JsonProperty("uid") 55 | private String uid; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/DepositInfoArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class DepositInfoArg implements WsChannelResponseArg { 16 | 17 | @Builder.Default 18 | @JSONField(name = "channel") 19 | @JsonProperty("channel") 20 | private Channel channel = Channel.DEPOSIT_INFO; 21 | 22 | /** 23 | * 币种名称,如 BTC 24 | */ 25 | @JSONField(name = "ccy") 26 | @JsonProperty("ccy") 27 | private String ccy; 28 | 29 | /** 30 | * 用户标识 31 | */ 32 | @JSONField(name = "uid") 33 | @JsonProperty("uid") 34 | private String uid; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/EconomicCalendarArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class EconomicCalendarArg implements WsChannelResponseArg { 16 | 17 | @Builder.Default 18 | @JSONField(name = "channel") 19 | @JsonProperty("channel") 20 | private Channel channel = Channel.ECONOMIC_CALENDAR; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/GridOrderContractArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class GridOrderContractArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.GRID_ORDERS_CONTRACT; 22 | 23 | /** 24 | * Instrument type 25 | * SPOT 26 | * ANY 27 | */ 28 | @NonNull 29 | @JSONField(name = "instType") 30 | @JsonProperty("instType") 31 | private InstrumentType instType; 32 | 33 | /** 34 | * 用户标识 35 | */ 36 | @JSONField(name = "uid") 37 | @JsonProperty("uid") 38 | private String uid; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/GridOrderSpotArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class GridOrderSpotArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.GRID_ORDERS_SPOT; 22 | 23 | /** 24 | * Instrument type 25 | * SPOT 26 | * ANY 27 | */ 28 | @NonNull 29 | @JSONField(name = "instType") 30 | @JsonProperty("instType") 31 | private InstrumentType instType; 32 | 33 | /** 34 | * 用户标识 35 | */ 36 | @JSONField(name = "uid") 37 | @JsonProperty("uid") 38 | private String uid; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/GridPositionsArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class GridPositionsArg implements WsChannelResponseArg { 16 | 17 | @Builder.Default 18 | @JSONField(name = "channel") 19 | @JsonProperty("channel") 20 | private Channel channel = Channel.DEPOSIT_INFO; 21 | 22 | /** 23 | * Algo Order ID 24 | */ 25 | @NonNull 26 | @JSONField(name = "algoId") 27 | @JsonProperty("algoId") 28 | private String algoId; 29 | 30 | /** 31 | * User Identifier 32 | */ 33 | @JSONField(name = "uid") 34 | @JsonProperty("uid") 35 | private String uid; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/GridSubOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class GridSubOrderArg implements WsChannelResponseArg { 16 | 17 | @Builder.Default 18 | @JSONField(name = "channel") 19 | @JsonProperty("channel") 20 | private Channel channel = Channel.GRID_SUB_ORDERS; 21 | 22 | /** 23 | * Algo Order ID 24 | */ 25 | @JSONField(name = "algoId") 26 | @JsonProperty("algoId") 27 | private String algoId; 28 | 29 | /** 30 | * User Identifier 31 | */ 32 | @JSONField(name = "uid") 33 | @JsonProperty("uid") 34 | private String uid; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/IndexCandlesticksArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 11 | import xyz.felh.okx.v5.enumeration.ws.Channel; 12 | 13 | @Data 14 | @ToString(callSuper = true) 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @SuperBuilder(toBuilder = true) 18 | public class IndexCandlesticksArg implements WsChannelResponseArg { 19 | 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel; 23 | 24 | /** 25 | * 现货指数 26 | */ 27 | @JSONField(name = "instId") 28 | @JsonProperty("instId") 29 | private String instId; 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/MarkPriceCandlesticksArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 11 | import xyz.felh.okx.v5.enumeration.ws.Channel; 12 | 13 | @Data 14 | @ToString(callSuper = true) 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @SuperBuilder(toBuilder = true) 18 | public class MarkPriceCandlesticksArg implements WsChannelResponseArg { 19 | 20 | @JSONField(name = "channel") 21 | @JsonProperty("channel") 22 | private Channel channel; 23 | 24 | /** 25 | * 产品ID 26 | */ 27 | @JSONField(name = "instId") 28 | @JsonProperty("instId") 29 | private String instId; 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/biz/WithdrawalInfoArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.biz; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class WithdrawalInfoArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.WITHDRAWAL_INFO; 22 | 23 | /** 24 | * 币种名称,如 BTC 25 | */ 26 | @JSONField(name = "ccy") 27 | @JsonProperty("ccy") 28 | private String ccy; 29 | 30 | /** 31 | * 用户标识 32 | */ 33 | @JSONField(name = "uid") 34 | @JsonProperty("uid") 35 | private String uid; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/AccountArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class AccountArg implements WsChannelResponseArg { 16 | 17 | @Builder.Default 18 | @JSONField(name = "channel") 19 | @JsonProperty("channel") 20 | private Channel channel = Channel.ACCOUNT; 21 | 22 | @NonNull 23 | @JSONField(name = "uid") 24 | @JsonProperty("uid") 25 | private String uid; 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/AccountGreeksArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class AccountGreeksArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.ACCOUNT_GREEKS; 22 | 23 | @JSONField(name = "ccy") 24 | @JsonProperty("ccy") 25 | private String ccy; 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/AmendOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class AmendOrderArg implements WsResponseArg { 18 | 19 | /** 20 | * Order ID 21 | */ 22 | @JSONField(name = "ordId") 23 | @JsonProperty("ordId") 24 | private String ordId; 25 | 26 | /** 27 | * Client Order ID as assigned by the client 28 | */ 29 | @JSONField(name = "clOrdId") 30 | @JsonProperty("clOrdId") 31 | private String clOrdId; 32 | 33 | /** 34 | * Timestamp when the order request processing is finished by our system, Unix timestamp format in milliseconds, e.g. 1597026383085 35 | */ 36 | @JSONField(name = "ts") 37 | @JsonProperty("ts") 38 | private Long ts; 39 | 40 | /** 41 | * Client Request ID as assigned by the client for order amendment 42 | */ 43 | @JSONField(name = "reqId") 44 | @JsonProperty("reqId") 45 | private String reqId; 46 | 47 | /** 48 | * Order status code, 0 means success 49 | */ 50 | @JSONField(name = "sCode") 51 | @JsonProperty("sCode") 52 | private Integer sCode; 53 | 54 | /** 55 | * Rejection or success message of event execution. 56 | */ 57 | @JSONField(name = "sMsg") 58 | @JsonProperty("sMsg") 59 | private String sMsg; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/BalanceAndPositionArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class BalanceAndPositionArg implements WsChannelResponseArg { 16 | 17 | @Builder.Default 18 | @JSONField(name = "channel") 19 | @JsonProperty("channel") 20 | private Channel channel = Channel.BALANCE_AND_POSITION; 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/CancelOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class CancelOrderArg implements WsResponseArg { 18 | 19 | /** 20 | * Order ID 21 | */ 22 | @JSONField(name = "ordId") 23 | @JsonProperty("ordId") 24 | private String ordId; 25 | 26 | /** 27 | * Client Order ID as assigned by the client 28 | */ 29 | @JSONField(name = "clOrdId") 30 | @JsonProperty("clOrdId") 31 | private String clOrdId; 32 | 33 | /** 34 | * Timestamp when the order request processing is finished by our system, Unix timestamp format in milliseconds, e.g. 1597026383085 35 | */ 36 | @JSONField(name = "ts") 37 | @JsonProperty("ts") 38 | private Long ts; 39 | 40 | /** 41 | * Order status code, 0 means success 42 | */ 43 | @JSONField(name = "sCode") 44 | @JsonProperty("sCode") 45 | private Integer sCode; 46 | 47 | /** 48 | * Rejection or success message of event execution. 49 | */ 50 | @JSONField(name = "sMsg") 51 | @JsonProperty("sMsg") 52 | private String sMsg; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/LiquidationWarningArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class LiquidationWarningArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.LIQUIDATION_WARNING; 22 | 23 | /** 24 | * 产品类型 25 | */ 26 | @NonNull 27 | @JSONField(name = "instType") 28 | @JsonProperty("instType") 29 | private InstrumentType instType; 30 | 31 | /** 32 | * 交易品种 33 | * 适用于交割/永续/期权 34 | */ 35 | @JSONField(name = "instFamily") 36 | @JsonProperty("instFamily") 37 | private String instFamily; 38 | 39 | /** 40 | * 产品ID 41 | */ 42 | @JSONField(name = "instId") 43 | @JsonProperty("instId") 44 | private String instId; 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/MassCancelOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.ToString; 9 | import lombok.experimental.SuperBuilder; 10 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 11 | 12 | @Data 13 | @ToString(callSuper = true) 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @SuperBuilder(toBuilder = true) 17 | public class MassCancelOrderArg implements WsResponseArg { 18 | 19 | /** 20 | * Result of the request true, false 21 | */ 22 | @JSONField(name = "result") 23 | @JsonProperty("result") 24 | private Boolean result; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/OrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class OrderArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.ORDERS; 22 | 23 | /** 24 | * 产品类型 25 | * SPOT:币币 26 | * MARGIN:币币杠杆 27 | * SWAP:永续合约 28 | * FUTURES:交割合约 29 | * OPTION:期权 30 | * ANY:全部 31 | */ 32 | @JSONField(name = "instType") 33 | @JsonProperty("instType") 34 | private InstrumentType instType; 35 | 36 | /** 37 | * 交易品种 38 | * 适用于交割/永续/期权 39 | */ 40 | @JSONField(name = "instFamily") 41 | @JsonProperty("instFamily") 42 | private String instFamily; 43 | 44 | /** 45 | * 产品ID 46 | */ 47 | @JSONField(name = "instId") 48 | @JsonProperty("instId") 49 | private String instId; 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/PlaceOrderArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 8 | 9 | @Data 10 | @ToString(callSuper = true) 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | @SuperBuilder(toBuilder = true) 14 | public class PlaceOrderArg implements WsResponseArg { 15 | 16 | /** 17 | * Order ID 18 | */ 19 | @JSONField(name = "ordId") 20 | @JsonProperty("ordId") 21 | private String ordId; 22 | 23 | /** 24 | * Client Order ID as assigned by the client 25 | */ 26 | @JSONField(name = "clOrdId") 27 | @JsonProperty("clOrdId") 28 | private String clOrdId; 29 | 30 | /** 31 | * Order tag 32 | */ 33 | @JSONField(name = "tag") 34 | @JsonProperty("tag") 35 | private String tag; 36 | 37 | /** 38 | * Timestamp when the order request processing is finished by our system, Unix timestamp format in milliseconds, e.g. 1597026383085 39 | */ 40 | @JSONField(name = "ts") 41 | @JsonProperty("ts") 42 | private Long ts; 43 | 44 | /** 45 | * Order status code, 0 means success 46 | */ 47 | @JSONField(name = "sCode") 48 | @JsonProperty("sCode") 49 | private Integer sCode; 50 | 51 | /** 52 | * Rejection or success message of event execution. 53 | */ 54 | @JSONField(name = "sMsg") 55 | @JsonProperty("sMsg") 56 | private String sMsg; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pri/PositionsArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pri; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class PositionsArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.POSITIONS; 22 | 23 | @NonNull 24 | @JSONField(name = "instType") 25 | @JsonProperty("instType") 26 | private InstrumentType instType; 27 | 28 | /** 29 | * 交易品种 30 | * 适用于交割/永续/期权 31 | */ 32 | @JSONField(name = "instFamily") 33 | @JsonProperty("instFamily") 34 | private String instFamily; 35 | 36 | /** 37 | * 产品ID 38 | */ 39 | @JSONField(name = "instId") 40 | @JsonProperty("instId") 41 | private String instId; 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/AdlWarningArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class AdlWarningArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.ADL_WARNINGS; 22 | 23 | /** 24 | * 产品类型 25 | */ 26 | @JSONField(name = "instType") 27 | @JsonProperty("instType") 28 | private InstrumentType instType; 29 | 30 | /** 31 | * 交易品种 32 | */ 33 | @JSONField(name = "instFamily") 34 | @JsonProperty("instFamily") 35 | private String instFamily; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/EstimatedPriceArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class EstimatedPriceArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.ESTIMATED_PRICE; 22 | 23 | /** 24 | * 产品类型 25 | * FUTURES:交割合约 26 | * SWAP:永续合约 27 | * OPTION:期权 28 | */ 29 | @JSONField(name = "instType") 30 | @JsonProperty("instType") 31 | private InstrumentType instType; 32 | 33 | /** 34 | * 交易品种 35 | * instFamily和instId必须指定一个 36 | */ 37 | @JSONField(name = "instFamily") 38 | @JsonProperty("instFamily") 39 | private String instFamily; 40 | 41 | 42 | /** 43 | * 产品ID 44 | * instFamily和instId必须指定一个 45 | */ 46 | @JSONField(name = "instId") 47 | @JsonProperty("instId") 48 | private String instId; 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/FundingRateArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class FundingRateArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.FUNDING_RATE; 22 | 23 | /** 24 | * 产品ID 25 | */ 26 | @JSONField(name = "instId") 27 | @JsonProperty("instId") 28 | private String instId; 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/IndexTickersArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class IndexTickersArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.INDEX_TICKERS; 22 | 23 | /** 24 | * 指数,以USD、USDT、BTC、USDC 为计价货币的指数,如 BTC-USDT 25 | */ 26 | @JSONField(name = "instId") 27 | @JsonProperty("instId") 28 | private String instId; 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/InstrumentsArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class InstrumentsArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.INSTRUMENTS; 22 | 23 | @NonNull 24 | @JSONField(name = "instType") 25 | @JsonProperty("instType") 26 | private InstrumentType instType; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/LiquidationOrdersArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | import xyz.felh.okx.v5.enumeration.InstrumentType; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class LiquidationOrdersArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.LIQUIDATION_ORDERS; 22 | 23 | /** 24 | * 产品type 25 | */ 26 | @JSONField(name = "instType") 27 | @JsonProperty("instType") 28 | private InstrumentType instType; 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/MarkPriceArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class MarkPriceArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.MARK_PRICE; 22 | 23 | /** 24 | * 产品ID 25 | */ 26 | @JSONField(name = "instId") 27 | @JsonProperty("instId") 28 | private String instId; 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/OpenInterestArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class OpenInterestArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.OPEN_INTEREST; 22 | 23 | /** 24 | * 产品ID 25 | */ 26 | @NonNull 27 | @JSONField(name = "instId") 28 | @JsonProperty("instId") 29 | private String instId; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/OptionSummaryArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | 11 | @Data 12 | @ToString(callSuper = true) 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @SuperBuilder(toBuilder = true) 16 | public class OptionSummaryArg implements WsChannelResponseArg { 17 | 18 | @Builder.Default 19 | @JSONField(name = "channel") 20 | @JsonProperty("channel") 21 | private Channel channel = Channel.OPT_SUMMARY; 22 | 23 | /** 24 | * 交易品种 25 | */ 26 | @JSONField(name = "instFamily") 27 | @JsonProperty("instFamily") 28 | private String instFamily; 29 | 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/entity/ws/response/pub/PriceLimitArg.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.entity.ws.response.pub; 2 | 3 | import com.alibaba.fastjson2.annotation.JSONField; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.*; 6 | import lombok.experimental.SuperBuilder; 7 | import xyz.felh.okx.v5.entity.ws.response.WsChannelResponseArg; 8 | import xyz.felh.okx.v5.enumeration.ws.Channel; 9 | 10 | @Data 11 | @ToString(callSuper = true) 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class PriceLimitArg implements WsChannelResponseArg { 16 | 17 | @Builder.Default 18 | @JSONField(name = "channel") 19 | @JsonProperty("channel") 20 | private Channel channel = Channel.PRICE_LIMIT; 21 | 22 | /** 23 | * 产品ID 24 | */ 25 | @JSONField(name = "instId") 26 | @JsonProperty("instId") 27 | private String instId; 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/AlgoOrderType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum AlgoOrderType { 8 | 9 | /** 10 | * Spot grid 11 | */ 12 | GRID("grid"), 13 | /** 14 | * Contract grid 15 | */ 16 | CONTRACT_GRID("contract_grid"); 17 | 18 | private final String value; 19 | 20 | AlgoOrderType(final String value) { 21 | this.value = value; 22 | } 23 | 24 | @JsonValue 25 | public String value() { 26 | return value; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ContractDirection.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum ContractDirection { 8 | 9 | LONG("long"), 10 | SHORT("short"), 11 | NEUTRAL("neutral"); 12 | 13 | private final String value; 14 | 15 | ContractDirection(final String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | public String value() { 21 | return value; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/InstrumentType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | 7 | @Getter 8 | public enum InstrumentType { 9 | 10 | /** 11 | * 币币 12 | */ 13 | SPOT("SPOT"), 14 | /** 15 | * 币币杠杆 16 | */ 17 | MARGIN("MARGIN"), 18 | /** 19 | * 永续合约 20 | */ 21 | SWAP("SWAP"), 22 | /** 23 | * 交割合约 24 | */ 25 | FUTURES("FUTURES"), 26 | /** 27 | * 期权 28 | */ 29 | OPTION("OPTION"), 30 | 31 | /** 32 | * 全部 33 | */ 34 | ANY("ANY"); 35 | 36 | private final String value; 37 | 38 | InstrumentType(final String value) { 39 | this.value = value; 40 | } 41 | 42 | @JsonValue 43 | public String value() { 44 | return value; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/OrderCategory.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum OrderCategory { 8 | 9 | /** 10 | * 普通委托订单种类 11 | */ 12 | NORMAL("normal"), 13 | /** 14 | * TWAP订单种类 15 | */ 16 | TWAP("twap"), 17 | /** 18 | * ADL订单种类 19 | */ 20 | ADL("adl"), 21 | /** 22 | * 爆仓订单种类 23 | */ 24 | FULL_LIQUIDATION("full_liquidation"), 25 | /** 26 | * 减仓订单种类 27 | */ 28 | PARTIAL_LIQUIDATION("partial_liquidation"), 29 | /** 30 | * 交割 31 | */ 32 | DELIVERY("delivery"), 33 | /** 34 | * 对冲减仓类型订单 35 | */ 36 | DDH("ddh"); 37 | 38 | 39 | private final String value; 40 | 41 | OrderCategory(final String value) { 42 | this.value = value; 43 | } 44 | 45 | @JsonValue 46 | public String value() { 47 | return value; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/OrderState.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum OrderState { 8 | 9 | /** 10 | * 等待成交 11 | */ 12 | LIVE("live"), 13 | /** 14 | * 部分成交 15 | */ 16 | PARTIALLY_FILLED("partially_filled"), 17 | /** 18 | * 完全成交 19 | */ 20 | FILLED("filled"), 21 | /** 22 | * 撤单成功 23 | */ 24 | CANCELED("canceled"), 25 | /** 26 | * 做市商保护机制导致的自动撤单 27 | */ 28 | MP_CANCELED("mmp_canceled"); 29 | 30 | 31 | private final String value; 32 | 33 | OrderState(final String value) { 34 | this.value = value; 35 | } 36 | 37 | @JsonValue 38 | public String value() { 39 | return value; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/OrderType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum OrderType { 8 | 9 | /** 10 | * 市价单 11 | */ 12 | MARKET("market"), 13 | /** 14 | * 限价单 15 | */ 16 | LIMIT("limit"), 17 | /** 18 | * 只做maker单 19 | */ 20 | POST_ONLY("post_only"), 21 | /** 22 | * 全部成交或立即取消 23 | */ 24 | FOK("fok"), 25 | /** 26 | * 立即成交并取消剩余 27 | */ 28 | IOC("ioc"), 29 | /** 30 | * 市价委托立即成交并取消剩余(仅适用交割、永续) 31 | */ 32 | OPTIMAL_LIMIT_IOC("optimal_limit_ioc"), 33 | /** 34 | * 做市商保护(仅适用于组合保证金账户模式下的期权订单) 35 | */ 36 | MMP("mmp"), 37 | /** 38 | * 做市商保护且只做maker单(仅适用于组合保证金账户模式下的期权订单) 39 | */ 40 | MMP_AND_POST_ONLY("mmp_and_post_only"), 41 | /** 42 | * 期权简选(全部成交或立即取消) 43 | */ 44 | OP_FOK("op_fok"); 45 | 46 | 47 | private final String value; 48 | 49 | OrderType(final String value) { 50 | this.value = value; 51 | } 52 | 53 | @JsonValue 54 | public String value() { 55 | return value; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/PositionsSide.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum PositionsSide { 8 | 9 | /** 10 | * 开平仓模式开多 11 | */ 12 | LONG("long"), 13 | /** 14 | * 开平仓模式开空 15 | */ 16 | SHORT("short"), 17 | /** 18 | * 买卖模式(交割/永续/期权:pos为正代表开多,pos为负代表开空。币币杠杆:posCcy为交易货币时,代表开多;posCcy为计价货币时,代表开空。) 19 | */ 20 | NET("net"); 21 | 22 | private final String value; 23 | 24 | PositionsSide(final String value) { 25 | this.value = value; 26 | } 27 | 28 | @JsonValue 29 | public String value() { 30 | return value; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/Side.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum Side { 8 | 9 | /** 10 | * 买 11 | */ 12 | BUY("buy"), 13 | /** 14 | * 卖 15 | */ 16 | SELL("sell"); 17 | 18 | private final String value; 19 | 20 | Side(final String value) { 21 | this.value = value; 22 | } 23 | 24 | @JsonValue 25 | public String value() { 26 | return value; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/StpMode.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum StpMode { 8 | 9 | CANCEL_MAKER("cancel_maker"), 10 | CANCEL_TAKER("cancel_taker"), 11 | CANCEL_BOTH("cancel_both"); 12 | 13 | private final String value; 14 | 15 | StpMode(final String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | public String value() { 21 | return value; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/TpOrderKind.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum TpOrderKind { 8 | 9 | CONDITION("condition"), 10 | LIMIT("limit"); 11 | 12 | private final String value; 13 | 14 | TpOrderKind(final String value) { 15 | this.value = value; 16 | } 17 | 18 | @JsonValue 19 | public String value() { 20 | return value; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/TriggerAction.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum TriggerAction { 8 | 9 | /** 10 | * START 11 | */ 12 | START("start"), 13 | /** 14 | * STOP 15 | */ 16 | STOP("stop"); 17 | 18 | private final String value; 19 | 20 | TriggerAction(final String value) { 21 | this.value = value; 22 | } 23 | 24 | @JsonValue 25 | public String value() { 26 | return value; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/TriggerCondition.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum TriggerCondition { 8 | 9 | CROSS_UP("cross_up"), 10 | CROSS_DOWN("cross_down"), 11 | ABOVE("above"), 12 | BELOW("below"), 13 | CROSS("cross"); 14 | 15 | private final String value; 16 | 17 | TriggerCondition(final String value) { 18 | this.value = value; 19 | } 20 | 21 | @JsonValue 22 | public String value() { 23 | return value; 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/TriggerPxType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum TriggerPxType { 8 | 9 | /** 10 | * 最新价格 11 | */ 12 | LAST("last"), 13 | /** 14 | * 指数价格 15 | */ 16 | INDEX("index"), 17 | /** 18 | * 标记价格 19 | */ 20 | MARK("mark"); 21 | 22 | private final String value; 23 | 24 | TriggerPxType(final String value) { 25 | this.value = value; 26 | } 27 | 28 | @JsonValue 29 | public String value() { 30 | return value; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/TriggerStrategy.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum TriggerStrategy { 8 | 9 | INSTANT("instant"), 10 | PRICE("price"), 11 | RSI("rsi"); 12 | 13 | private final String value; 14 | 15 | TriggerStrategy(final String value) { 16 | this.value = value; 17 | } 18 | 19 | @JsonValue 20 | public String value() { 21 | return value; 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/TriggerType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum TriggerType { 8 | 9 | MANUAL("manual"), 10 | AUTO("auto"); 11 | 12 | private final String value; 13 | 14 | TriggerType(final String value) { 15 | this.value = value; 16 | } 17 | 18 | @JsonValue 19 | public String value() { 20 | return value; 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/AdlWarningState.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum AdlWarningState { 8 | 9 | /** 10 | * 普通状态 11 | */ 12 | MARKET("normal"), 13 | /** 14 | * 预警状态 15 | */ 16 | LIMIT("warning"), 17 | 18 | /** 19 | * 已开启自动减仓 20 | */ 21 | ADL("adl"); 22 | 23 | 24 | private final String value; 25 | 26 | AdlWarningState(final String value) { 27 | this.value = value; 28 | } 29 | 30 | @JsonValue 31 | public String value() { 32 | return value; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/EventType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum EventType { 8 | 9 | /** 10 | * 首推快照 11 | */ 12 | SNAPSHOT("snapshot"), 13 | /** 14 | * 交割 15 | */ 16 | DELIVERED("delivered"), 17 | /** 18 | * 行权 19 | */ 20 | EXERCISED("exercised"), 21 | /** 22 | * 划转 23 | */ 24 | TRANSFERRED("transferred"), 25 | /** 26 | * 成交 27 | */ 28 | FILLED("filled"), 29 | /** 30 | * 强平 31 | */ 32 | LIQUIDATION("liquidation"), 33 | /** 34 | * 穿仓补偿 35 | */ 36 | CLAW_BACK("claw_back"), 37 | /** 38 | * ADL自动减仓 39 | */ 40 | ADL("adl"), 41 | /** 42 | * 资金费 43 | */ 44 | FUNDING_FEE("funding_fee"), 45 | /** 46 | * 调整保证金 47 | */ 48 | ADJUST_MARGIN("adjust_margin"), 49 | /** 50 | * 设置杠杆 51 | */ 52 | ST_LEVERAGE("set_leverage"), 53 | /** 54 | * 扣息 55 | */ 56 | INTEREST_DEDUCTION("interest_deduction"), 57 | ; 58 | 59 | 60 | private final String value; 61 | 62 | EventType(final String value) { 63 | this.value = value; 64 | } 65 | 66 | @JsonValue 67 | public String value() { 68 | return value; 69 | } 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/ExecType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum ExecType { 8 | 9 | /** 10 | * taker 11 | */ 12 | T("T"), 13 | /** 14 | * maker 15 | */ 16 | M("M"); 17 | 18 | private final String value; 19 | 20 | ExecType(final String value) { 21 | this.value = value; 22 | } 23 | 24 | @JsonValue 25 | public String value() { 26 | return value; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/FundingRateMethod.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum FundingRateMethod { 8 | 9 | /** 10 | * 当期收 11 | */ 12 | CURRENT_PERIOD("current_period"), 13 | /** 14 | * 跨期收 15 | */ 16 | NEXT_PERIOD("next_period"); 17 | 18 | private final String value; 19 | 20 | FundingRateMethod(final String value) { 21 | this.value = value; 22 | } 23 | 24 | @JsonValue 25 | public String value() { 26 | return value; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/FundingRateSettleState.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum FundingRateSettleState { 8 | 9 | /** 10 | * 结算中 11 | */ 12 | PROCESSING("processing"), 13 | /** 14 | * 已结算 15 | */ 16 | SETTLED("settled"); 17 | 18 | private final String value; 19 | 20 | FundingRateSettleState(final String value) { 21 | this.value = value; 22 | } 23 | 24 | @JsonValue 25 | public String value() { 26 | return value; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/MgnMode.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum MgnMode { 8 | 9 | /** 10 | * 全仓 11 | */ 12 | CROSS("cross"), 13 | /** 14 | * 逐仓 15 | */ 16 | ISOLATED("isolated"); 17 | 18 | private final String value; 19 | 20 | MgnMode(final String value) { 21 | this.value = value; 22 | } 23 | 24 | @JsonValue 25 | public String value() { 26 | return value; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/Operation.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum Operation { 8 | 9 | LOGIN("login", null), 10 | SUBSCRIBE("subscribe", null), 11 | UNSUBSCRIBE("unsubscribe", null), 12 | // once operation 13 | ORDER("order", "onPlaceOrderResponse"), 14 | BATCH_ORDERS("batch-orders", "onBatchPlaceOrdersResponse"), 15 | CANCEL_ORDER("cancel-order", "onCancelOrderResponse"), 16 | BATCH_CANCEL_ORDERS("batch-cancel-orders", "onBatchCancelOrdersResponse"), 17 | AMEND_ORDER("amend-order", "onAmendOrderResponse"), 18 | BATCH_AMEND_ORDERS("batch-amend-orders", "onBatchAmendOrdersResponse"), 19 | MASS_CANCEL_ORDERS("mass-cancel", "onMassCancelOrdersResponse"), 20 | ; 21 | 22 | private final String value; 23 | private final String rspCallbackMethodName; 24 | 25 | Operation(final String value, final String rspCallbackMethodName) { 26 | this.value = value; 27 | this.rspCallbackMethodName = rspCallbackMethodName; 28 | } 29 | 30 | @JsonValue 31 | public String value() { 32 | return value; 33 | } 34 | 35 | public static Operation fromValue(final String value) { 36 | for (Operation operation : Operation.values()) { 37 | if (operation.value.equals(value)) { 38 | return operation; 39 | } 40 | } 41 | return null; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/PriceType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum PriceType { 8 | 9 | /** 10 | * 代表按价格下单,单位为币 (请求参数 px 的数值单位是BTC或ETH) 11 | */ 12 | PX("px"), 13 | /** 14 | * 代表按pxVol下单 15 | */ 16 | PX_VOL("pxVol"), 17 | /** 18 | * 代表按照pxUsd下单,单位为USD (请求参数px 的数值单位是USD) 19 | */ 20 | PX_USD("pxUsd"); 21 | 22 | private final String value; 23 | 24 | PriceType(final String value) { 25 | this.value = value; 26 | } 27 | 28 | @JsonValue 29 | public String value() { 30 | return value; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/QuickMgnType.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum QuickMgnType { 8 | 9 | /** 10 | * 手动 11 | */ 12 | MANUAL("manual"), 13 | /** 14 | * 自动借币 15 | */ 16 | AUTO_BORROW("auto_borrow"), 17 | /** 18 | * 自动还币 19 | */ 20 | AUTO_REPAY("auto_repay"),; 21 | 22 | private final String value; 23 | 24 | QuickMgnType(final String value) { 25 | this.value = value; 26 | } 27 | 28 | @JsonValue 29 | public String value() { 30 | return value; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/TdMode.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum TdMode { 8 | 9 | // 保证金模式 10 | /** 11 | * 逐仓 12 | */ 13 | ISOLATED("isolated"), 14 | /** 15 | * 全仓 16 | */ 17 | CROSS("cross"), 18 | 19 | // 非保证金模式 20 | /** 21 | * 现金 22 | */ 23 | CASH("cash"), 24 | /** 25 | * 现货逐仓(仅适用于现货带单) ,现货带单时,tdMode 的值需要指定为spot_isolated 26 | */ 27 | SPOT_ISOLATED("spot_isolated"); 28 | 29 | private final String value; 30 | 31 | TdMode(final String value) { 32 | this.value = value; 33 | } 34 | 35 | @JsonValue 36 | public String value() { 37 | return value; 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/enumeration/ws/WsChannel.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.enumeration.ws; 2 | 3 | public enum WsChannel { 4 | 5 | PUBLIC, PRIVATE, BUSINESS 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/handler/WsErrorHandler.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.handler; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import lombok.extern.slf4j.Slf4j; 5 | import xyz.felh.okx.v5.OkxWsApiService; 6 | import xyz.felh.okx.v5.entity.ws.response.ErrorResponse; 7 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 8 | 9 | @Slf4j 10 | public class WsErrorHandler implements WsHandler { 11 | 12 | private final WsChannel wsChannel; 13 | private final ErrorResponse errorResponse; 14 | 15 | public WsErrorHandler(WsChannel wsChannel, String message) { 16 | this.wsChannel = wsChannel; 17 | this.errorResponse = JSONObject.parseObject(message, ErrorResponse.class); 18 | } 19 | 20 | @Override 21 | public void handle(OkxWsApiService okxWsApiService) { 22 | log.debug("wsChannel:{}", wsChannel); 23 | okxWsApiService.getWsMessageListener().onOperateError(errorResponse); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/handler/WsHandler.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.handler; 2 | 3 | import xyz.felh.okx.v5.OkxWsApiService; 4 | 5 | public interface WsHandler { 6 | 7 | void handle(OkxWsApiService okxWsApiService); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/handler/WsLoginHandler.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.handler; 2 | 3 | import com.alibaba.fastjson2.JSONObject; 4 | import lombok.extern.slf4j.Slf4j; 5 | import xyz.felh.okx.v5.OkxWsApiService; 6 | import xyz.felh.okx.v5.entity.ws.response.LoginResponse; 7 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 8 | 9 | @Slf4j 10 | public class WsLoginHandler implements WsHandler { 11 | 12 | private final WsChannel wsChannel; 13 | private final LoginResponse loginResponse; 14 | 15 | public WsLoginHandler(WsChannel wsChannel, String message) { 16 | this.wsChannel = wsChannel; 17 | this.loginResponse = JSONObject.parseObject(message, LoginResponse.class); 18 | } 19 | 20 | @Override 21 | public void handle(OkxWsApiService okxWsApiService) { 22 | log.debug("wsChannel: {} {}", wsChannel, loginResponse); 23 | okxWsApiService.setHasLogin(true); 24 | okxWsApiService.getWsMessageListener().onLoginSuccess(); 25 | okxWsApiService.getSubscribeStateService().restoreSubscribed(WsChannel.PRIVATE); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/handler/WsOnceHandler.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.handler; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import xyz.felh.okx.v5.OkxWsApiService; 5 | import xyz.felh.okx.v5.WsMessageListener; 6 | import xyz.felh.okx.v5.enumeration.ws.Operation; 7 | import xyz.felh.okx.v5.entity.ws.response.WsOnceResponse; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 9 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 10 | 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.lang.reflect.Method; 13 | 14 | @Slf4j 15 | public class WsOnceHandler implements WsHandler { 16 | 17 | private final WsOnceResponse response; 18 | private final WsChannel wsChannel; 19 | private final Operation operation; 20 | 21 | public WsOnceHandler(Class tClass, 22 | WsChannel wsChannel, 23 | String message, 24 | Operation operation) { 25 | this.response = WsOnceResponse.tryParse(tClass, message); 26 | this.wsChannel = wsChannel; 27 | this.operation = operation; 28 | } 29 | 30 | @Override 31 | public void handle(OkxWsApiService okxWsApiService) { 32 | log.debug("wsChannel {} {}", wsChannel, operation); 33 | try { 34 | if (response != null && okxWsApiService.getWsMessageListener() != null) { 35 | Method method = WsMessageListener.class.getDeclaredMethod(operation.getRspCallbackMethodName(), WsOnceResponse.class); 36 | method.setAccessible(true); 37 | method.invoke(okxWsApiService.getWsMessageListener(), response); 38 | } 39 | } catch (NoSuchMethodException e) { 40 | log.error("handle error", e); 41 | } catch (InvocationTargetException | IllegalAccessException e) { 42 | throw new RuntimeException(e); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/handler/WsSubscribeHandler.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.handler; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import xyz.felh.okx.v5.OkxWsApiService; 5 | import xyz.felh.okx.v5.WsMessageListener; 6 | import xyz.felh.okx.v5.entity.ws.request.WsRequestArg; 7 | import xyz.felh.okx.v5.entity.ws.response.Event; 8 | import xyz.felh.okx.v5.entity.ws.response.WsResponse; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 11 | 12 | import java.lang.reflect.InvocationTargetException; 13 | import java.lang.reflect.Method; 14 | 15 | @Slf4j 16 | public class WsSubscribeHandler implements WsHandler { 17 | 18 | private final Channel channel; 19 | private final WsResponse response; 20 | private final WsChannel wsChannel; 21 | 22 | public WsSubscribeHandler(Class rClass, 23 | Channel channel, 24 | String message, 25 | WsChannel wsChannel) { 26 | this.channel = channel; 27 | this.response = WsResponse.tryParse(rClass, message); 28 | this.wsChannel = wsChannel; 29 | } 30 | 31 | @Override 32 | public void handle(OkxWsApiService okxWsApiService) { 33 | try { 34 | if (response != null && okxWsApiService.getWsMessageListener() != null && okxWsApiService.getSubscribeStateService() != null) { 35 | Method method = WsMessageListener.class.getDeclaredMethod(channel.getOptCallbackMethodName(), WsResponse.class); 36 | method.setAccessible(true); 37 | method.invoke(okxWsApiService.getWsMessageListener(), response); 38 | if (response.getEvent() == Event.SUBSCRIBE) { 39 | okxWsApiService.getSubscribeStateService().confirmSubscribed(wsChannel, response.getArg()); 40 | } else if (response.getEvent() == Event.UNSUBSCRIBE) { 41 | okxWsApiService.getSubscribeStateService().removeSubscribed(wsChannel, response.getArg()); 42 | } 43 | } 44 | } catch (NoSuchMethodException e) { 45 | log.error("handle error", e); 46 | } catch (InvocationTargetException | IllegalAccessException e) { 47 | throw new RuntimeException(e); 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/handler/WsSubscribePushHandler.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.handler; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import xyz.felh.okx.v5.OkxWsApiService; 5 | import xyz.felh.okx.v5.WsMessageListener; 6 | import xyz.felh.okx.v5.entity.ws.WsSubscribeEntity; 7 | import xyz.felh.okx.v5.entity.ws.response.WsResponseArg; 8 | import xyz.felh.okx.v5.entity.ws.response.WsSubscribeResponse; 9 | import xyz.felh.okx.v5.enumeration.ws.Channel; 10 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 11 | 12 | import java.lang.reflect.InvocationTargetException; 13 | import java.lang.reflect.Method; 14 | 15 | @Slf4j 16 | public class WsSubscribePushHandler implements WsHandler { 17 | 18 | private final Channel channel; 19 | private final WsSubscribeResponse subscribeResponse; 20 | private final WsChannel wsChannel; 21 | 22 | public WsSubscribePushHandler(Class tClass, 23 | Class dClass, 24 | Channel channel, 25 | String message, 26 | WsChannel wsChannel) { 27 | this.channel = channel; 28 | this.subscribeResponse = WsSubscribeResponse.tryParse(tClass, dClass, message); 29 | this.wsChannel = wsChannel; 30 | } 31 | 32 | @Override 33 | public void handle(OkxWsApiService okxWsApiService) { 34 | log.debug("ws chanel {}", wsChannel); 35 | try { 36 | if (subscribeResponse != null && okxWsApiService.getWsMessageListener() != null) { 37 | Method method = WsMessageListener.class.getDeclaredMethod(channel.getRcvCallbackMethodName(), WsSubscribeResponse.class); 38 | method.setAccessible(true); 39 | method.invoke(okxWsApiService.getWsMessageListener(), subscribeResponse); 40 | } 41 | } catch (NoSuchMethodException e) { 42 | log.error("handle error", e); 43 | } catch (InvocationTargetException | IllegalAccessException e) { 44 | throw new RuntimeException(e); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/interceptor/AuthenticationInterceptor.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.interceptor; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import okhttp3.Interceptor; 5 | import okhttp3.Request; 6 | import okhttp3.RequestBody; 7 | import okhttp3.Response; 8 | import okio.Buffer; 9 | import org.jetbrains.annotations.NotNull; 10 | import xyz.felh.okx.v5.util.DateUtils; 11 | import xyz.felh.okx.v5.util.SignUtils; 12 | 13 | import java.io.IOException; 14 | import java.util.Date; 15 | 16 | import static xyz.felh.okx.v5.constant.OkxConstants.*; 17 | 18 | /** 19 | * OkHttp Interceptor that adds an authorization header 20 | */ 21 | @Slf4j 22 | public class AuthenticationInterceptor implements Interceptor { 23 | 24 | private final String apiKey; 25 | private final String secretKey; 26 | private final String passphrase; 27 | private final boolean simulated; 28 | 29 | public AuthenticationInterceptor(String apiKey, String secretKey, String passphrase, boolean simulated) { 30 | this.apiKey = apiKey; 31 | this.secretKey = secretKey; 32 | this.passphrase = passphrase; 33 | this.simulated = simulated; 34 | } 35 | 36 | @NotNull 37 | @Override 38 | public Response intercept(@NotNull Chain chain) throws IOException { 39 | String timestamp = DateUtils.format(DateUtils.FORMAT_UTC_ISO8601, new Date(), 0); 40 | String method = chain.request().method(); 41 | String body = EMPTY; 42 | if (method.equalsIgnoreCase("POST")) { 43 | body = bodyToString(chain.request().body()); 44 | } 45 | String sign = SignUtils.signRest(secretKey, 46 | timestamp, 47 | method, 48 | chain.request().url().encodedPath() 49 | + (chain.request().url().encodedQuery() != null ? ("?" + chain.request().url().encodedQuery()) : EMPTY), 50 | body); 51 | Request.Builder requestBuilder = chain.request() 52 | .newBuilder() 53 | .header(HEADER_OK_ACCESS_KEY, apiKey) 54 | .header(HEADER_OK_ACCESS_SIGN, sign) 55 | .header(HEADER_OK_ACCESS_TIMESTAMP, timestamp) 56 | .header(HEADER_OK_ACCESS_PASSPHRASE, passphrase); 57 | if (simulated) { 58 | requestBuilder.header(HEADER_X_SIMULATED_TRADING, "1"); 59 | } 60 | return chain.proceed(requestBuilder.build()); 61 | } 62 | 63 | private static String bodyToString(final RequestBody request) { 64 | try { 65 | final Buffer buffer = new Buffer(); 66 | if (request != null) { 67 | request.writeTo(buffer); 68 | } else { 69 | return EMPTY; 70 | } 71 | return buffer.readUtf8(); 72 | } catch (final IOException e) { 73 | log.error("Failed to serialize request body", e); 74 | return EMPTY; 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/util/DateUtils.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.util; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.time.ZoneId; 6 | import java.util.Date; 7 | import java.util.TimeZone; 8 | 9 | public class DateUtils { 10 | 11 | public static final String FORMAT_Y = "yyyy"; 12 | public static final String FORMAT_D_1 = "yyyy/MM/dd"; 13 | public static final String FORMAT_D_2 = "yyyy-MM-dd"; 14 | public static final String FORMAT_D_3 = "yyyyMMdd"; 15 | public static final String FORMAT_D_4 = "yyyy.MM.dd"; 16 | public static final String FORMAT_D = "dd"; 17 | public static final String FORMAT_DT_1 = "yyyy/MM/dd HH:mm:ss"; 18 | public static final String FORMAT_DT_2 = "yyyy-MM-dd HH:mm:ss"; 19 | public static final String FORMAT_DT_3 = "yyyyMMdd HH:mm:ss"; 20 | public static final String FORMAT_DT_4 = "yyyy-MM-dd HH:mm"; 21 | public static final String FORMAT_DT_5 = "yyyy.MM.dd HH:mm:ss"; 22 | public static final String FORMAT_DT_6 = "yyyyMMddHHmmss"; 23 | public static final String FORMAT_DT_7 = "yyyyMMddHH"; 24 | public static final String FORMAT_M_1 = "yyyy/MM"; 25 | public static final String FORMAT_M_2 = "yyyy-MM"; 26 | public static final String FORMAT_M_3 = "yyyyMM"; 27 | public static final String FORMAT_M = "MM"; 28 | public static final String FORMAT_MD_1 = "MM/dd"; 29 | public static final String FORMAT_MD_2 = "MM-dd"; 30 | public static final String FORMAT_MD_3 = "MMdd"; 31 | public static final String FORMAT_T_1 = "HH:mm:ss"; 32 | public static final String FORMAT_T_2 = "HH:mm"; 33 | public static final String FORMAT_TH = "HH"; 34 | public static final String FORMAT_TM = "mm"; 35 | public static final String FORMAT_TS = "ss"; 36 | public static final String FORMAT_UTC_ISO8601 = "yyyy-MM-dd'T'HH:mm:ss'Z'"; 37 | 38 | public static String format(String format, Date date) { 39 | SimpleDateFormat sdf = new SimpleDateFormat(format); 40 | return sdf.format(date); 41 | } 42 | 43 | /** 44 | * @param format format 45 | * @param date date 46 | * @param timeZone 时区数字 -8, 0, 8 等 47 | * @return date string 48 | */ 49 | public static String format(String format, Date date, int timeZone) { 50 | timeZone = timeZone % 13; 51 | SimpleDateFormat sdf = new SimpleDateFormat(format); 52 | ZoneId zoneId = ZoneId.of("GMT" + (timeZone >= 0 ? "+" : "") + timeZone); 53 | TimeZone tz = TimeZone.getTimeZone(zoneId); 54 | sdf.setTimeZone(tz); 55 | return sdf.format(date); 56 | } 57 | 58 | public static Date parse(String dateString, String format) { 59 | SimpleDateFormat sdf = new SimpleDateFormat(format); 60 | 61 | try { 62 | return sdf.parse(dateString); 63 | } catch (ParseException var4) { 64 | return null; 65 | } 66 | } 67 | 68 | public static Date parse(String dateString, String format, int timeZone) { 69 | SimpleDateFormat sdf = new SimpleDateFormat(format); 70 | ZoneId zoneId = ZoneId.of("GMT" + (timeZone >= 0 ? "+" : "") + timeZone); 71 | TimeZone tz = TimeZone.getTimeZone(zoneId); 72 | sdf.setTimeZone(tz); 73 | try { 74 | return sdf.parse(dateString); 75 | } catch (ParseException var4) { 76 | return null; 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/util/SignUtils.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import xyz.felh.okx.v5.entity.ws.request.pri.LoginArg; 5 | 6 | import javax.crypto.Mac; 7 | import javax.crypto.spec.SecretKeySpec; 8 | import java.util.Base64; 9 | 10 | 11 | @Slf4j 12 | public class SignUtils { 13 | 14 | public static String signRest(String secretKey, String timestamp, String method, String path, String body) { 15 | String str = String.format("%s%s%s%s", 16 | timestamp, // timestamp 17 | method, // method GET/POST 18 | path, // requestPath 19 | body // body 20 | ); 21 | try { 22 | return Base64.getEncoder().encodeToString(hmacSHA256(secretKey.getBytes(), str.getBytes())); 23 | } catch (Exception e) { 24 | throw new RuntimeException(e); 25 | } 26 | } 27 | 28 | public static String signWebsocket(LoginArg loginArg, String secretKey) { 29 | String str = String.format("%s%s%s", 30 | loginArg.getTimestamp(), 31 | "GET", 32 | "/users/self/verify"); 33 | try { 34 | return Base64.getEncoder().encodeToString(hmacSHA256(secretKey.getBytes(), str.getBytes())); 35 | } catch (Exception e) { 36 | throw new RuntimeException(e); 37 | } 38 | } 39 | 40 | /** 41 | * HmacSHA256算法,返回的结果始终是32位 42 | * 43 | * @param key 加密的键,可以是任何数据 44 | * @param content 待加密的内容 45 | * @return 加密后的内容 46 | * @throws Exception ex 47 | */ 48 | public static byte[] hmacSHA256(byte[] key, byte[] content) throws Exception { 49 | Mac hmacSha256 = Mac.getInstance("HmacSHA256"); 50 | hmacSha256.init(new SecretKeySpec(key, 0, key.length, "HmacSHA256")); 51 | return hmacSha256.doFinal(content); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/ws/BusinessWsListener.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.ws; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import okhttp3.Response; 5 | import okhttp3.WebSocket; 6 | import okio.ByteString; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | import xyz.felh.okx.v5.OkxWsApiService; 10 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 11 | 12 | /** 13 | * business channel ws listener 14 | */ 15 | @Slf4j 16 | public class BusinessWsListener extends FelhWsListener { 17 | 18 | public BusinessWsListener(@NotNull OkxWsApiService okxWsApiService) { 19 | super(WsChannel.BUSINESS, okxWsApiService); 20 | } 21 | 22 | @Override 23 | public void onOpen(@NotNull WebSocket webSocket, @NotNull Response response) { 24 | super.onOpen(webSocket, response); 25 | } 26 | 27 | @Override 28 | public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) { 29 | super.onMessage(webSocket, text); 30 | } 31 | 32 | @Override 33 | public void onMessage(@NotNull WebSocket webSocket, @NotNull ByteString bytes) { 34 | super.onMessage(webSocket, bytes); 35 | } 36 | 37 | @Override 38 | public void onClosed(@NotNull WebSocket webSocket, int code, @NotNull String reason) { 39 | super.onClosed(webSocket, code, reason); 40 | } 41 | 42 | @Override 43 | public void onClosing(@NotNull WebSocket webSocket, int code, @NotNull String reason) { 44 | super.onClosing(webSocket, code, reason); 45 | } 46 | 47 | @Override 48 | public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, @Nullable Response response) { 49 | super.onFailure(webSocket, t, response); 50 | } 51 | 52 | @Override 53 | protected void afterConnected() { 54 | okxWsApiService.getSubscribeStateService().restoreSubscribed(WsChannel.BUSINESS); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/ws/PrivateWsListener.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.ws; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import okhttp3.Response; 5 | import okhttp3.WebSocket; 6 | import okio.ByteString; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | import xyz.felh.okx.v5.OkxWsApiService; 10 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 11 | 12 | /** 13 | * private channel ws listener 14 | */ 15 | @Slf4j 16 | public class PrivateWsListener extends FelhWsListener { 17 | 18 | public PrivateWsListener(@NotNull OkxWsApiService okxWsApiService) { 19 | super(WsChannel.PRIVATE, okxWsApiService); 20 | } 21 | 22 | @Override 23 | public void onOpen(@NotNull WebSocket webSocket, @NotNull Response response) { 24 | super.onOpen(webSocket, response); 25 | } 26 | 27 | @Override 28 | public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) { 29 | super.onMessage(webSocket, text); 30 | } 31 | 32 | @Override 33 | public void onMessage(@NotNull WebSocket webSocket, @NotNull ByteString bytes) { 34 | super.onMessage(webSocket, bytes); 35 | } 36 | 37 | @Override 38 | public void onClosed(@NotNull WebSocket webSocket, int code, @NotNull String reason) { 39 | super.onClosed(webSocket, code, reason); 40 | } 41 | 42 | @Override 43 | public void onClosing(@NotNull WebSocket webSocket, int code, @NotNull String reason) { 44 | super.onClosing(webSocket, code, reason); 45 | } 46 | 47 | @Override 48 | public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, @Nullable Response response) { 49 | super.onFailure(webSocket, t, response); 50 | } 51 | 52 | @Override 53 | protected void afterConnected() { 54 | okxWsApiService.getSubscribeStateService().tryLogin(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/xyz/felh/okx/v5/ws/PublicWsListener.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5.ws; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import okhttp3.Response; 5 | import okhttp3.WebSocket; 6 | import okio.ByteString; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jetbrains.annotations.Nullable; 9 | import xyz.felh.okx.v5.OkxWsApiService; 10 | import xyz.felh.okx.v5.enumeration.ws.WsChannel; 11 | 12 | /** 13 | * public channel ws listener 14 | */ 15 | @Slf4j 16 | public class PublicWsListener extends FelhWsListener { 17 | 18 | public PublicWsListener(@NotNull OkxWsApiService okxWsApiService) { 19 | super(WsChannel.PUBLIC, okxWsApiService); 20 | } 21 | 22 | @Override 23 | public void onOpen(@NotNull WebSocket webSocket, @NotNull Response response) { 24 | super.onOpen(webSocket, response); 25 | } 26 | 27 | @Override 28 | public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) { 29 | super.onMessage(webSocket, text); 30 | } 31 | 32 | @Override 33 | public void onMessage(@NotNull WebSocket webSocket, @NotNull ByteString bytes) { 34 | super.onMessage(webSocket, bytes); 35 | } 36 | 37 | @Override 38 | public void onClosed(@NotNull WebSocket webSocket, int code, @NotNull String reason) { 39 | super.onClosed(webSocket, code, reason); 40 | } 41 | 42 | @Override 43 | public void onClosing(@NotNull WebSocket webSocket, int code, @NotNull String reason) { 44 | super.onClosing(webSocket, code, reason); 45 | } 46 | 47 | @Override 48 | public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, @Nullable Response response) { 49 | super.onFailure(webSocket, t, response); 50 | } 51 | 52 | @Override 53 | protected void afterConnected() { 54 | okxWsApiService.getSubscribeStateService().restoreSubscribed(WsChannel.PUBLIC); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/test/java/xyz/felh/okx/v5/OkxServiceTest.java: -------------------------------------------------------------------------------- 1 | package xyz.felh.okx.v5; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import com.fasterxml.jackson.databind.DeserializationFeature; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import com.fasterxml.jackson.databind.PropertyNamingStrategies; 8 | import lombok.extern.slf4j.Slf4j; 9 | import okhttp3.OkHttpClient; 10 | import org.junit.jupiter.api.Test; 11 | import xyz.felh.okx.v5.entity.rest.trading.order.booking.PlaceOrderReq; 12 | import xyz.felh.okx.v5.entity.ws.pri.Order; 13 | import xyz.felh.okx.v5.enumeration.AlgoOrderType; 14 | import xyz.felh.okx.v5.enumeration.OrderType; 15 | import xyz.felh.okx.v5.enumeration.Side; 16 | import xyz.felh.okx.v5.enumeration.ws.TdMode; 17 | 18 | import java.math.BigDecimal; 19 | import java.net.InetSocketAddress; 20 | import java.net.Proxy; 21 | import java.time.Duration; 22 | 23 | import static xyz.felh.okx.v5.OkxApiService.buildApi; 24 | import static xyz.felh.okx.v5.OkxApiService.defaultClient; 25 | 26 | @Slf4j 27 | public class OkxServiceTest { 28 | 29 | private OkxApiService getOkxService() { 30 | // 模拟盘 31 | String apiKey = System.getenv("API_KEY"); 32 | String passphrase = System.getenv("PASSPHRASE"); 33 | String secretKey = System.getenv("SECRET_KEY"); 34 | Duration defaultTimeout = Duration.ofSeconds(30); 35 | boolean simulated = true; 36 | Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("127.0.0.1", 7890)); 37 | OkHttpClient client = defaultClient(apiKey, secretKey, passphrase, simulated, defaultTimeout) 38 | .newBuilder() 39 | .proxy(proxy) 40 | .build(); 41 | return new OkxApiService(buildApi(apiKey, secretKey, passphrase, simulated, defaultTimeout), client, simulated); 42 | } 43 | 44 | @Test 45 | public void testGET() { 46 | OkxApiService service = getOkxService(); 47 | final var accountBalanceOkxRestResponse = service.getBalance("BTC"); 48 | log.info("test: {}", accountBalanceOkxRestResponse); 49 | } 50 | 51 | @Test 52 | public void placeOrder() { 53 | OkxApiService service = getOkxService(); 54 | var response = service.placeOrder(PlaceOrderReq.builder() 55 | .instId("BTC-USDT") 56 | .tdMode(TdMode.ISOLATED) 57 | .side(Side.BUY) 58 | .ordType(OrderType.MARKET) 59 | .sz(BigDecimal.ONE) 60 | .build()); 61 | 62 | // response = service.cancelOrder(CancelOrderReq.builder() 63 | // .instId("BTC-USDT") 64 | // .ordId("hell") 65 | // .build()); 66 | 67 | 68 | log.info("test: {}", response); 69 | } 70 | 71 | @Test 72 | public void getAiParam() { 73 | OkxApiService service = getOkxService(); 74 | var response = service.getGridAiParameterPublic( 75 | AlgoOrderType.GRID, 76 | "BTC-USDT", null, "7D"); 77 | log.info("test: {}", response); 78 | } 79 | 80 | @Test 81 | public void testIssue2() throws JsonProcessingException { 82 | ObjectMapper objectMapper = defaultObjectMapper(); 83 | Order order = objectMapper.readValue("{\"tpTriggerPxType\": \"a\"}", Order.class); 84 | System.out.println(order); 85 | } 86 | 87 | public static ObjectMapper defaultObjectMapper() { 88 | ObjectMapper mapper = new ObjectMapper(); 89 | mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 90 | mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); 91 | mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); 92 | mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); 93 | return mapper; 94 | } 95 | 96 | } 97 | --------------------------------------------------------------------------------