Don't fail if no buy-signal is present
This commit is contained in:
parent
f5dc10e4ae
commit
482f1faa88
@ -657,8 +657,16 @@ class RPC:
|
||||
return self._freqtrade.edge.accepted_pairs()
|
||||
|
||||
def _convert_dataframe_to_dict(self, pair, dataframe, last_analyzed):
|
||||
dataframe = dataframe.replace({NAN: None})
|
||||
dataframe['date'] = dataframe['date'].astype(int64) // 1000 // 1000
|
||||
# Move open to seperate column when signal for easy plotting
|
||||
if 'buy' in dataframe.columns:
|
||||
buy_mask = (dataframe['buy'] == 1)
|
||||
dataframe.loc[buy_mask, '_buy_signal_open'] = dataframe.loc[buy_mask, 'open']
|
||||
if 'sell' in dataframe.columns:
|
||||
sell_mask = (dataframe['sell'] == 1)
|
||||
dataframe.loc[sell_mask, '_sell_signal_open'] = dataframe.loc[sell_mask, 'open']
|
||||
dataframe = dataframe.replace({NAN: None})
|
||||
|
||||
return {
|
||||
'pair': pair,
|
||||
'columns': list(dataframe.columns),
|
||||
@ -676,8 +684,7 @@ class RPC:
|
||||
|
||||
def _rpc_analysed_history_full(self, pair: str, timeframe: str,
|
||||
timerange: str) -> Dict[str, Any]:
|
||||
timerange = TimeRange.parse_timerange(None if self.config.get(
|
||||
'timerange') is None else str(self.config.get('timerange')))
|
||||
timerange = TimeRange.parse_timerange(timerange)
|
||||
|
||||
_data = load_data(
|
||||
datadir=self._freqtrade.config.get("datadir"),
|
||||
@ -688,7 +695,7 @@ class RPC:
|
||||
)
|
||||
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
||||
strategy = StrategyResolver.load_strategy(self._freqtrade.config)
|
||||
df_analyzed = strategy.analyze_ticker(_data, {'pair': pair})
|
||||
df_analyzed = strategy.analyze_ticker(_data[pair], {'pair': pair})
|
||||
|
||||
return self._convert_dataframe_to_dict(pair, df_analyzed, arrow.Arrow.utcnow().datetime)
|
||||
|
||||
|
@ -818,6 +818,10 @@ def test_api_pair_candles(botclient, ohlcv_history):
|
||||
timeframe = '5m'
|
||||
amount = 2
|
||||
ohlcv_history['sma'] = ohlcv_history['close'].rolling(2).mean()
|
||||
ohlcv_history['buy'] = 0
|
||||
ohlcv_history.iloc[1]['buy'] = 1
|
||||
ohlcv_history['sell'] = 0
|
||||
|
||||
ftbot.dataprovider._set_cached_df("XRP/BTC", timeframe, ohlcv_history)
|
||||
|
||||
rc = client_get(client,
|
||||
@ -825,7 +829,9 @@ def test_api_pair_candles(botclient, ohlcv_history):
|
||||
assert_response(rc)
|
||||
assert 'columns' in rc.json
|
||||
assert isinstance(rc.json['columns'], list)
|
||||
assert rc.json['columns'] == ['date', 'open', 'high', 'low', 'close', 'volume', 'sma']
|
||||
assert rc.json['columns'] == ['date', 'open', 'high',
|
||||
'low', 'close', 'volume', 'sma', 'buy', 'sell',
|
||||
'_buy_signal_open', '_sell_signal_open']
|
||||
assert 'pair' in rc.json
|
||||
assert rc.json['pair'] == 'XRP/BTC'
|
||||
|
||||
@ -833,9 +839,10 @@ def test_api_pair_candles(botclient, ohlcv_history):
|
||||
assert len(rc.json['data']) == amount
|
||||
|
||||
assert (rc.json['data'] ==
|
||||
[[1511686200000, 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869, None],
|
||||
[[1511686200000, 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869,
|
||||
None, 0, 0, None, None],
|
||||
[1511686500000, 8.88e-05, 8.942e-05, 8.88e-05,
|
||||
8.893e-05, 0.05874751, 8.886500000000001e-05]
|
||||
8.893e-05, 0.05874751, 8.886500000000001e-05, 0, 0, None, None]
|
||||
])
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user