From bef088ff906e74df95781bc750620ebd49757660 Mon Sep 17 00:00:00 2001 From: kecheon Date: Tue, 13 Apr 2021 18:42:13 +0900 Subject: [PATCH] touch config files to dockerize --- docker-compose.yml | 8 +- tests/strategy/strats/default_strategy.py | 6 +- user_data/config.json | 141 ++++++++++++++++++++++ user_data/strategies/Strategy002.py | 135 +++++++++++++++++++++ 4 files changed, 283 insertions(+), 7 deletions(-) create mode 100644 user_data/config.json create mode 100644 user_data/strategies/Strategy002.py diff --git a/docker-compose.yml b/docker-compose.yml index 80e194ab2..ab7e18816 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ --- -version: '3' +version: "3" services: freqtrade: image: freqtradeorg/freqtrade:stable @@ -17,12 +17,12 @@ services: # Expose api on port 8080 (localhost only) # Please read the https://www.freqtrade.io/en/latest/rest-api/ documentation # before enabling this. - # ports: - # - "127.0.0.1:8080:8080" + ports: + - "127.0.0.1:8080:8080" # Default command used when running `docker compose up` command: > trade --logfile /freqtrade/user_data/logs/freqtrade.log --db-url sqlite:////freqtrade/user_data/tradesv3.sqlite --config /freqtrade/user_data/config.json - --strategy SampleStrategy + --strategy Strategy002 diff --git a/tests/strategy/strats/default_strategy.py b/tests/strategy/strats/default_strategy.py index 7171b93ae..b212f4279 100644 --- a/tests/strategy/strats/default_strategy.py +++ b/tests/strategy/strats/default_strategy.py @@ -29,7 +29,7 @@ class DefaultStrategy(IStrategy): stoploss = -0.10 # Optimal timeframe for the strategy - timeframe = '5m' + timeframe = '15m' # Optional order type mapping order_types = { @@ -119,7 +119,7 @@ class DefaultStrategy(IStrategy): """ dataframe.loc[ ( - (dataframe['rsi'] < 35) & + (dataframe['rsi'] < 30) & (dataframe['fastd'] < 35) & (dataframe['adx'] > 30) & (dataframe['plus_di'] > 0.5) @@ -142,7 +142,7 @@ class DefaultStrategy(IStrategy): dataframe.loc[ ( ( - (qtpylib.crossed_above(dataframe['rsi'], 70)) | + (qtpylib.crossed_above(dataframe['rsi'], 75)) | (qtpylib.crossed_above(dataframe['fastd'], 70)) ) & (dataframe['adx'] > 10) & diff --git a/user_data/config.json b/user_data/config.json new file mode 100644 index 000000000..04d3f94f8 --- /dev/null +++ b/user_data/config.json @@ -0,0 +1,141 @@ +{ + "max_open_trades": 2, + "stake_currency": "BTC", + "stake_amount": "unlimited", + "tradable_balance_ratio": 0.99, + "fiat_display_currency": "USD", + "timeframe": "1m", + "dry_run": true, + "dry_run_wallet": 1, + "cancel_open_orders_on_exit": false, + "unfilledtimeout": { + "buy": 10, + "sell": 30 + }, + "bid_strategy": { + "price_side": "bid", + "ask_last_balance": 0.0, + "use_order_book": false, + "order_book_top": 1, + "check_depth_of_market": { + "enabled": false, + "bids_to_ask_delta": 1 + } + }, + "ask_strategy": { + "price_side": "ask", + "use_order_book": false, + "order_book_min": 1, + "order_book_max": 1, + "use_sell_signal": true, + "sell_profit_only": false, + "ignore_roi_if_buy_signal": false + }, + "exchange": { + "name": "binance", + "key": "", + "secret": "", + "ccxt_config": {"enableRateLimit": true}, + "ccxt_async_config": { + "enableRateLimit": true, + "rateLimit": 200 + }, + "pair_whitelist": [ + // "ADA/BTC", + "ALGO/BTC", + // "ATOM/BTC", + "BAT/BTC", + // "BCH/BTC", + "BRD/BTC", + "BTG/BTC", + // "CAKE/BTC", + // "CHZ/BTC", + // "DCR/BTC", + "DOGE/BTC", + // "DREP/BTC", + "DASH/BTC", + // "EGLD/BTC", + // "EOS/BTC", + "ENJ/BTC", + // "ETH/BTC", + // "FTT/BTC", + "GTO/BTC", + "HBAR/BTC", + "IOST/BTC", + "IOTA/BTC", + // "LINK/BTC", + "LTC/BTC", + "MANA/BTC", + // "MITH/BTC", + "MKR/BTC", + // "NEO/BTC", + // "NKN/BTC", + // "NXS/BTC", + // "ONT/BTC", + "PPT/BTC", + // "QTUM/BTC", + // "RUNE/BTC", + "RVN/BTC", + // "SOL/BTC", + "SRM/BTC", + "TFUEL/BTC", + "THETA/BTC", + "TRX/BTC", + "VET/BTC", + "VIA/BTC", + "WAVES/BTC", + // "XEM/BTC", + "XLM/BTC", + "XMR/BTC", + "XRP/BTC", + "XTZ/BTC", + // "ZIL/BTC", + "ZRX/BTC", + "SXP/BTC", + // "WAN/BTC", + // "WIN/BTC", + ], + "pair_blacklist": [ + "BNB/BTC" + ] + }, + "pairlists": [ + {"method": "StaticPairList"} + ], + "edge": { + "enabled": false, + "process_throttle_secs": 3600, + "calculate_since_number_of_days": 7, + "allowed_risk": 0.01, + "stoploss_range_min": -0.01, + "stoploss_range_max": -0.1, + "stoploss_range_step": -0.01, + "minimum_winrate": 0.60, + "minimum_expectancy": 0.20, + "min_trade_number": 10, + "max_trade_duration_minute": 1440, + "remove_pumps": false + }, + "telegram": { + "enabled": false, + "token": "1356047596:AAHuyBLkOuoJ0SSYYOt5TXd2YBUzD3uzoEA", + "chat_id": "bitsbee1_bot" + }, + "api_server": { + "enabled": true, + "listen_ip_address": "0.0.0.0", + "listen_port": 8080, + "verbosity": "error", + "enable_openapi": false, + "jwt_secret_key": "06907b5231babf844792af80070386aab331065690b15f7d86964666fc64fc30", + "CORS_origins": [], + "username": "kecheon@gmail.com", + "password": "dmdcjs0" + }, + "bot_name": "freqtrade", + "initial_state": "running", + "forcebuy_enable": false, + "internals": { + "process_throttle_secs": 5 + } +} \ No newline at end of file diff --git a/user_data/strategies/Strategy002.py b/user_data/strategies/Strategy002.py new file mode 100644 index 000000000..23fa8bb3e --- /dev/null +++ b/user_data/strategies/Strategy002.py @@ -0,0 +1,135 @@ + +# --- Do not remove these libs --- +from freqtrade.strategy.interface import IStrategy +from typing import Dict, List +from functools import reduce +from pandas import DataFrame +# -------------------------------- + +import talib.abstract as ta +import freqtrade.vendor.qtpylib.indicators as qtpylib +import numpy # noqa + + +class Strategy002(IStrategy): + """ + Strategy 002 + author@: Gerald Lonlas + github@: https://github.com/freqtrade/freqtrade-strategies + + How to use it? + > python3 ./freqtrade/main.py -s Strategy002 + """ + + # Minimal ROI designed for the strategy. + # This attribute will be overridden if the config file contains "minimal_roi" + minimal_roi = { + "60": 0.01, + "30": 0.03, + "20": 0.04, + "0": 0.05 + } + + # Optimal stoploss designed for the strategy + # This attribute will be overridden if the config file contains "stoploss" + stoploss = -0.10 + + # Optimal timeframe for the strategy + timeframe = '1m' + + # trailing stoploss + trailing_stop = False + trailing_stop_positive = 0.01 + trailing_stop_positive_offset = 0.02 + + # run "populate_indicators" only for new candle + process_only_new_candles = False + + # Experimental settings (configuration will overide these if set) + use_sell_signal = True + sell_profit_only = True + ignore_roi_if_buy_signal = False + + # Optional order type mapping + order_types = { + 'buy': 'limit', + 'sell': 'limit', + 'stoploss': 'market', + 'stoploss_on_exchange': False + } + + def informative_pairs(self): + """ + Define additional, informative pair/interval combinations to be cached from the exchange. + These pair/interval combinations are non-tradeable, unless they are part + of the whitelist as well. + For more information, please consult the documentation + :return: List of tuples in the format (pair, interval) + """ + return [ + ("ETH/USDT", "15m"), + ("BTC/USDT", "5m"), + ] + + def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + """ + Adds several different TA indicators to the given DataFrame + + Performance Note: For the best performance be frugal on the number of indicators + you are using. Let uncomment only the indicator you are using in your strategies + or your hyperopt configuration, otherwise you will waste your memory and CPU usage. + """ + + # Stoch + stoch = ta.STOCH(dataframe) + dataframe['slowk'] = stoch['slowk'] + + # RSI + dataframe['rsi'] = ta.RSI(dataframe) + + # Inverse Fisher transform on RSI, values [-1.0, 1.0] (https://goo.gl/2JGGoy) + rsi = 0.1 * (dataframe['rsi'] - 50) + dataframe['fisher_rsi'] = (numpy.exp(2 * rsi) - 1) / (numpy.exp(2 * rsi) + 1) + + # Bollinger bands + bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) + dataframe['bb_lowerband'] = bollinger['lower'] + + # SAR Parabol + dataframe['sar'] = ta.SAR(dataframe) + + # Hammer: values [0, 100] + dataframe['CDLHAMMER'] = ta.CDLHAMMER(dataframe) + + return dataframe + + def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + """ + Based on TA indicators, populates the buy signal for the given dataframe + :param dataframe: DataFrame + :return: DataFrame with buy column + """ + dataframe.loc[ + ( + (dataframe['rsi'] < 30) & + (dataframe['slowk'] < 20) & + (dataframe['bb_lowerband'] > dataframe['close']) & + (dataframe['CDLHAMMER'] == 100) + ), + 'buy'] = 1 + + return dataframe + + def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + """ + Based on TA indicators, populates the sell signal for the given dataframe + :param dataframe: DataFrame + :return: DataFrame with buy column + """ + dataframe.loc[ + ( + (dataframe['sar'] > dataframe['close']) & + (dataframe['fisher_rsi'] > 0.55) + ), + 'sell'] = 1 + return dataframe