Enhance restclient and add tests for new api methods

This commit is contained in:
Matthias
2020-09-11 20:31:02 +02:00
parent bb4993dc20
commit f82d39e1b0
4 changed files with 98 additions and 4 deletions

View File

@@ -224,6 +224,62 @@ class FtRestClient():
return self._post("forcesell", data={"tradeid": tradeid})
def strategies(self):
"""Lists available strategies
:return: json object
"""
return self._get("strategies")
def plot_config(self):
"""Return plot configuration if the strategy defines one.
:return: json object
"""
return self._get("plot_config")
def available_pairs(self, timeframe=None, stake_currency=None):
"""Return available pair (backtest data) based on timeframe / stake_currency selection
:param timeframe: Only pairs with this timeframe available.
:param stake_currency: Only pairs that include this timeframe
:return: json object
"""
return self._get("available_pairs", params={
"stake_currency": stake_currency if timeframe else '',
"timeframe": timeframe if timeframe else '',
})
def pair_candles(self, pair, timeframe, limit=None):
"""Return live dataframe for <pair><timeframe>.
:param pair: Pair to get data for
:param timeframe: Only pairs with this timeframe available.
:param limit: Limit result to the last n candles.
:return: json object
"""
return self._get("available_pairs", params={
"pair": pair,
"timeframe": timeframe,
"limit": limit,
})
def pair_history(self, pair, timeframe, strategy, timerange=None):
"""Return historic, analyzed dataframe
:param pair: Pair to get data for
:param timeframe: Only pairs with this timeframe available.
:param strategy: Strategy to analyze and get values for
:param timerange: Timerange to get data for (same format than --timerange endpoints)
:return: json object
"""
return self._get("pair_history", params={
"pair": pair,
"timeframe": timeframe,
"strategy": strategy,
"timerange": timerange if timerange else '',
})
def add_arguments():
parser = argparse.ArgumentParser()