Merge pull request #5182 from aayush-jain18/docstring-cleanup

Docstring cleanup
This commit is contained in:
Matthias 2021-06-25 20:53:54 +02:00 committed by GitHub
commit ea89af30c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 30 additions and 21 deletions

View File

@ -15,6 +15,7 @@ def setup_optimize_configuration(args: Dict[str, Any], method: RunMode) -> Dict[
""" """
Prepare the configuration for the Hyperopt module Prepare the configuration for the Hyperopt module
:param args: Cli args from Arguments() :param args: Cli args from Arguments()
:param method: Bot running mode
:return: Configuration :return: Configuration
""" """
config = setup_utils_configuration(args, method) config = setup_utils_configuration(args, method)

View File

@ -15,6 +15,7 @@ def setup_utils_configuration(args: Dict[str, Any], method: RunMode) -> Dict[str
""" """
Prepare the configuration for utils subcommands Prepare the configuration for utils subcommands
:param args: Cli args from Arguments() :param args: Cli args from Arguments()
:param method: Bot running mode
:return: Configuration :return: Configuration
""" """
configuration = Configuration(args, method) configuration = Configuration(args, method)

View File

@ -52,8 +52,8 @@ class HDF5DataHandler(IDataHandler):
""" """
Store data in hdf5 file. Store data in hdf5 file.
:param pair: Pair - used to generate filename :param pair: Pair - used to generate filename
:timeframe: Timeframe - used to generate filename :param timeframe: Timeframe - used to generate filename
:data: Dataframe containing OHLCV data :param data: Dataframe containing OHLCV data
:return: None :return: None
""" """
key = self._pair_ohlcv_key(pair, timeframe) key = self._pair_ohlcv_key(pair, timeframe)

View File

@ -113,6 +113,7 @@ def refresh_data(datadir: Path,
:param timeframe: Timeframe (e.g. "5m") :param timeframe: Timeframe (e.g. "5m")
:param pairs: List of pairs to load :param pairs: List of pairs to load
:param exchange: Exchange object :param exchange: Exchange object
:param data_format: dataformat to use
:param timerange: Limit data to be loaded to this timerange :param timerange: Limit data to be loaded to this timerange
""" """
data_handler = get_datahandler(datadir, data_format) data_handler = get_datahandler(datadir, data_format)

View File

@ -49,8 +49,8 @@ class IDataHandler(ABC):
""" """
Store ohlcv data. Store ohlcv data.
:param pair: Pair - used to generate filename :param pair: Pair - used to generate filename
:timeframe: Timeframe - used to generate filename :param timeframe: Timeframe - used to generate filename
:data: Dataframe containing OHLCV data :param data: Dataframe containing OHLCV data
:return: None :return: None
""" """
@ -245,8 +245,8 @@ def get_datahandler(datadir: Path, data_format: str = None,
data_handler: IDataHandler = None) -> IDataHandler: data_handler: IDataHandler = None) -> IDataHandler:
""" """
:param datadir: Folder to save data :param datadir: Folder to save data
:data_format: dataformat to use :param data_format: dataformat to use
:data_handler: returns this datahandler if it exists or initializes a new one :param data_handler: returns this datahandler if it exists or initializes a new one
""" """
if not data_handler: if not data_handler:

View File

@ -55,8 +55,8 @@ class JsonDataHandler(IDataHandler):
format looks as follows: format looks as follows:
[[<date>,<open>,<high>,<low>,<close>]] [[<date>,<open>,<high>,<low>,<close>]]
:param pair: Pair - used to generate filename :param pair: Pair - used to generate filename
:timeframe: Timeframe - used to generate filename :param timeframe: Timeframe - used to generate filename
:data: Dataframe containing OHLCV data :param data: Dataframe containing OHLCV data
:return: None :return: None
""" """
filename = self._pair_data_filename(self._datadir, pair, timeframe) filename = self._pair_data_filename(self._datadir, pair, timeframe)

View File

@ -475,11 +475,11 @@ class Exchange:
return endpoint in self._api.has and self._api.has[endpoint] return endpoint in self._api.has and self._api.has[endpoint]
def amount_to_precision(self, pair: str, amount: float) -> float: def amount_to_precision(self, pair: str, amount: float) -> float:
''' """
Returns the amount to buy or sell to a precision the Exchange accepts Returns the amount to buy or sell to a precision the Exchange accepts
Re-implementation of ccxt internal methods - ensuring we can test the result is correct Re-implementation of ccxt internal methods - ensuring we can test the result is correct
based on our definitions. based on our definitions.
''' """
if self.markets[pair]['precision']['amount']: if self.markets[pair]['precision']['amount']:
amount = float(decimal_to_precision(amount, rounding_mode=TRUNCATE, amount = float(decimal_to_precision(amount, rounding_mode=TRUNCATE,
precision=self.markets[pair]['precision']['amount'], precision=self.markets[pair]['precision']['amount'],
@ -489,14 +489,14 @@ class Exchange:
return amount return amount
def price_to_precision(self, pair: str, price: float) -> float: def price_to_precision(self, pair: str, price: float) -> float:
''' """
Returns the price rounded up to the precision the Exchange accepts. Returns the price rounded up to the precision the Exchange accepts.
Partial Re-implementation of ccxt internal method decimal_to_precision(), Partial Re-implementation of ccxt internal method decimal_to_precision(),
which does not support rounding up which does not support rounding up
TODO: If ccxt supports ROUND_UP for decimal_to_precision(), we could remove this and TODO: If ccxt supports ROUND_UP for decimal_to_precision(), we could remove this and
align with amount_to_precision(). align with amount_to_precision().
Rounds up Rounds up
''' """
if self.markets[pair]['precision']['price']: if self.markets[pair]['precision']['price']:
# price = float(decimal_to_precision(price, rounding_mode=ROUND, # price = float(decimal_to_precision(price, rounding_mode=ROUND,
# precision=self.markets[pair]['precision']['price'], # precision=self.markets[pair]['precision']['price'],
@ -796,6 +796,8 @@ class Exchange:
""" """
Simple wrapper calling either fetch_order or fetch_stoploss_order depending on Simple wrapper calling either fetch_order or fetch_stoploss_order depending on
the stoploss_order parameter the stoploss_order parameter
:param order_id: OrderId to fetch order
:param pair: Pair corresponding to order_id
:param stoploss_order: If true, uses fetch_stoploss_order, otherwise fetch_order. :param stoploss_order: If true, uses fetch_stoploss_order, otherwise fetch_order.
""" """
if stoploss_order: if stoploss_order:

View File

@ -472,6 +472,7 @@ class FreqtradeBot(LoggingMixin):
""" """
Executes a limit buy for the given pair Executes a limit buy for the given pair
:param pair: pair for which we want to create a LIMIT_BUY :param pair: pair for which we want to create a LIMIT_BUY
:param stake_amount: amount of stake-currency for the pair
:return: True if a buy order is created, false if it fails. :return: True if a buy order is created, false if it fails.
""" """
time_in_force = self.strategy.order_time_in_force['buy'] time_in_force = self.strategy.order_time_in_force['buy']
@ -834,7 +835,7 @@ class FreqtradeBot(LoggingMixin):
""" """
Check to see if stoploss on exchange should be updated Check to see if stoploss on exchange should be updated
in case of trailing stoploss on exchange in case of trailing stoploss on exchange
:param Trade: Corresponding Trade :param trade: Corresponding Trade
:param order: Current on exchange stoploss order :param order: Current on exchange stoploss order
:return: None :return: None
""" """

View File

@ -56,6 +56,7 @@ def file_dump_json(filename: Path, data: Any, is_zip: bool = False, log: bool =
""" """
Dump JSON data into a file Dump JSON data into a file
:param filename: file to create :param filename: file to create
:param is_zip: if file should be zip
:param data: JSON Data to save :param data: JSON Data to save
:return: :return:
""" """

View File

@ -507,9 +507,8 @@ def text_table_sell_reason(sell_reason_stats: List[Dict[str, Any]], stake_curren
def text_table_strategy(strategy_results, stake_currency: str) -> str: def text_table_strategy(strategy_results, stake_currency: str) -> str:
""" """
Generate summary table per strategy Generate summary table per strategy
:param strategy_results: Dict of <Strategyname: DataFrame> containing results for all strategies
:param stake_currency: stake-currency - used to correctly name headers :param stake_currency: stake-currency - used to correctly name headers
:param max_open_trades: Maximum allowed open trades used for backtest
:param all_results: Dict of <Strategyname: DataFrame> containing results for all strategies
:return: pretty printed table with tabulate as string :return: pretty printed table with tabulate as string
""" """
floatfmt = _get_line_floatfmt(stake_currency) floatfmt = _get_line_floatfmt(stake_currency)

View File

@ -20,9 +20,9 @@ logger = logging.getLogger(__name__)
class VolatilityFilter(IPairList): class VolatilityFilter(IPairList):
''' """
Filters pairs by volatility Filters pairs by volatility
''' """
def __init__(self, exchange, pairlistmanager, def __init__(self, exchange, pairlistmanager,
config: Dict[str, Any], pairlistconfig: Dict[str, Any], config: Dict[str, Any], pairlistconfig: Dict[str, Any],

View File

@ -21,6 +21,7 @@ class ExchangeResolver(IResolver):
def load_exchange(exchange_name: str, config: dict, validate: bool = True) -> Exchange: def load_exchange(exchange_name: str, config: dict, validate: bool = True) -> Exchange:
""" """
Load the custom class from config parameter Load the custom class from config parameter
:param exchange_name: name of the Exchange to load
:param config: configuration dictionary :param config: configuration dictionary
""" """
# Map exchange name to avoid duplicate classes for identical exchanges # Map exchange name to avoid duplicate classes for identical exchanges

View File

@ -135,7 +135,7 @@ class IResolver:
extra_dir: Optional[str] = None) -> Any: extra_dir: Optional[str] = None) -> Any:
""" """
Search and loads the specified object as configured in hte child class. Search and loads the specified object as configured in hte child class.
:param objectname: name of the module to import :param object_name: name of the module to import
:param config: configuration dictionary :param config: configuration dictionary
:param extra_dir: additional directory to search for the given pairlist :param extra_dir: additional directory to search for the given pairlist
:raises: OperationalException if the class is invalid or does not exist. :raises: OperationalException if the class is invalid or does not exist.

View File

@ -349,7 +349,7 @@ class IStrategy(ABC, HyperStrategyMixin):
The 2nd, optional parameter ensures that locks are applied until the new candle arrives, The 2nd, optional parameter ensures that locks are applied until the new candle arrives,
and not stop at 14:00:00 - while the next candle arrives at 14:00:02 leaving a gap and not stop at 14:00:00 - while the next candle arrives at 14:00:02 leaving a gap
of 2 seconds for a buy to happen on an old signal. of 2 seconds for a buy to happen on an old signal.
:param: pair: "Pair to check" :param pair: "Pair to check"
:param candle_date: Date of the last candle. Optional, defaults to current date :param candle_date: Date of the last candle. Optional, defaults to current date
:returns: locking state of the pair in question. :returns: locking state of the pair in question.
""" """
@ -733,7 +733,8 @@ class IStrategy(ABC, HyperStrategyMixin):
Based on TA indicators, populates the buy signal for the given dataframe Based on TA indicators, populates the buy signal for the given dataframe
This method should not be overridden. This method should not be overridden.
:param dataframe: DataFrame :param dataframe: DataFrame
:param pair: Additional information, like the currently traded pair :param metadata: Additional information dictionary, with details like the
currently traded pair
:return: DataFrame with buy column :return: DataFrame with buy column
""" """
logger.debug(f"Populating buy signals for pair {metadata.get('pair')}.") logger.debug(f"Populating buy signals for pair {metadata.get('pair')}.")
@ -750,7 +751,8 @@ class IStrategy(ABC, HyperStrategyMixin):
Based on TA indicators, populates the sell signal for the given dataframe Based on TA indicators, populates the sell signal for the given dataframe
This method should not be overridden. This method should not be overridden.
:param dataframe: DataFrame :param dataframe: DataFrame
:param pair: Additional information, like the currently traded pair :param metadata: Additional information dictionary, with details like the
currently traded pair
:return: DataFrame with sell column :return: DataFrame with sell column
""" """
logger.debug(f"Populating sell signals for pair {metadata.get('pair')}.") logger.debug(f"Populating sell signals for pair {metadata.get('pair')}.")