From 96a43327ca5c3093bffc1aa2a7d7d87cfc231800 Mon Sep 17 00:00:00 2001 From: misagh Date: Wed, 7 Nov 2018 18:52:15 +0100 Subject: [PATCH] _pair_info moved to class header for reusibility --- freqtrade/edge/__init__.py | 9 +++++---- freqtrade/tests/edge/test_edge.py | 15 ++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/freqtrade/edge/__init__.py b/freqtrade/edge/__init__.py index 0a56e8bfa..5d62c1415 100644 --- a/freqtrade/edge/__init__.py +++ b/freqtrade/edge/__init__.py @@ -30,6 +30,11 @@ class Edge(): config: Dict = {} _cached_pairs: Dict[str, Any] = {} # Keeps a list of pairs + # pair info data type + _pair_info = namedtuple( + 'pair_info', + ['stoploss', 'winrate', 'risk_reward_ratio', 'required_risk_reward', 'expectancy']) + def __init__(self, config: Dict[str, Any], exchange=None) -> None: self.config = config @@ -42,10 +47,6 @@ class Edge(): self.advise_buy = self.strategy.advise_buy self.edge_config = self.config.get('edge', {}) - - # pair info data type - self._pair_info = namedtuple( - 'pair_info', 'stoploss, winrate, risk_reward_ratio, required_risk_reward, expectancy') self._cached_pairs: Dict[str, Any] = {} # Keeps a list of pairs self._total_capital: float = self.edge_config.get('total_capital_in_stake_currency') diff --git a/freqtrade/tests/edge/test_edge.py b/freqtrade/tests/edge/test_edge.py index 18e934352..4dee004cb 100644 --- a/freqtrade/tests/edge/test_edge.py +++ b/freqtrade/tests/edge/test_edge.py @@ -2,7 +2,6 @@ from freqtrade.tests.conftest import get_patched_exchange from freqtrade.edge import Edge from pandas import DataFrame, to_datetime from freqtrade.strategy.interface import SellType -from collections import namedtuple import arrow import numpy as np import math @@ -21,8 +20,6 @@ from unittest.mock import MagicMock ticker_start_time = arrow.get(2018, 10, 3) ticker_interval_in_minute = 60 _ohlc = {'date': 0, 'buy': 1, 'open': 2, 'high': 3, 'low': 4, 'close': 5, 'sell': 6, 'volume': 7} -_pair_info = namedtuple( - 'pair_info', 'stoploss, winrate, risk_reward_ratio, required_risk_reward, expectancy') def test_filter(mocker, default_conf): @@ -30,9 +27,9 @@ def test_filter(mocker, default_conf): edge = Edge(default_conf, exchange) mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock( return_value={ - 'E/F': _pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), - 'C/D': _pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), - 'N/O': _pair_info(-0.01, 0.66, 3.71, 0.50, 1.71) + 'E/F': Edge._pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), + 'C/D': Edge._pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), + 'N/O': Edge._pair_info(-0.01, 0.66, 3.71, 0.50, 1.71) } )) @@ -45,9 +42,9 @@ def test_stoploss(mocker, default_conf): edge = Edge(default_conf, exchange) mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock( return_value={ - 'E/F': _pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), - 'C/D': _pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), - 'N/O': _pair_info(-0.01, 0.66, 3.71, 0.50, 1.71) + 'E/F': Edge._pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), + 'C/D': Edge._pair_info(-0.01, 0.66, 3.71, 0.50, 1.71), + 'N/O': Edge._pair_info(-0.01, 0.66, 3.71, 0.50, 1.71) } ))