mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
move price point calculations out from populate functions
This commit is contained in:
parent
2a56031cdc
commit
632d00e01d
|
@ -73,7 +73,6 @@ def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
|
|||
(dataframe['fastd'] < 25) &
|
||||
(dataframe['adx'] > 30),
|
||||
'buy'] = 1
|
||||
dataframe.loc[dataframe['buy'] == 1, 'buy_price'] = dataframe['close']
|
||||
|
||||
return dataframe
|
||||
|
||||
|
@ -86,7 +85,6 @@ def populate_sell_trend(dataframe: DataFrame) -> DataFrame:
|
|||
dataframe.loc[
|
||||
(crossed_above(dataframe['rsi'], 70)),
|
||||
'sell'] = 1
|
||||
dataframe.loc[dataframe['sell'] == 1, 'sell_price'] = dataframe['close']
|
||||
|
||||
return dataframe
|
||||
|
||||
|
@ -106,6 +104,9 @@ def analyze_ticker(pair: str) -> DataFrame:
|
|||
dataframe = populate_indicators(dataframe)
|
||||
dataframe = populate_buy_trend(dataframe)
|
||||
dataframe = populate_sell_trend(dataframe)
|
||||
# TODO: buy_price and sell_price are only used by the plotter, should probably be moved there
|
||||
dataframe.loc[dataframe['buy'] == 1, 'buy_price'] = dataframe['close']
|
||||
dataframe.loc[dataframe['sell'] == 1, 'sell_price'] = dataframe['close']
|
||||
return dataframe
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import pytest
|
|||
from pandas import DataFrame
|
||||
|
||||
from freqtrade.analyze import parse_ticker_dataframe, populate_buy_trend, populate_indicators, \
|
||||
get_signal, SignalType
|
||||
get_signal, SignalType, populate_sell_trend
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -26,7 +26,11 @@ def test_dataframe_correct_length(result):
|
|||
def test_populates_buy_trend(result):
|
||||
dataframe = populate_buy_trend(populate_indicators(result))
|
||||
assert 'buy' in dataframe.columns
|
||||
assert 'buy_price' in dataframe.columns
|
||||
|
||||
|
||||
def test_populates_buy_trend(result):
|
||||
dataframe = populate_sell_trend(populate_indicators(result))
|
||||
assert 'sell' in dataframe.columns
|
||||
|
||||
|
||||
def test_returns_latest_buy_signal(mocker):
|
||||
|
|
Loading…
Reference in New Issue
Block a user