From f60d101076f29943650c92a7f476909894befe9c Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 3 Nov 2021 07:12:42 +0100 Subject: [PATCH 1/5] Some finetuning for OKEX --- freqtrade/commands/build_config_commands.py | 3 ++- freqtrade/templates/subtemplates/exchange_okex.j2 | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 freqtrade/templates/subtemplates/exchange_okex.j2 diff --git a/freqtrade/commands/build_config_commands.py b/freqtrade/commands/build_config_commands.py index ad38d2291..b0ca1a1bf 100644 --- a/freqtrade/commands/build_config_commands.py +++ b/freqtrade/commands/build_config_commands.py @@ -115,6 +115,7 @@ def ask_user_config() -> Dict[str, Any]: "ftx", "kucoin", "gateio", + "okex", Separator(), "other", ], @@ -142,7 +143,7 @@ def ask_user_config() -> Dict[str, Any]: "type": "password", "name": "exchange_key_password", "message": "Insert Exchange API Key password", - "when": lambda x: not x['dry_run'] and x['exchange_name'] == 'kucoin' + "when": lambda x: not x['dry_run'] and x['exchange_name'] in ('kucoin', 'okex') }, { "type": "confirm", diff --git a/freqtrade/templates/subtemplates/exchange_okex.j2 b/freqtrade/templates/subtemplates/exchange_okex.j2 new file mode 100644 index 000000000..b797dda41 --- /dev/null +++ b/freqtrade/templates/subtemplates/exchange_okex.j2 @@ -0,0 +1,12 @@ +"exchange": { + "name": "{{ exchange_name | lower }}", + "key": "{{ exchange_key }}", + "secret": "{{ exchange_secret }}", + "password": "{{ exchange_key_password }}", + "ccxt_config": {}, + "ccxt_async_config": {}, + "pair_whitelist": [ + ], + "pair_blacklist": [ + ] +} From 6fb0866350857eaca8adf5ba397d46e03f3e86b3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 3 Nov 2021 19:17:19 +0100 Subject: [PATCH 2/5] Add OKEX to list of officially supported exchanges --- README.md | 3 ++- docs/index.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c1651162..9882bce02 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,10 @@ Please read the [exchange specific notes](docs/exchanges.md) to learn about even - [X] [Binance](https://www.binance.com/) ([*Note for binance users](docs/exchanges.md#binance-blacklist)) - [X] [Bittrex](https://bittrex.com/) -- [X] [Kraken](https://kraken.com/) - [X] [FTX](https://ftx.com) - [X] [Gate.io](https://www.gate.io/ref/6266643) +- [X] [Kraken](https://kraken.com/) +- [X] [OKEX](https://www.okex.com/) - [ ] [potentially many others](https://github.com/ccxt/ccxt/). _(We cannot guarantee they will work)_ ### Community tested diff --git a/docs/index.md b/docs/index.md index 2dbf7aeda..833c49812 100644 --- a/docs/index.md +++ b/docs/index.md @@ -39,8 +39,9 @@ Please read the [exchange specific notes](exchanges.md) to learn about eventual, - [X] [Binance](https://www.binance.com/) ([*Note for binance users](docs/exchanges.md#binance-blacklist)) - [X] [Bittrex](https://bittrex.com/) - [X] [FTX](https://ftx.com) -- [X] [Kraken](https://kraken.com/) - [X] [Gate.io](https://www.gate.io/ref/6266643) +- [X] [Kraken](https://kraken.com/) +- [X] [OKEX](https://www.okex.com/) - [ ] [potentially many others through ccxt](https://github.com/ccxt/ccxt/). _(We cannot guarantee they will work)_ ### Community tested From 437e5f0645d837ee88ec99c736e91a2c42262a04 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 3 Nov 2021 19:19:51 +0100 Subject: [PATCH 3/5] Fix officially supported exchange list --- freqtrade/exchange/exchange.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 4143b79a5..f9553699b 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1534,7 +1534,7 @@ def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = Non def is_exchange_officially_supported(exchange_name: str) -> bool: - return exchange_name in ['bittrex', 'binance', 'kraken'] + return exchange_name in ['bittrex', 'binance', 'kraken', 'ftx', 'gateio', 'okex'] def ccxt_exchanges(ccxt_module: CcxtModuleType = None) -> List[str]: diff --git a/setup.py b/setup.py index b23fa814d..630bc0f86 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ setup( ], install_requires=[ # from requirements.txt - 'ccxt>=1.50.48', + 'ccxt>=1.60.11', 'SQLAlchemy', 'python-telegram-bot>=13.4', 'arrow>=0.17.0', From 048db4f5097657d72c701bbfbdbc6937a62076a6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 3 Nov 2021 19:27:17 +0100 Subject: [PATCH 4/5] Enhance "new exchange" documentation --- docs/developer.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/developer.md b/docs/developer.md index da47d903c..01f274131 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -250,11 +250,24 @@ Most exchanges supported by CCXT should work out of the box. To quickly test the public endpoints of an exchange, add a configuration for your exchange to `test_ccxt_compat.py` and run these tests with `pytest --longrun tests/exchange/test_ccxt_compat.py`. Completing these tests successfully a good basis point (it's a requirement, actually), however these won't guarantee correct exchange functioning, as this only tests public endpoints, but no private endpoint (like generate order or similar). -Also try to use `freqtrade download-data` for an extended timerange and verify that the data downloaded correctly (no holes, the specified timerange was actually downloaded). +Also try to use `freqtrade download-data` for an extended timerange (multiple months) and verify that the data downloaded correctly (no holes, the specified timerange was actually downloaded). These are prerequisites to have an exchange listed as either Supported or Community tested (listed on the homepage). The below are "extras", which will make an exchange better (feature-complete) - but are not absolutely necessary for either of the 2 categories. +Additional tests / steps to complete: + +* Verify data provided by `fetch_ohlcv()` - and eventually adjust `ohlcv_candle_limit` for this exchange +* Check L2 orderbook limit range (API documentation) - and eventually set as necessary +* Check if balance shows correctly (*) +* Create market order (*) +* Create limit order (*) +* Complete trade (buy + sell) (*) + * Compare result calculation between exchange and bot + * Ensure fees are applied correctly (check the database against the exchange) + +(*) Requires API keys and Balance on the exchange. + ### Stoploss On Exchange Check if the new exchange supports Stoploss on Exchange orders through their API. From c061b576a970fd7312bf5cfa71efce46ad50520e Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 4 Nov 2021 06:22:31 +0100 Subject: [PATCH 5/5] OKEX Notes --- docs/exchanges.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/exchanges.md b/docs/exchanges.md index badaa484a..90d9db8ab 100644 --- a/docs/exchanges.md +++ b/docs/exchanges.md @@ -182,6 +182,23 @@ Kucoin supports [time_in_force](configuration.md#understand-order_time_in_force) For Kucoin, please add `"KCS/"` to your blacklist to avoid issues. Accounts having KCS accounts use this to pay for fees - if your first trade happens to be on `KCS`, further trades will consume this position and make the initial KCS trade unsellable as the expected amount is not there anymore. +## OKEX + +OKEX requires a passphrase for each api key, you will therefore need to add this key into the configuration so your exchange section looks as follows: + +```json +"exchange": { + "name": "okex", + "key": "your_exchange_key", + "secret": "your_exchange_secret", + "password": "your_exchange_api_key_password", + // ... +} +``` + +!!! Warning + OKEX only provides 100 candles per api call. Therefore, the strategy will only have a pretty low amount of data available in backtesting mode. + ## All exchanges Should you experience constant errors with Nonce (like `InvalidNonce`), it is best to regenerate the API keys. Resetting Nonce is difficult and it's usually easier to regenerate the API keys.