コード例 #1
0
ファイル: evaluation.py プロジェクト: plagi/zenbot
 def __init__(self, *args, strategy: str, instrument: str, **kwargs):
     super(Andividual, self).__init__(*args, **kwargs)
     self.args = args_for_strategy(strategy)
     self.instruments = fuzz_product(instrument)
     self.strategy = strategy
     for _ in self.args:
         self.append(50 + (random.random() - 0.5) * 100)
コード例 #2
0
    def __init__(self, *args, **kwargs):
        super(Andividual, self).__init__(*args, **kwargs)
        self.args = args_for_strategy(self.strategy)
        # period and periodLength are the same and yield errors
        # if both are used.
        self.args = [a for a in self.args if a != 'periodLength']

        for _ in self.args:
            self.append(50 + (random.random() - 0.5) * 100)
コード例 #3
0
ファイル: evaluation.py プロジェクト: Hitlust/zenbot
    def __init__(self, *args,**kwargs):
        super(Andividual, self).__init__(*args, **kwargs)
        self.args = args_for_strategy(self.strategy)
        # period and periodLength are the same and yield errors
        # if both are used.
        self.args = [a for a in self.args if a != 'periodLength']

        for _ in self.args:
            self.append(50 + (random.random() - 0.5) * 100)
コード例 #4
0
 def __init__(self, *args, **kwargs):
     super(Andividual, self).__init__(*args, **kwargs)
     self.args = dict(args_for_strategy(self.strategy))
     if self.strategy == 'trend_ema':
         del self.args['neutral_rate']
     for __ in self.args:
         dmin = float(self.args[__]) - (float(self.args[__]) / 100 * rnddev)
         dmax = float(self.args[__]) + (float(self.args[__]) / 100 * rnddev)
         self.args[__] = random.uniform(dmin, dmax)
         self.append(self.args[__])
     self.args = self.args.keys()
コード例 #5
0
def test_parse_strategies():
    asd = b'''
macd
  description:
    Buy when (MACD - Signal > 0) and sell when (MACD - Signal < 0).
  options:
    --period=<value>  period length (default: 1h)
    --min_periods=<value>  min. number of history periods (default: 52)
    --ema_short_period=<value>  number of periods for the shorter EMA (default: 12)
    --ema_long_period=<value>  number of periods for the longer EMA (default: 26)
    --signal_period=<value>  number of periods for the signal EMA (default: 9)
    --up_trend_threshold=<value>  threshold to trigger a buy signal (default: 0)
    --down_trend_threshold=<value>  threshold to trigger a sold signal (default: 0)
    --overbought_rsi_periods=<value>  number of periods for overbought RSI (default: 25)
    --overbought_rsi=<value>  sold when RSI exceeds this value (default: 70)

sar
  description:
    Parabolic SAR
  options:
    --period=<value>  period length (default: 2m)
    --min_periods=<value>  min. number of history periods (default: 52)
    --sar_af=<value>  acceleration factor for parabolic SAR (default: 0.015)
    --sar_max_af=<value>  max acceleration factor for parabolic SAR (default: 0.3)

trend_ema (default)
  description:
    Buy when (EMA - last(EMA) > 0) and sell when (EMA - last(EMA) < 0). Optional buy on low RSI.
  options:
    --period=<value>  period length (default: 10m)
    --min_periods=<value>  min. number of history periods (default: 52)
    --trend_ema=<value>  number of periods for trend EMA (default: 20)
    --neutral_rate=<value>  avoid trades if abs(trend_ema) under this float (0 to disable, "auto" for a variable filter) (default: 0.06)
    --oversold_rsi_periods=<value>  number of periods for oversold RSI (default: 20)
    --oversold_rsi=<value>  buy when RSI reaches this value (default: 30)

    '''

    with patch('evaluation.subprocess.check_output', lambda *x, **y: asd):
        assert args_for_strategy('sar') == [
            'period', 'min_periods', 'sar_af', 'sar_max_af'
        ]
コード例 #6
0
ファイル: test_evaluation.py プロジェクト: BarnumD/zenbot
def test_parse_strategies():
    asd = b'''
macd
  description:
    Buy when (MACD - Signal > 0) and sell when (MACD - Signal < 0).
  options:
    --period=<value>  period length (default: 1h)
    --min_periods=<value>  min. number of history periods (default: 52)
    --ema_short_period=<value>  number of periods for the shorter EMA (default: 12)
    --ema_long_period=<value>  number of periods for the longer EMA (default: 26)
    --signal_period=<value>  number of periods for the signal EMA (default: 9)
    --up_trend_threshold=<value>  threshold to trigger a buy signal (default: 0)
    --down_trend_threshold=<value>  threshold to trigger a sold signal (default: 0)
    --overbought_rsi_periods=<value>  number of periods for overbought RSI (default: 25)
    --overbought_rsi=<value>  sold when RSI exceeds this value (default: 70)
sar
  description:
    Parabolic SAR
  options:
    --period=<value>  period length (default: 2m)
    --min_periods=<value>  min. number of history periods (default: 52)
    --sar_af=<value>  acceleration factor for parabolic SAR (default: 0.015)
    --sar_max_af=<value>  max acceleration factor for parabolic SAR (default: 0.3)
trend_ema (default)
  description:
    Buy when (EMA - last(EMA) > 0) and sell when (EMA - last(EMA) < 0). Optional buy on low RSI.
  options:
    --period=<value>  period length (default: 10m)
    --min_periods=<value>  min. number of history periods (default: 52)
    --trend_ema=<value>  number of periods for trend EMA (default: 20)
    --neutral_rate=<value>  avoid trades if abs(trend_ema) under this float (0 to disable, "auto" for a variable filter) (default: 0.06)
    --oversold_rsi_periods=<value>  number of periods for oversold RSI (default: 20)
    --oversold_rsi=<value>  buy when RSI reaches this value (default: 30)
    '''


    with patch('evaluation.subprocess.check_output', lambda *x, **y: asd):
        assert args_for_strategy('sar') == ['period', 'min_periods', 'sar_af', 'sar_max_af']
コード例 #7
0
ファイル: evaluation.py プロジェクト: JensvdHeydt/zenbot
 def __init__(self, *args, **kwargs):
     super(Andividual, self).__init__(*args, **kwargs)
     self.args = args_for_strategy(self.strategy)
     for _ in self.args:
         self.append(50 + (random.random() - 0.5) * 100)
コード例 #8
0
ファイル: evaluation.py プロジェクト: BarnumD/zenbot
 def __init__(self, *args,**kwargs):
     super(Andividual, self).__init__(*args, **kwargs)
     self.args = args_for_strategy(self.strategy)
     for _ in self.args:
         self.append(50 + (random.random() - 0.5) * 100)