Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing the Technical library in freqtrade #63

Closed
kobertkirk opened this issue Feb 2, 2020 · 5 comments
Closed

Implementing the Technical library in freqtrade #63

kobertkirk opened this issue Feb 2, 2020 · 5 comments

Comments

@kobertkirk
Copy link

I'm trying to implement the Ichimoku cloud indicator in a strategy from https://cryptocue.io/ichimoku-strategy-with-freqtrade/.

ichi.py

`
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame
from technical.indicators import accumulation_distribution
from technical.util import resample_to_interval, resampled_merge

import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy # noqa
from technical.indicators import ichimoku

class ichis(IStrategy):

# Minimal ROI designed for the strategy.
# This attribute will be overridden if the config file contains "minimal_roi"
minimal_roi = {

    "0": 1
}

# Optimal stoploss designed for the strategy
# This attribute will be overridden if the config file contains "stoploss"
stoploss = -0.1

# trailing stoploss
trailing_stop = True
trailing_stop_positive = -0.15
trailing_stop_positive_offset = 0.20 # Disabled / not configured
trailing_only_offset_is_reached = True

# Optimal ticker interval for the strategy
ticker_interval = '15m'

# 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 = False
ignore_roi_if_buy_signal = False

# Optional order type mapping
order_types = {
    'buy': 'limit',
    'sell': 'limit',
    'stoploss': 'market',
    'stoploss_on_exchange': False
}

# Optional order time in force
order_time_in_force = {
    'buy': 'gtc',
    'sell': 'gtc'
}

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)
       Sample: return [("ETH/USDT", "5m"),
                       ("BTC/USDT", "15m"),
                       ]
   """
    return []

def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
   
    ichi=ichimoku(dataframe)
    dataframe['tenkan']=ichi['tenkan_sen']
    dataframe['kijun']=ichi['kijun_sen']
    dataframe['senkou_a']=ichi['senkou_span_a']
    dataframe['senkou_b']=ichi['senkou_span_b']
    dataframe['cloud_green']=ichi['cloud_green']
    dataframe['cloud_red']=ichi['cloud_red']

    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 populated with indicators
   :param metadata: Additional information, like the currently traded pair
   :return: DataFrame with buy column
   """
   
    dataframe.loc[
        (
            (dataframe['tenkan'].shift(1)<dataframe['kijun'].shift(1)) &
            (dataframe['tenkan']>dataframe['kijun']) &
            (dataframe['cloud_red']==True)

        ),
        '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 populated with indicators
   :param metadata: Additional information, like the currently traded pair
   :return: DataFrame with buy column
   """
    dataframe.loc[
        (
           
        ),
        'sell'] = 1

    return dataframe`

I'm getting the error

freqtrade - ERROR - Impossible to load Strategy 'ichi'. This class does not exist or contains Python code errors.

I can get the default strategy to run. This error doesn't give me much to go off of. Is there a better place to get support using freqtrade and the technical library? I'm not finding much on google.

@hroff-1902
Copy link
Member

hroff-1902 commented Feb 2, 2020

Impossible to load Strategy 'ichi'
class ichis(IStrategy):

Align the usage: ichi/ichis ^^

The class name (not the name of the python file) should be used in the --strategy option

@kobertkirk
Copy link
Author

Thanks for the quick response! I will try it now.

@kobertkirk
Copy link
Author

I am getting this error now
freqtrade.resolvers.iresolver - WARNING - Could not import /home/kobert/freqtrade/user_data/strategies/ichi.py due to 'No module named 'technical''

I have the technical in the the .local/lib/python3.6/... and the freqtrade/.env/lib/...

I'm lost.

@kobertkirk
Copy link
Author

I figured it out. I deleted the thechnical folder in my enviroment and reinstalled it. Thanks for your help.

@hroff-1902
Copy link
Member

it's better ask such small questions in our Slack channels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants