New config (#6333)

* updated new-config to add trading_mode and margin_mode

* added trading_mode and margin_mode to config examples

* added okex config example

* new file:   config_examples/config_binance_futures.example.json

* removed trading_mode and margin_mode from base_config and binance and okex example

* deleted okex and futures config files

* updated full config file

* updated new-config command to add trading_mode and margin_mode to config

* new file:   config_examples/config_okex_futures.example.json

* removed config_okex_futures.example.json

* added trading_mode to test_start_new_config

* new-config asks exchange before asking futures

* Simplify trading_mode selection

* margin_mode is empty string for spot new configs

* build_config_commands sorted exchanges

* isort

Co-authored-by: Matthias <xmatthias@outlook.com>
This commit is contained in:
Sam Germain 2022-02-02 07:46:44 -06:00 committed by GitHub
parent c3684e8a1a
commit 179947fa72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 6 deletions

View File

@ -19,6 +19,8 @@
"sell_profit_offset": 0.0,
"ignore_roi_if_buy_signal": false,
"ignore_buying_expired_candle_after": 300,
"trading_mode": "futures",
"margin_mode": "isolated",
"minimal_roi": {
"40": 0.0,
"30": 0.01,

View File

@ -107,19 +107,27 @@ def ask_user_config() -> Dict[str, Any]:
"type": "select",
"name": "exchange_name",
"message": "Select exchange",
"choices": [
"choices": lambda x: [
"binance",
"binanceus",
"bittrex",
"kraken",
"ftx",
"kucoin",
"gateio",
"kraken",
"kucoin",
"okex",
Separator(),
Separator("-----------------------------------------------"),
"other",
],
},
{
"type": "confirm",
"name": "trading_mode",
"message": "Do you want to trade Perpetual Swaps (perpetual futures)?",
"default": False,
"filter": lambda val: 'futures' if val else 'spot',
"when": lambda x: x["exchange_name"] in ['binance', 'gateio'],
},
{
"type": "autocomplete",
"name": "exchange_name",
@ -196,7 +204,11 @@ def ask_user_config() -> Dict[str, Any]:
if not answers:
# Interrupted questionary sessions return an empty dict.
raise OperationalException("User interrupted interactive questions.")
answers['margin_mode'] = (
'isolated'
if answers.get('trading_mode') == 'futures'
else ''
)
# Force JWT token to be a random string
answers['api_server_jwt_key'] = secrets.token_hex()

View File

@ -2,8 +2,9 @@ import logging
from typing import Dict, List, Tuple
from freqtrade.enums import MarginMode, TradingMode
from freqtrade.exchange import Exchange
from freqtrade.exceptions import OperationalException
from freqtrade.exchange import Exchange
logger = logging.getLogger(__name__)

View File

@ -13,6 +13,8 @@
"fiat_display_currency": "{{ fiat_display_currency }}",{{ ('\n "timeframe": "' + timeframe + '",') if timeframe else '' }}
"dry_run": {{ dry_run | lower }},
"cancel_open_orders_on_exit": false,
"trading_mode": "{{ trading_mode }}",
"margin_mode": "{{ margin_mode }}",
"unfilledtimeout": {
"buy": 10,
"sell": 10,

View File

@ -44,6 +44,8 @@ def test_start_new_config(mocker, caplog, exchange):
'fiat_display_currency': 'EUR',
'timeframe': '15m',
'dry_run': True,
'trading_mode': 'spot',
'margin_mode': '',
'exchange_name': exchange,
'exchange_key': 'sampleKey',
'exchange_secret': 'Samplesecret',