rlportfolio.policy.gpm module
- class GPM
Bases:
Module- __init__(edge_index: ndarray | Tensor, edge_type: ndarray, nodes_to_select: ndarray | list[int] | Tensor, initial_features: int = 3, k_short: int = 3, k_medium: int = 21, conv_mid_features: int = 3, conv_final_features: int = 20, graph_layers: int = 1, time_window: int = 50, softmax_temperature: float = 1, num_workers: int = 1, device: str = 'cpu') GPM
GPM (Graph-based Portfolio Management) policy network initializer.
- Parameters:
edge_index – Graph connectivity in COO format.
edge_type – Type of each edge in edge_index.
nodes_to_select – ID of nodes to be selected to the portfolio.
initial_features – Number of input features.
k_short – Size of short convolutional kernel.
k_medium – Size of medium convolutional kernel.
conv_mid_features – Size of intermediate convolutional channels.
conv_final_features – Size of final convolutional channels.
graph_layers – Number of graph neural network layers.
time_window – Size of time window used as agent’s state.
softmax_temperature – Temperature parameter to softmax function.
num_workers – Number of workers to use in parallel execution of graph batches.
device – Device in which the neural network will be run.
Note
Reference article: https://doi.org/10.1016/j.neucom.2022.04.105.
- forward(observation: Tensor, last_action: Tensor) Tensor
Policy network’s forward propagation. Defines a most favorable action of this policy given the inputs.
- Parameters:
observation – environment observation.
last_action – Last action performed by agent.
- Returns:
Action to be taken.
- class GPMSimplified
Bases:
GPM- __init__(edge_index: ndarray | Tensor, edge_type: ndarray, nodes_to_select: ndarray | list[int] | Tensor, initial_features: int = 3, k_short: int = 3, k_medium: int = 21, conv_mid_features: int = 3, conv_final_features: int = 20, graph_layers: int = 1, time_window: int = 50, softmax_temperature: float = 1, num_workers: int = 1, device: str = 'cpu') GPMSimplified
GPM (Graph-based Portfolio Management) policy network initializer.
- Parameters:
edge_index – Graph connectivity in COO format.
edge_type – Type of each edge in edge_index.
nodes_to_select – ID of nodes to be selected to the portfolio.
initial_features – Number of input features.
k_short – Size of short convolutional kernel.
k_medium – Size of medium convolutional kernel.
conv_mid_features – Size of intermediate convolutional channels.
conv_final_features – Size of final convolutional channels.
graph_layers – Number of graph neural network layers.
time_window – Size of time window used as agent’s state.
softmax_temperature – Temperature parameter to softmax function.
num_workers – Number of workers to use in parallel execution of graph batches.
device – Device in which the neural network will be run.
Note
Reference article: https://doi.org/10.1016/j.neucom.2022.04.105.
- forward(observation: Tensor, last_action: Tensor) Tensor
Policy network’s forward propagation. Defines a most favorable action of this policy given the inputs.
- Parameters:
observation – environment observation.
last_action – Last action performed by agent.
- Returns:
Action to be taken.