Elffuss BraidHub

kikocis/freqtrade public

develop · 4.5 KiBRenderedRawPermalink
1# Sandbox API testing
2
3Some exchanges provide sandboxes or testbeds for risk-free testing, while running the bot against a real exchange.
4With some configuration, freqtrade (in combination with ccxt) provides access to these.
5
6This document is an overview to configure Freqtrade to be used with sandboxes.
7This can be useful to developers and trader alike.
8
9!!! Warning
10 Sandboxes usually have very low volume, and either a very wide spread, or no orders available at all.
11 Therefore, sandboxes will usually not do a good job of showing you how a strategy would work in real trading.
12
13## Exchanges known to have a sandbox / testnet
14
15* [binance](https://testnet.binance.vision/)
16* [coinbasepro](https://public.sandbox.pro.coinbase.com)
17* [gemini](https://exchange.sandbox.gemini.com/)
18* [huobipro](https://www.testnet.huobi.pro/)
19* [kucoin](https://sandbox.kucoin.com/)
20* [phemex](https://testnet.phemex.com/)
21
22!!! Note
23 We did not test correct functioning of all of the above testnets. Please report your experiences with each sandbox.
24
25---
26
27## Configure a Sandbox account
28
29When testing your API connectivity, make sure to use the appropriate sandbox / testnet URL.
30
31In general, you should follow these steps to enable an exchange's sandbox:
32
33* Figure out if an exchange has a sandbox (most likely by using google or the exchange's support documents)
34* Create a sandbox account (often the sandbox-account requires separate registration)
35* [Add some test assets to account](#add-test-funds)
36* Create API keys
37
38### Add test funds
39
40Usually, sandbox exchanges allow depositing funds directly via web-interface.
41You should make sure to have a realistic amount of funds available to your test-account, so results are representable of your real account funds.
42
43!!! Warning
44 Test exchanges will **NEVER** require your real credit card or banking details!
45
46## Configure freqtrade to use a exchange's sandbox
47
48### Sandbox URLs
49
50Freqtrade makes use of CCXT which in turn provides a list of URLs to Freqtrade.
51These include `['test']` and `['api']`.
52
53* `[Test]` if available will point to an Exchanges sandbox.
54* `[Api]` normally used, and resolves to live API target on the exchange.
55
56To make use of sandbox / test add "sandbox": true, to your config.json
57
58```json
59 "exchange": {
60 "name": "coinbasepro",
61 "sandbox": true,
62 "key": "5wowfxemogxeowo;heiohgmd",
63 "secret": "/ZMH1P62rCVmwefewrgcewX8nh4gob+lywxfwfxwwfxwfNsH1ySgvWCUR/w==",
64 "password": "1bkjfkhfhfu6sr",
65 "outdated_offset": 5
66 "pair_whitelist": [
67 "BTC/USD"
68 ]
69 },
70 "datadir": "user_data/data/coinbasepro_sandbox"
71```
72
73Also the following information:
74
75* api-key (created for the sandbox webpage)
76* api-secret (noted earlier)
77* password (the passphrase - noted earlier)
78
79!!! Tip "Different data directory"
80 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.
81 This can be done by adding the `"datadir"` key to the configuration.
82 Now, whenever you use this configuration, your data directory will be set to this directory.
83
84---
85
86## You should now be ready to test your sandbox
87
88Ensure 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>).
89
90## Common problems with sandbox exchanges
91
92Sandbox exchange instances often have very low volume, which can cause some problems which usually are not seen on a real exchange instance.
93
94### Old Candles problem
95
96Since Sandboxes often have low volume, candles can be quite old and show no volume.
97To 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.
98
99### Unfilled orders
100
101Sandboxes often have very low volumes - which means that many trades can go unfilled, or can go unfilled for a very long time.
102
103To mitigate this, you can try to match the first order on the opposite orderbook side using the following configuration:
104
105``` jsonc
106 "order_types": {
107 "buy": "limit",
108 "sell": "limit"
109 // ...
110 },
111 "bid_strategy": {
112 "price_side": "ask",
113 // ...
114 },
115 "ask_strategy":{
116 "price_side": "bid",
117 // ...
118 },
119 ```
120
121 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.