Trade binance futures with freqtrade
Fig 1. market tickers with strategy indicators and actions |
For a strategy, checkout support line. If need setup assistance leave a comment below, or send a message via Request Service form.
A short walkthrough on freqtrade configuration.
Freqtrade is a standalone platform. It supports data acquisition, indicators and expert advisors (strategies). You may use backtest with fixed parameters as well as apply optimization to boost the performance. Spot market as well as derivatives usage has been built in.
Beginners may rely on functional web interface. Advanced users may utilize command line interface.
-
Check config.json to be configured for futures:
-
1. trading mode
"trading_mode": "futures", "margin_mode": "isolated",
-
2. exchange pairs
"exchange": { "name": "binance", "sandbox": true, "key": "your_exchange_key", "secret": "your_exchange_secret", "password": "", "log_responses": false, "ccxt_config": {}, "ccxt_async_config": {}, "pair_whitelist": [ "BTC/USDT", "ETH/USDT" ], "outdated_offset": 5, "markets_refresh_interval": 60 }
Leverage trading requires a custom strategy. For details inspect freqtrade/strategy/interface.py
def leverage(self, pair: str, current_time: datetime, current_rate: float, proposed_leverage: float, max_leverage: float, side: str, **kwargs) -> float: """ Customize leverage for each new trade. This method is only called in futures mode. :param pair: Pair that's currently analyzed :param current_time: datetime object, containing the current datetime :param current_rate: Rate, calculated based on pricing settings in exit_pricing. :param proposed_leverage: A leverage proposed by the bot. :param max_leverage: Max leverage allowed on this pair :param side: 'long' or 'short' - indicating the direction of the proposed trade :return: A leverage amount, which is between 1.0 and max_leverage. """ return 1.0
It's reasonable to use VPS for 24/7 execution. docker-compose.yml provides easy automation in this case
--- version: '2' services: web: build: context: ../../.. dockerfile: ./follow_the_leader/strategies/c2/Dockerfile restart: always volumes: - ../../..:/app:ro - ../../../tmp/cache/freqtrade/ui_data:/app/deps/d2-fork/freqtrade/rpc/api_server/ui/installed:rw - ../../../tmp/cache:/app/tmp/cache:rw ports: - 127.0.0.1:7779:8080
Service entrypoint may install frontend files, and then serve it with python
t5 = os.path.join( t4, 'freqtrade', 'rpc', 'api_server', 'ui', 'installed', 'index.html', ) if not os.path.exists(t5): subprocess.check_call([ 'python', '-m', 'freqtrade', 'install-ui', ], cwd=t4,) with subprocess.Popen([ 'python', '-m', 'freqtrade', 'webserver', '--userdir', t2, '--config', t3, ], cwd=t4,) as p: p.wait()
Tickers data is being stored in plain .json files at data/<exchange>/<symbol>-<timeframe>*.json
BTC_USDT-1m-futures.json BTC_USDT-5m-futures.json BTC_USDT-8h-funding_rate.json BTC_USDT-8h-mark.json ETH_USDT-1m-futures.json ETH_USDT-5m-futures.json ETH_USDT-8h-funding_rate.json ETH_USDT-8h-mark.json
Fig 2. backtest breakdown with profit and loss assessment |
Fig 3. detailed info on orders taken by strategy |
Comments
Post a Comment