From ed62a32b639ea215236c8e49390479190c6d851a Mon Sep 17 00:00:00 2001 From: rizer1980 <4340180@gmail.com> Date: Tue, 16 Apr 2024 15:18:13 +0300 Subject: [PATCH 1/2] [bybit] add demo-api url --- .../org/knowm/xchange/bybit/BybitExchange.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java b/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java index 5adb148d243..11c7dc77425 100644 --- a/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java +++ b/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java @@ -2,6 +2,7 @@ import java.io.IOException; import org.knowm.xchange.BaseExchange; +import org.knowm.xchange.Exchange; import org.knowm.xchange.ExchangeSpecification; import org.knowm.xchange.bybit.dto.BybitCategory; import org.knowm.xchange.bybit.dto.account.walletbalance.BybitAccountType; @@ -17,6 +18,8 @@ public class BybitExchange extends BaseExchange { public static final String SPECIFIC_PARAM_ACCOUNT_TYPE = "accountType"; + private static final String BASE_URL = "https://api.bybit.com"; + private static final String DEMO_URL = "https://api-demo.bybit.com"; @Override protected void initServices() { @@ -33,7 +36,7 @@ protected void initServices() { @Override public ExchangeSpecification getDefaultExchangeSpecification() { ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass()); - exchangeSpecification.setSslUri("https://api.bybit.com"); + exchangeSpecification.setSslUri(BASE_URL); exchangeSpecification.setHost("bybit.com"); exchangeSpecification.setPort(80); exchangeSpecification.setExchangeName("Bybit"); @@ -97,4 +100,14 @@ public void remoteInit() throws IOException, ExchangeException { BybitAdapters.symbolToCurrencyPairMetaData( (BybitOptionInstrumentInfo) instrumentInfo))); } + + @Override + public void applySpecification(ExchangeSpecification exchangeSpecification) { + if (exchangeSpecification + .getExchangeSpecificParametersItem(Exchange.USE_SANDBOX) + .equals(true)) { + exchangeSpecification.setSslUri(DEMO_URL); + } + super.applySpecification(exchangeSpecification); + } } From 9e41a191fad21762f849efb81662953e579746eb Mon Sep 17 00:00:00 2001 From: rizer1980 <4340180@gmail.com> Date: Tue, 16 Apr 2024 18:12:21 +0300 Subject: [PATCH 2/2] [bybit] fix --- .../src/main/java/org/knowm/xchange/bybit/BybitExchange.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java b/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java index 11c7dc77425..c69031864eb 100644 --- a/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java +++ b/xchange-bybit/src/main/java/org/knowm/xchange/bybit/BybitExchange.java @@ -43,6 +43,8 @@ public ExchangeSpecification getDefaultExchangeSpecification() { exchangeSpecification.setExchangeDescription("BYBIT"); exchangeSpecification.setExchangeSpecificParametersItem( SPECIFIC_PARAM_ACCOUNT_TYPE, BybitAccountType.UNIFIED); + exchangeSpecification.setExchangeSpecificParametersItem( + Exchange.USE_SANDBOX, false); return exchangeSpecification; }