Fix problem with inf values returned from dataframe for api methods

This commit is contained in:
Matthias 2021-02-11 20:21:07 +01:00
parent aa79574c0c
commit 843fb204e9
2 changed files with 3 additions and 2 deletions

View File

@ -167,7 +167,7 @@ def reload_config(rpc: RPC = Depends(get_rpc)):
@router.get('/pair_candles', response_model=PairHistory, tags=['candle data']) @router.get('/pair_candles', response_model=PairHistory, tags=['candle data'])
def pair_candles(pair: str, timeframe: str, limit: Optional[int], rpc=Depends(get_rpc)): def pair_candles(pair: str, timeframe: str, limit: Optional[int], rpc: RPC = Depends(get_rpc)):
return rpc._rpc_analysed_dataframe(pair, timeframe, limit) return rpc._rpc_analysed_dataframe(pair, timeframe, limit)

View File

@ -9,7 +9,7 @@ from math import isnan
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Any, Dict, List, Optional, Tuple, Union
import arrow import arrow
from numpy import NAN, int64, mean from numpy import NAN, inf, int64, mean
from pandas import DataFrame from pandas import DataFrame
from freqtrade.configuration.timerange import TimeRange from freqtrade.configuration.timerange import TimeRange
@ -747,6 +747,7 @@ class RPC:
sell_mask = (dataframe['sell'] == 1) sell_mask = (dataframe['sell'] == 1)
sell_signals = int(sell_mask.sum()) sell_signals = int(sell_mask.sum())
dataframe.loc[sell_mask, '_sell_signal_open'] = dataframe.loc[sell_mask, 'open'] dataframe.loc[sell_mask, '_sell_signal_open'] = dataframe.loc[sell_mask, 'open']
dataframe = dataframe.replace([inf, -inf], NAN)
dataframe = dataframe.replace({NAN: None}) dataframe = dataframe.replace({NAN: None})
res = { res = {