mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 18:23:55 +00:00
Convert types to support valid json
This commit is contained in:
parent
a38b33cd9c
commit
133ca9c770
|
@ -517,7 +517,7 @@ class ApiServer(RPC):
|
||||||
"""
|
"""
|
||||||
pair = request.args.get("pair")
|
pair = request.args.get("pair")
|
||||||
timeframe = request.args.get("timeframe")
|
timeframe = request.args.get("timeframe")
|
||||||
limit = request.args.get("limit")
|
limit = request.args.get("limit", type=int)
|
||||||
|
|
||||||
results = self._rpc_analysed_history(pair, timeframe, limit)
|
results = self._rpc_analysed_history(pair, timeframe, limit)
|
||||||
return self.rest_dump(results)
|
return self.rest_dump(results)
|
||||||
|
|
|
@ -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, mean
|
from numpy import NAN, mean, int64
|
||||||
|
|
||||||
from freqtrade.constants import CANCEL_REASON
|
from freqtrade.constants import CANCEL_REASON
|
||||||
from freqtrade.exceptions import ExchangeError, PricingError
|
from freqtrade.exceptions import ExchangeError, PricingError
|
||||||
|
@ -656,12 +656,14 @@ class RPC:
|
||||||
|
|
||||||
def _rpc_analysed_history(self, pair, timeframe, limit):
|
def _rpc_analysed_history(self, pair, timeframe, limit):
|
||||||
|
|
||||||
data, last_analyzed = self._freqtrade.dataprovider.get_analyzed_dataframe(pair, timeframe)
|
_data, last_analyzed = self._freqtrade.dataprovider.get_analyzed_dataframe(pair, timeframe)
|
||||||
if limit:
|
if limit:
|
||||||
data = data.iloc[:-limit]
|
_data = _data.iloc[-limit:]
|
||||||
|
_data = _data.replace({NAN: None})
|
||||||
|
_data['date'] = _data['date'].astype(int64) // 1000 // 1000
|
||||||
return {
|
return {
|
||||||
'columns': data.columns,
|
'columns': list(_data.columns),
|
||||||
'data': data.values.tolist(),
|
'data': _data.values.tolist(),
|
||||||
'length': len(data),
|
'length': len(_data),
|
||||||
'last_analyzed': last_analyzed,
|
'last_analyzed': last_analyzed,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user