/** Extract futures leverage used by spec */ private static int futuresLeverageOfConfig(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters().containsKey("Futures_Leverage")) { return Integer.valueOf( (String) exchangeSpecification.getExchangeSpecificParameters().get("Futures_Leverage")); } else { // default choice of 10x leverage is "safe" choice and default by OkCoin. return 10; } }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) { exchangeSpecification.setSslUri("https://sandbox.trade.dvchain.co"); exchangeSpecification.setHost("sandbox.trade.dvchain.co"); } } }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) { exchangeSpecification.setSslUri("https://testnet.bitmex.com/"); exchangeSpecification.setHost("testnet.bitmex.com"); } } }
/** Extract contract used by spec */ public static FuturesContract futuresContractOfConfig( ExchangeSpecification exchangeSpecification) { FuturesContract contract; if (exchangeSpecification.getExchangeSpecificParameters().containsKey("Futures_Contract")) { contract = (FuturesContract) exchangeSpecification.getExchangeSpecificParameters().get("Futures_Contract"); } else if (exchangeSpecification .getExchangeSpecificParameters() .containsKey("Futures_Contract_String")) { contract = FuturesContract.valueOfIgnoreCase( FuturesContract.class, (String) exchangeSpecification .getExchangeSpecificParameters() .get("Futures_Contract_String")); } else { throw new RuntimeException( "`Futures_Contract` or `Futures_Contract_String` not defined in exchange specific parameters."); } return contract; }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) { exchangeSpecification.setSslUri("https://api.sandbox.gemini.com"); exchangeSpecification.setHost("api.sandbox.gemini.com"); } } }
/** * Constructor * * @param exchange */ public OkCoinBaseService(Exchange exchange) { super(exchange); useIntl = (Boolean) exchange.getExchangeSpecification().getExchangeSpecificParameters().get("Use_Intl"); }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Intl").equals(true) && exchangeSpecification.getExchangeSpecificParametersItem("Use_Futures").equals(false)) { exchangeSpecification.setSslUri("https://www.okex.com/api"); exchangeSpecification.setHost("www.okex.com"); } else if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Intl").equals(true) && exchangeSpecification.getExchangeSpecificParametersItem("Use_Futures").equals(true)) { exchangeSpecification.setSslUri("https://www.okex.com/api"); exchangeSpecification.setHost("www.okex.com"); } } }
/** Not available from exchange since TheRock needs currency pair in order to cancel an order */ @Override public boolean cancelOrder(String orderId) throws IOException { CurrencyPair cp = (CurrencyPair) exchange .getExchangeSpecification() .getExchangeSpecificParameters() .get(TheRockExchange.CURRENCY_PAIR); if (cp == null) { throw new ExchangeException("Provide TheRockCancelOrderParams with orderId and currencyPair"); } return cancelOrder(cp, orderId); }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) { exchangeSpecification.setSslUri("https://api-public.sandbox.pro.coinbase.com"); exchangeSpecification.setHost("api-public.sandbox.pro.coinbase.com"); } } }
/** Extract futures leverage used by spec */ private static int futuresLeverageOfConfig(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters().containsKey("Futures_Leverage")) { return Integer.valueOf( (String) exchangeSpecification.getExchangeSpecificParameters().get("Futures_Leverage")); } else { // default choice of 10x leverage is "safe" choice and default by OkCoin. return 10; } }
@Override protected void initServices() { concludeHostParams(exchangeSpecification); if (exchangeSpecification.getExchangeSpecificParameters() != null && exchangeSpecification.getExchangeSpecificParametersItem("Use_Futures").equals(true)) { FuturesContract contract = futuresContractOfConfig(exchangeSpecification); this.marketDataService = new OkCoinFuturesMarketDataService(this, contract); if (exchangeSpecification.getApiKey() != null) { this.accountService = new OkCoinFuturesAccountService(this); this.tradeService = new OkCoinFuturesTradeService( this, contract, futuresLeverageOfConfig(exchangeSpecification)); } } else { this.marketDataService = new OkCoinMarketDataService(this); if (exchangeSpecification.getApiKey() != null) { this.accountService = new OkCoinAccountService(this); this.tradeService = new OkCoinTradeService(this); } } }
/** * Constructor * * @param exchange */ public OkCoinBaseService(Exchange exchange) { super(exchange); useIntl = (Boolean) exchange.getExchangeSpecification().getExchangeSpecificParameters().get("Use_Intl"); }
exchangeSpecification.setPlainTextUri(defaultSpecification.getPlainTextUri()); if (exchangeSpecification.getExchangeSpecificParameters() == null) { exchangeSpecification.setExchangeSpecificParameters( defaultSpecification.getExchangeSpecificParameters()); } else { defaultSpecification.getExchangeSpecificParameters().entrySet()) { if (exchangeSpecification.getExchangeSpecificParametersItem(entry.getKey()) == null) { exchangeSpecification.setExchangeSpecificParametersItem(
/** Extract contract used by spec */ public static FuturesContract futuresContractOfConfig( ExchangeSpecification exchangeSpecification) { FuturesContract contract; if (exchangeSpecification.getExchangeSpecificParameters().containsKey("Futures_Contract")) { contract = (FuturesContract) exchangeSpecification.getExchangeSpecificParameters().get("Futures_Contract"); } else if (exchangeSpecification .getExchangeSpecificParameters() .containsKey("Futures_Contract_String")) { contract = FuturesContract.valueOfIgnoreCase( FuturesContract.class, (String) exchangeSpecification .getExchangeSpecificParameters() .get("Futures_Contract_String")); } else { throw new RuntimeException( "`Futures_Contract` or `Futures_Contract_String` not defined in exchange specific parameters."); } return contract; }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) { exchangeSpecification.setSslUri("https://api-public.sandbox.gdax.com"); exchangeSpecification.setHost("api-public.sandbox.gdax.com"); } } }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Intl").equals(true) && exchangeSpecification.getExchangeSpecificParametersItem("Use_Futures").equals(false)) { exchangeSpecification.setSslUri("https://www.okex.com/api"); exchangeSpecification.setHost("www.okex.com"); } else if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Intl").equals(true) && exchangeSpecification.getExchangeSpecificParametersItem("Use_Futures").equals(true)) { exchangeSpecification.setSslUri("https://www.okex.com/api"); exchangeSpecification.setHost("www.okex.com"); } } }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) { exchangeSpecification.setSslUri("https://testnet.bitmex.com/"); exchangeSpecification.setHost("testnet.bitmex.com"); } } }
/** Adjust host parameters depending on exchange specific parameters */ private static void concludeHostParams(ExchangeSpecification exchangeSpecification) { if (exchangeSpecification.getExchangeSpecificParameters() != null) { if (exchangeSpecification.getExchangeSpecificParametersItem("Use_Sandbox").equals(true)) { exchangeSpecification.setSslUri("https://api.sandbox.gemini.com"); exchangeSpecification.setHost("api.sandbox.gemini.com"); } } }
@Override protected void initServices() { concludeHostParams(exchangeSpecification); if (exchangeSpecification.getExchangeSpecificParameters() != null && exchangeSpecification.getExchangeSpecificParametersItem("Use_Futures").equals(true)) { FuturesContract contract = futuresContractOfConfig(exchangeSpecification); this.marketDataService = new OkCoinFuturesMarketDataService(this, contract); if (exchangeSpecification.getApiKey() != null) { this.accountService = new OkCoinFuturesAccountService(this); this.tradeService = new OkCoinFuturesTradeService( this, contract, futuresLeverageOfConfig(exchangeSpecification)); } } else { this.marketDataService = new OkCoinMarketDataService(this); if (exchangeSpecification.getApiKey() != null) { this.accountService = new OkCoinAccountService(this); this.tradeService = new OkCoinTradeService(this); } } }
exchangeSpecification.setPlainTextUri(defaultSpecification.getPlainTextUri()); if (exchangeSpecification.getExchangeSpecificParameters() == null) { exchangeSpecification.setExchangeSpecificParameters( defaultSpecification.getExchangeSpecificParameters()); } else { defaultSpecification.getExchangeSpecificParameters().entrySet()) { if (exchangeSpecification.getExchangeSpecificParametersItem(entry.getKey()) == null) { exchangeSpecification.setExchangeSpecificParametersItem(