mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-13 03:33:55 +00:00
Return strategy with analyzed data
This commit is contained in:
parent
18bbfdd341
commit
32e6ea314c
|
@ -657,7 +657,8 @@ class RPC:
|
||||||
raise RPCException('Edge is not enabled.')
|
raise RPCException('Edge is not enabled.')
|
||||||
return self._freqtrade.edge.accepted_pairs()
|
return self._freqtrade.edge.accepted_pairs()
|
||||||
|
|
||||||
def _convert_dataframe_to_dict(self, pair: str, dataframe: DataFrame, last_analyzed: datetime):
|
def _convert_dataframe_to_dict(self, strategy: str, pair: str, dataframe: DataFrame,
|
||||||
|
last_analyzed: datetime):
|
||||||
|
|
||||||
dataframe.loc[:, '__date_ts'] = dataframe.loc[:, 'date'].astype(int64) // 1000 // 1000
|
dataframe.loc[:, '__date_ts'] = dataframe.loc[:, 'date'].astype(int64) // 1000 // 1000
|
||||||
# Move open to seperate column when signal for easy plotting
|
# Move open to seperate column when signal for easy plotting
|
||||||
|
@ -671,6 +672,7 @@ class RPC:
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'pair': pair,
|
'pair': pair,
|
||||||
|
'strategy': strategy,
|
||||||
'columns': list(dataframe.columns),
|
'columns': list(dataframe.columns),
|
||||||
'data': dataframe.values.tolist(),
|
'data': dataframe.values.tolist(),
|
||||||
'length': len(dataframe),
|
'length': len(dataframe),
|
||||||
|
@ -687,7 +689,8 @@ class RPC:
|
||||||
_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:].copy()
|
_data = _data.iloc[-limit:].copy()
|
||||||
return self._convert_dataframe_to_dict(pair, _data, last_analyzed)
|
return self._convert_dataframe_to_dict(self._freqtrade.config['strategy'],
|
||||||
|
pair, _data, last_analyzed)
|
||||||
|
|
||||||
def _rpc_analysed_history_full(self, config: Dict[str, any], pair: str, timeframe: str,
|
def _rpc_analysed_history_full(self, config: Dict[str, any], pair: str, timeframe: str,
|
||||||
timerange: str) -> Dict[str, Any]:
|
timerange: str) -> Dict[str, Any]:
|
||||||
|
@ -704,7 +707,8 @@ class RPC:
|
||||||
strategy = StrategyResolver.load_strategy(config)
|
strategy = StrategyResolver.load_strategy(config)
|
||||||
df_analyzed = strategy.analyze_ticker(_data[pair], {'pair': pair})
|
df_analyzed = strategy.analyze_ticker(_data[pair], {'pair': pair})
|
||||||
|
|
||||||
return self._convert_dataframe_to_dict(pair, df_analyzed, arrow.Arrow.utcnow().datetime)
|
return self._convert_dataframe_to_dict(strategy.get_strategy_name(), pair, df_analyzed,
|
||||||
|
arrow.Arrow.utcnow().datetime)
|
||||||
|
|
||||||
def _rpc_plot_config(self) -> Dict[str, Any]:
|
def _rpc_plot_config(self) -> Dict[str, Any]:
|
||||||
|
|
||||||
|
|
|
@ -827,6 +827,8 @@ def test_api_pair_candles(botclient, ohlcv_history):
|
||||||
rc = client_get(client,
|
rc = client_get(client,
|
||||||
f"{BASE_URI}/pair_candles?limit={amount}&pair=XRP%2FBTC&timeframe={timeframe}")
|
f"{BASE_URI}/pair_candles?limit={amount}&pair=XRP%2FBTC&timeframe={timeframe}")
|
||||||
assert_response(rc)
|
assert_response(rc)
|
||||||
|
assert 'strategy' in rc.json
|
||||||
|
assert rc.json['strategy'] == 'DefaultStrategy'
|
||||||
assert 'columns' in rc.json
|
assert 'columns' in rc.json
|
||||||
assert 'data_start_ts' in rc.json
|
assert 'data_start_ts' in rc.json
|
||||||
assert 'data_start' in rc.json
|
assert 'data_start' in rc.json
|
||||||
|
|
Loading…
Reference in New Issue
Block a user