-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bitget] Add placing of market orders
- Loading branch information
Showing
18 changed files
with
363 additions
and
30 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
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
20 changes: 20 additions & 0 deletions
20
...t/src/main/java/org/knowm/xchange/bitget/config/converter/OrderTypeToStringConverter.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,20 @@ | ||
package org.knowm.xchange.bitget.config.converter; | ||
|
||
import com.fasterxml.jackson.databind.util.StdConverter; | ||
import org.knowm.xchange.dto.Order.OrderType; | ||
|
||
/** Converts {@code OrderType} to string */ | ||
public class OrderTypeToStringConverter extends StdConverter<OrderType, String> { | ||
|
||
@Override | ||
public String convert(OrderType value) { | ||
switch (value) { | ||
case BID: | ||
return "buy"; | ||
case ASK: | ||
return "sell"; | ||
default: | ||
throw new IllegalArgumentException("Can't map " + value); | ||
} | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
xchange-bitget/src/main/java/org/knowm/xchange/bitget/dto/trade/BitgetPlaceOrderDto.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,111 @@ | ||
package org.knowm.xchange.bitget.dto.trade; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import java.math.BigDecimal; | ||
import java.time.Instant; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.extern.jackson.Jacksonized; | ||
import org.knowm.xchange.bitget.config.converter.OrderTypeToStringConverter; | ||
import org.knowm.xchange.bitget.config.converter.StringToOrderTypeConverter; | ||
import org.knowm.xchange.bitget.dto.trade.BitgetOrderInfoDto.OrderType; | ||
import org.knowm.xchange.dto.Order; | ||
|
||
@Data | ||
@Builder | ||
@Jacksonized | ||
public class BitgetPlaceOrderDto { | ||
|
||
@JsonProperty("symbol") | ||
private String symbol; | ||
|
||
@JsonProperty("side") | ||
@JsonDeserialize(converter = StringToOrderTypeConverter.class) | ||
@JsonSerialize(converter = OrderTypeToStringConverter.class) | ||
private Order.OrderType orderSide; | ||
|
||
@JsonProperty("orderType") | ||
private OrderType orderType; | ||
|
||
@JsonProperty("force") | ||
private TimeInForce timeInForce; | ||
|
||
@JsonProperty("price") | ||
private BigDecimal price; | ||
|
||
@JsonProperty("size") | ||
private BigDecimal size; | ||
|
||
@JsonProperty("clientOid") | ||
private String clientOid; | ||
|
||
@JsonProperty("triggerPrice") | ||
private BigDecimal triggerPrice; | ||
|
||
@JsonProperty("tpslType") | ||
private TpSlType tpSlType; | ||
|
||
@JsonProperty("requestTime") | ||
private Instant requestTime; | ||
|
||
@JsonProperty("receiveWindow") | ||
private Instant receiveWindow; | ||
|
||
@JsonProperty("stpMode") | ||
private StpMode stpMode; | ||
|
||
@JsonProperty("presetTakeProfitPrice") | ||
private BigDecimal presetTakeProfitPrice; | ||
|
||
@JsonProperty("executeTakeProfitPrice") | ||
private BigDecimal executeTakeProfitPrice; | ||
|
||
@JsonProperty("presetStopLossPrice") | ||
private BigDecimal presetStopLossPrice; | ||
|
||
@JsonProperty("executeStopLossPrice") | ||
private BigDecimal executeStopLossPrice; | ||
|
||
|
||
public enum TimeInForce { | ||
@JsonProperty("gtc") | ||
GOOD_TIL_CANCELLED, | ||
|
||
@JsonProperty("post_only") | ||
POST_ONLY, | ||
|
||
@JsonProperty("fok") | ||
FILL_OR_KILL, | ||
|
||
@JsonProperty("ioc") | ||
IMMEDIATE_OR_CANCEL | ||
} | ||
|
||
|
||
public enum TpSlType { | ||
@JsonProperty("normal") | ||
NORMAL, | ||
|
||
@JsonProperty("tpsl") | ||
SPOT_TP_SL | ||
} | ||
|
||
|
||
public enum StpMode { | ||
@JsonProperty("none") | ||
NONE, | ||
|
||
@JsonProperty("cancel_taker") | ||
CANCEL_TAKER, | ||
|
||
@JsonProperty("cancel_maker") | ||
CANCEL_MAKER, | ||
|
||
@JsonProperty("cancel_both") | ||
CANCEL_BOTH | ||
} | ||
|
||
|
||
} |
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.