From 37d0c0724f912c15d4cd41dabef1723fd6191758 Mon Sep 17 00:00:00 2001 From: yuanhaijiang Date: Mon, 30 Mar 2026 08:38:26 +0800 Subject: [PATCH] sdk update --- .gitignore | 6 + huobi_contract_Java.iml | 70 +--- pom.xml | 2 +- .../constants/HuobiFutureAPIConstants.java | 43 ++- .../HuobiLinearSwapAPIConstants.java | 19 +- src/main/java/com/huobi/api/enums/OpEnum.java | 18 + .../usdt/account/AccountBillsRequest.java | 35 ++ .../request/usdt/algo/AlgoOrderRequest.java | 194 +++++++++++ .../usdt/algo/CancelAlgoOrdersRequest.java | 36 ++ .../algo/QueryAlgoOrderHistoryRequest.java | 93 ++++++ .../usdt/algo/QueryAlgoOrdersRequest.java | 47 +++ .../usdt/algo/QueryOpenAlgoOrdersRequest.java | 68 ++++ .../copyTradingTrade/TraderApikeyParam.java | 20 ++ .../TraderFollowerDeleteParam.java | 22 ++ .../TraderFollowerSettingsParam.java | 32 ++ .../TraderFollowersParam.java | 17 + .../TraderProfitSharingHistoryParam.java | 18 + .../copyTradingTrade/TraderTransferParam.java | 56 ++++ ...erUnrealizedProfitSharingSummaryParam.java | 14 + .../MarketEliteAccountRatioRequest.java | 31 ++ .../MarketElitePositionRatioRequest.java | 29 ++ ...MarketEstimatedSettlementPriceRequest.java | 23 ++ .../MarketFundingRateHistoryRequest.java | 62 ++++ .../usdt/market/MarketFundingRateRequest.java | 24 ++ .../MarketLiquidationOrdersRequest.java | 59 ++++ .../market/MarketOpenInterestRequest.java | 23 ++ .../usdt/market/MarketPriceLimitRequest.java | 25 ++ .../usdt/market/MarketRiskLimitRequest.java | 4 + .../MarketSettlementHistoryRequest.java | 57 ++++ .../usdt/trade/PositionMarginRequest.java | 23 ++ .../trade/PositionRiskLimitTierRequest.java | 18 + .../usdt/trade/TradeCancelAfterRequest.java | 17 + .../usdt/trade/TradeOrderHistoryRequest.java | 2 +- .../usdt/account/AccountBillsResponse.java | 43 +++ .../AccountFeeDeductionCurrencyResponse.java | 26 ++ .../ContractAccountBalanceResonse.java | 3 + .../response/usdt/algo/AlgoOrderResponse.java | 38 +++ .../usdt/algo/CancelAlgoOrdersResponse.java | 65 ++++ .../algo/QueryAlgoOrderHistoryResponse.java | 143 ++++++++ .../usdt/algo/QueryAlgoOrdersResponse.java | 138 ++++++++ .../algo/QueryOpenAlgoOrdersResponse.java | 138 ++++++++ .../usdt/copyTradingTrade/ApikeyResult.java | 35 ++ .../copyTradingTrade/BaseArrayResult.java | 19 ++ .../usdt/copyTradingTrade/ConfigResult.java | 26 ++ .../DeleteFollowerResult.java | 26 ++ .../FollowerSettingsResult.java | 30 ++ .../copyTradingTrade/FollowersResult.java | 54 +++ .../copyTradingTrade/InstrumentResult.java | 20 ++ .../ProfitSharingHistoryResult.java | 38 +++ .../ProfitSharingHistorySummaryResult.java | 26 ++ .../copyTradingTrade/StatisticsResult.java | 72 ++++ .../usdt/copyTradingTrade/TransferResult.java | 16 + .../UnrealizedProfitSharingSummaryResult.java | 26 ++ .../MarketEliteAccountRatioResponse.java | 62 ++++ .../MarketElitePositionRatioResponse.java | 62 ++++ ...arketEstimatedSettlementPriceResponse.java | 58 ++++ .../MarketFundingRateHistoryResponse.java | 66 ++++ .../market/MarketFundingRateResponse.java | 78 +++++ .../MarketLiquidationOrdersResponse.java | 98 ++++++ .../market/MarketOpenInterestResponse.java | 83 +++++ .../usdt/market/MarketPriceLimitResponse.java | 57 ++++ .../usdt/market/MarketRiskLimitResponse.java | 3 + .../MarketSettlementHistoryResponse.java | 72 ++++ .../usdt/trade/PositionMarginResponse.java | 24 ++ .../usdt/trade/PositionRiskLimitResponse.java | 3 + .../trade/PositionRiskLimitTierResponse.java | 47 +++ .../usdt/trade/TradeCancelAfterResponse.java | 25 ++ .../usdt/account/AccountAPIService.java | 5 +- .../usdt/account/AccountAPIServiceImpl.java | 77 ++++- .../api/service/usdt/algo/AlgoAPIService.java | 44 +++ .../service/usdt/algo/AlgoAPIServiceImpl.java | 313 ++++++++++++++++++ .../CopyTradingTradeAPIService.java | 31 ++ .../CopyTradingTradeAPIServiceImpl.java | 269 +++++++++++++++ .../CopytradingAPIServiceImpl.java | 1 + .../service/usdt/market/MarketAPIService.java | 65 +++- .../usdt/market/MarketAPIServiceImpl.java | 301 ++++++++++++++++- .../service/usdt/trade/TradeAPIService.java | 8 +- .../usdt/trade/TradeAPIServiceImpl.java | 80 ++++- .../wss/constants/HuobiSwapsWSSConstants.java | 1 + .../wss/constants/HuobiUsdtWSSConstants.java | 3 + .../huobi/wss/event/AccountSubResponse.java | 252 ++++++++++++++ .../wss/event/AlgoOrdersSubResponse.java | 109 ++++++ ...ponse.java => MatchOrdersOldResponse.java} | 2 +- .../wss/event/MatchOrdersSubOldResponse.java | 71 ++++ .../wss/event/MatchOrdersSubResponse.java | 241 +++++++++++--- .../wss/handle/WssNotificationHandle.java | 28 +- .../future/wss/WssNotificationSubTest.java | 2 +- .../swap/wss/WssNotificationSubTest.java | 2 +- .../usdt/wss/WssNotificationSubTest.java | 15 +- 89 files changed, 4699 insertions(+), 148 deletions(-) create mode 100644 .gitignore create mode 100644 src/main/java/com/huobi/api/enums/OpEnum.java create mode 100644 src/main/java/com/huobi/api/request/usdt/account/AccountBillsRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/algo/AlgoOrderRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/algo/CancelAlgoOrdersRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrderHistoryRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrdersRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/algo/QueryOpenAlgoOrdersRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderApikeyParam.java create mode 100644 src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerDeleteParam.java create mode 100644 src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerSettingsParam.java create mode 100644 src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowersParam.java create mode 100644 src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderProfitSharingHistoryParam.java create mode 100644 src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderTransferParam.java create mode 100644 src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderUnrealizedProfitSharingSummaryParam.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketEliteAccountRatioRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketElitePositionRatioRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketEstimatedSettlementPriceRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateHistoryRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketLiquidationOrdersRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketOpenInterestRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketPriceLimitRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/market/MarketSettlementHistoryRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/trade/PositionMarginRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/trade/PositionRiskLimitTierRequest.java create mode 100644 src/main/java/com/huobi/api/request/usdt/trade/TradeCancelAfterRequest.java create mode 100644 src/main/java/com/huobi/api/response/usdt/account/AccountBillsResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/account/AccountFeeDeductionCurrencyResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/algo/AlgoOrderResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/algo/CancelAlgoOrdersResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrderHistoryResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrdersResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/algo/QueryOpenAlgoOrdersResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ApikeyResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/BaseArrayResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ConfigResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/DeleteFollowerResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowerSettingsResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowersResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/InstrumentResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistoryResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistorySummaryResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/StatisticsResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/TransferResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/copyTradingTrade/UnrealizedProfitSharingSummaryResult.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketEliteAccountRatioResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketElitePositionRatioResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketEstimatedSettlementPriceResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateHistoryResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketLiquidationOrdersResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketOpenInterestResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketPriceLimitResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/market/MarketSettlementHistoryResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/trade/PositionMarginResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitTierResponse.java create mode 100644 src/main/java/com/huobi/api/response/usdt/trade/TradeCancelAfterResponse.java create mode 100644 src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIService.java create mode 100644 src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIServiceImpl.java create mode 100644 src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIService.java create mode 100644 src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIServiceImpl.java create mode 100644 src/main/java/com/huobi/wss/event/AccountSubResponse.java create mode 100644 src/main/java/com/huobi/wss/event/AlgoOrdersSubResponse.java rename src/main/java/com/huobi/wss/event/{MatchOrdersResponse.java => MatchOrdersOldResponse.java} (97%) create mode 100644 src/main/java/com/huobi/wss/event/MatchOrdersSubOldResponse.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..abb02d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +.idea/ +logs/ +target +*.iml +*.tmp diff --git a/huobi_contract_Java.iml b/huobi_contract_Java.iml index 5e405d8..1daccae 100644 --- a/huobi_contract_Java.iml +++ b/huobi_contract_Java.iml @@ -1,76 +1,8 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 80638fd..79c2073 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.huobi.contract.api huobi_contract_Java - 1.0.1 + 1.0.2 diff --git a/src/main/java/com/huobi/api/constants/HuobiFutureAPIConstants.java b/src/main/java/com/huobi/api/constants/HuobiFutureAPIConstants.java index 02a8ab8..be3e56d 100644 --- a/src/main/java/com/huobi/api/constants/HuobiFutureAPIConstants.java +++ b/src/main/java/com/huobi/api/constants/HuobiFutureAPIConstants.java @@ -99,6 +99,9 @@ public class HuobiFutureAPIConstants { //联合保证金接口 public static final String ACCOUNT_BALANCE = "/v5/account/balance"; // 1.查询账户余额 public static final String ACCOUNT_MULTI_ASSETS_MARGIN = "/v5/account/multi_assets_margin"; // 2.设置联合保证金模式 + public static final String ACCOUNT_FEE_DEDUCTION_CURRENCY = "/v5/account/fee_deduction_currency"; //查看手续费抵扣币种 + public static final String ACCOUNT_BILLS = "/v5/account/bills"; //查询流水记录 + public static final String TRADE_ORDER = "/v5/trade/order"; // 3.下单 public static final String TRADE_BACHORDER = "/v5/trade/batch_orders"; // 4.批量下单 public static final String CANCEL_TRADE_ORDER = "/v5/trade/cancel_order"; // 5.撤单 @@ -115,16 +118,44 @@ public class HuobiFutureAPIConstants { public static final String SET_POSITION_LEVER = "/v5/position/lever"; // 16.设置杠杆等级 public static final String POSITION_MODE = "/api/v5/position/mode"; // 17.查询持仓模式 public static final String SET_POSITION_MODE = "/api/v5/position/mode"; // 18.设置持仓模式 - public static final String POSITION_RISKLIMIT = "/v5/position/riskLimit"; // 19.查询持仓风险限额 - public static final String MARKET_RISK_LIMIT = "/v5/market/risk_limit"; // 20.查询合约风险限额 + public static final String POSITION_RISK_LIMIT = "/v5/position/risk/limit"; // 19.查询持仓风险限额 + public static final String POSITION_RISK_LIMIT_TIER = "/v5/position/risk/limit_tier"; // 26.查询持仓风险限额 + public static final String POSITION_MARGIN = "/v5/position/margin"; // 调整逐仓仓位保证金 + + public static final String MARKET_RISK_LIMIT = "/v5/market/risk/limit"; // 20.查询合约风险限额 public static final String ASSETS_DEDUCTION_CURRENCY = "/v5/assets_deduction_currency"; // 21.查询可抵扣手续费币种 public static final String MULTI_ASSETS_MARGIN_LIST = "/v5/market/multi_assets_margin"; // 22.查询联合保证金支持币种 - public static final String Market_Risk_Limit = "/v5/market/risk/limit"; // 23.查询合约风险限额 - public static final String Position_Risk_Limit = "/v5/position/risk/limit"; // 24.查询持仓风险限额 public static final String Get_Trade_Order_Response = "/v5/trade/order"; // 25.查询订单信息 - public static final String Fee_Deduction_Currency = "/v5/account/fee_deduction_currency"; - + public static final String TRADE_CANCEL_AFTER = "/v5/trade/cancel-after"; + /** + GET /v5/market/funding_rate + GET /v5/market/funding_rate_history + GET /v5/market/contract_info + GET /v5/market/open_interest + GET /v5/market/price_limit + GET /v5/market/liquidation_orders + GET /v5/market/settlement_history + GET /v5/market/elite_account_ratio + GET /v5/market/elite_position_ratio + GET /v5/market/estimated_settlement_price + */ + // 市场数据相关 + public static final String MARKET_FUNDING_RATE = "/v5/market/funding_rate"; + public static final String MARKET_FUNDING_RATE_HISTORY = "/v5/market/funding_rate_history"; + public static final String MARKET_CONTRACT_INFO = "/v5/market/contract_info"; + public static final String MARKET_OPEN_INTEREST = "/v5/market/open_interest"; + public static final String MARKET_PRICE_LIMIT = "/v5/market/price_limit"; + public static final String MARKET_LIQUIDATION_ORDERS = "/v5/market/liquidation_orders"; + public static final String MARKET_SETTLEMENT_HISTORY = "/v5/market/settlement_history"; + public static final String MARKET_ELITE_ACCOUNT_RATIO = "/v5/market/elite_account_ratio"; + public static final String MARKET_ELITE_POSITION_RATIO = "/v5/market/elite_position_ratio"; + public static final String MARKET_ESTIMATED_SETTLEMENT_PRICE = "/v5/market/estimated_settlement_price"; + public static final String ALGO_ORDER = "/v5/algo/order"; + public static final String ALGO_ORDER_CANCEL = "/v5/algo/cancel-orders"; + public static final String ALGO_ORDER_QUERY = "/v5/algo/order"; + public static final String ALGO_ORDER_OPENS_QUERY = "/v5/algo/order/opens"; + public static final String ALGO_ORDER_HISTORY_QUERY = "/v5/algo/order/history"; } diff --git a/src/main/java/com/huobi/api/constants/HuobiLinearSwapAPIConstants.java b/src/main/java/com/huobi/api/constants/HuobiLinearSwapAPIConstants.java index 353e08d..afe64d3 100644 --- a/src/main/java/com/huobi/api/constants/HuobiLinearSwapAPIConstants.java +++ b/src/main/java/com/huobi/api/constants/HuobiLinearSwapAPIConstants.java @@ -128,14 +128,21 @@ public class HuobiLinearSwapAPIConstants { public static final String Copytrading_Trader_Open_Orders = "/copytrading/trader/open_orders"; // 18.查询当前委托 public static final String Copytrading_Trader_Tpsl_Open_Orders = "/copytrading/trader/tpsl_open_orders"; // 19.查询当前止盈止损委托 + // 合约跟单 V6 接口 + public static final String CopytradingV6_Trader_Instruments = "/api/v6/copyTrading/trader/instruments"; + public static final String CopytradingV6_Trader_Statistics = "/api/v6/copyTrading/trader/statistics"; + public static final String CopytradingV6_Trader_Profit_Sharing_History = "/api/v6/copyTrading/trader/profit-sharing-history"; + public static final String CopytradingV6_Trader_Profit_Sharing_History_Summary = "/api/v6/copyTrading/trader/profit-sharing-history-summary"; + public static final String CopytradingV6_Trader_Unrealized_Profit_Sharing_Summary = "/api/v6/copyTrading/trader/unrealized-profit-sharing-summary"; + public static final String CopytradingV6_Trader_Followers = "/api/v6/copyTrading/trader/followers"; + public static final String CopytradingV6_Trader_Follower = "/api/v6/copyTrading/trader/follower"; + public static final String CopytradingV6_Trader_Transfer = "/api/v6/copyTrading/trader/transfer"; + public static final String CopytradingV6_Trader_Follower_Settings = "/api/v6/copyTrading/trader/follower-settings"; + public static final String CopytradingV6_Trader_Config = "/api/v6/copyTrading/trader/config"; + public static final String CopytradingV6_Trader_Apikey = "/api/v6/copyTrading/trader/apikey"; + //返佣 public static final String Invitee_Rebate_All_Rebate_Detail = "/v2/invitee/rebate/all_rebate/detail"; // 查询全部返佣信息 public static final String Invitee_Rebate_Batcher_Rebate_Detail = "/v2/invitee/rebate/batcher_rebate/detail"; // 查询批量返佣信息 - public static final String Earn_Project_Query_Earn_Project_List = "/v1/earn/project/queryEarnProjectList"; - public static final String Earn_Order_Demand_Add = "/v1/earn/order/demand/add"; - public static final String Earn_Order_Demand_Redeem_Order = "/v1/earn/order/demand/redeem-order"; - public static final String Earn_Order_User_Assets_List = "/v1/earn/order/user/assets/list"; - - } diff --git a/src/main/java/com/huobi/api/enums/OpEnum.java b/src/main/java/com/huobi/api/enums/OpEnum.java new file mode 100644 index 0000000..2ed6181 --- /dev/null +++ b/src/main/java/com/huobi/api/enums/OpEnum.java @@ -0,0 +1,18 @@ +package com.huobi.api.enums; + +public enum OpEnum { + + SUB("sub"), + UNSUB("unsub"); + + private String value; + + OpEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/src/main/java/com/huobi/api/request/usdt/account/AccountBillsRequest.java b/src/main/java/com/huobi/api/request/usdt/account/AccountBillsRequest.java new file mode 100644 index 0000000..f91819e --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/account/AccountBillsRequest.java @@ -0,0 +1,35 @@ +package com.huobi.api.request.usdt.account; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@AllArgsConstructor +@Data +@Builder +public class AccountBillsRequest { + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("margin_mode") + private String marginMode; + + @SerializedName("type") + private String type; + + @SerializedName("start_time") + private String startTime; + + @SerializedName("end_time") + private String endTime; + + @SerializedName("from") + private Long from; + + @SerializedName("limit") + private Integer limit; + + @SerializedName("direct") + private String direct; +} diff --git a/src/main/java/com/huobi/api/request/usdt/algo/AlgoOrderRequest.java b/src/main/java/com/huobi/api/request/usdt/algo/AlgoOrderRequest.java new file mode 100644 index 0000000..4ac8515 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/algo/AlgoOrderRequest.java @@ -0,0 +1,194 @@ +package com.huobi.api.request.usdt.algo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 算法订单请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AlgoOrderRequest { + + /** + * 合约代码 + * 必填: true + */ + private String contractCode; + + /** + * 订单类型 + * 必填: true + * 取值: tp(止盈), sl(止损), tpsl(止盈止损), trigger(计划委托), trailing_stop(跟踪委托) + */ + private String type; + + /** + * 仓位方向 + * 必填: true + * 取值: long(多), short(空), both(单向持仓) + */ + private String positionSide; + + /** + * 订单方向 + * 必填: true + * 取值: buy(买), sell(卖) + */ + private String side; + + /** + * 客户端策略订单ID + * 必填: false + */ + private String algoClientOrderId; + + /** + * 保证金模式 + * 必填: true + * 取值: isolated(逐仓), cross(全仓) + */ + private String marginMode; + + /** + * 委托张数 + * 必填: false + */ + private String volume; + + /** + * 止盈触发价格 + * 必填: false + * 适用于: 止盈/止盈止损委托 + */ + private String tpTriggerPrice; + + /** + * 止盈委托价格 + * 必填: false + * 适用于: 止盈/止盈止损委托 + * 备注: 最优N档委托类型时无需填写价格 + */ + private String tpOrderPrice; + + /** + * 止盈委托类型 + * 必填: false + * 取值: market(市价), limit(限价), optimal_5(最优5档), + * optimal_10(最优10档), optimal_20(最优20档) + * 默认值: market + * 适用于: 止盈/止盈止损委托 + */ + private String tpType; + + /** + * 止盈价格触发类型 + * 必填: false + * 取值: last(最新价), mark(标记价格) + * 默认值: last + * 适用于: 止盈/止盈止损委托 + */ + private String tpTriggerPriceType; + + /** + * 止损触发价格 + * 必填: false + * 适用于: 止损/止盈止损委托 + */ + private String slTriggerPrice; + + /** + * 止损委托价格 + * 必填: false + * 适用于: 止损/止盈止损委托 + * 备注: 最优N档委托类型时无需填写价格 + */ + private String slOrderPrice; + + /** + * 止损委托类型 + * 必填: false + * 取值: market(市价), limit(限价), optimal_5(最优5档), + * optimal_10(最优10档), optimal_20(最优20档) + * 默认值: market + * 适用于: 止损/止盈止损委托 + */ + private String slType; + + /** + * 止损价格触发类型 + * 必填: false + * 取值: last(最新价), mark(标记价格) + * 默认值: last + * 适用于: 止损/止盈止损委托 + */ + private String slTriggerPriceType; + + /** + * 委托价格 + * 必填: false + * 适用于: 计划委托 + */ + private String price; + + /** + * 最优档位 + * 必填: false + * 取值: opponent(对手价), optimal_5(最优5档), + * optimal_10(最优10档), optimal_20(最优20档) + * 适用于: 计划委托 + */ + private String priceMatch; + + /** + * 计划委托触发价格 + * 必填: false + * 适用于: 计划委托 + */ + private String triggerPrice; + + /** + * 计划委托触发价格类型 + * 必填: false + * 取值: last(最新价) + * 默认值: last + * 适用于: 计划委托 + */ + private String triggerPriceType; + + /** + * 激活价格 + * 必填: false + * 备注: 如果不填写激活价格,即下单后就被激活 + * 适用于: 跟踪委托 + */ + private String activePrice; + + /** + * 最优档位 + * 必填: false + * 取值: optimal_5(最优5档), optimal_10(最优10档), + * optimal_20(最优20档), formula_price(理论价格) + * 适用于: 跟踪委托 + */ + private String orderPriceType; + + /** + * 回调幅度的比例 + * 必填: false + * 示例: "0.05"代表"5%" + * 适用于: 跟踪委托 + */ + private String callbackRate; + + /** + * 只减仓 + * 必填: false + * 适用于: 跟踪委托 + */ + private Boolean reduceOnly; +} diff --git a/src/main/java/com/huobi/api/request/usdt/algo/CancelAlgoOrdersRequest.java b/src/main/java/com/huobi/api/request/usdt/algo/CancelAlgoOrdersRequest.java new file mode 100644 index 0000000..cc0bcf9 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/algo/CancelAlgoOrdersRequest.java @@ -0,0 +1,36 @@ +package com.huobi.api.request.usdt.algo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 撤销策略委托订单请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CancelAlgoOrdersRequest { + + /** + * 策略委托单ID + * 必填: 可选 + * 备注: algoId和algoClientOrderId必须传一个,若两个都传,以algoId为准 + */ + private String algoId; + + /** + * 客户订单ID + * 必填: 可选 + * 备注: algoId和algoClientOrderId必须传一个,若两个都传,以algoId为准 + */ + private String algoClientOrderId; + + /** + * 交易对 + * 必填: 是 + */ + private String contractCode; +} diff --git a/src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrderHistoryRequest.java b/src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrderHistoryRequest.java new file mode 100644 index 0000000..bab0b50 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrderHistoryRequest.java @@ -0,0 +1,93 @@ +package com.huobi.api.request.usdt.algo; + +// 请求参数类 +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询历史策略委托单请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QueryAlgoOrderHistoryRequest { + + /** + * 合约代码 + * 必填: 否 + * 示例: "BTC-USDT" + */ + private String contractCode; + + /** + * 保证金模式 + * 必填: 否 + * cross:全仓 + * isolated: 逐仓 + */ + private String marginMode; + + /** + * 订单状态 + * 必填: 否 + * 可以查多个状态,使用逗号分隔 + * effective:完全触发 + * canceled:完全取消 + * failed: 失败 + */ + private List states; + + /** + * 订单类型 + * 必填: 是 + * tp:止盈 + * sl: 止损 + * tpsl: 止盈止损 + * trigger:计划委托 + * trailing_stop:跟踪委托 + */ + private String type; + + /** + * 查询开始时间 + * 必填: 否 + * UNIX时间戳,以毫秒为单位 + * 取值范围 [((end-time) – 48h), (end-time)] + */ + private Long startTime; + + /** + * 查询结束时间 + * 必填: 否 + * UNIX时间戳,以毫秒为单位 + * 取值范围 [(present-90d), present] + */ + private Long endTime; + + /** + * 查询的起始ID + * 必填: 否 + * 默认从0开始 + */ + private Long from; + + /** + * 分页页面大小 + * 必填: 否 + * 默认为10,最大为100 + */ + private Integer limit; + + /** + * 翻页方向 + * 必填: 否 + * prev: 上一页 + * next: 下一页 + * 默认next + */ + private String direct; +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrdersRequest.java b/src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrdersRequest.java new file mode 100644 index 0000000..a304ba7 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/algo/QueryAlgoOrdersRequest.java @@ -0,0 +1,47 @@ +package com.huobi.api.request.usdt.algo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询策略委托订单请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QueryAlgoOrdersRequest { + + /** + * 策略委托单ID + * 必填: 可选 + * 备注: algoId和algoClientOrderId必须传一个,若两个都传,以algoId为准 + */ + private String algoId; + + /** + * 客户订单ID + * 必填: 可选 + * 备注: algoId和algoClientOrderId必须传一个,若两个都传,以algoId为准 + */ + private String algoClientOrderId; + + /** + * 订单类型 + * 必填: 是 + * tp:止盈 + * sl: 止损 + * tpsl: 止盈止损 + * trigger:计划委托 + * trailing_stop:跟踪委托 + */ + private String type; + + /** + * 交易对 + * 必填: 可选 + */ + private String contractCode; +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/request/usdt/algo/QueryOpenAlgoOrdersRequest.java b/src/main/java/com/huobi/api/request/usdt/algo/QueryOpenAlgoOrdersRequest.java new file mode 100644 index 0000000..fc4fee6 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/algo/QueryOpenAlgoOrdersRequest.java @@ -0,0 +1,68 @@ +package com.huobi.api.request.usdt.algo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询当前未触发策略委托请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QueryOpenAlgoOrdersRequest { + + /** + * 交易对 + * 必填: 否 + */ + private String contractCode; + + /** + * 策略委托单ID + * 必填: 否 + */ + private String algoId; + + /** + * 客户订单ID + * 必填: 否 + */ + private String algoClientOrderId; + + /** + * 订单类型 + * 必填: 是 + * tp:止盈 + * sl: 止损 + * tpsl: 止盈止损 + * trigger:计划委托 + * trailing_stop:跟踪委托 + */ + private String type; + + /** + * 查询的起始ID + * 必填: 否 + * 默认从0开始 + */ + private Long from; + + /** + * 分页页面大小 + * 必填: 否 + * 默认为10,最大为100 + */ + private Integer limit; + + /** + * 翻页方向 + * 必填: 否 + * prev: 上一页 + * next: 下一页 + * 默认next + */ + private String direct; +} diff --git a/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderApikeyParam.java b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderApikeyParam.java new file mode 100644 index 0000000..bf6efec --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderApikeyParam.java @@ -0,0 +1,20 @@ +package com.huobi.api.request.usdt.copyTradingTrade; + +import lombok.*; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TraderApikeyParam { + + /** + * 产品类型 + * + * PERP 永续合约 + * + * SPOT 现货交易 + */ + private String instType; +} diff --git a/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerDeleteParam.java b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerDeleteParam.java new file mode 100644 index 0000000..2479739 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerDeleteParam.java @@ -0,0 +1,22 @@ +package com.huobi.api.request.usdt.copyTradingTrade; + +import lombok.*; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TraderFollowerDeleteParam { + + // 跟随者用户id + // 最大单次可移除10位跟单者 + private List followerUids; + + // 产品类型 + //PERP 永续合约 + //SPOT 现货交易 + private String instType; +} diff --git a/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerSettingsParam.java b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerSettingsParam.java new file mode 100644 index 0000000..3af02ef --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowerSettingsParam.java @@ -0,0 +1,32 @@ +package com.huobi.api.request.usdt.copyTradingTrade; + +import lombok.*; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TraderFollowerSettingsParam { + + /** + * 产品类型 + */ + private String instType; + + /** + * 开启或关闭跟单 + */ + private Boolean enable; + + /** + * + * 分润比例,开启跟单时可配。 + */ + private String profitSharingRatio; + + /** + * 跟单人数上限,开启跟单时可配。 + */ + private String maxFollowers; +} diff --git a/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowersParam.java b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowersParam.java new file mode 100644 index 0000000..06dd15b --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderFollowersParam.java @@ -0,0 +1,17 @@ +package com.huobi.api.request.usdt.copyTradingTrade; + +import lombok.*; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TraderFollowersParam { + private String instType; + private String begin; + private String end; + private String after; + private String before; + private String limit; +} diff --git a/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderProfitSharingHistoryParam.java b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderProfitSharingHistoryParam.java new file mode 100644 index 0000000..03b1ade --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderProfitSharingHistoryParam.java @@ -0,0 +1,18 @@ +package com.huobi.api.request.usdt.copyTradingTrade; + +import lombok.*; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TraderProfitSharingHistoryParam { + private String instId; + private String instType; + private String begin; + private String end; + private String after; + private String before; + private String limit; +} diff --git a/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderTransferParam.java b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderTransferParam.java new file mode 100644 index 0000000..bbab1fe --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderTransferParam.java @@ -0,0 +1,56 @@ +package com.huobi.api.request.usdt.copyTradingTrade; + +import lombok.*; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TraderTransferParam { + + /** + * 划转的资金数量 + */ + private String amt; + + /** + * 转出账户类型 + * 1:现货账户 + * + * 2:U本位合约账户 + * + * 3:交易账户(统一账户预留类型) + * + * 4:合约跟单账户 + * + * 5:现货跟单账户(预留类型) + * + * 同类型账户不可相互划转,否则报错。 + */ + private String from; + + /** + * 转入账户类型 + * + * 1:现货账户 + * + * 2:U本位合约账户 + * + * 3:交易账户(统一账户预留类型) + * + * 4:合约跟单账户 + * + * 5:现货跟单账户(预留类型) + * + * 同类型账户不可相互划转,否则报错。 + */ + private String to; + + /** + * 币种,当前仅支持USDT。 + * + * 若不传,默认为USDT + */ + private String ccy; +} diff --git a/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderUnrealizedProfitSharingSummaryParam.java b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderUnrealizedProfitSharingSummaryParam.java new file mode 100644 index 0000000..774f666 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/copyTradingTrade/TraderUnrealizedProfitSharingSummaryParam.java @@ -0,0 +1,14 @@ +package com.huobi.api.request.usdt.copyTradingTrade; + +import lombok.*; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TraderUnrealizedProfitSharingSummaryParam { + + private String instType; + private String ccy; +} diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketEliteAccountRatioRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketEliteAccountRatioRequest.java new file mode 100644 index 0000000..6a80690 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketEliteAccountRatioRequest.java @@ -0,0 +1,31 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import com.google.gson.annotations.SerializedName; +import java.util.List; + +/** + * 查询精英账户多空持仓对比-账户数请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketEliteAccountRatioRequest { + /** + * 合约代码 + * 必填参数 + * 永续:"BTC-USDT"... , 交割:"BTC-USDT-FUTURES" ... + */ + private String contractCode; + + /** + * 时间周期类型 + * 必填参数 + * 可选值:5min, 15min, 30min, 60min, 4hour, 1day + */ + private String period; +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketElitePositionRatioRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketElitePositionRatioRequest.java new file mode 100644 index 0000000..27c45fa --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketElitePositionRatioRequest.java @@ -0,0 +1,29 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询精英账户多空持仓对比-持仓数请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketElitePositionRatioRequest { + /** + * 合约代码 + * 必填参数 + * 永续:"BTC-USDT"... , 交割:"BTC-USDT-FUTURES" ... + */ + private String contractCode; + + /** + * 时间周期 + * 必填参数 + * 可选值:5min, 15min, 30min, 60min, 4hour, 1day + */ + private String period; +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketEstimatedSettlementPriceRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketEstimatedSettlementPriceRequest.java new file mode 100644 index 0000000..d6949d5 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketEstimatedSettlementPriceRequest.java @@ -0,0 +1,23 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询预估结算价请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketEstimatedSettlementPriceRequest { + /** + * 合约代码 + * 可选参数 + * 永续:"BTC-USDT"... ,交割:"BTC-USDT-210625"... + * 如果不传,返回所有合约的预估结算价 + */ + private String contractCode; +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateHistoryRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateHistoryRequest.java new file mode 100644 index 0000000..d139a49 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateHistoryRequest.java @@ -0,0 +1,62 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询历史资金费率请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketFundingRateHistoryRequest { + + /** + * 合约代码 + * 必填: 是 + * 永续:"BTC-USDT"... ,交割:"BTC-USDT-210625"... + */ + private String contractCode; + + /** + * 查询开始时间 + * 必填: 否 + * UNIX时间戳,以毫秒为单位 + * 取值范围 [((end-time) – 48h), (end-time)] + */ + private Long startTime; + + /** + * 查询结束时间 + * 必填: 否 + * UNIX时间戳,以毫秒为单位 + * 取值范围 [(present-90d), present] + */ + private Long endTime; + + /** + * 查询的起始ID + * 必填: 否 + * 默认从0开始 + */ + private Long from; + + /** + * 分页页面大小 + * 必填: 否 + * 默认为10,最大为100 + */ + private Integer limit; + + /** + * 翻页方向 + * 必填: 否 + * prev: 上一页 + * next: 下一页 + * 默认next + */ + private String direct; +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateRequest.java new file mode 100644 index 0000000..bb9dea9 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketFundingRateRequest.java @@ -0,0 +1,24 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询当前资金费率请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketFundingRateRequest { + + /** + * 交易对名称 + * 必填: 是 + * 使用逗号分隔,可查询多个,最多查询10个 + * 示例: "BTC-USDT,ETH-USDT" + */ + private String contractCode; +} diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketLiquidationOrdersRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketLiquidationOrdersRequest.java new file mode 100644 index 0000000..2c130bf --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketLiquidationOrdersRequest.java @@ -0,0 +1,59 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询强平订单请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketLiquidationOrdersRequest { + /** + * 合约代码,contract_code 和 pair 必须传一个 + */ + private String contractCode; + + /** + * 交易对,contract_code 和 pair 必须传一个 + */ + private String pair; + + /** + * 查询开始时间,UNIX时间戳(毫秒) + * 默认值:当前时间 - 2小时 + */ + private Long startTime; + + /** + * 查询结束时间,UNIX时间戳(毫秒) + * 默认值:当前时间 + */ + private Long endTime; + + /** + * 查询方向 + * prev:向前查询,数据按时间倒序排列 + * next:向后查询,数据按时间正序排列 + * 默认值:next + */ + private String direct; + + /** + * 查询起始ID + * 如果是向前(prev)查询,则赋值为上一次查询结果中得到的最小id + * 如果是向后(next)查询,则赋值为上一次查询结果中得到的最大id + */ + private Long from; + + /** + * 分页页面大小 + * 默认值:10 + * 最大值:100 + */ + private Integer limit; +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketOpenInterestRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketOpenInterestRequest.java new file mode 100644 index 0000000..d3061cd --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketOpenInterestRequest.java @@ -0,0 +1,23 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询当前平台合约持仓总量请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketOpenInterestRequest { + + /** + * 合约代码 + * 必填: 是 + * 永续:"BTC-USDT"... ,交割:"BTC-USDT-210625"... + */ + private String contractCode; +} diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketPriceLimitRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketPriceLimitRequest.java new file mode 100644 index 0000000..b5d6951 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketPriceLimitRequest.java @@ -0,0 +1,25 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询限价最高买价与最低卖价请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketPriceLimitRequest { + + /** + * 合约代码 + * 必填: 否 + * 永续:"BTC-USDT"... + * 交割:"BTC-USDT-210625"... + * 如果不传,返回所有合约的价格限制 + */ + private String contractCode; +} diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketRiskLimitRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketRiskLimitRequest.java index 233457e..5e7a8ed 100644 --- a/src/main/java/com/huobi/api/request/usdt/market/MarketRiskLimitRequest.java +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketRiskLimitRequest.java @@ -20,4 +20,8 @@ public class MarketRiskLimitRequest { @SerializedName("tier") private String tier; + + @SerializedName("volume_unit") + private String volumeUnit; + } diff --git a/src/main/java/com/huobi/api/request/usdt/market/MarketSettlementHistoryRequest.java b/src/main/java/com/huobi/api/request/usdt/market/MarketSettlementHistoryRequest.java new file mode 100644 index 0000000..a343c2f --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/market/MarketSettlementHistoryRequest.java @@ -0,0 +1,57 @@ +package com.huobi.api.request.usdt.market; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询平台结算历史请求参数 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MarketSettlementHistoryRequest { + /** + * 合约代码 + * 必填参数 + * 永续合约示例:"BTC-USDT" + * 交割合约示例:"BTC-USDT-210625" + */ + private String contractCode; + + /** + * 查询开始时间,UNIX时间戳(毫秒) + * 默认值:当前时间 - 48小时 + */ + private Long startTime; + + /** + * 查询结束时间,UNIX时间戳(毫秒) + * 默认值:当前时间 + */ + private Long endTime; + + /** + * 查询方向 + * prev:向前查询,数据按时间倒序排列 + * next:向后查询,数据按时间正序排列 + * 默认值:next + */ + private String direct; + + /** + * 查询起始ID + * 如果是向前(prev)查询,则赋值为上一次查询结果中得到的最小query_id + * 如果是向后(next)查询,则赋值为上一次查询结果中得到的最大query_id + */ + private String from; + + /** + * 分页页面大小 + * 默认值:10 + * 最大值:100 + */ + private Integer limit; +} diff --git a/src/main/java/com/huobi/api/request/usdt/trade/PositionMarginRequest.java b/src/main/java/com/huobi/api/request/usdt/trade/PositionMarginRequest.java new file mode 100644 index 0000000..6ab2d82 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/trade/PositionMarginRequest.java @@ -0,0 +1,23 @@ +package com.huobi.api.request.usdt.trade; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@AllArgsConstructor +@Builder +@Data +public class PositionMarginRequest { + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("position_side") + private String position_side; + + @SerializedName("amount") + private String amount; + + @SerializedName("type") + private String type; +} diff --git a/src/main/java/com/huobi/api/request/usdt/trade/PositionRiskLimitTierRequest.java b/src/main/java/com/huobi/api/request/usdt/trade/PositionRiskLimitTierRequest.java new file mode 100644 index 0000000..d977e8c --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/trade/PositionRiskLimitTierRequest.java @@ -0,0 +1,18 @@ +package com.huobi.api.request.usdt.trade; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@AllArgsConstructor +@Builder +@Data +public class PositionRiskLimitTierRequest { + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("margin_mode") + private String marginMode; + +} diff --git a/src/main/java/com/huobi/api/request/usdt/trade/TradeCancelAfterRequest.java b/src/main/java/com/huobi/api/request/usdt/trade/TradeCancelAfterRequest.java new file mode 100644 index 0000000..4984237 --- /dev/null +++ b/src/main/java/com/huobi/api/request/usdt/trade/TradeCancelAfterRequest.java @@ -0,0 +1,17 @@ +package com.huobi.api.request.usdt.trade; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@AllArgsConstructor +@Builder +@Data +public class TradeCancelAfterRequest { + @SerializedName("on_off") + private String onOff; + + @SerializedName("time_out") + private String timeOut; +} diff --git a/src/main/java/com/huobi/api/request/usdt/trade/TradeOrderHistoryRequest.java b/src/main/java/com/huobi/api/request/usdt/trade/TradeOrderHistoryRequest.java index 7cf89bb..a920068 100644 --- a/src/main/java/com/huobi/api/request/usdt/trade/TradeOrderHistoryRequest.java +++ b/src/main/java/com/huobi/api/request/usdt/trade/TradeOrderHistoryRequest.java @@ -39,6 +39,6 @@ public class TradeOrderHistoryRequest { @SerializedName("margin_mode") private String marginMode; - @SerializedName("time_in_force") + @SerializedName("margin_mode") private String timeInForce; } diff --git a/src/main/java/com/huobi/api/response/usdt/account/AccountBillsResponse.java b/src/main/java/com/huobi/api/response/usdt/account/AccountBillsResponse.java new file mode 100644 index 0000000..822349f --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/account/AccountBillsResponse.java @@ -0,0 +1,43 @@ +package com.huobi.api.response.usdt.account; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +@Data +@AllArgsConstructor +public class AccountBillsResponse { + @SerializedName("code") + private Integer code; + @SerializedName("data") + private List data; + @SerializedName("message") + private String message; + @SerializedName("ts") + private Long ts; + private class DataBean { + + @SerializedName("id") + private String id; + + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("margin_mode") + private String marginMode; + + @SerializedName("type") + private String type; + + @SerializedName("currency") + private String currency; + + @SerializedName("amount") + private String amount; + + @SerializedName("created_time") + private String createdTime; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/account/AccountFeeDeductionCurrencyResponse.java b/src/main/java/com/huobi/api/response/usdt/account/AccountFeeDeductionCurrencyResponse.java new file mode 100644 index 0000000..5912d80 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/account/AccountFeeDeductionCurrencyResponse.java @@ -0,0 +1,26 @@ +package com.huobi.api.response.usdt.account; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +@Data +@AllArgsConstructor +public class AccountFeeDeductionCurrencyResponse { + @SerializedName("code") + private Integer code; + @SerializedName("data") + private DataBean data; + @SerializedName("message") + private String message; + @SerializedName("ts") + private Long ts; + private class DataBean { + @SerializedName("fee_option") + private Integer feeOption; + @SerializedName("deduction_currency") + private String deductionCurrency; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/account/ContractAccountBalanceResonse.java b/src/main/java/com/huobi/api/response/usdt/account/ContractAccountBalanceResonse.java index b4010f9..78253c7 100644 --- a/src/main/java/com/huobi/api/response/usdt/account/ContractAccountBalanceResonse.java +++ b/src/main/java/com/huobi/api/response/usdt/account/ContractAccountBalanceResonse.java @@ -71,6 +71,9 @@ public class Details { @SerializedName("profit_unreal") private String profitUnreal; + @SerializedName("isolated_profit_unreal") + private String isolatedProfitUnreal; + @SerializedName("initial_margin") private String initialMargin; diff --git a/src/main/java/com/huobi/api/response/usdt/algo/AlgoOrderResponse.java b/src/main/java/com/huobi/api/response/usdt/algo/AlgoOrderResponse.java new file mode 100644 index 0000000..0b98adc --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/algo/AlgoOrderResponse.java @@ -0,0 +1,38 @@ +package com.huobi.api.response.usdt.algo; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Builder +@AllArgsConstructor +@Data +public class AlgoOrderResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + @Data + @AllArgsConstructor + private class DataBean { + + @SerializedName("algo_id") + private String algoId; + + @SerializedName("algo_client_order_id") + private String algoClientOrderId; + } +} + diff --git a/src/main/java/com/huobi/api/response/usdt/algo/CancelAlgoOrdersResponse.java b/src/main/java/com/huobi/api/response/usdt/algo/CancelAlgoOrdersResponse.java new file mode 100644 index 0000000..49718c8 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/algo/CancelAlgoOrdersResponse.java @@ -0,0 +1,65 @@ +package com.huobi.api.response.usdt.algo; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 撤销策略委托订单响应 + */ +@Builder +@AllArgsConstructor +@Data +public class CancelAlgoOrdersResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class DataBean { + /** + * 订单ID + */ + @SerializedName("algo_id") + private String algoId; + + /** + * 客户订单ID + */ + @SerializedName("algo_client_order_id") + private String algoClientOrderId; + + /** + * 是否撤销成功 + */ + @SerializedName("success") + private Boolean success; + + /** + * 错误信息(撤销失败时返回) + */ + @SerializedName("error_msg") + private String errorMsg; + + /** + * 错误码(撤销失败时返回) + */ + @SerializedName("error_code") + private Integer errorCode; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrderHistoryResponse.java b/src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrderHistoryResponse.java new file mode 100644 index 0000000..dded64f --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrderHistoryResponse.java @@ -0,0 +1,143 @@ +package com.huobi.api.response.usdt.algo; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +// 响应类 - 历史订单数据结构 +/** + * 查询历史策略委托单响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class QueryAlgoOrderHistoryResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 历史策略订单数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class HistoryAlgoOrderData { + @SerializedName("id") + private String id; + + @SerializedName("volume") + private String volume; + + @SerializedName("type") + private String type; + + @SerializedName("state") + private String state; + + @SerializedName("side") + private String side; + + @SerializedName("price") + private String price; + + @SerializedName("algo_id") + private String algoId; + + @SerializedName("algo_client_order_id") + private String algoClientOrderId; + + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("position_side") + private String positionSide; + + @SerializedName("margin_mode") + private String marginMode; + + @SerializedName("relation_order_id") + private String relationOrderId; + + @SerializedName("actual_volume") + private String actualVolume; + + @SerializedName("actual_price") + private String actualPrice; + + @SerializedName("actual_time") + private String actualTime; + + @SerializedName("created_time") + private String createdTime; + + @SerializedName("updated_time") + private String updatedTime; + + @SerializedName("order_source") + private String orderSource; + + @SerializedName("price_match") + private String priceMatch; + + @SerializedName("trigger_price") + private String triggerPrice; + + @SerializedName("trigger_price_type") + private String triggerPriceType; + + // 止盈相关字段 + @SerializedName("tp_trigger_price") + private String tpTriggerPrice; + + @SerializedName("tp_order_price") + private String tpOrderPrice; + + @SerializedName("tp_type") + private String tpType; + + @SerializedName("tp_trigger_price_type") + private String tpTriggerPriceType; + + // 止损相关字段 + @SerializedName("sl_trigger_price") + private String slTriggerPrice; + + @SerializedName("sl_order_price") + private String slOrderPrice; + + @SerializedName("sl_type") + private String slType; + + @SerializedName("sl_trigger_price_type") + private String slTriggerPriceType; + + // 跟踪委托相关字段 + @SerializedName("active_price") + private String activePrice; + + @SerializedName("order_price_type") + private String orderPriceType; + + @SerializedName("callback_rate") + private String callbackRate; + + @SerializedName("reduce_only") + private Boolean reduceOnly; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrdersResponse.java b/src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrdersResponse.java new file mode 100644 index 0000000..9fda935 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/algo/QueryAlgoOrdersResponse.java @@ -0,0 +1,138 @@ +package com.huobi.api.response.usdt.algo; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询策略委托订单响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class QueryAlgoOrdersResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 策略订单数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class DataBean { + @SerializedName("id") + private String id; + + @SerializedName("algo_id") + private String algoId; + + @SerializedName("algo_client_order_id") + private String algoClientOrderId; + + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("volume") + private String volume; + + @SerializedName("type") + private String type; + + @SerializedName("state") + private String state; + + @SerializedName("position_side") + private String positionSide; + + @SerializedName("margin_mode") + private String marginMode; + + @SerializedName("side") + private String side; + + @SerializedName("tp_trigger_price") + private String tpTriggerPrice; + + @SerializedName("tp_order_price") + private String tpOrderPrice; + + @SerializedName("tp_type") + private String tpType; + + @SerializedName("tp_trigger_price_type") + private String tpTriggerPriceType; + + @SerializedName("sl_trigger_price") + private String slTriggerPrice; + + @SerializedName("sl_order_price") + private String slOrderPrice; + + @SerializedName("sl_type") + private String slType; + + @SerializedName("sl_trigger_price_type") + private String slTriggerPriceType; + + @SerializedName("price") + private String price; + + @SerializedName("price_match") + private String priceMatch; + + @SerializedName("trigger_price") + private String triggerPrice; + + @SerializedName("trigger_price_type") + private String triggerPriceType; + + @SerializedName("active_price") + private String activePrice; + + @SerializedName("order_price_type") + private String orderPriceType; + + @SerializedName("callback_rate") + private String callbackRate; + + @SerializedName("reduce_only") + private Boolean reduceOnly; + + @SerializedName("actual_volume") + private String actualVolume; + + @SerializedName("actual_price") + private String actualPrice; + + @SerializedName("actual_time") + private String actualTime; + + @SerializedName("relation_order_id") + private String relationOrderId; + + @SerializedName("created_time") + private String createdTime; + + @SerializedName("updated_time") + private String updatedTime; + + @SerializedName("order_source") + private String orderSource; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/algo/QueryOpenAlgoOrdersResponse.java b/src/main/java/com/huobi/api/response/usdt/algo/QueryOpenAlgoOrdersResponse.java new file mode 100644 index 0000000..39bb87f --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/algo/QueryOpenAlgoOrdersResponse.java @@ -0,0 +1,138 @@ +package com.huobi.api.response.usdt.algo; + +import com.google.gson.annotations.SerializedName; +import lombok.*; + +import java.util.List; + +/** + * 查询当前未触发策略委托响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class QueryOpenAlgoOrdersResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 当前未触发策略订单数据 + * 注意:这个结构与查询单笔订单的AlgoOrderData不同 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class DataBean { + @SerializedName("id") + private String id; + + @SerializedName("volume") + private String volume; + + @SerializedName("type") + private String type; + + @SerializedName("state") + private String state; + + @SerializedName("side") + private String side; + + @SerializedName("algo_id") + private String algoId; + + @SerializedName("algo_client_order_id") + private String algoClientOrderId; + + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("position_side") + private String positionSide; + + @SerializedName("margin_mode") + private String marginMode; + + @SerializedName("created_time") + private String createdTime; + + @SerializedName("updated_time") + private String updatedTime; + + @SerializedName("order_source") + private String orderSource; + + @SerializedName("active_price") + private String activePrice; + + @SerializedName("callback_rate") + private String callbackRate; + + @SerializedName("reduce_only") + private Boolean reduceOnly; + + @SerializedName("order_price_type") + private String orderPriceType; + + // 以下是可选字段,根据不同的订单类型可能有不同的值 + @SerializedName("tp_trigger_price") + private String tpTriggerPrice; + + @SerializedName("tp_order_price") + private String tpOrderPrice; + + @SerializedName("tp_type") + private String tpType; + + @SerializedName("tp_trigger_price_type") + private String tpTriggerPriceType; + + @SerializedName("sl_trigger_price") + private String slTriggerPrice; + + @SerializedName("sl_order_price") + private String slOrderPrice; + + @SerializedName("sl_type") + private String slType; + + @SerializedName("sl_trigger_price_type") + private String slTriggerPriceType; + + @SerializedName("price") + private String price; + + @SerializedName("price_match") + private String priceMatch; + + @SerializedName("trigger_price") + private String triggerPrice; + + @SerializedName("trigger_price_type") + private String triggerPriceType; + + @SerializedName("actual_volume") + private String actualVolume; + + @SerializedName("actual_price") + private String actualPrice; + + @SerializedName("actual_time") + private String actualTime; + + @SerializedName("relation_order_id") + private String relationOrderId; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ApikeyResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ApikeyResult.java new file mode 100644 index 0000000..17fd60e --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ApikeyResult.java @@ -0,0 +1,35 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +import java.util.List; + +/** + * 参数 数据类型 是否必填 描述 + * label String true APIKey的备注 + * accessKey String true API公钥 + * secretKey String true API的私钥 + * perm Array of strings true APIKey权限 read:可读 trade:交易 例如:"perm": ["read","trade"] + * ts String true 创建时间 Unix微秒精度时间戳格式,例如:1759161600000000 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class ApikeyResult { + /** APIKey的备注 */ + private String label; + + /** API公钥 */ + private String accessKey; + + /** API的私钥 */ + private String secretKey; + + /** APIKey权限 read:可读 trade:交易 例如:"perm": ["read","trade"] */ + private List perm; + + /** 创建时间 Unix微秒精度时间戳格式,例如:1759161600000000 */ + private String ts; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/BaseArrayResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/BaseArrayResult.java new file mode 100644 index 0000000..0c19ebc --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/BaseArrayResult.java @@ -0,0 +1,19 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class BaseArrayResult { + + private String code; + + private String msg; + + private List data; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ConfigResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ConfigResult.java new file mode 100644 index 0000000..91c3d5b --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ConfigResult.java @@ -0,0 +1,26 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * enable Boolean true 当前带单开启状态 true 开启 false 关闭 + * profitSharingRatio String true 当前分润比例 带单状态为开启时存在。 目前支持档位: 0.1(10%分润) 0.15(15%分润) 0.20(20%分润) 0.25(25%分润) + * maxFollowers String true 跟单人数,带单状态为开启时存在。 默认为100。 目前支持档位: 100 200 500 1000 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class ConfigResult { + + /** 当前带单开启状态 true 开启 false 关闭 */ + private Boolean enable; + + /** 当前分润比例 带单状态为开启时存在。 目前支持档位: 0.1(10%分润) 0.15(15%分润) 0.20(20%分润) 0.25(25%分润) */ + private String profitSharingRatio; + + /** 跟单人数,带单状态为开启时存在。 默认为100。 目前支持档位: 100 200 500 1000 */ + private String maxFollowers; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/DeleteFollowerResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/DeleteFollowerResult.java new file mode 100644 index 0000000..e2a7425 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/DeleteFollowerResult.java @@ -0,0 +1,26 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * followerUid String true 跟随者用户id + * sCode String true 结果代码 + * sMsg String true 结果消息 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class DeleteFollowerResult { + + /** 跟随者用户id */ + private String followerUid; + + /** 结果代码 */ + private String sCode; + + /** 结果消息 */ + private String sMsg; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowerSettingsResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowerSettingsResult.java new file mode 100644 index 0000000..89e357e --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowerSettingsResult.java @@ -0,0 +1,30 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * instType String true 产品类型 PERP 永续合约 + * enable Boolean true 开启或关闭跟单 true 开启 false 关闭 + * profitSharingRatio String true 分润比例,开启跟单时可配。 目前支持档位: 0.1(10%分润) 0.15(15%分润) 0.20(20%分润) 0.25(25%分润) + * maxFollowers String true 跟单人数上限,开启跟单时可配。 默认为100。 目前支持档位: 100 200 500 1000 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class FollowerSettingsResult { + + /** 产品类型 PERP 永续合约 */ + private String instType; + + /** 开启或关闭跟单 true 开启 false 关闭 */ + private Boolean enable; + + /** 分润比例,开启跟单时可配。 目前支持档位: 0.1(10%分润) 0.15(15%分润) 0.20(20%分润) 0.25(25%分润) */ + private String profitSharingRatio; + + /** 跟单人数上限,开启跟单时可配。 默认为100。 目前支持档位: 100 200 500 1000 */ + private String maxFollowers; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowersResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowersResult.java new file mode 100644 index 0000000..3b698f7 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/FollowersResult.java @@ -0,0 +1,54 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * id String true 记录ID + * instType String true 产品类型 PERP 永续合约 + * followerAvatarLink String true 跟随者头像链接地址 + * followerName String true 跟随者昵称 + * followerUid String true 跟随者用户id + * followTime String true 跟随日期 Unix时间戳的微秒数格式,如 1597026383085000 + * followerAssetAmt String true 跟单者资产金额,单位为USDT + * followerProfitSharingAmt String true 跟单收益金额,单位为 USDT + * followerTradeAmt String true 跟随者交易额,单位为 USDT + * totalProfitSharingAmt String true 总分润金额,单位为 USDT + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class FollowersResult { + + /** 记录ID */ + private String id; + + /** 产品类型 PERP 永续合约 */ + private String instType; + + /** 跟随者头像链接地址 */ + private String followerAvatarLink; + + /** 跟随者昵称 */ + private String followerName; + + /** 跟随者用户id */ + private String followerUid; + + /** 跟随日期 Unix时间戳的微秒数格式,如 1597026383085000 */ + private String followTime; + + /** 跟单者资产金额,单位为USDT */ + private String followerAssetAmt; + + /** 跟单收益金额,单位为 USDT */ + private String followerProfitSharingAmt; + + /** 跟随者交易额,单位为 USDT */ + private String followerTradeAmt; + + /** 总分润金额,单位为 USDT */ + private String totalProfitSharingAmt; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/InstrumentResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/InstrumentResult.java new file mode 100644 index 0000000..5cb468e --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/InstrumentResult.java @@ -0,0 +1,20 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * instId String false 产品ID,如:BTC-USDT-PERP + * instType String false 产品类型 PERP 永续合约 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class InstrumentResult { + + private String instId; + + private String instType; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistoryResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistoryResult.java new file mode 100644 index 0000000..739a18e --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistoryResult.java @@ -0,0 +1,38 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * id String true 记录ID + * instType String true 产品类型 PERP 永续合约 + * followerName String true 跟单人的昵称 + * ccy String true 分润币种 + * profitSharingAmt String true 分润金额 + * ts String true 分润时间 Unix微秒精度时间戳格式,例如:1759161600000000 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class ProfitSharingHistoryResult { + + /** 记录ID */ + private String id; + + /** 产品类型 PERP 永续合约 */ + private String instType; + + /** 跟单人的昵称 */ + private String followerName; + + /** 分润币种 */ + private String ccy; + + /** 分润金额 */ + private String profitSharingAmt; + + /** 分润时间 Unix微秒精度时间戳格式,例如:1759161600000000 */ + private String ts; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistorySummaryResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistorySummaryResult.java new file mode 100644 index 0000000..33d14ff --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/ProfitSharingHistorySummaryResult.java @@ -0,0 +1,26 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * instType String true 产品类型 PERP 永续合约 + * ccy String true 分润币种 + * totalAmt String true 总分润金额 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class ProfitSharingHistorySummaryResult { + + /** 产品类型 PERP 永续合约 */ + private String instType; + + /** 分润币种 */ + private String ccy; + + /** 总分润金额 */ + private String totalAmt; +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/StatisticsResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/StatisticsResult.java new file mode 100644 index 0000000..ba65925 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/StatisticsResult.java @@ -0,0 +1,72 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +import java.util.List; + +/** + * 参数 数据类型 是否必填 描述 + * instType String true 产品类型 PERP 永续合约 + * totalFollowerNum String true 累计跟随人数 + * curFollowerNum String true 当前跟随人数 + * totalPnl String true 总收益(USDT) + * followerTotalPnl String true 跟单者总收益(USDT) + * winRate String true 胜率 例如: 0.1 代表 10% + * winNum String true 盈利带单笔数 + * lossNum String true 亏损带单笔数 + * profitDetails90d Array of objects true 最近90天内收益详情 + * > pnlRate String true 收益率 例如: 0.1 代表 10% + * > pnl String true 收益(USDT) + * > ts String true 结算周期,精度为微秒时间戳。 结算单位为天,代表对应收益信息为该天之内产生。 例如:1759161600000000 对应时间是2025-09-30 00:00:00.000 ,代表在25年9月30号这一天内产生的收益。 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class StatisticsResult { + + /** 产品类型 PERP 永续合约 */ + private String instType; + + /** 累计跟随人数 */ + private String totalFollowerNum; + + /** 当前跟随人数 */ + private String curFollowerNum; + + /** 总收益(USDT) */ + private String totalPnl; + + /** 跟单者总收益(USDT) */ + private String followerTotalPnl; + + /** 胜率 例如: 0.1 代表 10% */ + private String winRate; + + /** 盈利带单笔数 */ + private String winNum; + + /** 亏损带单笔数 */ + private String lossNum; + + /** 最近90天内收益详情 */ + private List profitDetails90d; + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + @ToString + public static class ProfitDetail { + + /** 收益率 例如: 0.1 代表 10% */ + private String pnlRate; + + /** 收益(USDT) */ + private String pnl; + + /** 结算周期,精度为微秒时间戳。 结算单位为天,代表对应收益信息为该天之内产生。 例如:1759161600000000 对应时间是2025-09-30 00:00:00.000 ,代表在25年9月30号这一天内产生的收益。 */ + private String ts; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/TransferResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/TransferResult.java new file mode 100644 index 0000000..649af5b --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/TransferResult.java @@ -0,0 +1,16 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * code String true 0 = 划转成功 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class TransferResult { + +} diff --git a/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/UnrealizedProfitSharingSummaryResult.java b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/UnrealizedProfitSharingSummaryResult.java new file mode 100644 index 0000000..ba4314e --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/copyTradingTrade/UnrealizedProfitSharingSummaryResult.java @@ -0,0 +1,26 @@ +package com.huobi.api.response.usdt.copyTradingTrade; + +import lombok.*; + +/** + * 参数 数据类型 是否必填 描述 + * instType String true 产品类型 PERP 永续合约 + * ccy String true 分润币种 + * totalAmt String true 总待分润金额 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class UnrealizedProfitSharingSummaryResult { + + /** 产品类型 PERP 永续合约 */ + private String instType; + + /** 分润币种 */ + private String ccy; + + /** 总待分润金额 */ + private String totalAmt; +} diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketEliteAccountRatioResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketEliteAccountRatioResponse.java new file mode 100644 index 0000000..bde2fd3 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketEliteAccountRatioResponse.java @@ -0,0 +1,62 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询精英账户多空持仓对比-账户数响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketEliteAccountRatioResponse { + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 精英账户多空持仓对比数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class EliteAccountRatioData { + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 净多仓的账户比例 + */ + @SerializedName("buy_ratio") + private String buyRatio; + + /** + * 净空仓的账户比例 + */ + @SerializedName("sell_ratio") + private String sellRatio; + + /** + * 数据生成时间,UNIX时间戳,以毫秒为单位 + */ + @SerializedName("ts") + private String ts; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketElitePositionRatioResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketElitePositionRatioResponse.java new file mode 100644 index 0000000..c19af17 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketElitePositionRatioResponse.java @@ -0,0 +1,62 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询精英账户多空持仓对比-持仓数响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketElitePositionRatioResponse { + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 精英账户多空持仓对比数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ElitePositionRatioData { + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 净多仓的账户比例 + */ + @SerializedName("buy_ratio") + private String buyRatio; + + /** + * 净空仓的账户比例 + */ + @SerializedName("sell_ratio") + private String sellRatio; + + /** + * 数据生成时间,UNIX时间戳,以毫秒为单位 + */ + @SerializedName("ts") + private String ts; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketEstimatedSettlementPriceResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketEstimatedSettlementPriceResponse.java new file mode 100644 index 0000000..a4e4e1b --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketEstimatedSettlementPriceResponse.java @@ -0,0 +1,58 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询预估结算价响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketEstimatedSettlementPriceResponse { + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 预估结算价数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class EstimatedSettlementPriceData { + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 结算类型 + * "delivery":交割 + * "settlement":结算 + */ + @SerializedName("settlement_type") + private String settlementType; + + /** + * 本期预估结算价格 + */ + @SerializedName("estimated_settlement_price") + private String estimatedSettlementPrice; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateHistoryResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateHistoryResponse.java new file mode 100644 index 0000000..8d4c3d2 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateHistoryResponse.java @@ -0,0 +1,66 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询历史资金费率响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketFundingRateHistoryResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("success") + private Boolean success; + + @SerializedName("ts") + private Long ts; + + /** + * 历史资金费率数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class FundingRateHistoryData { + /** + * 查询ID + */ + @SerializedName("id") + private String id; + + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 当期资金费率 + */ + @SerializedName("funding_rate") + private String fundingRate; + + /** + * 当期资金费率时间 + */ + @SerializedName("funding_time") + private String fundingTime; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateResponse.java new file mode 100644 index 0000000..b5f950f --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketFundingRateResponse.java @@ -0,0 +1,78 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询当前资金费率响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketFundingRateResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("success") + private Boolean success; + + @SerializedName("ts") + private Long ts; + + /** + * 资金费率数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class DataBean { + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 当期资金费率 + */ + @SerializedName("funding_rate") + private String fundingRate; + + /** + * 当期资金费率时间 + */ + @SerializedName("funding_time") + private String fundingTime; + + /** + * 下一期资金费率时间 + */ + @SerializedName("next_funding_time") + private String nextFundingTime; + + /** + * 资金费率下限 + */ + @SerializedName("min_funding_rate") + private String minFundingRate; + + /** + * 资金费率上限 + */ + @SerializedName("max_funding_rate") + private String maxFundingRate; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketLiquidationOrdersResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketLiquidationOrdersResponse.java new file mode 100644 index 0000000..58b9c33 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketLiquidationOrdersResponse.java @@ -0,0 +1,98 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询强平订单响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketLiquidationOrdersResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 强平订单数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class LiquidationOrderData { + /** + * 查询ID + */ + @SerializedName("id") + private String id; + + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 强平时间(毫秒时间戳) + */ + @SerializedName("liquidation_time") + private String liquidationTime; + + /** + * 买卖方向 + * buy: 买 + * sell: 卖 + */ + @SerializedName("side") + private String side; + + /** + * 持仓方向 + * long: 多 + * short: 空 + * both: 单向持仓 + */ + @SerializedName("position_side") + private String positionSide; + + /** + * 强平数量(张) + */ + @SerializedName("volume") + private String volume; + + /** + * 强平数量(币) + */ + @SerializedName("amount") + private String amount; + + /** + * 破产价格 + */ + @SerializedName("bankrupt_price") + private String bankruptPrice; + + /** + * 强平金额(计价币种) + */ + @SerializedName("trade_turnover") + private String tradeTurnover; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketOpenInterestResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketOpenInterestResponse.java new file mode 100644 index 0000000..6817cb3 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketOpenInterestResponse.java @@ -0,0 +1,83 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 查询当前平台合约持仓总量响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketOpenInterestResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private OpenInterestData data; + + @SerializedName("message") + private String message; + + @SerializedName("success") + private Boolean success; + + @SerializedName("ts") + private Long ts; + + /** + * 持仓总量数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class OpenInterestData { + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 持仓量(币),单边数量 + */ + @SerializedName("amount") + private String amount; + + /** + * 持仓量(张),单边数量 + */ + @SerializedName("volume") + private String volume; + + /** + * 总持仓额(单位为合约的计价币种,如USDT) + */ + @SerializedName("value") + private String value; + + /** + * 最近24小时成交量(币)(当前时间-24小时),值是买卖双边之和 + */ + @SerializedName("trade_amount") + private String tradeAmount; + + /** + * 最近24小时成交量(张)(当前时间-24小时),值是买卖双边之和 + */ + @SerializedName("trade_volume") + private String tradeVolume; + + /** + * 最近24小时成交额 (当前时间-24小时),值是买卖双边之和 + */ + @SerializedName("trade_turnover") + private String tradeTurnover; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketPriceLimitResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketPriceLimitResponse.java new file mode 100644 index 0000000..7812aac --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketPriceLimitResponse.java @@ -0,0 +1,57 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询限价最高买价与最低卖价响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketPriceLimitResponse { + + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 价格限制数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class PriceLimitData { + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 最高买价 + */ + @SerializedName("high_limit") + private String highLimit; + + /** + * 最低卖价 + */ + @SerializedName("low_limit") + private String lowLimit; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketRiskLimitResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketRiskLimitResponse.java index 69a1b16..12608d7 100644 --- a/src/main/java/com/huobi/api/response/usdt/market/MarketRiskLimitResponse.java +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketRiskLimitResponse.java @@ -39,5 +39,8 @@ private class DataBean { @SerializedName("min_volume") private String minVolume; + + @SerializedName("volume_unit") + private String volumeUnit; } } diff --git a/src/main/java/com/huobi/api/response/usdt/market/MarketSettlementHistoryResponse.java b/src/main/java/com/huobi/api/response/usdt/market/MarketSettlementHistoryResponse.java new file mode 100644 index 0000000..e97a382 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/market/MarketSettlementHistoryResponse.java @@ -0,0 +1,72 @@ +package com.huobi.api.response.usdt.market; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import java.util.List; + +/** + * 查询平台结算历史响应 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class MarketSettlementHistoryResponse { + @SerializedName("code") + private Integer code; + + @SerializedName("data") + private List data; + + @SerializedName("message") + private String message; + + @SerializedName("ts") + private Long ts; + + /** + * 结算历史数据 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SettlementHistoryData { + /** + * 查询ID,可作为下一次查询请求的from字段 + */ + @SerializedName("id") + private String id; + + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 结算时间(时间戳,单位毫秒) + * 当settlement_type为交割时,该时间为交割时间 + * 当settlement_type为结算时,该时间为结算时间 + */ + @SerializedName("settlement_time") + private String settlementTime; + + /** + * 分摊比例 + */ + @SerializedName("clawback_ratio") + private String clawbackRatio; + + /** + * 结算价格 + * 当settlement_type为交割时,该价格为交割价格 + * 当settlement_type为结算时,该价格为结算价格 + */ + @SerializedName("settlement_price") + private String settlementPrice; + } +} \ No newline at end of file diff --git a/src/main/java/com/huobi/api/response/usdt/trade/PositionMarginResponse.java b/src/main/java/com/huobi/api/response/usdt/trade/PositionMarginResponse.java new file mode 100644 index 0000000..0a1c11a --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/trade/PositionMarginResponse.java @@ -0,0 +1,24 @@ +package com.huobi.api.response.usdt.trade; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +@Data +@AllArgsConstructor +public class PositionMarginResponse { + + @SerializedName("code") + private Integer code; + @SerializedName("data") + private DataBean data; + @SerializedName("message") + private String message; + @SerializedName("ts") + private Long ts; + + private class DataBean { + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitResponse.java b/src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitResponse.java index 73711eb..2e9f2c0 100644 --- a/src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitResponse.java +++ b/src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitResponse.java @@ -39,5 +39,8 @@ private class DataBean { @SerializedName("min_volume") private String minVolume; + + @SerializedName("volume_unit") + private String volumeUnit; } } diff --git a/src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitTierResponse.java b/src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitTierResponse.java new file mode 100644 index 0000000..6cb8b46 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/trade/PositionRiskLimitTierResponse.java @@ -0,0 +1,47 @@ +package com.huobi.api.response.usdt.trade; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +@Data +@AllArgsConstructor +public class PositionRiskLimitTierResponse { + + @SerializedName("code") + private Integer code; + @SerializedName("data") + private List data; + @SerializedName("message") + private String message; + @SerializedName("ts") + private Long ts; + + private class DataBean { + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("margin_mode") + private String marginMode; + + @SerializedName("tier") + private String tier; + + @SerializedName("max_lever") + private String maxLever; + + @SerializedName("maintenance_margin_rate") + private String maintenanceMarginRate; + + @SerializedName("max_volume") + private String maxVolume; + + @SerializedName("min_volume") + private String minVolume; + + @SerializedName("volume_unit") + private String volumeUnit; + } +} diff --git a/src/main/java/com/huobi/api/response/usdt/trade/TradeCancelAfterResponse.java b/src/main/java/com/huobi/api/response/usdt/trade/TradeCancelAfterResponse.java new file mode 100644 index 0000000..a892a13 --- /dev/null +++ b/src/main/java/com/huobi/api/response/usdt/trade/TradeCancelAfterResponse.java @@ -0,0 +1,25 @@ +package com.huobi.api.response.usdt.trade; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class TradeCancelAfterResponse { + @SerializedName("code") + private Integer code; + @SerializedName("data") + private DataBean data; + @SerializedName("message") + private String message; + @SerializedName("ts") + private Long ts; + private class DataBean { + @SerializedName("current_time") + private String currentTime; + + @SerializedName("trigger_time") + private String triggerTime; + } +} diff --git a/src/main/java/com/huobi/api/service/usdt/account/AccountAPIService.java b/src/main/java/com/huobi/api/service/usdt/account/AccountAPIService.java index 0fd4b61..121b131 100644 --- a/src/main/java/com/huobi/api/service/usdt/account/AccountAPIService.java +++ b/src/main/java/com/huobi/api/service/usdt/account/AccountAPIService.java @@ -56,14 +56,15 @@ public interface AccountAPIService { SwapApiTradingStatusResponse getSwapApiTradingStatusResponse();// 22.获取用户API指标禁用信息 ContractAccountBalanceResonse getContractAccountBalance(); // 22. 联合保证金查询账户余额 - MultiAssetsMarginResponse setMultiAssetsMargin(int assetsMode); // 23.设置联合保证金模式 + AccountFeeDeductionCurrencyResponse getAccountFeeDeductionCurrency(); // 查看手续费抵扣币种 + AccountBillsResponse getAccountBills(AccountBillsRequest request); // 查询流水记录 QueryAllRebateDetailResponse queryAllRebateDetail(String direct, String fromId, Long limit); QueryBatcherRebateDetailResponse queryBatcherRebateDetail(String inviteeUidList); AccountFeeDeductionCurrency accountFeeDeductionCurrencyResponse(Integer feeOption, String deductionCurrency); ProjectQueryEarnProjectList projectQueryEarnProjectListResponse(String currency, Integer pageNum, Integer pageSize); EarnOrderDemandAdd earnOrderDemandAddResponse(Long id, BigDecimal amount, String requestId); - EarnOrderDemandRedeemOrde earnOrderDemandRedeemOrderResponse(Long id, BigDecimal amount, String requestId); + EarnOrderDemandRedeemOrde earnOrderDemandRedeemOrdeResponse(Long id, BigDecimal amount, String requestId); EarnOrderUserAssetsList earnOrderUserAssetsListResponse(Integer projectType, String currency, Integer pageNum, Integer pageSize); } diff --git a/src/main/java/com/huobi/api/service/usdt/account/AccountAPIServiceImpl.java b/src/main/java/com/huobi/api/service/usdt/account/AccountAPIServiceImpl.java index fc68d43..18de71d 100644 --- a/src/main/java/com/huobi/api/service/usdt/account/AccountAPIServiceImpl.java +++ b/src/main/java/com/huobi/api/service/usdt/account/AccountAPIServiceImpl.java @@ -611,6 +611,71 @@ public MultiAssetsMarginResponse setMultiAssetsMargin(int assetsMode) { throw new ApiException(body); } + @Override + public AccountFeeDeductionCurrencyResponse getAccountFeeDeductionCurrency() { + String body; + try { + Map params = new HashMap<>(); + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiFutureAPIConstants.ACCOUNT_FEE_DEDUCTION_CURRENCY, params); + AccountFeeDeductionCurrencyResponse response = JSON.parseObject(body, AccountFeeDeductionCurrencyResponse.class); + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public AccountBillsResponse getAccountBills(AccountBillsRequest request) { + String body; + try { + Map params = new HashMap<>(); + + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + if (StringUtils.isNotEmpty(request.getMarginMode())) { + params.put("margin_mode", request.getMarginMode()); + } + + if (StringUtils.isNotEmpty(request.getType())) { + params.put("type", request.getType()); + } + + if (StringUtils.isNotEmpty(request.getStartTime())) { + params.put("start_time", request.getStartTime()); + } + + if (StringUtils.isNotEmpty(request.getEndTime())) { + params.put("end_time", request.getEndTime()); + } + + if (request.getFrom() != null) { + params.put("from", request.getFrom()); + } + + if (request.getLimit() != null) { + params.put("limit", request.getLimit()); + } + + if (StringUtils.isNotEmpty(request.getDirect())) { + params.put("direct", request.getDirect()); + } + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiFutureAPIConstants.ACCOUNT_BILLS, params); + AccountBillsResponse response = JSON.parseObject(body, AccountBillsResponse.class); + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + @Override public QueryAllRebateDetailResponse queryAllRebateDetail(String direct, String fromId, Long limit) { String body; @@ -668,7 +733,7 @@ public AccountFeeDeductionCurrency accountFeeDeductionCurrencyResponse(Integer f if (StringUtils.isNotEmpty(deductionCurrency)) { params.put("deduction_currency", deductionCurrency); } - body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiFutureAPIConstants.Fee_Deduction_Currency, params); + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.SWAP_ACCOUNT_INFO, params); logger.debug("body:{}", body); AccountFeeDeductionCurrency response = JSON.parseObject(body, AccountFeeDeductionCurrency.class); if (response != null) { @@ -695,7 +760,7 @@ public ProjectQueryEarnProjectList projectQueryEarnProjectListResponse(String cu if (pageSize != null) { params.put("pageSize", pageSize); } - body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.Earn_Project_Query_Earn_Project_List, params); + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.Invitee_Rebate_All_Rebate_Detail, params); logger.debug("body:{}", body); ProjectQueryEarnProjectList response = JSON.parseObject(body, ProjectQueryEarnProjectList.class); if (response != null) { @@ -721,7 +786,7 @@ public EarnOrderDemandAdd earnOrderDemandAddResponse(Long id, BigDecimal amount, if (StringUtils.isNotEmpty(requestId)) { params.put("requestId", requestId); } - body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.Earn_Order_Demand_Add, params); + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.SWAP_ACCOUNT_INFO, params); logger.debug("body:{}", body); EarnOrderDemandAdd response = JSON.parseObject(body, EarnOrderDemandAdd.class); if (response != null) { @@ -735,7 +800,7 @@ public EarnOrderDemandAdd earnOrderDemandAddResponse(Long id, BigDecimal amount, } @Override - public EarnOrderDemandRedeemOrde earnOrderDemandRedeemOrderResponse(Long id, BigDecimal amount, String requestId) { + public EarnOrderDemandRedeemOrde earnOrderDemandRedeemOrdeResponse(Long id, BigDecimal amount, String requestId) { String body; try { Map params = new HashMap<>(); @@ -748,7 +813,7 @@ public EarnOrderDemandRedeemOrde earnOrderDemandRedeemOrderResponse(Long id, Big if (StringUtils.isNotEmpty(requestId)) { params.put("requestId", requestId); } - body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.Earn_Order_Demand_Redeem_Order, params); + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.SWAP_ACCOUNT_INFO, params); logger.debug("body:{}", body); EarnOrderDemandRedeemOrde response = JSON.parseObject(body, EarnOrderDemandRedeemOrde.class); if (response != null) { @@ -778,7 +843,7 @@ public EarnOrderUserAssetsList earnOrderUserAssetsListResponse(Integer projectTy if (pageSize != null) { params.put("pageSize", pageSize); } - body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.Earn_Order_User_Assets_List, params); + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.Invitee_Rebate_All_Rebate_Detail, params); logger.debug("body:{}", body); EarnOrderUserAssetsList response = JSON.parseObject(body, EarnOrderUserAssetsList.class); if (response != null) { diff --git a/src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIService.java b/src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIService.java new file mode 100644 index 0000000..2f5d949 --- /dev/null +++ b/src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIService.java @@ -0,0 +1,44 @@ +package com.huobi.api.service.usdt.algo; + +import com.huobi.api.request.usdt.algo.*; +import com.huobi.api.response.usdt.algo.*; + +public interface AlgoAPIService { + + /** + * 创建策略委托订单 + */ + AlgoOrderResponse algoOrder(AlgoOrderRequest request); + + /** + * 撤销单个策略委托订单 + * + * @param request 撤销请求参数 + * @return 撤销结果 + */ + CancelAlgoOrdersResponse cancelAlgoOrder(CancelAlgoOrdersRequest request); + + /** + * 查询策略委托订单 + * + * @param request 查询请求参数 + * @return 查询结果 + */ + QueryAlgoOrdersResponse queryAlgoOrder(QueryAlgoOrdersRequest request); + + /** + * 查询当前未触发的策略委托 + * + * @param request 查询请求参数 + * @return 查询结果 + */ + QueryOpenAlgoOrdersResponse queryOpenAlgoOrders(QueryOpenAlgoOrdersRequest request); + + /** + * 查询历史策略委托单 + * + * @param request 查询请求参数 + * @return 查询结果 + */ + QueryAlgoOrderHistoryResponse queryAlgoOrderHistory(QueryAlgoOrderHistoryRequest request); +} diff --git a/src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIServiceImpl.java b/src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIServiceImpl.java new file mode 100644 index 0000000..1707d8c --- /dev/null +++ b/src/main/java/com/huobi/api/service/usdt/algo/AlgoAPIServiceImpl.java @@ -0,0 +1,313 @@ +package com.huobi.api.service.usdt.algo; + +import com.alibaba.fastjson.JSON; +import com.huobi.api.constants.HuobiFutureAPIConstants; +import com.huobi.api.exception.ApiException; +import com.huobi.api.request.usdt.algo.*; +import com.huobi.api.response.usdt.algo.*; +import com.huobi.api.util.HbdmHttpClient; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +public class AlgoAPIServiceImpl implements AlgoAPIService { + + String api_key = ""; // huobi申请的apiKey + String secret_key = ""; // huobi申请的secretKey + String url_prex = "https://api.hbdm.com"; + + Logger logger = LoggerFactory.getLogger(getClass()); + + public AlgoAPIServiceImpl(String api_key, String secret_key) { + this.api_key = api_key; + this.secret_key = secret_key; + } + + @Override + public AlgoOrderResponse algoOrder(AlgoOrderRequest request) { + String body; + Map params = new HashMap<>(); + try { + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + if (StringUtils.isNotEmpty(request.getType())) { + params.put("type", request.getType()); + } + + if (StringUtils.isNotEmpty(request.getPositionSide())) { + params.put("position_side", request.getPositionSide()); + } + + if (StringUtils.isNotEmpty(request.getSide())) { + params.put("side", request.getSide()); + } + + if (StringUtils.isNotEmpty(request.getMarginMode())) { + params.put("margin_mode", request.getMarginMode()); + } + + // 可选字段 + if (StringUtils.isNotEmpty(request.getAlgoClientOrderId())) { + params.put("algo_client_order_id", request.getAlgoClientOrderId()); + } + + if (StringUtils.isNotEmpty(request.getVolume())) { + params.put("volume", request.getVolume()); + } + + // 止盈相关参数 + if (StringUtils.isNotEmpty(request.getTpTriggerPrice())) { + params.put("tp_trigger_price", request.getTpTriggerPrice()); + } + + if (StringUtils.isNotEmpty(request.getTpOrderPrice())) { + params.put("tp_order_price", request.getTpOrderPrice()); + } + + if (StringUtils.isNotEmpty(request.getTpType())) { + params.put("tp_type", request.getTpType()); + } + + if (StringUtils.isNotEmpty(request.getTpTriggerPriceType())) { + params.put("tp_trigger_price_type", request.getTpTriggerPriceType()); + } + + // 止损相关参数 + if (StringUtils.isNotEmpty(request.getSlTriggerPrice())) { + params.put("sl_trigger_price", request.getSlTriggerPrice()); + } + + if (StringUtils.isNotEmpty(request.getSlOrderPrice())) { + params.put("sl_order_price", request.getSlOrderPrice()); + } + + if (StringUtils.isNotEmpty(request.getSlType())) { + params.put("sl_type", request.getSlType()); + } + + if (StringUtils.isNotEmpty(request.getSlTriggerPriceType())) { + params.put("sl_trigger_price_type", request.getSlTriggerPriceType()); + } + + // 计划委托相关参数 + if (StringUtils.isNotEmpty(request.getPrice())) { + params.put("price", request.getPrice()); + } + + if (StringUtils.isNotEmpty(request.getPriceMatch())) { + params.put("price_match", request.getPriceMatch()); + } + + if (StringUtils.isNotEmpty(request.getTriggerPrice())) { + params.put("trigger_price", request.getTriggerPrice()); + } + + if (StringUtils.isNotEmpty(request.getTriggerPriceType())) { + params.put("trigger_price_type", request.getTriggerPriceType()); + } + + // 跟踪委托相关参数 + if (StringUtils.isNotEmpty(request.getActivePrice())) { + params.put("active_price", request.getActivePrice()); + } + + if (StringUtils.isNotEmpty(request.getOrderPriceType())) { + params.put("order_price_type", request.getOrderPriceType()); + } + + if (StringUtils.isNotEmpty(request.getCallbackRate())) { + params.put("callback_rate", request.getCallbackRate()); + } + + if (request.getReduceOnly() != null) { + params.put("reduce_only", request.getReduceOnly()); + } + + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiFutureAPIConstants.ALGO_ORDER, params); + logger.debug("body:{}", body); + AlgoOrderResponse response = JSON.parseObject(body, AlgoOrderResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public CancelAlgoOrdersResponse cancelAlgoOrder(CancelAlgoOrdersRequest request) { + String body; + Map params = new HashMap<>(); + try { + if (StringUtils.isNotEmpty(request.getAlgoId())) { + params.put("algo_id", request.getAlgoId()); + } + + if (StringUtils.isNotEmpty(request.getAlgoClientOrderId())) { + params.put("algo_client_order_id", request.getAlgoClientOrderId()); + } + + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiFutureAPIConstants.ALGO_ORDER_CANCEL, params); + logger.debug("body:{}", body); + CancelAlgoOrdersResponse response = JSON.parseObject(body, CancelAlgoOrdersResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public QueryAlgoOrdersResponse queryAlgoOrder(QueryAlgoOrdersRequest request) { + String body; + Map params = new HashMap<>(); + try { + // 必填参数校验 + if (StringUtils.isEmpty(request.getType())) { + throw new IllegalArgumentException("type参数为必填项"); + } + params.put("type", request.getType()); + + // 可选参数 + if (StringUtils.isNotEmpty(request.getAlgoId())) { + params.put("algo_id", request.getAlgoId()); + } + + if (StringUtils.isNotEmpty(request.getAlgoClientOrderId())) { + params.put("algo_client_order_id", request.getAlgoClientOrderId()); + } + + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + // 使用GET请求查询 + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiFutureAPIConstants.ALGO_ORDER_QUERY, params); + logger.debug("查询策略订单返回body:{}", body); + + QueryAlgoOrdersResponse response = JSON.parseObject(body, QueryAlgoOrdersResponse.class); + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public QueryOpenAlgoOrdersResponse queryOpenAlgoOrders(QueryOpenAlgoOrdersRequest request) { + String body; + Map params = new HashMap<>(); + try { + params.put("type", request.getType()); + + // 可选参数 + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + if (StringUtils.isNotEmpty(request.getAlgoId())) { + params.put("algo_id", request.getAlgoId()); + } + + if (StringUtils.isNotEmpty(request.getAlgoClientOrderId())) { + params.put("algo_client_order_id", request.getAlgoClientOrderId()); + } + + if (request.getFrom() != null) { + params.put("from", request.getFrom()); + } + + if (request.getLimit() != null) { + params.put("limit", request.getLimit()); + } + + if (StringUtils.isNotEmpty(request.getDirect())) { + params.put("direct", request.getDirect()); + } + + // 使用GET请求查询 + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiFutureAPIConstants.ALGO_ORDER_OPENS_QUERY, params); + logger.debug("查询当前未触发策略订单返回body:{}", body); + + QueryOpenAlgoOrdersResponse response = JSON.parseObject(body, QueryOpenAlgoOrdersResponse.class); + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public QueryAlgoOrderHistoryResponse queryAlgoOrderHistory(QueryAlgoOrderHistoryRequest request) { + String body; + Map params = new HashMap<>(); + try { + // 必填参数校验 + if (StringUtils.isEmpty(request.getType())) { + throw new IllegalArgumentException("type参数为必填项"); + } + params.put("type", request.getType()); + + // 可选参数 + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + if (StringUtils.isNotEmpty(request.getMarginMode())) { + params.put("margin_mode", request.getMarginMode()); + } + + if (request.getStates() != null && !request.getStates().isEmpty()) { + params.put("states", String.join(",", request.getStates())); + } + + if (request.getStartTime() != null) { + params.put("start_time", request.getStartTime()); + } + + if (request.getEndTime() != null) { + params.put("end_time", request.getEndTime()); + } + + if (request.getFrom() != null) { + params.put("from", request.getFrom()); + } + + if (request.getLimit() != null) { + params.put("limit", request.getLimit()); + } + + if (StringUtils.isNotEmpty(request.getDirect())) { + params.put("direct", request.getDirect()); + } + + // 使用GET请求查询 + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiFutureAPIConstants.ALGO_ORDER_HISTORY_QUERY, params); + logger.debug("查询历史策略订单返回body:{}", body); + + QueryAlgoOrderHistoryResponse response = JSON.parseObject(body, QueryAlgoOrderHistoryResponse.class); + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } +} diff --git a/src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIService.java b/src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIService.java new file mode 100644 index 0000000..bf0d883 --- /dev/null +++ b/src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIService.java @@ -0,0 +1,31 @@ +package com.huobi.api.service.usdt.copyTradingTrade; + +import com.huobi.api.request.usdt.copyTradingTrade.*; +import com.huobi.api.response.usdt.copyTradingTrade.*; + +import java.util.List; + +public interface CopyTradingTradeAPIService { + + BaseArrayResult queryTraderInstruments(String instType); + + BaseArrayResult queryTraderStatistics(String instType); + + BaseArrayResult queryTraderProfitSharingHistory(TraderProfitSharingHistoryParam param); + + BaseArrayResult queryTraderProfitSharingHistorySummary(String instType); + + BaseArrayResult queryTraderUnrealizedProfitSharingSummary(TraderUnrealizedProfitSharingSummaryParam param); + + BaseArrayResult queryTraderFollowers(TraderFollowersParam param); + + BaseArrayResult deleteTraderFollower(TraderFollowerDeleteParam param); + + BaseArrayResult traderTransfer(TraderTransferParam param); + + BaseArrayResult traderFollowerSettings(TraderFollowerSettingsParam param); + + BaseArrayResult traderConfig(String instType); + + BaseArrayResult traderApikey(TraderApikeyParam param); +} diff --git a/src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIServiceImpl.java b/src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIServiceImpl.java new file mode 100644 index 0000000..4f3ca36 --- /dev/null +++ b/src/main/java/com/huobi/api/service/usdt/copyTradingTrade/CopyTradingTradeAPIServiceImpl.java @@ -0,0 +1,269 @@ +package com.huobi.api.service.usdt.copyTradingTrade; + +import com.alibaba.fastjson.JSON; +import com.huobi.api.constants.HuobiLinearSwapAPIConstants; +import com.huobi.api.exception.ApiException; +import com.huobi.api.request.usdt.copyTradingTrade.*; +import com.huobi.api.response.usdt.copyTradingTrade.*; +import com.huobi.api.util.HbdmHttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.alibaba.fastjson.TypeReference; + +import java.util.HashMap; +import java.util.Map; + +public class CopyTradingTradeAPIServiceImpl implements CopyTradingTradeAPIService { + + String api_key = ""; // huobi申请的apiKey + String secret_key = ""; // huobi申请的secretKey + String url_prex = "https://api.hbdm.com"; + String successCode = "0"; + + Logger logger = LoggerFactory.getLogger(getClass()); + + public CopyTradingTradeAPIServiceImpl(String api_key, String secret_key) { + this.api_key = api_key; + this.secret_key = secret_key; + } + + + @Override + public BaseArrayResult queryTraderInstruments(String instType) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", instType); + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Instruments, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult queryTraderStatistics(String instType) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", instType); + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Statistics, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult queryTraderProfitSharingHistory(TraderProfitSharingHistoryParam param) { + String body; + try { + Map params = new HashMap<>(); + params.put("instId", param.getInstId()); + params.put("instType", param.getInstType()); + params.put("begin", param.getBegin()); + params.put("end", param.getEnd()); + params.put("after", param.getAfter()); + params.put("before", param.getBefore()); + params.put("limit", param.getLimit()); + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Profit_Sharing_History, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult queryTraderProfitSharingHistorySummary(String instType) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", instType); + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Profit_Sharing_History_Summary, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult queryTraderUnrealizedProfitSharingSummary(TraderUnrealizedProfitSharingSummaryParam param) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", param.getInstType()); + params.put("ccy", param.getCcy()); + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Unrealized_Profit_Sharing_Summary, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult queryTraderFollowers(TraderFollowersParam param) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", param.getInstType()); + params.put("begin", param.getBegin()); + params.put("end", param.getEnd()); + params.put("after", param.getAfter()); + params.put("before", param.getBefore()); + params.put("limit", param.getLimit()); + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Followers, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult deleteTraderFollower(TraderFollowerDeleteParam param) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", param.getInstType()); + params.put("followerUids", param.getFollowerUids()); + + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Follower, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult traderTransfer(TraderTransferParam param) { + String body; + try { + Map params = new HashMap<>(); + params.put("amt", param.getAmt()); + params.put("from", param.getFrom()); + params.put("to", param.getTo()); + params.put("ccy", param.getCcy()); + + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Transfer, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult traderFollowerSettings(TraderFollowerSettingsParam param) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", param.getInstType()); + params.put("enable", param.getEnable() != null ? String.valueOf(param.getEnable()) : null); + params.put("profitSharingRatio", param.getProfitSharingRatio()); + params.put("maxFollowers", param.getMaxFollowers()); + + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Follower_Settings, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult traderConfig(String instType) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", instType); + + body = HbdmHttpClient.getInstance().doGetKey(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Config, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public BaseArrayResult traderApikey(TraderApikeyParam param) { + String body; + try { + Map params = new HashMap<>(); + params.put("instType", param.getInstType()); + + body = HbdmHttpClient.getInstance().doPost(api_key, secret_key, url_prex + HuobiLinearSwapAPIConstants.CopytradingV6_Trader_Apikey, params); + logger.debug("body:{}", body); + BaseArrayResult response = JSON.parseObject(body, new TypeReference>() {}); + if (successCode.equals(response.getCode())) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } +} diff --git a/src/main/java/com/huobi/api/service/usdt/copytrading/CopytradingAPIServiceImpl.java b/src/main/java/com/huobi/api/service/usdt/copytrading/CopytradingAPIServiceImpl.java index 693dde1..32b6096 100644 --- a/src/main/java/com/huobi/api/service/usdt/copytrading/CopytradingAPIServiceImpl.java +++ b/src/main/java/com/huobi/api/service/usdt/copytrading/CopytradingAPIServiceImpl.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.Map; + public class CopytradingAPIServiceImpl implements CopytradingAPIService{ String api_key = ""; // huobi申请的apiKey String secret_key = ""; // huobi申请的secretKey diff --git a/src/main/java/com/huobi/api/service/usdt/market/MarketAPIService.java b/src/main/java/com/huobi/api/service/usdt/market/MarketAPIService.java index 99278e4..e4c6a76 100644 --- a/src/main/java/com/huobi/api/service/usdt/market/MarketAPIService.java +++ b/src/main/java/com/huobi/api/service/usdt/market/MarketAPIService.java @@ -1,6 +1,6 @@ package com.huobi.api.service.usdt.market; -import com.huobi.api.request.usdt.market.MarketRiskLimitRequest; +import com.huobi.api.request.usdt.market.*; import com.huobi.api.request.usdt.account.LinearSwapBasisRequest; import com.huobi.api.request.usdt.account.SwapMarketHistoryKlineRequest; import com.huobi.api.response.usdt.market.*; @@ -35,4 +35,67 @@ public interface MarketAPIService { AssetsDeductionCurrencyResponse assetsDeductionCurrencyResponse(); MarketMultiAssetsMarginListResponse marketMultiAssetsMarginListResponse(); + + /** + * 查询当前资金费率 + * @param request 请求参数 + * @return 资金费率响应 + */ + MarketFundingRateResponse getFundingRate(MarketFundingRateRequest request); + + /** + * 查询历史资金费率 + * @param request 请求参数 + * @return 历史资金费率响应 + */ + MarketFundingRateHistoryResponse getFundingRateHistory(MarketFundingRateHistoryRequest request); + + /** + * 查询当前平台合约持仓总量 + * @param request 请求参数 + * @return 持仓总量响应 + */ + MarketOpenInterestResponse getOpenInterest(MarketOpenInterestRequest request); + + /** + * 查询限价最高买价与最低卖价 + * @param request 请求参数 + * @return 价格限制响应 + */ + MarketPriceLimitResponse getPriceLimit(MarketPriceLimitRequest request); + + /** + * 查询强平订单 + * @param request 请求参数 + * @return 强平订单响应 + */ + MarketLiquidationOrdersResponse getLiquidationOrders(MarketLiquidationOrdersRequest request); + + /** + * 查询平台结算历史 + * @param request 请求参数 + * @return 结算历史响应 + */ + MarketSettlementHistoryResponse getSettlementHistory(MarketSettlementHistoryRequest request); + + /** + * 查询精英账户多空持仓对比-账户数 + * @param request 请求参数 + * @return 精英账户多空持仓对比响应 + */ + MarketEliteAccountRatioResponse getEliteAccountRatio(MarketEliteAccountRatioRequest request); + + /** + * 查询精英账户多空持仓对比-持仓数 + * @param request 请求参数 + * @return 精英账户多空持仓对比响应 + */ + MarketElitePositionRatioResponse getElitePositionRatio(MarketElitePositionRatioRequest request); + + /** + * 查询预估结算价 + * @param request 请求参数 + * @return 预估结算价响应 + */ + MarketEstimatedSettlementPriceResponse getEstimatedSettlementPrice(MarketEstimatedSettlementPriceRequest request); } diff --git a/src/main/java/com/huobi/api/service/usdt/market/MarketAPIServiceImpl.java b/src/main/java/com/huobi/api/service/usdt/market/MarketAPIServiceImpl.java index 6cdc98a..7cb1aee 100644 --- a/src/main/java/com/huobi/api/service/usdt/market/MarketAPIServiceImpl.java +++ b/src/main/java/com/huobi/api/service/usdt/market/MarketAPIServiceImpl.java @@ -4,7 +4,7 @@ import com.huobi.api.constants.HuobiFutureAPIConstants; import com.huobi.api.constants.HuobiLinearSwapAPIConstants; import com.huobi.api.exception.ApiException; -import com.huobi.api.request.usdt.market.MarketRiskLimitRequest; +import com.huobi.api.request.usdt.market.*; import com.huobi.api.request.usdt.account.LinearSwapBasisRequest; import com.huobi.api.request.usdt.account.SwapMarketHistoryKlineRequest; import com.huobi.api.response.usdt.account.SwapAccountInfoResponse; @@ -359,4 +359,303 @@ public MarketMultiAssetsMarginListResponse marketMultiAssetsMarginListResponse() throw new ApiException(body); } + @Override + public MarketFundingRateResponse getFundingRate(MarketFundingRateRequest request) { + String body; + Map params = new HashMap<>(); + try { + params.put("contract_code", request.getContractCode()); + + // 使用GET请求查询(市场数据接口通常不需要鉴权) + body = HbdmHttpClient.getInstance().doGet(url_prex + HuobiFutureAPIConstants.MARKET_FUNDING_RATE, params); + logger.debug("查询资金费率返回body:{}", body); + + MarketFundingRateResponse response = JSON.parseObject(body, MarketFundingRateResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketFundingRateHistoryResponse getFundingRateHistory(MarketFundingRateHistoryRequest request) { + String body; + Map params = new HashMap<>(); + try { + params.put("contract_code", request.getContractCode()); + + // 可选参数 + if (request.getStartTime() != null) { + params.put("start_time", request.getStartTime()); + } + + if (request.getEndTime() != null) { + params.put("end_time", request.getEndTime()); + } + + if (request.getFrom() != null) { + params.put("from", request.getFrom()); + } + + if (request.getLimit() != null) { + params.put("limit", request.getLimit()); + } + + if (StringUtils.isNotEmpty(request.getDirect())) { + params.put("direct", request.getDirect()); + } + + // 使用GET请求查询(市场数据接口通常不需要鉴权) + body = HbdmHttpClient.getInstance().doGet(url_prex + HuobiFutureAPIConstants.MARKET_FUNDING_RATE_HISTORY, params); + logger.debug("查询历史资金费率返回body:{}", body); + + MarketFundingRateHistoryResponse response = JSON.parseObject(body, MarketFundingRateHistoryResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketOpenInterestResponse getOpenInterest(MarketOpenInterestRequest request) { + String body; + Map params = new HashMap<>(); + try { + params.put("contract_code", request.getContractCode()); + + // 使用GET请求查询(市场数据接口通常不需要鉴权) + body = HbdmHttpClient.getInstance().doGet(url_prex + HuobiFutureAPIConstants.MARKET_OPEN_INTEREST, params); + logger.debug("查询持仓总量返回body:{}", body); + + MarketOpenInterestResponse response = JSON.parseObject(body, MarketOpenInterestResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketPriceLimitResponse getPriceLimit(MarketPriceLimitRequest request) { + String body; + Map params = new HashMap<>(); + try { + params.put("contract_code", request.getContractCode()); + + // 使用GET请求查询(市场数据接口通常不需要鉴权) + body = HbdmHttpClient.getInstance().doGet(url_prex + HuobiFutureAPIConstants.MARKET_PRICE_LIMIT, params); + logger.debug("查询价格限制返回body:{}", body); + + MarketPriceLimitResponse response = JSON.parseObject(body, MarketPriceLimitResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketLiquidationOrdersResponse getLiquidationOrders(MarketLiquidationOrdersRequest request) { + String body; + Map params = new HashMap<>(); + try { + // 设置请求参数 + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + if (StringUtils.isNotEmpty(request.getPair())) { + params.put("pair", request.getPair()); + } + if (request.getStartTime() != null) { + params.put("start_time", request.getStartTime()); + } + if (request.getEndTime() != null) { + params.put("end_time", request.getEndTime()); + } + if (StringUtils.isNotEmpty(request.getDirect())) { + params.put("direct", request.getDirect()); + } + if (request.getFrom() != null) { + params.put("from", request.getFrom()); + } + if (request.getLimit() != null) { + params.put("limit", request.getLimit()); + } + + // 发送GET请求,市场数据接口不需要鉴权 + body = HbdmHttpClient.getInstance().doGet( + url_prex + HuobiFutureAPIConstants.MARKET_LIQUIDATION_ORDERS, + params + ); + logger.debug("查询强平订单返回body:{}", body); + + // 解析响应 + MarketLiquidationOrdersResponse response = JSON.parseObject(body, MarketLiquidationOrdersResponse.class); + + // 检查响应码 + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketSettlementHistoryResponse getSettlementHistory(MarketSettlementHistoryRequest request) { + String body; + Map params = new HashMap<>(); + try { + // 设置请求参数 + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + if (request.getStartTime() != null) { + params.put("start_time", request.getStartTime()); + } + if (request.getEndTime() != null) { + params.put("end_time", request.getEndTime()); + } + if (StringUtils.isNotEmpty(request.getDirect())) { + params.put("direct", request.getDirect()); + } + if (StringUtils.isNotEmpty(request.getFrom())) { + params.put("from", request.getFrom()); + } + if (request.getLimit() != null) { + params.put("limit", request.getLimit()); + } + + // 发送GET请求,市场数据接口不需要鉴权 + body = HbdmHttpClient.getInstance().doGet( + url_prex + HuobiFutureAPIConstants.MARKET_SETTLEMENT_HISTORY, + params + ); + logger.debug("查询结算历史返回body:{}", body); + + // 解析响应 + MarketSettlementHistoryResponse response = JSON.parseObject(body, MarketSettlementHistoryResponse.class); + + // 检查响应码 + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketEliteAccountRatioResponse getEliteAccountRatio(MarketEliteAccountRatioRequest request) { + String body; + Map params = new HashMap<>(); + try { + // 设置请求参数 + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + if (StringUtils.isNotEmpty(request.getPeriod())) { + params.put("period", request.getPeriod()); + } + + // 发送GET请求,市场数据接口不需要鉴权 + body = HbdmHttpClient.getInstance().doGet( + url_prex + HuobiFutureAPIConstants.MARKET_ELITE_ACCOUNT_RATIO, + params + ); + logger.debug("查询精英账户多空持仓对比返回body:{}", body); + + // 解析响应 + MarketEliteAccountRatioResponse response = JSON.parseObject(body, MarketEliteAccountRatioResponse.class); + + // 检查响应码 + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketElitePositionRatioResponse getElitePositionRatio(MarketElitePositionRatioRequest request) { + String body; + Map params = new HashMap<>(); + try { + // 设置请求参数 + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + if (StringUtils.isNotEmpty(request.getPeriod())) { + params.put("period", request.getPeriod()); + } + + // 发送GET请求,市场数据接口不需要鉴权 + body = HbdmHttpClient.getInstance().doGet( + url_prex + HuobiFutureAPIConstants.MARKET_ELITE_POSITION_RATIO, + params + ); + logger.debug("查询精英账户多空持仓对比(持仓数)返回body:{}", body); + + // 解析响应 + MarketElitePositionRatioResponse response = JSON.parseObject(body, MarketElitePositionRatioResponse.class); + + // 检查响应码 + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public MarketEstimatedSettlementPriceResponse getEstimatedSettlementPrice(MarketEstimatedSettlementPriceRequest request) { + String body; + Map params = new HashMap<>(); + try { + // 设置请求参数 + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + // 发送GET请求,市场数据接口不需要鉴权 + body = HbdmHttpClient.getInstance().doGet( + url_prex + HuobiFutureAPIConstants.MARKET_ESTIMATED_SETTLEMENT_PRICE, + params + ); + logger.debug("查询预估结算价返回body:{}", body); + + // 解析响应 + MarketEstimatedSettlementPriceResponse response = JSON.parseObject(body, MarketEstimatedSettlementPriceResponse.class); + + // 检查响应码 + if (response.getCode() != null && response.getCode() == 200) { + return response; + } + + } catch (Exception e) { + throw new ApiException(e); + } + throw new ApiException(body); + } + } \ No newline at end of file diff --git a/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIService.java b/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIService.java index aa303b5..7c49ee6 100644 --- a/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIService.java +++ b/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIService.java @@ -37,7 +37,7 @@ public interface TradeAPIService { SwapPositionSideResponse swapPositionSideResponse(SwapPositionSideRequest request); // 16.查询持仓模式 - TradeOrderResponse tradeOrderResponse(TradeOrderRequest request); + TradeOrderResponse tradeOrderResponse(TradeOrderRequest request); //下单 TradeBachOrderResponse tradeBachOrder(TradeBachOrderRequest request); @@ -71,7 +71,11 @@ public interface TradeAPIService { PositionRiskLimitResponse positionRiskLimitResponse(PositionRiskLimitRequest request); - GetTradeOrderResponse getTradeOrderResponse(GetTradeOrderRequest request); + PositionRiskLimitTierResponse positionRiskLimitTierResponse(PositionRiskLimitTierRequest request); + + PositionMarginResponse positionMarginResponse(PositionMarginRequest request); + GetTradeOrderResponse getTradeOrderResponse(GetTradeOrderRequest request); + TradeCancelAfterResponse tradeCancelAfterResponse(TradeCancelAfterRequest request); //下单 } diff --git a/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIServiceImpl.java b/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIServiceImpl.java index 3766481..96bb22f 100644 --- a/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIServiceImpl.java +++ b/src/main/java/com/huobi/api/service/usdt/trade/TradeAPIServiceImpl.java @@ -1134,7 +1134,7 @@ public PositionRiskLimitResponse positionRiskLimitResponse(PositionRiskLimitRequ if (StringUtils.isNotEmpty(request.getPositionSide())) { params.put("position_side", request.getPositionSide()); } - body=HbdmHttpClient.getInstance().doPost(api_key,secret_key,url_prex + HuobiFutureAPIConstants.POSITION_RISKLIMIT,params); + body=HbdmHttpClient.getInstance().doPost(api_key,secret_key,url_prex + HuobiFutureAPIConstants.POSITION_RISK_LIMIT,params); logger.debug("body:{}",body); PositionRiskLimitResponse response=JSON.parseObject(body,PositionRiskLimitResponse.class); if (response.getCode() != null && response.getCode() == 200){ @@ -1146,6 +1146,61 @@ public PositionRiskLimitResponse positionRiskLimitResponse(PositionRiskLimitRequ throw new ApiException(body); } + @Override + public PositionRiskLimitTierResponse positionRiskLimitTierResponse(PositionRiskLimitTierRequest request) { + String body; + try{ + Map params=new HashMap<>(); + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + if (StringUtils.isNotEmpty(request.getMarginMode())) { + params.put("margin_mode", request.getMarginMode()); + } + body=HbdmHttpClient.getInstance().doPost(api_key,secret_key,url_prex + HuobiFutureAPIConstants.POSITION_RISK_LIMIT_TIER,params); + logger.debug("body:{}",body); + PositionRiskLimitTierResponse response=JSON.parseObject(body,PositionRiskLimitTierResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + }catch(Exception e){ + throw new ApiException(e); + } + throw new ApiException(body); + } + + @Override + public PositionMarginResponse positionMarginResponse(PositionMarginRequest request) { + String body; + try{ + Map params = new HashMap<>(); + if (StringUtils.isNotEmpty(request.getContractCode())) { + params.put("contract_code", request.getContractCode()); + } + + if (StringUtils.isNotEmpty(request.getPosition_side())) { + params.put("position_side", request.getPosition_side()); + } + + if (StringUtils.isNotEmpty(request.getAmount())) { + params.put("amount", request.getAmount()); + } + + if (StringUtils.isNotEmpty(request.getType())) { + params.put("type", request.getType()); + } + body=HbdmHttpClient.getInstance().doPost(api_key,secret_key,url_prex + HuobiFutureAPIConstants.POSITION_MARGIN,params); + logger.debug("body:{}",body); + PositionMarginResponse response=JSON.parseObject(body,PositionMarginResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + }catch(Exception e){ + throw new ApiException(e); + } + throw new ApiException(body); + } + @Override public GetTradeOrderResponse getTradeOrderResponse(GetTradeOrderRequest request) { String body; @@ -1174,4 +1229,27 @@ public GetTradeOrderResponse getTradeOrderResponse(GetTradeOrderRequest request) } throw new ApiException(body); } + + @Override + public TradeCancelAfterResponse tradeCancelAfterResponse(TradeCancelAfterRequest request) { + String body; + try{ + Map params=new HashMap<>(); + if (StringUtils.isNotEmpty(request.getOnOff())) { + params.put("on_off", request.getOnOff()); + } + if (StringUtils.isNotEmpty(request.getTimeOut())) { + params.put("time_out", request.getTimeOut()); + } + body=HbdmHttpClient.getInstance().doGetKey(api_key,secret_key,url_prex + HuobiFutureAPIConstants.TRADE_CANCEL_AFTER,params); + logger.debug("body:{}",body); + TradeCancelAfterResponse response=JSON.parseObject(body,TradeCancelAfterResponse.class); + if (response.getCode() != null && response.getCode() == 200){ + return response; + } + }catch(Exception e){ + throw new ApiException(e); + } + throw new ApiException(body); + } } diff --git a/src/main/java/com/huobi/wss/constants/HuobiSwapsWSSConstants.java b/src/main/java/com/huobi/wss/constants/HuobiSwapsWSSConstants.java index 309bb6a..1a6623c 100644 --- a/src/main/java/com/huobi/wss/constants/HuobiSwapsWSSConstants.java +++ b/src/main/java/com/huobi/wss/constants/HuobiSwapsWSSConstants.java @@ -33,6 +33,7 @@ public class HuobiSwapsWSSConstants { public static final String PUBLIC_FUNDING_RATE = "public.$contract_code.funding_rate";// 6.订阅资金费率推送(免鉴权)(sub) public static final String PUBLIC_CONTRACT_INFO = "public.$contract_code.contract_info";// 7.订阅合约信息变动(免鉴权)(sub) public static final String TRIGGER_ORDER_CONTRACT_CODE = "trigger_order.$contract_code";// 8.订阅计划委托订单更新(sub) + public static final String MATCH_ORDERS_CONTRACT_CODE = "match_orders.$contract_code";// 9.订阅撮合后的订单数据 //系统状态更新接口 public static final String PUBLIC_HEARTBEAT = "public.$service.heartbeat";// 1.订阅系统状态更新 diff --git a/src/main/java/com/huobi/wss/constants/HuobiUsdtWSSConstants.java b/src/main/java/com/huobi/wss/constants/HuobiUsdtWSSConstants.java index ccd33a7..119b4bd 100644 --- a/src/main/java/com/huobi/wss/constants/HuobiUsdtWSSConstants.java +++ b/src/main/java/com/huobi/wss/constants/HuobiUsdtWSSConstants.java @@ -37,6 +37,7 @@ public class HuobiUsdtWSSConstants { public static final String TRIGGER_ORDER_CROSS_CONTRACT_CODE = "trigger_order_cross.$contract_code"; // 11.【全仓】订阅计划委托订单更新(sub) public static final String MATCHORDERS_CONTRACT_CODE = "matchOrders.$contract_code"; // 12.【逐仓】订阅合约订单撮合数据(sub) public static final String MATCHORDERS_CROSS_CONTRACT_CODE = "matchOrders_cross.$contract_code"; // 13.【逐仓】订阅合约订单撮合数据(sub) + public static final String MATCH_ORDERS_CONTRACT_CODE = "match_orders.$contract_code";// 14.订阅撮合后的订单数据 //指数与基差数据接口 订阅 public static final String MARKET_INDEX_SUB = "market.$contract_code.index.$period"; // 1.订阅(sub)指数K线数据 @@ -55,4 +56,6 @@ public class HuobiUsdtWSSConstants { //系统状态更新接口 public static final String PUBLIC_HEARTBEAT = "public.$service.heartbeat"; // 1.【通用】订阅系统状态更新 + public static final String ALGO_ORDERS_CONTRACT_CODE = "algo_orders.$contract_code"; //订阅策略订单频道 + public static final String ACCOUNT = "account"; //订阅账户变动数据 } diff --git a/src/main/java/com/huobi/wss/event/AccountSubResponse.java b/src/main/java/com/huobi/wss/event/AccountSubResponse.java new file mode 100644 index 0000000..6017304 --- /dev/null +++ b/src/main/java/com/huobi/wss/event/AccountSubResponse.java @@ -0,0 +1,252 @@ +package com.huobi.wss.event; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +public class AccountSubResponse { + /** + * 操作名称 + * 固定值:notify + */ + @SerializedName("op") + private String op; + + /** + * 推送的主题 + * 固定值:account + */ + @SerializedName("topic") + private String topic; + + /** + * 服务端应答时间戳 + */ + @SerializedName("ts") + private Long ts; + + /** + * 账户变化通知相关事件说明 + * 事件类型: + * snapshot:首推快照 + * create_order: 订单下单 + * cancel_order: 订单撤单 + * delivered:交割 + * transferred:划转 + * filled:成交 + * liquidation:强平 + * adl:ADL自动减仓 + * funding_fee:资金费 + * set_leverage:设置杠杆 + * price_update :价格更新 (api 用户不要) + * auto_exchange:自动兑换 + */ + @SerializedName("event") + private String event; + + /** + * 用户uid + */ + @SerializedName("uid") + private String uid; + + /** + * 账户数据 + */ + @SerializedName("data") + private List data; + + /** + * 账户数据明细 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class AccountData { + + /** + * 账户状态 + * 1(NORMAL): 正常(交易,划转) + * 2(LOCKED): 暂时未用到 + * 3(LIQUIDATING):强平中,不允许交易、划转、收取资金费 + * 4(BANKRUPTCY): 暂时未用到 + * 5(ADL): adl中,不允许交易、收取资金费、划转 + * 6(OPEN_LIMIT): 风控撤单中,合约交易只允许下减仓单,可以转入,不允许转出 + */ + @SerializedName("state") + private String state; + + /** + * 账户权益 + */ + @SerializedName("equity") + private String equity; + + /** + * 初始保证金 + */ + @SerializedName("initial_margin") + private String initialMargin; + + /** + * 维持保证金 + */ + @SerializedName("maintenance_margin") + private String maintenanceMargin; + + /** + * 维持保证金率 + */ + @SerializedName("maintenance_margin_rate") + private String maintenanceMarginRate; + + /** + * 未实现盈亏 + */ + @SerializedName("profit_unreal") + private String profitUnreal; + + /** + * 可用保证金 + */ + @SerializedName("available_margin") + private String availableMargin; + + /** + * 体验金(usdt) + */ + @SerializedName("voucher_value") + private String voucherValue; + + /** + * 账户创建时间 + */ + @SerializedName("created_time") + private String createdTime; + + /** + * 账户更新时间 + */ + @SerializedName("updated_time") + private String updatedTime; + + /** + * 版本号 + */ + @SerializedName("version") + private String version; + + /** + * 币种详情列表 + */ + @SerializedName("details") + private List details; + } + + /** + * 币种详情 + */ + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class CurrencyDetail { + + /** + * 币种 + */ + @SerializedName("currency") + private String currency; + + /** + * 该币种资产权益 + */ + @SerializedName("equity") + private String equity; + + /** + * 该币种逐仓资产权益 + */ + @SerializedName("isolated_equity") + private String isolatedEquity; + + /** + * 该币种可用 + */ + @SerializedName("available") + private String available; + + /** + * 该币种可转 + */ + @SerializedName("withdraw_available") + private String withdrawAvailable; + + /** + * 该币种全仓未实现盈亏 + */ + @SerializedName("profit_unreal") + private String profitUnreal; + + /** + * 该币种逐仓未实现盈亏 + */ + @SerializedName("isolated_profit_unreal") + private String isolatedProfitUnreal; + + /** + * 该币种初始保证金 + */ + @SerializedName("initial_margin") + private String initialMargin; + + /** + * 该币种维持保证金 + */ + @SerializedName("maintenance_margin") + private String maintenanceMargin; + + /** + * 该币种维持保证金率 + */ + @SerializedName("maintenance_margin_rate") + private String maintenanceMarginRate; + + /** + * 该币种初始保证金率 + */ + @SerializedName("initial_margin_rate") + private String initialMarginRate; + + /** + * 体验金 + */ + @SerializedName("voucher") + private String voucher; + + /** + * 体验金(usdt) + */ + @SerializedName("voucher_value") + private String voucherValue; + + /** + * 创建时间 + */ + @SerializedName("created_time") + private String createdTime; + + /** + * 更新时间 + */ + @SerializedName("updated_time") + private String updatedTime; + } +} diff --git a/src/main/java/com/huobi/wss/event/AlgoOrdersSubResponse.java b/src/main/java/com/huobi/wss/event/AlgoOrdersSubResponse.java new file mode 100644 index 0000000..588624b --- /dev/null +++ b/src/main/java/com/huobi/wss/event/AlgoOrdersSubResponse.java @@ -0,0 +1,109 @@ +package com.huobi.wss.event; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class AlgoOrdersSubResponse { + + @SerializedName("id") + private String id; + + @SerializedName("algo_id") + private String algoId; + + @SerializedName("algo_client_order_id") + private String algoClientOrderId; + + @SerializedName("contract_code") + private String contractCode; + + @SerializedName("volume") + private String volume; + + @SerializedName("type") + private String type; + + @SerializedName("state") + private String state; + + @SerializedName("position_side") + private String positionSide; + + @SerializedName("margin_mode") + private String marginMode; + + @SerializedName("side") + private String side; + + @SerializedName("tp_trigger_price") + private String tpTriggerPrice; + + @SerializedName("tp_order_price") + private String tpOrderPrice; + + @SerializedName("tp_type") + private String tpType; + + @SerializedName("tp_trigger_price_type") + private String tpTriggerPriceType; + + @SerializedName("sl_trigger_price") + private String slTriggerPrice; + + @SerializedName("sl_order_price") + private String slOrderPrice; + + @SerializedName("sl_type") + private String slType; + + @SerializedName("sl_trigger_price_type") + private String slTriggerPriceType; + + @SerializedName("price") + private String price; + + @SerializedName("price_match") + private String priceMatch; + + @SerializedName("trigger_price") + private String triggerPrice; + + @SerializedName("trigger_price_type") + private String triggerPriceType; + + @SerializedName("active_price") + private String activePrice; + + @SerializedName("order_price_type") + private String orderPriceType; + + @SerializedName("callback_rate") + private String callbackRate; + + @SerializedName("reduce_only") + private Boolean reduceOnly; + + @SerializedName("actual_volume") + private String actualVolume; + + @SerializedName("actual_price") + private String actualPrice; + + @SerializedName("actual_time") + private String actualTime; + + @SerializedName("relation_order_id") + private String relationOrderId; + + @SerializedName("created_time") + private String createdTime; + + @SerializedName("updated_time") + private String updatedTime; + + @SerializedName("order_source") + private String orderSource; +} diff --git a/src/main/java/com/huobi/wss/event/MatchOrdersResponse.java b/src/main/java/com/huobi/wss/event/MatchOrdersOldResponse.java similarity index 97% rename from src/main/java/com/huobi/wss/event/MatchOrdersResponse.java rename to src/main/java/com/huobi/wss/event/MatchOrdersOldResponse.java index 538d713..633b7da 100644 --- a/src/main/java/com/huobi/wss/event/MatchOrdersResponse.java +++ b/src/main/java/com/huobi/wss/event/MatchOrdersOldResponse.java @@ -10,7 +10,7 @@ @AllArgsConstructor @Data -public class MatchOrdersResponse { +public class MatchOrdersOldResponse { private String op; private String topic; private Long ts; diff --git a/src/main/java/com/huobi/wss/event/MatchOrdersSubOldResponse.java b/src/main/java/com/huobi/wss/event/MatchOrdersSubOldResponse.java new file mode 100644 index 0000000..c50b76c --- /dev/null +++ b/src/main/java/com/huobi/wss/event/MatchOrdersSubOldResponse.java @@ -0,0 +1,71 @@ +package com.huobi.wss.event; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +public class MatchOrdersSubOldResponse { + private String op; + private String topic; + private Long ts; + private String uid; + private String symbol; + @SerializedName("contract_code") + private String contractCode; + private Integer status; + @SerializedName("order_id") + private Long orderId; + @SerializedName("order_id_str") + private String orderIdStr; + @SerializedName("client_order_id") + private Long clientOrderId; + @SerializedName("order_type") + private Integer orderType; + @SerializedName("trade_volume") + private BigDecimal tradeVolume; + private BigDecimal volume; + private String direction; + private String offset; + @SerializedName("lever_rate") + private Integer leverRate; + private BigDecimal price; + @SerializedName("created_at") + private Long createdAt; + @SerializedName("order_source") + private String orderSource; + @SerializedName("order_price_type") + private String orderPriceType; + @SerializedName("margin_account") + private String marginAccount; + @SerializedName("margin_mode") + private String marginMode; + @SerializedName("is_tpsl") + private Integer isTpsl; + @SerializedName("reduce_only") + private Integer reduceOnly; + private List trade; + @Data + @Builder + @AllArgsConstructor + public static class Trade { + private String id; + @SerializedName("trade_id") + private Long tradeId; + @SerializedName("trade_price") + private BigDecimal tradePrice; + @SerializedName("trade_volume") + private BigDecimal tradeVolume; + @SerializedName("trade_turnover") + private BigDecimal tradeTurnover; + @SerializedName("created_at") + private Long createdAt; + private String role; + } +} diff --git a/src/main/java/com/huobi/wss/event/MatchOrdersSubResponse.java b/src/main/java/com/huobi/wss/event/MatchOrdersSubResponse.java index 3e79dc5..70bfe23 100644 --- a/src/main/java/com/huobi/wss/event/MatchOrdersSubResponse.java +++ b/src/main/java/com/huobi/wss/event/MatchOrdersSubResponse.java @@ -4,68 +4,223 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.math.BigDecimal; import java.util.List; +/** + * 合约订单推送响应实体类 + * 对应 topic: match_orders + */ @Data @Builder +@NoArgsConstructor @AllArgsConstructor public class MatchOrdersSubResponse { + + /** + * 操作名称,推送固定值为 notify + */ private String op; + + /** + * 推送的主题 + */ private String topic; + + /** + * 服务端应答时间戳 + */ private Long ts; + + /** + * 用户uid + */ private String uid; - private String symbol; - @SerializedName("contract_code") - private String contractCode; - private Integer status; - @SerializedName("order_id") - private Long orderId; - @SerializedName("order_id_str") - private String orderIdStr; - @SerializedName("client_order_id") - private Long clientOrderId; - @SerializedName("order_type") - private Integer orderType; - @SerializedName("trade_volume") - private BigDecimal tradeVolume; - private BigDecimal volume; - private String direction; - private String offset; - @SerializedName("lever_rate") - private Integer leverRate; - private BigDecimal price; - @SerializedName("created_at") - private Long createdAt; - @SerializedName("order_source") - private String orderSource; - @SerializedName("order_price_type") - private String orderPriceType; - @SerializedName("margin_account") - private String marginAccount; - @SerializedName("margin_mode") - private String marginMode; - @SerializedName("is_tpsl") - private Integer isTpsl; - @SerializedName("reduce_only") - private Integer reduceOnly; - private List trade; + + /** + * 订单数据列表 + */ + private List data; + + /** + * 订单数据实体 + */ @Data @Builder + @NoArgsConstructor @AllArgsConstructor - public static class Trade { + public static class OrderData { + + /** + * 记录ID + */ private String id; + + /** + * 订单ID + */ + @SerializedName("order_id") + private String orderId; + + /** + * 用户自定义订单ID + */ + @SerializedName("client_order_id") + private String clientOrderId; + + /** + * 合约代码 + */ + @SerializedName("contract_code") + private String contractCode; + + /** + * 合约类型 + */ + @SerializedName("contract_type") + private String contractType; + + /** + * 买卖方向 + * buy:买 "sell":卖 + */ + private String side; + + /** + * 仓位方向 + * "long":多 "short":空 "both":单向持仓 + */ + @SerializedName("position_side") + private String positionSide; + + /** + * 订单类型 + * "market": 市价,"limit":限价, "post_only":只挂单 + */ + private String type; + + /** + * 价格匹配 + * 行情当前没有 + */ + @SerializedName("price_match") + private String priceMatch; + + /** + * 成交ID + */ @SerializedName("trade_id") - private Long tradeId; + private String tradeId; + + /** + * 保证金模式 + * 枚举 cross + */ + @SerializedName("margin_mode") + private String marginMode; + + /** + * 委托价格(字符串格式,可转换为BigDecimal) + */ + private String price; + + /** + * 委托数量(字符串格式,可转换为BigDecimal) + */ + private String volume; + + /** + * 废弃参数 + */ + @SerializedName("lever_rate") + private String leverRate; + + /** + * 订单状态 + * new, partially_filled, partially_canceled, filled, canceled + */ + private String state; + + /** + * 订单来源 + * system:系统、web:用户网页、api:用户API、m:用户M站、risk:风控系统、 + * settlement:交割结算、ios:ios客户端、android:安卓客户端、windows:windows客户端、 + * mac:mac客户端、trigger:计划委托触发、tpsl:止盈止损触发、ADL: adl订单 + */ + @SerializedName("order_source") + private String orderSource; + + /** + * 订单时效 + * fok, ioc, gtc,非必填,默认是gtc + */ + @SerializedName("time_in_force") + private String timeInForce; + + /** + * 只减仓 + */ + @SerializedName("reduce_only") + private Boolean reduceOnly; + + /** + * 成交均价(字符串格式,可转换为BigDecimal) + */ @SerializedName("trade_price") - private BigDecimal tradePrice; + private String tradePrice; + + /** + * 成交数量(字符串格式,可转换为BigDecimal) + */ @SerializedName("trade_volume") - private BigDecimal tradeVolume; + private String tradeVolume; + + /** + * 累计成交数量(字符串格式,可转换为BigDecimal) + */ + @SerializedName("total_trade_volume") + private String totalTradeVolume; + + /** + * 成交金额(字符串格式,可转换为BigDecimal) + */ @SerializedName("trade_turnover") - private BigDecimal tradeTurnover; - @SerializedName("created_at") - private Long createdAt; + private String tradeTurnover; + + /** + * 撤单原因 + */ + @SerializedName("cancel_reason") + private String cancelReason; + + /** + * 订单创建时间, UTC时间戳(MS) + */ + @SerializedName("created_time") + private String createdTime; + + /** + * 撮合更新时间, UTC时间戳(MS) + */ + @SerializedName("match_time") + private String matchTime; + + /** + * 防自成交策略 + * allow: 允许自成交 + * cancel_taker: 撤销taker单 + * cancel_maker: 撤销maker单 + * cancel_both: 撤销全部订单 + */ + @SerializedName("self_match_prevent") + private String selfMatchPrevent; + + /** + * 成交角色 + * taker,maker + */ private String role; } -} +} \ No newline at end of file diff --git a/src/main/java/com/huobi/wss/handle/WssNotificationHandle.java b/src/main/java/com/huobi/wss/handle/WssNotificationHandle.java index ff08e86..6e7bb5a 100644 --- a/src/main/java/com/huobi/wss/handle/WssNotificationHandle.java +++ b/src/main/java/com/huobi/wss/handle/WssNotificationHandle.java @@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.huobi.api.enums.OpEnum; import com.huobi.wss.SubscriptionListener; import com.huobi.wss.util.ApiSignature; import com.huobi.wss.util.ZipUtil; @@ -47,18 +48,29 @@ public WssNotificationHandle(String host,String url, String accessKey, String se } public void sub(List channels, SubscriptionListener callback) throws URISyntaxException { - doConnect(channels, callback); + doConnect(OpEnum.SUB, null, channels, null, callback); } + public void sub(List channels, Map extReq, SubscriptionListener callback) throws URISyntaxException { + doConnect(OpEnum.SUB, null, channels, extReq, callback); + } + + public void cidSub(String cid, List channels, SubscriptionListener callback) throws URISyntaxException { + doConnect(OpEnum.SUB, cid, channels, null, callback); + } - private void doConnect(List channels, SubscriptionListener callback) throws URISyntaxException { + public void cidSub(String cid, List channels, Map extReq, SubscriptionListener callback) throws URISyntaxException { + doConnect(OpEnum.SUB, cid, channels, extReq, callback); + } + + private void doConnect(OpEnum opEnum, String cid, List channels, Map extReq, SubscriptionListener callback) throws URISyntaxException { pushUrl="wss://" + host + url; webSocketClient = new WebSocketClient(new URI(pushUrl)) { @Override public void onOpen(ServerHandshake serverHandshake) { addAuth(); - doSub(channels); + doSub(opEnum, cid, channels, extReq); dealReconnect(); } @@ -108,10 +120,16 @@ public void onError(Exception e) { } - private void doSub(List channels) { + private void doSub(OpEnum opEnum, String cid, List channels, Map extReq) { channels.stream().forEach(e -> { JSONObject sub = new JSONObject(); - sub.put("op", "sub"); + sub.put("op", opEnum.getValue()); + if (!StringUtils.isEmpty(cid)) { + sub.put("cid", cid); + } + if (extReq != null && !extReq.isEmpty()) { + sub.putAll(extReq); + } sub.put("topic", e); webSocketClient.send(sub.toString()); }); diff --git a/src/test/java/com/huobi/future/wss/WssNotificationSubTest.java b/src/test/java/com/huobi/future/wss/WssNotificationSubTest.java index 9fdf693..41387ec 100644 --- a/src/test/java/com/huobi/future/wss/WssNotificationSubTest.java +++ b/src/test/java/com/huobi/future/wss/WssNotificationSubTest.java @@ -105,7 +105,7 @@ public void test7() throws URISyntaxException, InterruptedException { wssNotificationHandle.sub(channels, response -> { logger.info("订阅订单撮合数据(sub)用户收到的数据===============:{}", JSON.toJSON(response)); Long currentTimeMillis = System.currentTimeMillis(); - MatchOrdersSubResponse event = JSON.parseObject(response, MatchOrdersSubResponse.class); + MatchOrdersSubOldResponse event = JSON.parseObject(response, MatchOrdersSubOldResponse.class); logger.info("订阅订单撮合数据(sub)的ts为:{},当前的时间戳为:{},时间间隔为:{}毫秒", event.getTs(), currentTimeMillis, currentTimeMillis - event.getTs()); }); Thread.sleep(Integer.MAX_VALUE); diff --git a/src/test/java/com/huobi/swap/wss/WssNotificationSubTest.java b/src/test/java/com/huobi/swap/wss/WssNotificationSubTest.java index bbda878..1009d26 100644 --- a/src/test/java/com/huobi/swap/wss/WssNotificationSubTest.java +++ b/src/test/java/com/huobi/swap/wss/WssNotificationSubTest.java @@ -65,7 +65,7 @@ public void test4() throws URISyntaxException, InterruptedException { wssNotificationHandle.sub(channels, response -> { logger.info("订阅合约订单撮合数据(sub)用户收到的数据===============:{}", JSON.toJSON(response)); Long currentTimeMillis = System.currentTimeMillis(); - MatchOrdersSubResponse event = JSON.parseObject(response, MatchOrdersSubResponse.class); + MatchOrdersSubOldResponse event = JSON.parseObject(response, MatchOrdersSubOldResponse.class); logger.info("订阅合约订单撮合数据(sub)的ts为:{},当前的时间戳为:{},时间间隔为:{}毫秒", event.getTs(), currentTimeMillis, currentTimeMillis - event.getTs()); }); Thread.sleep(Integer.MAX_VALUE); diff --git a/src/test/java/com/huobi/usdt/wss/WssNotificationSubTest.java b/src/test/java/com/huobi/usdt/wss/WssNotificationSubTest.java index 5859621..a9358b0 100644 --- a/src/test/java/com/huobi/usdt/wss/WssNotificationSubTest.java +++ b/src/test/java/com/huobi/usdt/wss/WssNotificationSubTest.java @@ -169,7 +169,7 @@ public void test12() throws URISyntaxException, InterruptedException { wssNotificationHandle.sub(channels, response -> { logger.info("用户收到的数据===============:{}", JSON.toJSON(response)); Long currentTimeMillis = System.currentTimeMillis(); - MatchOrdersSubResponse event = JSON.parseObject(response, MatchOrdersSubResponse.class); + MatchOrdersSubOldResponse event = JSON.parseObject(response, MatchOrdersSubOldResponse.class); logger.info("ts为:{},当前的时间戳为:{},时间间隔为:{}毫秒", event.getTs(), currentTimeMillis, currentTimeMillis - event.getTs()); }); Thread.sleep(Integer.MAX_VALUE); @@ -187,4 +187,17 @@ public void test13() throws URISyntaxException, InterruptedException { }); Thread.sleep(Integer.MAX_VALUE); } + + @Test + public void test14() throws URISyntaxException, InterruptedException { + List channels = Lists.newArrayList(); + channels.add("match_orders.BTC-USDT"); + wssNotificationHandle.sub(channels, response -> { + logger.info("用户收到的数据===============:{}", JSON.toJSON(response)); + Long currentTimeMillis = System.currentTimeMillis(); + MatchOrdersSubResponse event = JSON.parseObject(response, MatchOrdersSubResponse.class); + logger.info("ts为:{},当前的时间戳为:{},时间间隔为:{}毫秒", event.getTs(), currentTimeMillis, currentTimeMillis - event.getTs()); + }); + Thread.sleep(Integer.MAX_VALUE); + } }