Skip to content

Commit

Permalink
Merge pull request #4836 from rizer1980/PR/bybit-add-testnet
Browse files Browse the repository at this point in the history
[bybit] add demo-api url
  • Loading branch information
timmolter authored Apr 17, 2024
2 parents 6c01aab + 9e41a19 commit e6df06a
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -33,13 +36,15 @@ 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");
exchangeSpecification.setExchangeDescription("BYBIT");
exchangeSpecification.setExchangeSpecificParametersItem(
SPECIFIC_PARAM_ACCOUNT_TYPE, BybitAccountType.UNIFIED);
exchangeSpecification.setExchangeSpecificParametersItem(
Exchange.USE_SANDBOX, false);
return exchangeSpecification;
}

Expand Down Expand Up @@ -97,4 +102,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);
}
}

0 comments on commit e6df06a

Please sign in to comment.