2018-07-27 20:18:12 +00:00
# Sandbox API testing
2018-08-07 07:25:21 +00:00
2020-08-23 19:12:08 +00:00
Some exchanges provide sandboxes or testbeds for risk-free testing, while running the bot against a real exchange.
With some configuration, freqtrade (in combination with ccxt) provides access to these.
2018-07-27 20:18:12 +00:00
2020-08-23 19:16:44 +00:00
This document is an overview to configure Freqtrade to be used with sandboxes.
2020-08-23 19:12:08 +00:00
This can be useful to developers and trader alike.
2018-07-27 20:18:12 +00:00
2021-03-01 18:12:02 +00:00
!!! Warning
Sandboxes usually have very low volume, and either a very wide spread, or no orders available at all.
Therefore, sandboxes will usually not do a good job of showing you how a strategy would work in real trading.
2020-08-23 19:12:08 +00:00
## Exchanges known to have a sandbox / testnet
2018-08-07 07:25:21 +00:00
2020-08-23 19:12:08 +00:00
* [binance ](https://testnet.binance.vision/ )
* [coinbasepro ](https://public.sandbox.pro.coinbase.com )
* [gemini ](https://exchange.sandbox.gemini.com/ )
* [huobipro ](https://www.testnet.huobi.pro/ )
* [kucoin ](https://sandbox.kucoin.com/ )
* [phemex ](https://testnet.phemex.com/ )
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
!!! Note
We did not test correct functioning of all of the above testnets. Please report your experiences with each sandbox.
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
---
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
## Configure a Sandbox account
2018-07-29 09:12:05 +00:00
2020-08-23 19:16:44 +00:00
When testing your API connectivity, make sure to use the appropriate sandbox / testnet URL.
2018-07-29 09:12:05 +00:00
2020-08-23 19:12:08 +00:00
In general, you should follow these steps to enable an exchange's sandbox:
2018-07-27 20:18:12 +00:00
2020-08-23 19:16:44 +00:00
* Figure out if an exchange has a sandbox (most likely by using google or the exchange's support documents)
* Create a sandbox account (often the sandbox-account requires separate registration)
* [Add some test assets to account ](#add-test-funds )
* Create API keys
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
### Add test funds
2018-08-07 07:25:21 +00:00
2020-08-23 19:12:08 +00:00
Usually, sandbox exchanges allow depositing funds directly via web-interface.
You should make sure to have a realistic amount of funds available to your test-account, so results are representable of your real account funds.
2018-08-07 07:25:21 +00:00
2020-08-23 19:12:08 +00:00
!!! Warning
2020-08-23 19:16:44 +00:00
Test exchanges will **NEVER** require your real credit card or banking details!
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
## Configure freqtrade to use a exchange's sandbox
2018-08-07 07:25:21 +00:00
2020-08-23 19:12:08 +00:00
### Sandbox URLs
2018-08-07 07:25:21 +00:00
Freqtrade makes use of CCXT which in turn provides a list of URLs to Freqtrade.
These include `['test']` and `['api']` .
2020-08-23 19:16:44 +00:00
* `[Test]` if available will point to an Exchanges sandbox.
* `[Api]` normally used, and resolves to live API target on the exchange.
2018-07-27 20:18:12 +00:00
To make use of sandbox / test add "sandbox": true, to your config.json
2018-08-07 07:25:21 +00:00
```json
2018-07-27 20:18:12 +00:00
"exchange": {
2020-08-23 19:12:08 +00:00
"name": "coinbasepro",
2018-07-27 20:18:12 +00:00
"sandbox": true,
"key": "5wowfxemogxeowo;heiohgmd",
"secret": "/ZMH1P62rCVmwefewrgcewX8nh4gob+lywxfwfxwwfxwfNsH1ySgvWCUR/w==",
"password": "1bkjfkhfhfu6sr",
2018-08-07 07:25:21 +00:00
"outdated_offset": 5
2018-07-27 20:18:12 +00:00
"pair_whitelist": [
"BTC/USD"
2020-08-23 19:12:08 +00:00
]
},
"datadir": "user_data/data/coinbasepro_sandbox"
2018-07-27 20:18:12 +00:00
```
2018-08-07 07:25:21 +00:00
2020-08-23 19:12:08 +00:00
Also the following information:
2018-08-07 07:25:21 +00:00
2020-08-23 19:16:44 +00:00
* api-key (created for the sandbox webpage)
* api-secret (noted earlier)
* password (the passphrase - noted earlier)
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
!!! Tip "Different data directory"
We also recommend to set `datadir` to something identifying downloaded data as sandbox data, to avoid having sandbox data mixed with data from the real exchange.
This can be done by adding the `"datadir"` key to the configuration.
Now, whenever you use this configuration, your data directory will be set to this directory.
2018-07-27 20:18:12 +00:00
---
2018-08-07 07:25:21 +00:00
## You should now be ready to test your sandbox
2020-08-23 19:12:08 +00:00
Ensure Freqtrade logs show the sandbox URL, and trades made are shown in sandbox. Also make sure to select a pair which shows at least some decent value (which very often is BTC/< somestablecoin > ).
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
## Common problems with sandbox exchanges
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
Sandbox exchange instances often have very low volume, which can cause some problems which usually are not seen on a real exchange instance.
2018-08-07 07:25:21 +00:00
2020-08-23 19:12:08 +00:00
### Old Candles problem
2018-07-27 20:18:12 +00:00
2020-08-23 19:12:08 +00:00
Since Sandboxes often have low volume, candles can be quite old and show no volume.
To disable the error "Outdated history for pair ...", best increase the parameter `"outdated_offset"` to a number that seems realistic for the sandbox you're using.
2020-08-24 09:17:27 +00:00
### Unfilled orders
Sandboxes often have very low volumes - which means that many trades can go unfilled, or can go unfilled for a very long time.
To mitigate this, you can try to match the first order on the opposite orderbook side using the following configuration:
``` jsonc
"order_types": {
2022-03-09 06:39:32 +00:00
"entry": "limit",
"exit": "limit"
2020-08-24 09:17:27 +00:00
// ...
},
2022-03-27 16:03:49 +00:00
"entry_pricing": {
"price_side": "other",
2020-08-24 09:17:27 +00:00
// ...
},
2022-03-27 16:03:49 +00:00
"exit_pricing":{
"price_side": "other",
2020-08-24 09:17:27 +00:00
// ...
},
```
The configuration is similar to the suggested configuration for market orders - however by using limit-orders you can avoid moving the price too much, and you can set the worst price you might get.