evaluate package¶
Submodules¶
evaluate.evaluator module¶
- class evaluate.evaluator.Evaluator(args: Namespace)¶
Bases:
object
the evaluator to evaluate the portfolio performance
- static add_args(parser: ArgumentParser) None ¶
add arguments to the parser
to add arguments to the parser, modify the method as follows:
@staticmethod def add_args(parser: argparse.ArgumentParser) -> None: parser.add_argument( ... )
then add arguments to the parser
- Parameters:
parser (argparse.ArgumentParser) – the parser to add arguments to
- __init__(args: Namespace) None ¶
initialize the evaluator
- Parameters:
args (argparse.Namespace) – the arguments
- reset(initial_balance: float = None) None ¶
reset the evaluator
- Parameters:
initial_balance (float) – the initial balance, if None, use the initial balance from the arguments. Defaults to None.
- push(portfolio_value: float, portfolio_weight: Tuple[Tensor, Tensor], current_price: Tensor) None ¶
push the portfolio value and weight to the evaluator
- Parameters:
portfolio_value (float) – the portfolio value
portfolio_weight (Tuple[torch.Tensor, torch.Tensor]) – the portfolio weight before and after trading
current_price (torch.Tensor) – the current price of the considered assets
- output_record_to_json(path: str) None ¶
output the record to a json file
- Parameters:
path (str) – the path to the output file
- evaluate() None ¶
evaluate the portfolio
- Raises:
ValueError – portfolio_value_list is empty
ValueError – portfolio_weight_list is empty
- calculate_CR() float ¶
evaluate the CR metric
- Returns:
the CR metric
- Return type:
float
- calculate_SR() float ¶
evaluate the SR metric
- Returns:
the SR metric
- Return type:
float
- calculate_SteR() float ¶
evaluate the SteR metric
- Returns:
the SteR metric
- Return type:
float
- calculate_AT() float ¶
evaluate the AT metric
- Returns:
the AT metric
- Return type:
float
- calculate_MDD() float ¶
evaluate the MDD metric
- Returns:
the MDD metric
- Return type:
float