4

i wrote a small script to download ohlcv data from binance or bybit with ccxt. I want to get candle data from the testnet as well as the main net. I looked at ccxt code and there are urls for both nets, yet i do not know how to set the option.

I guess there has to be something like. bybitt = ccxt.binance({ 'option': { 'defaultMarket': 'future' }})

Does anyone know?

stdout
  • 79
  • 1
  • 6

1 Answers1

16

With CCXT you can switch to the sandbox/testnet if the underlying exchange has it, using the .set_sandbox_mode method like so:

import ccxt
exchange = ccxt.binance({'enableRateLimit': True})
exchange.set_sandbox_mode(True)
Igor Kroitor
  • 1,548
  • 13
  • 16
  • I can read my balances using ccxt and my API keys, now I set sandbox_mode and it's not working anymore – DenCowboy Sep 14 '20 at 20:17
  • @DenCowboy paste your version numbers, your code and most importantly your verbose output as explained here: https://github.com/ccxt/ccxt/wiki/FAQ#what-is-required-to-get-help – Igor Kroitor Sep 15 '20 at 10:53
  • 2
    Make sure you don't confuse the testnet API keys with the exchange's production API keys. – Igor Kroitor Oct 27 '20 at 16:25
  • 1
    @DenCowboy because you need to use different API keys for sandbox and normal mode – Devid Mercer Oct 20 '22 at 15:50