|
3 | 3 | import static org.knowm.xchange.bybit.dto.BybitCategory.INVERSE;
|
4 | 4 | import static org.knowm.xchange.bybit.dto.BybitCategory.OPTION;
|
5 | 5 | import static org.knowm.xchange.bybit.dto.marketdata.instruments.option.BybitOptionInstrumentInfo.OptionType.CALL;
|
6 |
| -import static org.knowm.xchange.bybit.dto.marketdata.instruments.option.BybitOptionInstrumentInfo.OptionType.PUT; |
7 | 6 |
|
8 | 7 | import java.math.BigDecimal;
|
9 |
| -import java.text.DateFormat; |
10 | 8 | import java.text.ParseException;
|
11 | 9 | import java.text.SimpleDateFormat;
|
12 | 10 | import java.time.LocalDate;
|
13 | 11 | import java.time.format.DateTimeFormatter;
|
14 | 12 | import java.time.format.DateTimeFormatterBuilder;
|
15 |
| -import java.time.temporal.TemporalAccessor; |
16 | 13 | import java.util.ArrayList;
|
17 | 14 | import java.util.Arrays;
|
18 | 15 | import java.util.Date;
|
|
26 | 23 | import org.knowm.xchange.bybit.dto.marketdata.instruments.BybitInstrumentInfo;
|
27 | 24 | import org.knowm.xchange.bybit.dto.marketdata.instruments.linear.BybitLinearInverseInstrumentInfo;
|
28 | 25 | import org.knowm.xchange.bybit.dto.marketdata.instruments.option.BybitOptionInstrumentInfo;
|
29 |
| -import org.knowm.xchange.bybit.dto.marketdata.instruments.option.BybitOptionInstrumentInfo.OptionType; |
30 | 26 | import org.knowm.xchange.bybit.dto.marketdata.instruments.spot.BybitSpotInstrumentInfo;
|
31 | 27 | import org.knowm.xchange.bybit.dto.marketdata.tickers.BybitTicker;
|
32 | 28 | import org.knowm.xchange.bybit.dto.marketdata.tickers.linear.BybitLinearInverseTicker;
|
@@ -65,11 +61,12 @@ public class BybitAdapters {
|
65 | 61 | public static Wallet adaptBybitBalances(List<BybitCoinWalletBalance> coinWalletBalances) {
|
66 | 62 | List<Balance> balances = new ArrayList<>(coinWalletBalances.size());
|
67 | 63 | for (BybitCoinWalletBalance bybitCoinBalance : coinWalletBalances) {
|
| 64 | + BigDecimal availableToWithdraw = bybitCoinBalance.getAvailableToWithdraw().isEmpty() ? BigDecimal.ZERO : new BigDecimal(bybitCoinBalance.getAvailableToWithdraw()); |
68 | 65 | balances.add(
|
69 | 66 | new Balance(
|
70 | 67 | new Currency(bybitCoinBalance.getCoin()),
|
71 | 68 | new BigDecimal(bybitCoinBalance.getEquity()),
|
72 |
| - new BigDecimal(bybitCoinBalance.getAvailableToWithdraw()))); |
| 69 | + availableToWithdraw)); |
73 | 70 | }
|
74 | 71 | return Wallet.Builder.from(balances).build();
|
75 | 72 | }
|
@@ -242,19 +239,19 @@ public static InstrumentMetaData symbolToCurrencyPairMetaData(
|
242 | 239 | .build();
|
243 | 240 | }
|
244 | 241 |
|
245 |
| - public static Order adaptBybitOrderDetails(BybitOrderDetail bybitOrderResult) { |
| 242 | + public static Order adaptBybitOrderDetails(BybitOrderDetail bybitOrderResult, BybitCategory category) { |
246 | 243 | Order.Builder builder;
|
247 | 244 |
|
248 | 245 | switch (bybitOrderResult.getOrderType()) {
|
249 | 246 | case MARKET:
|
250 | 247 | builder =
|
251 | 248 | new MarketOrder.Builder(
|
252 |
| - adaptOrderType(bybitOrderResult), guessSymbol(bybitOrderResult.getSymbol())); |
| 249 | + adaptOrderType(bybitOrderResult), convertBybitSymbolToInstrument(bybitOrderResult.getSymbol(),category)); |
253 | 250 | break;
|
254 | 251 | case LIMIT:
|
255 | 252 | builder =
|
256 | 253 | new LimitOrder.Builder(
|
257 |
| - adaptOrderType(bybitOrderResult), guessSymbol(bybitOrderResult.getSymbol())) |
| 254 | + adaptOrderType(bybitOrderResult), convertBybitSymbolToInstrument(bybitOrderResult.getSymbol(),category)) |
258 | 255 | .limitPrice(bybitOrderResult.getPrice());
|
259 | 256 | break;
|
260 | 257 | default:
|
|
0 commit comments