Skip to content

Commit

Permalink
* Added mark_price_kline interface
Browse files Browse the repository at this point in the history
  • Loading branch information
fuwei6056 committed Mar 12, 2021
1 parent 21d4c95 commit 497fd65
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 0 deletions.
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class HuobiFutureAPIConstants {
public static final String CONTRACT_ESTIMATED_SETTLEMENT_PRICE = "/api/v1/contract_estimated_settlement_price"; // 22.获取预估结算价
public static final String BATCH_MERGED = "/market/detail/batch_merged"; // 23.批量获取聚合行情
public static final String CONTRACT_LADDER_MARGIN = "/api/v1/contract_ladder_margin"; // 24.获取平台阶梯保证金
public static final String MARK_PRICE_KLINE = "/index/market/history/mark_price_kline"; // 25.获取标记价格的K线数据

//合约资产接口
public static final String CONTRACT_ACCOUNT_INFO = "/api/v1/contract_account_info"; // 1.获取用户账户信息
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.huobi.api.response.market;


import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Builder
@Data
@AllArgsConstructor
public class MarkPriceKlineResponse {
private String status;
private Long ts;
private String ch;
private List<DataBean> data;

@Builder
@Data
@AllArgsConstructor
public static class DataBean{
private Long id;
private String vol;
private String count;
private String open;
private String close;
private String low;
private String high;
private String amount;
@SerializedName("trade_turnover")
private String tradeTurnover;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ public interface MarketAPIService {
MarketBatchMergedResponse getMarketBatchMerged(String symbol);

ContractLadderMarginResponse getContractLadderMargin(String symbol);

MarkPriceKlineResponse getMarkPriceKline(String symbol,String period,Integer size);
}
Original file line number Diff line number Diff line change
Expand Up @@ -588,4 +588,25 @@ public ContractLadderMarginResponse getContractLadderMargin(String symbol) {
}
throw new ApiException(body);
}

@Override
public MarkPriceKlineResponse getMarkPriceKline(String symbol, String period, Integer size) {
String body;
try {
Map<String, Object> params = new HashMap<>();
params.put("symbol",symbol.toUpperCase());
params.put("period",period);
params.put("size",size);
body = HbdmHttpClient.getInstance().doGet(url_prex + HuobiFutureAPIConstants.MARK_PRICE_KLINE, params);
logger.debug("body:{}",body);
MarkPriceKlineResponse response = JSON.parseObject(body, MarkPriceKlineResponse.class);
if ("ok".equalsIgnoreCase(response.getStatus())) {
return response;
}

} catch (Exception e) {
body = e.getMessage();
}
throw new ApiException(body);
}
}
5 changes: 5 additions & 0 deletions src/test/java/com/huobi/future/api/MarketAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,9 @@ public void getContractLadderMargin(){
logger.debug("24.获取平台阶梯保证金: {}",JSON.toJSONString(response));
}

@Test
public void getMarkPriceKline(){
MarkPriceKlineResponse response=huobiAPIService.getMarkPriceKline("btc_cq","5min",10);
logger.debug("25.获取标记价格的K线数据: {}",JSON.toJSONString(response));
}
}

0 comments on commit 497fd65

Please sign in to comment.