forked from knowm/XChange
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request knowm#814 from jheusser/bitvc_huobi_support
Support Huobi trading in BitVc adapter
- Loading branch information
Showing
13 changed files
with
338 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
xchange-bitvc/src/main/java/com/xeiam/xchange/bitvc/Huobi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.xeiam.xchange.bitvc; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.ws.rs.FormParam; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import com.xeiam.xchange.bitvc.dto.account.HuobiAccountInfo; | ||
import com.xeiam.xchange.bitvc.dto.trade.BitVcCancelOrderResult; | ||
import com.xeiam.xchange.bitvc.dto.trade.BitVcOrder; | ||
import com.xeiam.xchange.bitvc.dto.trade.BitVcPlaceOrderResult; | ||
|
||
import si.mazi.rescu.ParamsDigest; | ||
|
||
|
||
@Path("") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public interface Huobi { | ||
|
||
@POST | ||
public HuobiAccountInfo getAccountInfo(@FormParam("access_key") String accessKey, @FormParam("created") long created, @FormParam("method") String method, @FormParam("sign") ParamsDigest sign) throws IOException; | ||
|
||
@POST | ||
public BitVcOrder[] getOrders(@FormParam("access_key") String accessKey, @FormParam("coin_type") int coinType, @FormParam("created") long created, @FormParam("method") String method, @FormParam("sign") ParamsDigest sign) | ||
throws IOException; | ||
|
||
@POST | ||
public BitVcPlaceOrderResult placeLimitOrder(@FormParam("access_key") String accessKey, @FormParam("amount") String amount, @FormParam("coin_type") int coinType, @FormParam("created") long created, | ||
@FormParam("price") String price, @FormParam("method") String method, @FormParam("sign") ParamsDigest sign) throws IOException; | ||
|
||
@POST | ||
public BitVcPlaceOrderResult placeMarketOrder(@FormParam("access_key") String accessKey, @FormParam("amount") String amount, @FormParam("coin_type") int coinType, | ||
@FormParam("created") long created, @FormParam("method") String method, @FormParam("sign") ParamsDigest sign) throws IOException; | ||
|
||
@POST | ||
public BitVcCancelOrderResult cancelOrder(@FormParam("access_key") String accessKey, @FormParam("coin_type") int coinType, @FormParam("created") long created, @FormParam("id") long id, | ||
@FormParam("method") String method, @FormParam("sign") ParamsDigest sign) throws IOException; | ||
} |
87 changes: 87 additions & 0 deletions
87
xchange-bitvc/src/main/java/com/xeiam/xchange/bitvc/dto/account/HuobiAccountInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.xeiam.xchange.bitvc.dto.account; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class HuobiAccountInfo { | ||
|
||
private final BigDecimal availableCny; | ||
private final BigDecimal availableBtc; | ||
private final BigDecimal availableLtc; | ||
private final BigDecimal frozenCny; | ||
private final BigDecimal frozenBtc; | ||
private final BigDecimal frozenLtc; | ||
private final BigDecimal loanCny; | ||
private final BigDecimal loanBtc; | ||
private final BigDecimal loanLtc; | ||
|
||
private final String message; | ||
|
||
public HuobiAccountInfo(@JsonProperty("available_cny_display") final BigDecimal availableCnyDisplay, @JsonProperty("available_btc_display") final BigDecimal availableBtcDisplay, | ||
@JsonProperty("available_ltc_display") final BigDecimal availableLtcDisplay, @JsonProperty("frozen_cny_display") final BigDecimal frozenCnyDisplay, | ||
@JsonProperty("frozen_btc_display") final BigDecimal frozenBtcDisplay, @JsonProperty("frozen_ltc_display") final BigDecimal frozenLtcDisplay, @JsonProperty("loan_cny_display") final BigDecimal loanCnyDisplay, | ||
@JsonProperty("loan_btc_display") final BigDecimal loanBtcDisplay, @JsonProperty("loan_ltc_display") final BigDecimal loanLtcDisplay, @JsonProperty("message") String message) { | ||
|
||
this.availableCny = availableCnyDisplay; | ||
this.availableBtc = availableBtcDisplay; | ||
this.availableLtc = availableLtcDisplay; | ||
this.frozenCny = frozenCnyDisplay; | ||
this.frozenBtc = frozenBtcDisplay; | ||
this.frozenLtc = frozenLtcDisplay; | ||
this.loanCny = loanCnyDisplay; | ||
this.loanBtc = loanBtcDisplay; | ||
this.loanLtc = loanLtcDisplay; | ||
|
||
this.message = message; | ||
} | ||
|
||
public BigDecimal getAvailableCnyDisplay() { | ||
|
||
return availableCny == null ? BigDecimal.ZERO : availableCny; | ||
} | ||
|
||
public BigDecimal getAvailableBtcDisplay() { | ||
|
||
return availableBtc == null ? BigDecimal.ZERO : availableBtc; | ||
} | ||
|
||
public BigDecimal getAvailableLtcDisplay() { | ||
|
||
return availableLtc == null ? BigDecimal.ZERO : availableLtc; | ||
} | ||
|
||
public BigDecimal getFrozenCnyDisplay() { | ||
|
||
return frozenCny == null ? BigDecimal.ZERO : frozenCny; | ||
} | ||
|
||
public BigDecimal getFrozenBtcDisplay() { | ||
|
||
return frozenBtc == null ? BigDecimal.ZERO : frozenBtc; | ||
} | ||
|
||
public BigDecimal getFrozenLtcDisplay() { | ||
|
||
return frozenLtc == null ? BigDecimal.ZERO : frozenLtc; | ||
} | ||
|
||
public BigDecimal getLoanCnyDisplay() { | ||
|
||
return loanCny == null ? BigDecimal.ZERO : loanCny; | ||
} | ||
|
||
public BigDecimal getLoanBtcDisplay() { | ||
|
||
return loanBtc == null ? BigDecimal.ZERO : loanBtc; | ||
} | ||
|
||
public BigDecimal getLoanLtcDisplay() { | ||
|
||
return loanLtc == null ? BigDecimal.ZERO : loanLtc; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.