_pair_info moved to class header for reusibility
This commit is contained in:
parent
b425cc3e3b
commit
96a43327ca
@ -30,6 +30,11 @@ class Edge():
|
|||||||
config: Dict = {}
|
config: Dict = {}
|
||||||
_cached_pairs: Dict[str, Any] = {} # Keeps a list of pairs
|
_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:
|
def __init__(self, config: Dict[str, Any], exchange=None) -> None:
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
@ -42,10 +47,6 @@ class Edge():
|
|||||||
self.advise_buy = self.strategy.advise_buy
|
self.advise_buy = self.strategy.advise_buy
|
||||||
|
|
||||||
self.edge_config = self.config.get('edge', {})
|
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._cached_pairs: Dict[str, Any] = {} # Keeps a list of pairs
|
||||||
|
|
||||||
self._total_capital: float = self.edge_config.get('total_capital_in_stake_currency')
|
self._total_capital: float = self.edge_config.get('total_capital_in_stake_currency')
|
||||||
|
@ -2,7 +2,6 @@ from freqtrade.tests.conftest import get_patched_exchange
|
|||||||
from freqtrade.edge import Edge
|
from freqtrade.edge import Edge
|
||||||
from pandas import DataFrame, to_datetime
|
from pandas import DataFrame, to_datetime
|
||||||
from freqtrade.strategy.interface import SellType
|
from freqtrade.strategy.interface import SellType
|
||||||
from collections import namedtuple
|
|
||||||
import arrow
|
import arrow
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import math
|
import math
|
||||||
@ -21,8 +20,6 @@ from unittest.mock import MagicMock
|
|||||||
ticker_start_time = arrow.get(2018, 10, 3)
|
ticker_start_time = arrow.get(2018, 10, 3)
|
||||||
ticker_interval_in_minute = 60
|
ticker_interval_in_minute = 60
|
||||||
_ohlc = {'date': 0, 'buy': 1, 'open': 2, 'high': 3, 'low': 4, 'close': 5, 'sell': 6, 'volume': 7}
|
_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):
|
def test_filter(mocker, default_conf):
|
||||||
@ -30,9 +27,9 @@ def test_filter(mocker, default_conf):
|
|||||||
edge = Edge(default_conf, exchange)
|
edge = Edge(default_conf, exchange)
|
||||||
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
||||||
return_value={
|
return_value={
|
||||||
'E/F': _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': _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': _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)
|
edge = Edge(default_conf, exchange)
|
||||||
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
|
||||||
return_value={
|
return_value={
|
||||||
'E/F': _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': _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': _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)
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user